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")
def average(*ijs): s = compact(*ijs) l = len(ijs) return h.map_ij(lambda x: x/l, s)
def compact(*ijs): return h.map_ij(h.add, *ijs)
#!/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)
def __process__(self, spcs, year, iteration): x = get_totalled_ij(spcs, year, iteration) biof = get_ij(spcs, "biof", year, iteration) return h.map_ij(lambda a,b: a-b, x, biof)