Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for QBOi variables #179

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 36 additions & 22 deletions e3sm_to_cmip/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ def handle_variables(
)
data.update(new_data)
get_dims = False
print_message(new_data.keys(),"debug")

if simple and not loaded_one:
loaded_one = True
Expand All @@ -539,8 +540,10 @@ def handle_variables(

if "lev" in new_data.keys():
dims = (timename, "lev", "lat", "lon")
elif "plev" in new_data.keys():
elif "plev" in new_data.keys() and "lon" in new_data.keys():
dims = (timename, "plev", "lat", "lon")
else:
dims = (timename, "plev", "lat")
ds[outvar_name] = (dims, new_data[var_name])
for d in dims:
ds.coords[d] = new_data[d][:]
Expand Down Expand Up @@ -651,15 +654,24 @@ def get_dimension_data(filename, variable, levels=None, get_dims=False):

# load the lon and lat and time info & bounds
if get_dims:
data.update(
{
"lat": ds["lat"],
"lon": ds["lon"],
"lat_bnds": ds["lat_bnds"],
"lon_bnds": ds["lon_bnds"],
"time": ds["time"],
}
)
try:
data.update(
{
"lat": ds["lat"],
"lon": ds["lon"],
"lat_bnds": ds["lat_bnds"],
"lon_bnds": ds["lon_bnds"],
"time": ds["time"],
}
)
except:
data.update(
{
"lat": ds["lat"],
"lat_bnds": ds["lat_bnds"],
"time": ds["time"],
}
)
try:
time2 = ds["time2"]
except KeyError:
Expand Down Expand Up @@ -752,19 +764,21 @@ def load_axis(data, levels=None, has_time=True):
lev = cmor.axis(name, units=units, coord_vals=coord_vals)

# add lon/lat
lat = cmor.axis(
"latitude",
units=data["lat"].units,
coord_vals=data["lat"].values,
cell_bounds=data["lat_bnds"].values,
)
if data["lat"]:
lat = cmor.axis(
"latitude",
units=data["lat"].units,
coord_vals=data["lat"].values,
cell_bounds=data["lat_bnds"].values,
)

lon = cmor.axis(
"longitude",
units=data["lon"].units,
coord_vals=data["lon"].values,
cell_bounds=data["lon_bnds"].values,
)
if data["lon"]:
lon = cmor.axis(
"longitude",
units=data["lon"].units,
coord_vals=data["lon"].values,
cell_bounds=data["lon_bnds"].values,
)

if levels and time is not None:
axes = [time, lev, lat, lon]
Expand Down
85 changes: 85 additions & 0 deletions e3sm_to_cmip/resources/qboi_template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"_control_vocabulary_file": "CMIP6_CV.json",

"_AXIS_ENTRY_FILE": "CMIP6_coordinate.json",

"_FORMULA_VAR_FILE": "CMIP6_formula_terms.json",

"_cmip6_option": "CMIP6",

"tracking_prefix": "hdl:21.14100",

"activity_id": "CMIP",

"outpath": "CMIP6",

"experiment_id": "piControl",

"sub_experiment_id": "none",

"sub_experiment": "none",

"source_type": "AOGCM AER",

"mip_era": "CMIP6",

"calendar": "noleap",

"realization_index": "1",

"initialization_index": "1",

"physics_index": "1",

"forcing_index": "1",

"project PI": "Dave Bader ([email protected])",

"data contact": "[email protected]",

"history": "Output from 20180129.DECKv1b_piControl.ne30_oEC.edison",

"comment": "",

"references": "Golaz, J.-C., L. P. Van Roekel, X. Zheng and co-authors, 2022: The DOE E3SM Model Version 2: Overview of the physical model and initial model evaluation. JAMES, doi: 10.1029/2022MS003156; http://e3sm.org",

"grid": "gs1x1",

"grid_label": "gr",

"nominal_resolution": "100 km",

"institution_id": "E3SM-Project",

"branch_time_in_parent": "0.0D0",

"branch_time_in_child": "0.0D0",

"parent_experiment_id": "piControl-spinup",

"parent_activity_id": "CMIP",

"parent_mip_era": "CMIP6",

"parent_source_id": "E3SM-1-0",

"parent_time_units": "days since 0001-01-01",

"parent_variant_label": "r1i1p1f1",

"branch_method": "Spin-up documentation",

"run_variant": "",

"source_id": "E3SM-1-0",

"source": "E3SM 1.0 (2018)",

"_history_template": "%s ;rewrote data to be consistent with <activity_id> for variable <variable_id> found in table <table_id>.",

"output_path_template": "<mip_era><activity_id><institution_id><source_id><experiment_id><_member_id><table><variable_id><grid_label><version>",

"output_file_template": "<variable_id><table><source_id><experiment_id><_member_id><grid_label>",

"license": "CMIP6 model data produced by E3SM-Project is licensed under a Creative Commons Attribution 4.0 International License (https://creativecommons.org/licenses/by/4.0/). Consult https://pcmdi.llnl.gov/CMIP6/TermsOfUse for terms of use governing CMIP6 output, including citation requirements and proper acknowledgment. Further information about this data, including some limitations, can be found via the further_info_url (recorded as a global attribute in this file) and at https://pcmdi.llnl.gov/. The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law."
}
6 changes: 6 additions & 0 deletions e3sm_to_cmip/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"CMIP6_CF3hr.json",
"CMIP6_CFday.json",
"CMIP6_fx.json",
"QBOi_monZ.json",
"QBOi_mon.json",
"QBOi_dayZ.json",
"QBOi_day.json",
"QBOi_6hrPt.json",
"QBOi_3hr.json",
]

LAND_TABLES = ["CMIP6_Lmon.json", "CMIP6_LImon.json"]
Expand Down