Code fails on assumption of 1 clim file per variable name not accounting for components (i.e precc, precl vs prect) or comparable variables (i.e ts vs sst) #228
Labels
bug
Something isn't working
ADF run type
Model vs. Obs
What happened?
There are a couple of layers to this. But the source of the error is in regrid_and_vert_interp.py, in this section:
if len(mclim_fils) > 1:
#Combine all cam files together into a single data set:
mclim_ds = xr.open_mfdataset(mclim_fils, combine='by_coords')
else:
#Open single file as new xsarray dataset:
mclim_ds = xr.open_dataset(mclim_fils[0])
#End if
First, if one wants to use the yaml file for the default AMWG behavior, the code currently assumes that "PRECT" is there and does not check for PRECL and PRECC. but i believe the rest of the code can handle PRECL and PRECC (presumably the timeseries file creation combines the terms into PRECT, but i don't remember for sure), but in this case I am using timeseries files already generated offline, not via ADF.
Second, if one variable is not there (i.e. SST), it is also not trying to find TS and mask it. It looks for an SST clim file and fails.
So currently, in these instances, the code errors out because the len(mclim_fils) is actually zero. but the code snippet above assumes that it will only ever be mor than 1 or 1 (because the else has the action of subscripting assuming length 1). It'd be great to check if it's zero, and then give a clear error message "No clim file for variable X found. " . Additionally, it'd be great if it would check for comparable variables and combine (in case of prect) and/or use an alternate like TS for SST. and let the user know with "Using Y instead" or "Can't find alternate variable. Skipping X."
ADF Hash you are using
bcf3630
What machine were you running the ADF on?
CISL machine
What python environment were you using?
NPL (CISL machines only)
Extra info
No response
The text was updated successfully, but these errors were encountered: