dtcenter / METplus

Python scripting infrastructure for MET tools.
https://metplus.readthedocs.io
Apache License 2.0
98 stars 37 forks source link

Update setting of environment variables for MET config files to add support for all to METPLUS_ vars #768

Closed georgemccabe closed 3 years ago

georgemccabe commented 3 years ago

We are moving towards a new format of setting environment variables that are read by the wrapped MET config files.

METPLUS_MODEL = model = "WRF"; or METPLUS_MODEL = ""

Describe the Enhancement

Engineering: Modifications to each wrapper should be made to

Documentation:

Time Estimate

~5 days

Sub-Issues

Consider breaking the enhancement down into sub-issues.

Relevant Deadlines

4.0.0

Funding Source

2790541 (no longer valid) Now split between 2702691, 2788881, 2799991

Define the Metadata

Assignee

Labels

Projects and Milestone

Define Related Issue(s)

Consider the impact to the other METplus components.

Enhancement Checklist

See the METplus Workflow for details.

georgemccabe commented 3 years ago

Dan and I are working on branch feature_768_metconfig I have finished implementing support for all new METPLUS environment variables in the following wrappers:

ASCII2NC EnsembleStat GridStat MODE MTD PointStat

Changes made to these wrappers are easy to replicate in the other wrappers. Some variables have already been supported in the other wrappers with changes to be consistent across wrappers.

Still need to finish:

GridDiag PB2NC SeriesAnalysis STATAnalysis TCGen TCPairs TCRMW TCStat

georgemccabe commented 3 years ago

Finished: GridDiag PB2NC SeriesAnalysis STATAnalysis TCGen TCRMW

To go: TCPairs TCStat

Still need to test changes against previous version to ensure output is the same and update docs

georgemccabe commented 3 years ago

All wrappers have now implemented the new method for setting environment variables.

georgemccabe commented 3 years ago

@DanielAdriaansen I added a check for unused environment variables in the wrapped MET config files. Any item that is in the wrappers WRAPPER_ENV_VAR_KEYS list that is not found in the wrapped MET config file will produce a warning:

(command_builder.py:146) WARNING: Environment variable ${METPLUS_FCST_FIELD} is not utilized in MET config file: /d1/personal/mccabe/METplus/parm/met_config/PointStatConfig_wrapped
(command_builder.py:146) WARNING: Environment variable ${METPLUS_OBS_FIELD} is not utilized in MET config file: /d1/personal/mccabe/METplus/parm/met_config/PointStatConfig_wrapped
(command_builder.py:146) WARNING: Environment variable ${METPLUS_MESSAGE_TYPE} is not utilized in MET config file: /d1/personal/mccabe/METplus/parm/met_config/PointStatConfig_wrapped
(command_builder.py:146) WARNING: Environment variable ${METPLUS_CLIMO_MEAN_FILE} is not utilized in MET config file: /d1/personal/mccabe/METplus/parm/met_config/PointStatConfig_wrapped
(command_builder.py:146) WARNING: Environment variable ${METPLUS_CLIMO_STDEV_FILE} is not utilized in MET config file: /d1/personal/mccabe/METplus/parm/met_config/PointStatConfig_wrapped
(command_builder.py:146) WARNING: Environment variable ${METPLUS_OBS_WINDOW_DICT} is not utilized in MET config file: /d1/personal/mccabe/METplus/parm/met_config/PointStatConfig_wrapped
(command_builder.py:146) WARNING: Environment variable ${METPLUS_MASK_GRID} is not utilized in MET config file: /d1/personal/mccabe/METplus/parm/met_config/PointStatConfig_wrapped
(command_builder.py:146) WARNING: Environment variable ${METPLUS_MASK_POLY} is not utilized in MET config file: /d1/personal/mccabe/METplus/parm/met_config/PointStatConfig_wrapped
(command_builder.py:146) WARNING: Environment variable ${METPLUS_MASK_SID} is not utilized in MET config file: /d1/personal/mccabe/METplus/parm/met_config/PointStatConfig_wrapped
(command_builder.py:146) WARNING: Environment variable ${METPLUS_OUTPUT_PREFIX} is not utilized in MET config file: /d1/personal/mccabe/METplus/parm/met_config/PointStatConfig_wrapped

This should make it easier for you to see what has not yet been updated in the files in parm/met_config. Keep in mind that if I have forgotten to add a variable name to the wrapper's list, then it will not show up here.

georgemccabe commented 3 years ago

The diff output from running develop and this branch can be found on kiowa here:

/d1/personal/mccabe/diff-output/diff.log

The differences in the CyclonePlotter text file are due to the wrapper writing the output in a different order each run, which will be resolved with this PR: #797

