# determine if we will use the range in the variable or a fixed range scale = wisdom['scale'] if scale == 'original': print('[raster2kml] using original range [%g - %g] %s' % (fa_min, fa_max, native_unit)) else: fa_min, fa_max = scale[0], scale[1] fa[fa < fa_min] = fa_min fa[fa > fa_max] = fa_max print('[raster2kml] enforcing range as [%g - %g] %s' % (fa_min, fa_max, native_unit)) # render all requested colorbars for cb_unit in cb_units: cb_path = os.path.join(out_path, ('%s-%02d-%s-' % (varname,dom_id,tstr)) + cb_unit.replace('/','_') + "-cb.png") print("[raster2png] rendering colorbar for unit %s as [%s] ..." % (cb_unit, cb_path)) cbu_min, cbu_max = convert_value(native_unit, cb_unit, fa_min), convert_value(native_unit, cb_unit, fa_max) cb_png_data = make_colorbar([cbu_min,cbu_max],'vertical',2,cmap,wisdom['name'] + ' ' + cb_unit,varname) with open(cb_path, 'w') as f: f.write(cb_png_data) raster_path_pfix = os.path.join(out_path, '%s-%02d-%s' % (varname,dom_id,tstr)) print("[raster2png] creating raster from grid (Spherical Mercator) and saving to %s.png ..." % raster_path_pfix) raster_png_data,corner_coords = basemap_raster_mercator(lon,lat,fa,fa_min,fa_max,cmap) with open(raster_path_pfix + '.png','w') as f: f.write(raster_png_data) with open(raster_path_pfix + '.coords','w') as f: for lon,lat in corner_coords: f.write('%f,%f\n' % (lon,lat)) print("[raster2png] done.")
fa[fa < fa_min] = fa_min fa[fa > fa_max] = fa_max print('[raster2kml] enforcing range as [%g - %g] %s' % (fa_min, fa_max, native_unit)) # render all requested colorbars for cb_unit in cb_units: cb_path = os.path.join(out_path, ('%s-%02d-%s-' % (varname, dom_id, tstr)) + cb_unit.replace('/', '_') + "-cb.png") print("[raster2png] rendering colorbar for unit %s as [%s] ..." % (cb_unit, cb_path)) cbu_min, cbu_max = convert_value(native_unit, cb_unit, fa_min), convert_value( native_unit, cb_unit, fa_max) cb_png_data = make_colorbar([cbu_min, cbu_max], 'vertical', 2, cmap, wisdom['name'] + ' ' + cb_unit, varname) with open(cb_path, 'w') as f: f.write(cb_png_data) raster_path_pfix = os.path.join(out_path, '%s-%02d-%s' % (varname, dom_id, tstr)) print( "[raster2png] creating raster from grid (Spherical Mercator) and saving to %s.png ..." % raster_path_pfix) raster_png_data, corner_coords = basemap_raster_mercator( lon, lat, fa, fa_min, fa_max, cmap) with open(raster_path_pfix + '.png', 'w') as f: f.write(raster_png_data) with open(raster_path_pfix + '.coords', 'w') as f: for lon, lat in corner_coords: f.write('%f,%f\n' % (lon, lat))