def __process__(self, spcs, sector, year, iteration): ij = self.get_ij(spcs, sector, year, iteration) title = self.make_title(spcs, sector, year, iteration) filename = self.make_filename(spcs, sector, year, iteration) h.plot_ij(ij, filename=filename, title=title, cblabel="Emissions", vmin=1, vmax=3e6, norm=h.LogNorm()) return filename
def __process__(self, quant, diag): filename = self.filename(quant, diag) title = self.title(quant, diag) x = emission_diagnostic_batch[quant, diag] vmin, vmax = self.vlimits[diag] cblabel = self.units[diag] h.plot_ij(x, filename=filename, title=title, cblabel=cblabel, mask=h.na_ocean_mask, vmin=vmin, vmax=vmax)
def __process__(self, year): a, b = sectoral_emissions_batch[year] title = "Anth Emissions in {}".format(year) filename = join(plt_dir, "{}_{}.png".format("anth", year)) plot_ij(a, title=title, filename=filename, vmin=1.0, vmax=1e8, mask=na_ocean_mask, norm=LogNorm()) title = "Biof Emissions in {}".format(year) filename = join(plt_dir, "{}_{}.png".format("biof", year)) plot_ij(b, title=title, filename=filename, vmin=1.0, vmax=1e8, mask=na_ocean_mask, norm=LogNorm())
def __process__(self, quant, rel): filename = self.filename(quant, rel) title = self.title(quant, rel) trend = self.trend_sources[rel][quant] vmin, vmax = self.vlims[rel] mask = self.get_mask(quant, rel, trend) cbticks = self.cbticks[rel] h.plot_ij(trend, filename=filename, title=title, cblabel="Change/yr [% of avg.]", vmin=vmin, vmax=vmax, mask=mask, cbticks=cbticks, norm=h.SymNorm())
def plot_gdt(datafile, ij, plots_dir, year=None): print "Plotting", datafile match = gdt_regex.match(datafile) species, hygr, sector, iteration = match.groups() title = ' '.join([str(year), sector_name[sector], (species+hygr).upper(), "Gradient, Iteration ", iteration]) cblabel = '' filename = os.path.join(plots_dir, "_".join([(species+hygr), sector, str(year), iteration])) gch.plot_ij(ij, filename=filename, title=title, cblabel=cblabel, norm=gch.SymLogNorm(1e-2), vmin=-5e2, vmax=5e2)
def plot_sf(datafile, ij, plots_dir, year=None): match = sf_regex.match(datafile) species, hygr, sector, iteration = match.groups() title = ' '.join([str(year), (species+hygr).upper(), sector_name[sector], ", Iteration ", iteration]) cblabel = "Scale Factor" filename = os.path.join(plots_dir, "_".join([(species+hygr), sector, str(year), iteration]) + ".png") print "Plotting {} for {} in {} ".format(datafile, year, filename) gch.plot_ij(ij, filename=filename, title=title, cblabel=cblabel, vmin=0, vmax=1)
def oc_plots(oc_raw, oc_ast, year): oc_raw_conc = h.map_ij(h.ppbv_to_conc, oc_raw) oc_ast_conc = h.map_ij(h.ppbv_to_conc, oc_ast) oc_log_ratio = h.map_ij(np.log, h.map_ij(h.divider(default=1), oc_ast_conc, oc_raw_conc)) h.plot_ij(oc_raw_conc, filename=os.path.join(plt_dir, "oc_raw_{}.png".format(year)), title="GEOS-Chem Raw OC {}".format(year), cblabel="ug/m^3", vmin=0, vmax=3.5) h.plot_ij(oc_ast_conc, filename=os.path.join(plt_dir, "oc_ast_{}.png".format(year)), title="GEOS-Chem Assimilated OC {}".format(year), cblabel="ug/m^3", vmin=0, vmax=3.5) h.plot_ij(oc_log_ratio, filename=os.path.join(plt_dir, "oc_ratio_{}.png".format(year)), title="OC Ln(opt/prior) {}".format(year), cblabel='', vmin=-_oc_lim, vmax=_oc_lim, cmap="RdBu")
def bc_plots(bc_raw, bc_ast, year): bc_raw_conc = h.map_ij(h.ppbv_to_conc, bc_raw) bc_ast_conc = h.map_ij(h.ppbv_to_conc, bc_ast) bc_log_ratio = h.map_ij(np.log, h.map_ij(h.divider(default=1), bc_ast_conc, bc_raw_conc)) h.plot_ij(bc_raw_conc, filename=os.path.join(plt_dir, "bc_raw_{}".format(year)), title="GEOS-Chem Raw BC {}".format(year), cblabel="ug/m^3", vmin=0, vmax=0.6) h.plot_ij(bc_ast_conc, filename=os.path.join(plt_dir, "bc_ast_{}.png".format(year)), title="GEOS-Chem Assimilated BC {}".format(year), cblabel="ug/m^3", vmin=0, vmax=0.6) h.plot_ij(bc_log_ratio, filename=os.path.join(plt_dir, "bc_ratio_{}.png".format(year)), title="BC Ln(opt/prior) {}".format(year), cblabel='', norm=h.SymNorm(), vmin=-_bc_lim, vmax=_bc_lim, cmap="RdBu")
#!/usr/bin/python import gc_helpers as h, re dd = h.data_dirs[1] an_ems = h.map_ij(h.add, *dd.match(re.compile("bc_anth.blkc.1.dat")).values()) bf_ems = h.map_ij(h.add, *dd.match(re.compile("bc_biof.blkc.1.dat")).values()) bb_ems = h.map_ij(h.add, *dd.match(re.compile("bc_biob.blkc.1.dat")).values()) def max_frac(a,b,c): n = max(a,b,c) d = a+b+c if d!=0: return n/d else: return -1 f = h.map_ij(max_frac, an_ems, bf_ems, bb_ems) h.plot_ij(f, "fraction.png", "Fraction emitted by dominant sector", cblabel= "max(sectors)/sum(sectors)", vmin=0, vmax=1)
from emissions import opt_ems_batch, get_totalled_ij # Import bc and oc by: # [bc, oc] # [anth, biob, biof, biog, total] # years # iterations raw_anth_bc = [get_totalled_ij("bc", yr, 1) for yr in years] raw_anth_oc = [get_totalled_ij("oc", yr, 1) for yr in years] def sub(a,b): return a - b ast_biof_bc = [ij.map_ij(sub, opt_ems_batch["bc", yr, 9], rab) for yr, rab in zip(years, raw_anth_bc)] ast_biof_oc = [ij.map_ij(sub, opt_ems_batch["oc", yr, 9], rab) for yr, rao in zip(years, raw_anth_oc)] def fname(spcs, yr): name = "{}.{}.png".format(spcs, yr) return os.path.join("./plt/const_anth/", name) if __name__ == "__main__": for bc, oc, year in zip(ast_biof_bc, ast_biof_oc, years): plot_ij(bc, filename=fname("bc", yr)) plot_ij(oc, filename=fname("oc", yr))
def plot(ij, spcs, sector, year): title = "Log(opt/prior) for {} {} {}".format(spcs, sector, year) filename = os.path.join(plt_dir, "{}_{}_{}.png".format(spcs, sector, year)) h.plot_ij(ij, filename, title, cblabel="log(opt/prior)", vmin=-2,vmax=2)