The differences in the TCStat output have been resolved in a config change on the feature branch feature_768_met_config

DanielAdriaansen commented 3 years ago

All met_tool_wrapper GridStat use cases were tested with the new wrapped GridStat config file and no differences between the output of each use case using the wrapped GridStat config file from this branch and the wrapped GridStat config file from the develop branch were noted. Documentation for the met_tool_wrapper GridStat use cases has been updated. Next up will be testing model_applications GridStat use cases:

GridStat_fcstCESM_obsGFS_ConusTemp.py
GridStat_fcstHRRR_obsPracPerfect_SurrogateSevereProb.py
GridStat_fcstHRRR_obsPracPerfect_SurrogateSevere.py
GridStat_MODE_fcstIMS_obsNCEP_sea_ice.py
GridStat_fcstGFS_obsGFS_climoNCEP_MultiField.py
GridStat_fcstGFS_obsGFS_Sfc_MultiField.py
GridStat_fcstGFS_obsCCPA_GRIB.py
GridStat_fcstHREFmean_obsStgIV_Gempak.py
GridStat_fcstHREFmean_obsStgIV_NetCDF.py
GridStat_fcstHRRR-TLE_obsStgIV_GRIB.py
GridStat_SeriesAnalysis_fcstNMME_obsCPC_seasonal_forecast.py
GridStat_fcstGloTEC_obsGloTEC_vx7.py
DanielAdriaansen commented 3 years ago

All of the GridStat model_applications use cases have been updated in two places:

  1. Each METplus conf file was switched to use the GridStatConfig_wrapped MET config file
  2. Each METplus docs Python/RST file was updated so the literalinclude is including the GridStatConfig_wrappped MET config file
  3. Each METplus conf file for the use case was switched from using CONFIG_DIR to PARM_BASE/met_config (for GRID_STAT_MET_CONFIG only)

No testing was done on these changes locally. I will be moving to the next wrapper now.

A checklist of sorts based on my experience with GridStat:

DanielAdriaansen commented 3 years ago

Checklist for each wrapper:

DanielAdriaansen commented 3 years ago

Update- it looks like the GridStat S2S model_applications use case needs some attention. I think some output_flag or nc_pairs_flag changes are needed to get the use case to work properly. I tried testing with GRID_STAT_MET_CONFIG_OVERRIDES but I can't get that to work presently.

DanielAdriaansen commented 3 years ago

With the help of George all GridStat use cases are passing now. I am moving to EnsembleStat.

DanielAdriaansen commented 3 years ago

EnsembleStat use cases have been updated and docs changes are complete. Here are a list of use cases changed:

met_tool_wrapper/EnsembleStat/EnsembleStat.conf
met_tool_wrapper/EnsembleStat/EnsembleStat_python_embedding.conf
model_applications/air_quality_and_comp/EnsembleStat_fcstICAP_obsMODIS_aod.conf
model_applications/convection_allowing_models/EnsembleStat_fcstHRRRE_obsHRRRE_Sfc_MultiField.conf
model_applications/convection_allowing_models/EnsembleStat_fcstHRRR_fcstOnly_SurrogateSevere.conf
model_applications/precipitation/EnsembleStat_fcstHRRRE_FcstOnly_NetCDF.conf
model_applications/precipitation/EnsembleStat_fcstWOFS_obsWOFS.conf

