E3SM-Project/e3sm_to_cmip

[Bug]: Custom `freq` argument is not being considered when CMORizing

tomvothecoder opened this issue · 1 comments

What happened?

In #213, I am attempting to generate the pr CMIP variable using a frequency of "3hr". The frequency for the handler is updated correctly in the code, but it isn't being considered when CMORizing.

What did you expect to happen? Are there are possible answers you came across?

I think this is due to the way handlers are derived. Handler objects are generated, then the dictionary representation is extracted (maintains legacy structure to continue supporting legacy python handlers) and the table key is updated based on the freq arg. However, the original and VarHandler.table attributes are never updated which means the VarHandler.cmorize() method uses the original VarHandler.table value.

Minimum Complete Reproducible Example (MCRE)

from e3sm_to_cmip.__main__ import E3SMtoCMIP

# -----------------
# SETUP
# -----------------
# historical
exp = "historical"
# expshort=hist-nat
# exp=hist-all-xGHG-xaer
caseid = "v2.LR.${exp}_0101"
start = 1850
end = 1850
ypf = 1

# -----------------
# PATHS
# -----------------
e2c_path = "/p/user_pub/e3sm/zhang40/e3sm_to_cmip_data"
model_data = "$e2c_path/model-output"
result_dir2 = "qa/115-branch"
result_dir = "/p/user_pub/e3sm/e3sm_to_cmip/test-cases/115-branch"

map_file = f"{e2c_path}/maps/map_ne30pg2_to_cmip6_180x360_aave.20200201.nc"
tables_path = f"{e2c_path}/cmor/cmip6-cmor-tables/Tables/"
metadata_path = f"{e2c_path}/user_metadata.json"

input_path = f"{model_data}/v2.eam.h4_input"
raw_var_list = "PRECT"
rgr_dir = f"{result_dir}/rgr_3hr"
native_dir = f"{result_dir}/native_3hr"
cmip_var_list = "pr"

# -----------------
# ARGS and CALL
# -----------------
args = [
    "--freq",
    "3hr",
    "-i",
    rgr_dir,
    "-o",
    result_dir2,
    "-v",
    cmip_var_list,
    "-t",
    tables_path,
    "-u",
    metadata_path,
    "--serial",
]

run = E3SMtoCMIP(args)
run.run()

Relevant log output

Example output with day frequency and not 3hr frequency:

/home/vo13/E3SM-Project/e3sm_to_cmip/qa/115-branch/CMIP6/CMIP/E3SM-Project/E3SM-1-0/piControl/r1i1p1f1/day/pr/gr/tests/pr_day_E3SM-1-0_piControl_r1i1p1f1_gr_18500101-18501231.nc

Anything else we need to know?

Related to an issue here:

Environment

e3sm_to_cmip=1.10.0

Nevermind, this only affects PR #213 because I refactored lib.py and moved the functions to VarHandler.cmorize().
I need to find a way to update VarHandler.table attribute.