def make_KML_average_columns(averages_dict): kml = KML() aves = {} for point, bucket in averages_dict.items(): aves[point] = {"vel": [], "azm": []} vel = Mean() + point.velocity azm = Mean() + point.azimuth for en in ens: vel += en.velocity azm += en.azimuth aves[point]["vel"] = vel aves[point]["azm"] = azm f = open("../data/column_averages.xml",'w') f.write("latitude, longitude, velocity_mean, v_std, v_n, azimuth_mean, a_std, a_n\n") mkstr = lambda x: ("%s" % x).replace(", ","<br/>").replace("=",": ") for point, ave in aves.items(): vel = ave["vel"] azm = ave["azm"] text = "<h2>Velocity:</h2><p>%s</p>" % mkstr(vel) text += "<h2>Azimuth:</h2><p>%s</p>" % mkstr(azm) desc = description_from_text(text) pt = Placemark(int(azm), point.point, desc) kml.addPlacemark(pt) line = list(point.point) line.append(vel()) line.append(azm()) f.write(",".join(line) + "\n") f.close() kml.output("../data/column_averages.kml")
def make_KML_average_columns(averages_dict): kml = KML() aves = {} for point, bucket in averages_dict.items(): aves[point] = {"vel": [], "azm": []} vel = Mean() + point.velocity azm = Mean() + point.azimuth for en in ens: vel += en.velocity azm += en.azimuth aves[point]["vel"] = vel aves[point]["azm"] = azm f = open("../data/column_averages.xml", 'w') f.write( "latitude, longitude, velocity_mean, v_std, v_n, azimuth_mean, a_std, a_n\n" ) mkstr = lambda x: ("%s" % x).replace(", ", "<br/>").replace("=", ": ") for point, ave in aves.items(): vel = ave["vel"] azm = ave["azm"] text = "<h2>Velocity:</h2><p>%s</p>" % mkstr(vel) text += "<h2>Azimuth:</h2><p>%s</p>" % mkstr(azm) desc = description_from_text(text) pt = Placemark(int(azm), point.point, desc) kml.addPlacemark(pt) line = list(point.point) line.append(vel()) line.append(azm()) f.write(",".join(line) + "\n") f.close() kml.output("../data/column_averages.kml")
def outputData(name, collection, atDepth=None): kml = KML(name) file = open("../data/%s.csv" % name.replace(" ", "_"), "w") file.write( "number, latitude, longitude, v_mean, v_dev, v_n, v_err, v_min, v_max, a_mean, a_dev, a_n, a_err, a_min, a_max, d_mean, d_dev, d_n, d_err, d_min, d_max\n" ) for lst in collection.values(): for col in lst: col.calcAverages() point = col.point if atDepth: velocity, azimuth = col.averageAtDepth(atDepth) else: velocity, azimuth = col.velocity, col.azimuth name = int(degrees(azimuth)) # Cast to a Python int b/c MeanAzimuth has a long string representation depth = col.depth style = int(velocity) if style == 0: style = "O" elif (name < 0) or (style < 0): style = "red-diamond" name = "" PL = Placemark(name, point, velocity, azimuth, depth, style) kml.addPlacemark(PL) file.write("%i, %f, %f," % (PL.id, point[0], point[1])) for val in [velocity, azimuth, depth]: for v in val(): file.write(" %0.3f," % v) file.write("\n") # Kludge to zero out the ID number, so that we have a new zero point for each depth. PL.zero() kml.output() file.close()
def outputData(name, collection, atDepth=None): kml = KML(name) file = open("../data/%s.csv" % name.replace(" ", "_"), "w") file.write( "number, latitude, longitude, v_mean, v_dev, v_n, v_err, v_min, v_max, a_mean, a_dev, a_n, a_err, a_min, a_max, d_mean, d_dev, d_n, d_err, d_min, d_max\n" ) for lst in collection.values(): for col in lst: col.calcAverages() point = col.point if atDepth: velocity, azimuth = col.averageAtDepth(atDepth) else: velocity, azimuth = col.velocity, col.azimuth name = int( degrees(azimuth) ) # Cast to a Python int b/c MeanAzimuth has a long string representation depth = col.depth style = int(velocity) if style == 0: style = "O" elif ((name < 0) or (style < 0)): style = "red-diamond" name = "" PL = Placemark(name, point, velocity, azimuth, depth, style) kml.addPlacemark(PL) file.write("%i, %f, %f," % (PL.id, point[0], point[1])) for val in [velocity, azimuth, depth]: for v in val(): file.write(" %0.3f," % v) file.write("\n") # Kludge to zero out the ID number, so that we have a new zero point for each depth. PL.zero() kml.output() file.close()
def make_KML_from_ensemble_list(ensemble_list, designator=None): kml = KML() for en in ensemble_list: kml.addPlacemark(make_Placemark(ensemble)) des = str(designator) if designator else "" kml.output("../data/transects%s.kml" % des)