The docs build except for the glossary entry for ENS_ENSEMBLE_STAT_DATATYPE (see #828).

DanielAdriaansen commented 3 years ago

Moving to ASCII2NC:

DanielAdriaansen commented 3 years ago

ASCII2NC was a breeze, and only had met_toolwrapper use cases and one METPLUS* item to support. Here are the modified use cases:

met_tool_wrapper/ASCII2NC/ASCII2NC.conf

The docs build except for previously mentioned errors.

DanielAdriaansen commented 3 years ago

Moving to GridDiag:

georgemccabe commented 3 years ago

I have started some of the MODE examples, so I would skip that tool for now.

DanielAdriaansen commented 3 years ago

GridDiag similarly straightforward, mainly due to lack of model_applications use cases. Here are the modified use cases:

met_tool_wrapper/GridDiag/GridDiag.conf

Docs build successfully.

DanielAdriaansen commented 3 years ago

Moving to PB2NC:

DanielAdriaansen commented 3 years ago

PB2NC was also straightforward. Here are the modified use cases:

use_cases/met_tool_wrapper/PB2NC/PB2NC.conf

Docs build successfully.

DanielAdriaansen commented 3 years ago

Moving to PointStat:

DanielAdriaansen commented 3 years ago

PointStat is complete. Automation is running now. Here are the modified use cases:

met_tool_wrapper/PointStat/PointStat.conf
met_tool_wrapper/PointStat/PointStat_once_per_field.conf
model_applications/medium_range/PointStat_fcstGFS_obsGDAS_UpperAir_MultiField_PrepBufr.conf
model_applications/medium_range/PointStat_fcstGFS_obsNAM_Sfc_MultiField_PrepBufr.conf
model_applications/tc_and_extra_tc/UserScript_ASCII2NC_PointStat_fcstHAFS_obsFRD_NetCDFci_overrides.conf

Docs build.

DanielAdriaansen commented 3 years ago

Moving to StatAnalysis:

DanielAdriaansen commented 3 years ago

StatAnalysis is complete. All use cases appear to be passing automation. Here are the modified use cases:

met_tool_wrapper/StatAnalysis/StatAnalysis.conf
met_tool_wrapper/StatAnalysis/StatAnalysis_python_embedding.conf
model_applications/data_assimilation/StatAnalysis_fcstHAFS_obsPrepBufr_JEDI_IODA_interface.conf

Docs build- some issues with items not in conf glossary. Will resolve later.

DanielAdriaansen commented 3 years ago

Moving to SeriesAnalysis:

DanielAdriaansen commented 3 years ago

SeriesAnalysis is complete. Automation has not run yet. Here are the modified use cases:

met_tool_wrapper/SeriesAnalysis/SeriesAnalysis.conf
met_tool_wrapper/SeriesAnalysis/SeriesAnalysis_python_embedding.conf
model_applications/s2s/GridStat_SeriesAnalysis_fcstNMME_obsCPC_seasonal_forecast.conf

Note that it appears all SeriesAnalysis use cases were already using the _wrapped MET config file, and that file already contained all the new METPLUS_* items supported by series_analysis_wrapper so theoretically these changes are only for documentation and all use cases should still run.

Docs build- some issues with items not in conf glossary. Will resolve later.

DanielAdriaansen commented 3 years ago

Moving to TcGen:

DanielAdriaansen commented 3 years ago

TCGen is complete. Automation has not run yet. Here are the modified use cases:

met_tool_wrapper/TCGen/TCGen.conf

Note that it appears all TCGen use cases were already using the _wrapped MET config file, and that file already contained all the new METPLUS_* items supported by tc_gen_wrapper so theoretically these changes are only for documentation and all use cases should still run.

Docs build- some issues with items not in conf glossary. Will resolve later.

NOTE- these changes align with METv9.1 When #801 is complete this section will need to be updated appropriately.

DanielAdriaansen commented 3 years ago

Moving to TcPairs:

DanielAdriaansen commented 3 years ago

TCPairs is complete. Automation has not run yet. Here are the modified use cases:

met_tool_wrapper/TCPairs/TCPairs_extra_tropical.py
met_tool_wrapper/TCPairs/TCPairs_tropical.py
model_applications/tc_and_extra_tc/Plotter_fcstGFS_obsGFS_ExtraTC.py
model_applications/tc_and_extra_tc/Plotter_fcstGFS_obsGFS_RPlotting.py

Docs build- some issues with items not in conf glossary. Will resolve later.

The use cases using TCPairs should be monitored because the _wrapped MET config file was changed for these use cases.

DanielAdriaansen commented 3 years ago

Moving to TcRMW:

georgemccabe commented 3 years ago

While doing this work, I learned that the values for fcst_raw_plot.color_table and the equivalent obs color table were incorrect in the parm/met_config/MODEConfig_wrapped file (differs from share/met/config version). This will result in differences in ps output. I have seen this a couple cases but there may be more. Once we get a full list of use cases that are affected, we can rerun them with the old value to confirm that no differences arise to ensure that the changes are expected.

Use cases that should have no differences if the color scale is changed back to the wrong default (may not be a complete list):

The following run includes overriding the color scale to the old value for these 3 cases. If no differences occur in result, then we can safely assume that the output of these 3 use cases will differ and that is expected: https://github.com/dtcenter/METplus/actions/runs/625210865 We will need to update the develop-ref branch from develop after these changes are merged in.

georgemccabe commented 3 years ago

Update: The following are output in the difference output that are expected changes:

Caused by incorrect default color table in default wrapped MET config:

met_tool_wrapper

Text diff A:/data/truth/MODE/mode/2005080712/mode_WRF_RH_vs_WRF_RH_P500_120000L_20050807_120000V_000000A.ps B:/data/output/MODE/mode/2005080712/mode_WRF_RH_vs_WRF_RH_P500_120000L_20050807_120000V_000000A.ps

convection_allowing_models:0-5

Text diff A:/data/truth/MODE_fcstHRRR_obsMRMS_Hail_GRIB2/hailtest/mode_270000L_20190529_030000V_010000A.ps B:/data/output/MODE_fcstHRRR_obsMRMS_Hail_GRIB2/hailtest/mode_270000L_20190529_030000V_010000A.ps Text diff A:/data/truth/MODE_fcstHRRR_obsMRMS_Hail_GRIB2/hailtest/mode_260000L_20190529_020000V_010000A.ps B:/data/output/MODE_fcstHRRR_obsMRMS_Hail_GRIB2/hailtest/mode_260000L_20190529_020000V_010000A.ps

convection_allowing_models:6+

Text diff A:/data/truth/MODE_fcstFV3_obsGOES_BrightnessTemp/convection_allowing_models/brightness_temperature/mode_FV3_core_lsm1_020000L_20190521_020000V_NAA.ps B:/data/output/MODE_fcstFV3_obsGOES_BrightnessTemp/convection_allowing_models/brightness_temperature/mode_FV3_core_lsm1_020000L_20190521_020000V_NAA.ps

New output from new use cases (PointStat_python_embedding and MODE_python_embedding) that are not found in truth data set

met_tool_wrapper

file not found (new output) A: B:/data/output/PointStat_python_embedding/metplus_final.conf file not found (new output) A: B:/data/output/PointStat_python_embedding/point_stat_py_embed/point_stat_000000L_20200906_060000V.stat file not found (new output) A: B:/data/output/MODE_python_emedding/metplus_final.conf file not found (new output) A: B:/data/output/MODE_python_emedding/met_tool_wrapper/MODE_python_embedding/2005080712/mode_FCST_vs_OBS_120000L_20050807_120000V_120000A_obj.nc file not found (new output) A: B:/data/output/MODE_python_emedding/met_tool_wrapper/MODE_python_embedding/2005080712/mode_FCST_vs_OBS_120000L_20050807_120000V_120000A_cts.txt file not found (new output) A: B:/data/output/MODE_python_emedding/met_tool_wrapper/MODE_python_embedding/2005080712/mode_FCST_vs_OBS_120000L_20050807_120000V_120000A_obj.txt file not found (new output) A: B:/data/output/MODE_python_emedding/met_tool_wrapper/MODE_python_embedding/2005080712/mode_FCST_vs_OBS_120000L_20050807_120000V_120000A.ps

Extra masking fields were generated mistakenly

We need @lindsayrblank to confirm that the extra fields are not needed, but I believe this to be the case. The settings for this use case had an empty string set for the mask.grid, i.e.:

mask = {
   grid = [ "" ];
  poly = [ ${VERIF_MASK} ];
}

This should actually be set to:

grid = [];

because we want to only use the poly values to determine the grid. All of the downstream output from MODE is identical to the truth data, which implies that the extra mask output fields are not being used in the use case.

COMPARING GridStat_MODE_fcstIMS_obsNCEP_sea_ice/model_applications/cryosphere/sea_ice/GridStat/20190201/grid_stat/grid_stat_IMS_ICEC_vs_NCEP_ICEC_Z0_000000L_20190201_220000V.stat file_A: /data/truth/GridStat_MODE_fcstIMS_obsNCEP_sea_ice/model_applications/cryosphere/sea_ice/GridStat/20190201/grid_stat/grid_stat_IMS_ICEC_vs_NCEP_ICEC_Z0_000000L_20190201_220000V.stat file_B: /data/output/GridStat_MODE_fcstIMS_obsNCEP_sea_ice/model_applications/cryosphere/sea_ice/GridStat/20190201/grid_stat/grid_stat_IMS_ICEC_vs_NCEP_ICEC_Z0_000000L_20190201_220000V.stat

Comparing text files Comparing stat file ERROR: Different number of lines in /data/output/GridStat_MODE_fcstIMS_obsNCEP_sea_ice/model_applications/cryosphere/sea_ice/GridStat/20190201/grid_stat/grid_stat_IMS_ICEC_vs_NCEP_ICEC_Z0_000000L_20190201_220000V.stat File_A: 18 File_B: 9 ERROR: File differs: /data/output/GridStat_MODE_fcstIMS_obsNCEP_sea_ice/model_applications/cryosphere/sea_ice/GridStat/20190201/grid_stat/grid_stat_IMS_ICEC_vs_NCEP_ICEC_Z0_000000L_20190201_220000V.stat

COMPARING GridStat_MODE_fcstIMS_obsNCEP_sea_ice/model_applications/cryosphere/sea_ice/GridStat/20190201/grid_stat/grid_stat_IMS_ICEC_vs_NCEP_ICEC_Z0_000000L_20190201_220000V_pairs.nc file_A: /data/truth/GridStat_MODE_fcstIMS_obsNCEP_sea_ice/model_applications/cryosphere/sea_ice/GridStat/20190201/grid_stat/grid_stat_IMS_ICEC_vs_NCEP_ICEC_Z0_000000L_20190201_220000V_pairs.nc file_B: /data/output/GridStat_MODE_fcstIMS_obsNCEP_sea_ice/model_applications/cryosphere/sea_ice/GridStat/20190201/grid_stat/grid_stat_IMS_ICEC_vs_NCEP_ICEC_Z0_000000L_20190201_220000V_pairs.nc

Comparing NetCDF ERROR: Field list differs between files File_A: ['DIFF_ICEC_Z0_ICECZ0', 'DIFF_ICEC_Z0_ICEC_Z0_data_mask', 'FCST_ICECZ0', 'FCST_ICEC_Z0eq1.0_NBRHD_25', 'FCST_ICEC_Z0eq1.0_NBRHD_49', 'FCST_ICEC_Z0eq1.0_NBRHD_81', 'FCST_ICEC_Z0eq1.0_NBRHD_9', 'FCST_ICEC_Z0_data_mask', 'FCST_ICEC_Z0_data_mask_eq1.0_NBRHD_25', 'FCST_ICEC_Z0_data_mask_eq1.0_NBRHD_49', 'FCST_ICEC_Z0_data_mask_eq1.0_NBRHD_81', 'FCST_ICEC_Z0_data_mask_eq1.0_NBRHD_9', 'OBS_ICECZ0', 'OBS_ICEC_Z0ge0.40_NBRHD_25', 'OBS_ICEC_Z0ge0.40_NBRHD_49', 'OBS_ICEC_Z0ge0.40_NBRHD_81', 'OBS_ICEC_Z0ge0.40_NBRHD_9', 'OBS_ICEC_Z0_data_mask', 'OBS_ICEC_Z0_data_mask_ge0.40_NBRHD_25', 'OBS_ICEC_Z0_data_mask_ge0.40_NBRHD_49', 'OBS_ICEC_Z0_data_mask_ge0.40_NBRHD_81', 'OBS_ICEC_Z0_data_mask_ge0.40_NBRHD_9', 'lat', 'lon'] File_B:['DIFF_ICEC_Z0_ICEC_Z0_data_mask', 'FCST_ICEC_Z0_data_mask', 'FCST_ICEC_Z0_data_mask_eq1.0_NBRHD_25', 'FCST_ICEC_Z0_data_mask_eq1.0_NBRHD_49', 'FCST_ICEC_Z0_data_mask_eq1.0_NBRHD_81', 'FCST_ICEC_Z0_data_mask_eq1.0_NBRHD_9', 'OBS_ICEC_Z0_data_mask', 'OBS_ICEC_Z0_data_mask_ge0.40_NBRHD_25', 'OBS_ICEC_Z0_data_mask_ge0.40_NBRHD_49', 'OBS_ICEC_Z0_data_mask_ge0.40_NBRHD_81', 'OBS_ICEC_Z0_data_mask_ge0.40_NBRHD_9', 'lat', 'lon'] Using File_A fields. ERROR: Field DIFF_ICEC_Z0_ICECZ0 not found

No output lines in truth data

precipitation

Text diff A:/data/truth/GridStat_fcstGFS_obsCCPA_GRIB/model_applications/precipitation/GridStat_fcstGFS_obsCCPA_GRIB/met_out/GFS/precip/201706130000/grid_stat/grid_stat_GFS_APCP_vs_ANLYS_APCP_A24_240000L_20170613_000000V.stat B:/data/output/GridStat_fcstGFS_obsCCPA_GRIB/model_applications/precipitation/GridStat_fcstGFS_obsCCPA_GRIB/met_out/GFS/precip/201706130000/grid_stat/grid_stat_GFS_APCP_vs_ANLYS_APCP_A24_240000L_20170613_000000V.stat

Threshold values were removed from this use case, which caused there to be no output lines. 5 threshold values were added back and the use case now produces output.

georgemccabe commented 3 years ago

Full logs of the differences tests can be viewed here (for ~90 days): https://github.com/dtcenter/METplus/actions/runs/633804009

DanielAdriaansen commented 3 years ago

We should also update the docs about adding a new use case to note that a MET conf file is no longer needed- the _wrapped file should be used.

https://dtcenter.github.io/METplus/latest/Contributors_Guide/add_use_case.html