Skip to content
Snippets Groups Projects
Verified Commit 2edd2e89 authored by Kelleher, Michael's avatar Kelleher, Michael
Browse files

Add initial version of SMB components plot

parent b7def18e
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
Module containing routines to create map plots of Surface Mass Balance data.
"""
import os
from typing import OrderedDict
import numpy as np
import numpy.ma as ma
import matplotlib.pyplot as plt
......@@ -13,6 +14,7 @@ from netCDF4 import Dataset
from scipy.interpolate import griddata
from matplotlib import colors as c
from livvkit import elements as el
import xarray as xr
DESCRIBE_CORE = """
Filled contour of modeled annual surface mass balance of the Greenland ice
......@@ -372,7 +374,9 @@ def plot_metadata(args, config):
if lons_model.ndim == 1 and lons_model.shape[0] < 1000:
lons_model, lats_model = np.meshgrid(lons_model, lats_model)
elif lons_model.shape[0] >= 1000:
lons_model, lats_model, mbasins = mali_to_contour(lons_model, lats_model, mbasins)
lons_model, lats_model, mbasins = mali_to_contour(
lons_model, lats_model, mbasins
)
xi, yi = pmap(lons_model.squeeze(), lats_model.squeeze())
_ = pmap.pcolormesh(xi, yi, mbasins, cmap=forcolors, zorder=2)
......@@ -442,3 +446,42 @@ def plot_metadata(args, config):
img_list.append(img_elem)
return img_list
def component_plot(args, config):
"""Plot each component of surface mass balance."""
img_list = []
mons = np.arange(1, 13)
in_files = [config["aavg"].replace("ANN", f"{mon:02d}") for mon in mons]
model_data = xr.open_mfdataset(in_files).load()
_vars = config["vars"]
scale = (3600 * 24 * 365) / 1000.
model_plot = OrderedDict({
"Pr_tot": model_data[_vars["rain"]] + model_data[_vars["snow"]],
"Melt": model_data[_vars["melt"]],
"Runoff": model_data[_vars["runoff"]],
"Re-freeze": model_data[_vars["freeze"]],
"Rain": model_data[_vars["rain"]],
})
for _var in model_plot:
plt.plot(mons, model_plot[_var] * scale, label=_var, linestyle="-")
plt.ylabel("m / yr")
plt.legend()
plt.tight_layout()
img_file = os.path.join(args.out, "plot_aavg_component.png")
plt.savefig(img_file)
plt.close()
img_link = os.path.join(
"imgs", os.path.basename(args.out), os.path.basename(img_file)
)
img_elem = el.Image(
"SMB Components (Model) AAVG",
"Componentwise breakdown of SMB",
img_link,
height=args.img_height,
group=IMG_GROUP,
)
img_list.append(img_elem)
return img_list
\ No newline at end of file
......@@ -101,7 +101,7 @@ def run(name, config):
preproc.main(args, config)
img_list = []
img_list.extend(plt_spatial.component_plot(args, config))
img_list.extend(plt_spatial.plot_metadata(args, config))
img_list.extend(plt_spatial.plot_core(args, config))
img_list.extend(plt_spatial.plot_ib_spatial(args, config))
......
......@@ -17,6 +17,7 @@
]
},
"climo": "data/e3sm/lnd/20201112.A_BGWCYCL1850.ne30pg2_r05_oECv3_gis1to10.cori-knl.intel.testIGinitCond_ANN_climo.nc",
"aavg": "data/e3sm/lnd/20201112.A_BGWCYCL1850.ne30pg2_r05_oECv3_gis1to10.cori-knl.intel.testIGinitCond_ANN_climo_aavg..nc",
"latlon": "data/e3sm/lnd/20201112.A_BGWCYCL1850.ne30pg2_r05_oECv3_gis1to10.cori-knl.intel.testIGinitCond_ANN_climo.nc",
"elevation": "data/e3sm/lnd/20201112.A_BGWCYCL1850.ne30pg2_r05_oECv3_gis1to10.cori-knl.intel.testIGinitCond_ANN_climo.nc",
"latv": "lat",
......@@ -31,6 +32,13 @@
"zwally_file": "model_zwally_basins_elm.csv",
"ib_file": "IceBridge_modelXY_elm.csv",
"smb_cf_file": "SMB_CoreFirnEstimates_elm.csv",
"smb_mo_file": "SMB_Obs_Model_elm.csv"
"smb_mo_file": "SMB_Obs_Model_elm.csv",
"vars": {
"rain": "RAIN",
"snow": "SNOW",
"melt": "QICE_MELT",
"runoff": "QRUNOFF",
"freeze": "QICE_FRZ"
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment