What happened?
I was writing a new climo() function in #677 and found a bug in the existing climo() function. The existing climo() function does not have a conditional statement for season == "ANN", causing this function to break if this case is true.
|
# Compute climatology |
|
if season == "ANNUALCYCLE": |
|
cycle = [ |
|
"01", |
|
"02", |
|
"03", |
|
"04", |
|
"05", |
|
"06", |
|
"07", |
|
"08", |
|
"09", |
|
"10", |
|
"11", |
|
"12", |
|
] |
|
elif season == "SEASONALCYCLE": |
|
cycle = ["DJF", "MAM", "JJA", "SON"] |
|
else: |
|
cycle = [season] |
Downstream in the lat_lon_driver.run_diag() function, there is a section of code to get the land_frac and ocean_frac.
|
# Get land/ocean fraction for masking. |
|
try: |
|
land_frac = test_data.get_climo_variable("LANDFRAC", season) |
|
ocean_frac = test_data.get_climo_variable("OCNFRAC", season) |
|
except Exception: |
|
mask_path = os.path.join( |
|
e3sm_diags.INSTALL_PATH, "acme_ne30_ocean_land_mask.nc" |
|
) |
|
with cdms2.open(mask_path) as f: |
|
land_frac = f("LANDFRAC") |
|
ocean_frac = f("OCNFRAC") |
- If we run with
"ANN", this section of code silently ignores this error due to except Exception (which captures all possible exceptions).
- As a result, the exception will open the default mask file (
acme_ne30_ocean_land_mask.nc) in all cases even if the masking variables exist in the test data and the climatology can be calculated for them.
What did you expect to happen?
climo() should support "ANN"
lat_lon_driver.run_diag() should only capture specific exceptions (e.g,. RunTimeError) and produce a logger warning if captured
- Check all other drivers for similar cases as 2. and fix them
Minimal Complete Verifiable Example
Relevant log output
Anything else we need to know?
In PR #677 (work-in-progress), I wrote a new climo() function that resolves this issue:
https://github.com/E3SM-Project/e3sm_diags/pull/677/files#diff-682f63237e8473278ef0ba3c452382fd62c09bb5cd23a435c8397dfd1ae98487
Environment
Latest stable release and main branch
What happened?
I was writing a new
climo()function in #677 and found a bug in the existingclimo()function. The existingclimo()function does not have a conditional statement forseason == "ANN", causing this function to break if this case is true.e3sm_diags/e3sm_diags/driver/utils/climo.py
Lines 47 to 66 in 4a82b0e
Downstream in the
lat_lon_driver.run_diag()function, there is a section of code to get theland_fracandocean_frac.e3sm_diags/e3sm_diags/driver/lat_lon_driver.py
Lines 132 to 142 in 4a82b0e
"ANN", this section of code silently ignores this error due toexcept Exception(which captures all possible exceptions).acme_ne30_ocean_land_mask.nc)in all cases even if the masking variables exist in the test data and the climatology can be calculated for them.What did you expect to happen?
climo()should support"ANN"lat_lon_driver.run_diag()should only capture specific exceptions (e.g,.RunTimeError) and produce a logger warning if capturedMinimal Complete Verifiable Example
Relevant log output
Anything else we need to know?
In PR #677 (work-in-progress), I wrote a new
climo()function that resolves this issue:https://github.com/E3SM-Project/e3sm_diags/pull/677/files#diff-682f63237e8473278ef0ba3c452382fd62c09bb5cd23a435c8397dfd1ae98487
Environment
Latest stable release and
mainbranch