-
Notifications
You must be signed in to change notification settings - Fork 38
Feature #2560 Update Fire use case #2956
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
… using Python Embedding
…it is no longer used
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.
Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.
Files not reviewed (3)
- docs/Release_Guide/release_steps/met/update_web_server_data.rst: Language not supported
- internal/tests/use_cases/all_use_cases.txt: Language not supported
- parm/use_cases/model_applications/fire/GridStat_fcstWRF_obsMMA_fire_perimeter.conf: Language not supported
Comments suppressed due to low confidence (3)
metplus/wrappers/runtime_freq_wrapper.py:889
- Consider verifying that the remove_quotes function is idempotent to prevent potential double quoting if the file path is already enclosed in quotation marks.
file_list = [f'"{remove_quotes(item)}"' if ' ' in item else item for item in file_list]
metplus/wrappers/py_embed_ingest_wrapper.py:109
- Setting RDP_SKIP_RUN_CHECK unconditionally may affect behavior in other wrappers; consider adding a comment that explains this configuration update and its intended scope.
self.config.set('config', 'RDP_SKIP_RUN_CHECK', True)
internal/tests/pytests/wrappers/point_stat/test_point_stat_wrapper.py:911
- [nitpick] Ensure that the substring check for 'PYTHON' in the OBS_POINT_STAT_INPUT_TEMPLATE reliably distinguishes the Python embedding case from standard file paths; a stricter condition or additional comment could enhance clarity.
if 'OBS_POINT_STAT_INPUT_TEMPLATE' in config_overrides and 'PYTHON' in config_overrides['OBS_POINT_STAT_INPUT_TEMPLATE']:
Addressing feedback from Copilot:
The file_list values are not always surrounded by quotation marks. A "file path" in this list can be a call to a Python script or a string that defines grid information. The logic to handle this already adds quotation marks. However, updates to the use case in this PR uncovered that file paths that include a space character are not properly quoted. This new line ensures that quotation marks are added around paths with spaces. Since the values can potentially already include quotation marks, the
I added a comment to explain why this was set. The config variable is meant to be internal and not set by users, so I did not add info about this variable to the documentation. It is only used to prevent an incorrect error from being logged, so there is no harm if a user accidentally creates a config variable with the same name.
I agree that the check for the string 'PYTHON' will break down if a file path includes the string. I didn't think it was necessarily to come up with a more robust solution because this is an internally-used test and it is unlikely that any future modifications to the tests will include the string and cause an issue. If a developer does do this, the tests will break and a closer review should uncover the requirements of a new test. |
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.
George, thanks for pointing out the differences that this PR causes. I definitely do think that we should add set_attr
options to eliminate the diffs in the stat files and reduce the ones in the NetCDF files. The "truth" units (%) are better than the new "output" units (1). And if we're updating the units, we may as well update the level string as well. And this will serve as a nice example of the -set_attr
options in a METplus Use Case.
I'd recommend adding:
FCST_VAR1_OPTIONS = -set_attr_units % -set_attr_level Z0
I'll just proposed that one line change to the code.
parm/use_cases/model_applications/fire/GridStat_fcstWRF_obsMMA_fire_perimeter.conf
Show resolved
Hide resolved
Co-authored-by: John Halley Gotway <johnhg@ucar.edu>
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.
Thanks @georgemccabe for adding the set_attr_units
and set_attr_level
options to minimize the diffs. The remaining differences for the WRF-Fire Grid-Stat runs are in the NetCDF matched pairs files:
- The
long_name
variable attributes are modified but that's totally fine since the content for that is now being read directly from the input files. - The grid definition information listed in the global attributes are modified slightly, generally in the second decimal place, but so too have the
x_pin
andy_pin
locations.
You suggested that these were minor diffs based on rounding, but I think they're actually significant differences. But those differences are actually fine. They are just two different ways of defining the same grid!
The x/y pin locations define the location of the reference lat/lon in the grid. The old x/y of (0,0) means that lat/lon (37.402645, -107.881439) occurs at the lower-left corner of the grid. The new x/y of (235.5, 235.5) means that lat/lon (37.461014, -107.80799) occurs at the center of the grid.
The lat/lon difference from old to new reference location is (-0.058369, 0.073449). Very roughly assuming 110km per degree latitude, with d_km = 0.027542
a shift of 235.5 grid points in the x/y directions = 6.486 km = 0.05896 degrees of latitude... which is very close to the actual latitude difference we're seeing!
So the lat/lon locations have changed very slightly in a way that's consistent with the x/y pin location change... for a very, very tiny grid.
The we're running Grid-Stat with forecast data defined relative to the center of the grid and "observation" data (output from Gen-Vx-Mask) defined relative to the lower-left corner of the grid. Since those grid definitions differ, Grid-Stat needs to put them on a common grid. And in metplus_final.conf
I see we're auto-regridding to the forecast grid:
GRID_STAT_REGRID_TO_GRID = FCST
And with nothing overriding the default regridding method in the default Grid-Stat config file, we're regridding using the nearest neighbor method. So the "obs" input data is being regridded with nearest neighbor to forecast grid. But since they're in the same location on earth, we end up getting exactly the same contingency table counts and statistics.
This is a pretty subtle difference. I'd say your options are:
- Keep everything as-is and let Grid-Stat keep doing its regridding between two grids that are equivalent but defined with different parameters.
- Modify the Python embedding script used when running Gen-Vx-Mask so that the forecast and observation grids are defined the same way for Grid-Stat.
Honestly, either approach is totally fine. And sticking with the existing "auto-regridding" does demonstrate the functionality of grid handling in MET.
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 of these changes, but I added a bunch of details and ended with a question in this PR comment. Feel free to stick with the changes as-is or tweak the observation grid definition to avoid unnecessary regridding. Either way is totally fine.
Hi @JohnHalleyGotway , thank you for the detailed summary of what is going on with the diffs. I'll note that GenVxMask is not using Python Embedding. A script is run to convert the fire boundary data to a poly file, then the grid is defined explicitly:
so I won't be able to change the obs grid to use the same x/y pin. That said, I am OK with leaving the "different but same" grid definition and let MET regrid to the forecast. |
Read WRF Fire subgrid field natively in MET instead of using Python Embedding script
Pull Request Testing
Ran fire use case using MET branch to test that it can read the WRF Fire subgrid field without Python Embedding
Reviewed the differences and confirmed they are acceptable (see below)
Review code changes and diffs in fire use case output
The FCST_LEV value has changed because it was previously passed as a hard-coded string in the Python Embedding script but now it lists the NetCDF format
The FCST_UNITS changed because the Python Embedding script passed a hard-coded
%
value but the units value in the NetCDF WRF file is1
The lat and lon values differ by a small amount due to rounding
The field names in the NetCDF output have changed because of the difference in the level values. Should we use set_attr values to change this?
DIFF_FIRE_AREA_Z0_FIRE_PERIM_all_all_FULL
changed toDIFF_FIRE_AREA_0_all_all_FIRE_PERIM_all_all_FULL
FCST_FIRE_AREA_Z0_FULL
changed toFCST_FIRE_AREA_0_all_all_FULL
I confirmed that these fields look the same despite the name change
Do these changes include sufficient documentation updates, ensuring that no errors or warnings exist in the build of the documentation? [Yes]
Do these changes include sufficient testing updates? [Yes]
Will this PR result in changes to the test suite? [Yes]
If yes, describe the new output and/or changes to the existing output:
The fire use case will contain diffs that will require an update to the truth data
Do these changes introduce new SonarQube findings? [No]
If yes, please describe:
Please complete this pull request review by 4/11/2025.
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 METplus-Wrappers-X.Y.Z Development project for official releases