-
Notifications
You must be signed in to change notification settings - Fork 26
Feature #2781 Convert MET NetCDF point obs to Pandas DataFrame #2877
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
Conversation
…a to pandas so it can be read and modified in a python embedding script. Added example python embedding script
…rn value to catch if function fails to read data
…when file passed to script cannot be read by the NetCDF library
…n from observation header IDs
…reads MET NetCDF point observation file and converts it to a pandas DataFrame
scripts/python/met/point_nc.py
Outdated
return False | ||
|
||
try: | ||
dataset = nc.Dataset(nc_filename, 'r') |
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.
Minor: one more space than other lines
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.
I approve the changes. No duplicated codes and the new API produces PANDA data frame.
I was able to test this on seneca. It takes 20s to read in this file:
which is close to 1M observations. Better running of I worked with the DataFrame a bit in Python and didn't observe any trouble. I wonder if we need any documentation of this? Maybe in Appendix F? @JohnHalleyGotway thoughts? |
I guess we have this section, which is empty: I thought maybe Maybe I will add a "to-do" item here: on #2414 to document the "MET Python Module". |
…name. Also raise TypeError exception from nc_point_obs.read_data() if input file cannot be read
@hsoh-u , I talked with @DanielAdriaansen about these changes. Based on his feedback, I added an init function to nc_point_obs to take an input file path so it can be initialized without calling read_data(). I also changed the read_data() function to raise an exception instead of return a boolean for success. |
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.
I approve the changes.
Expected Differences
Do these changes introduce new tools, command line arguments, or configuration file options? [No]
Do these changes modify the structure of existing or add new output data types (e.g. statistic line types or NetCDF variables)? [No]
Pull Request Testing
On seneca, I created a test script that runs plot_point_obs both passing an input file directly into MET and passing that same file through a python embedding script that converts the data to a Pandas DataFrame, then passes it to MET.
Test directory:
/d1/projects/METplus/METplus_Data/development/met_2781
To run the script:
or just compare the output files
output/raw_subset.png
andoutput/pyembed_subset.png
which should contain the same plot.I also added a unit test to demonstrate the new Python Embedding example and confirmed that it runs successfully both on seneca and in GHA.
@DanielAdriaansen : confirm that the new logic works with your test data
@hsoh-u : confirm that the new python logic is in the correct location and matches the format/standards of the rest of the python logic
Could consider adding an example of using the new script somewhere, but I am not sure where that would live.
Do these changes include sufficient testing updates? [Yes]
Will this PR result in changes to the MET test suite? [Yes]
There will be 1 additional output file generated:
Will this PR result in changes to existing METplus Use Cases? [No]
If yes, create a new Update Truth METplus issue to describe them.
Do these changes introduce new SonarQube findings? [No]
Please complete this pull request review by 5/7/2024.
Pull Request Checklist
See the METplus Workflow for details.
Select: Reviewer(s) and Development issue
Select: Milestone as the version that will include these changes
Select: Coordinated METplus-X.Y Support project for bugfix releases or MET-X.Y.Z Development project for official releases