-
Notifications
You must be signed in to change notification settings - Fork 92
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
Indexing fix in multiple python scripts #1287
base: main
Are you sure you want to change the base?
Conversation
…ation, the code would crash with scalars. The updates should be equivalent to the old code but do not cause errors.
…ython/netcdf libraries, the lack of nc extension has caused the function to crash.
I copied this from FatesPFTIndexSwapper.py, because the code was giving an attribute error.
Apparently this is different between scipy/io/netcdf and netCDF4
Fixing a bug I introduced when I replaced variable retrieval with variables.get. I had forgotten to replace square brackets with parentheses.
@@ -4,11 +4,19 @@ | |||
# --input or --fin: input filename. | |||
# --output or --fout: output filename. If missing, will assume its directly modifying the input file, and will prompt unless -O is specified | |||
|
|||
import netCDF4 as nc | |||
#import netCDF4 as nc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its nice that we are being more consistent in the library usage, this will lower the dependency threshold, nice catch @mpaiao
varin = dsin.variables.get(v_name) | ||
v_type = dsin.variables[v_name].typecode() | ||
v_dims = varin.dimensions | ||
print(" V_NAME = ",v_name,"; V_TYPE = ",v_type,"; V_DIMS = ",v_dims) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you want to keep this print statement, or was it just for debugging?
Minor updates on multiple python scripts, for indexing and for using netcdf from scipy.io libraries
Description:
I don't know if this is only happening on my computer, but
FatesPFTIndexSwapper.py
started to issue the following indexing error when it attempted to copy scalars:The suggested change in the code seems to work fine (though I still get the RuntimeWarning message). I made similar updates in a few other scripts. I also updated
ncvarsort.py
to use scipy.Collaborators:
Expectation of Answer Changes:
No change in the FATES code, just the tool.
Checklist
If this is your first time contributing, please read the CONTRIBUTING document.
All checklist items must be checked to enable merging this pull request:
Contributor
Integrator
Documentation
Test Results:
CTSM (or) E3SM (specify which) test hash-tag:
CTSM (or) E3SM (specify which) baseline hash-tag:
FATES baseline hash-tag:
Test Output: