Skip to content
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

Update develop-ref after #2877 #2881

Merged
merged 86 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
d8572b9
2673 Moved dvariable declaration after include
Feb 2, 2024
6ebfdac
#2673 Move down namespace below include
Feb 2, 2024
c788602
Feature #2395 wdir (#2820)
JohnHalleyGotway Feb 14, 2024
67ee04e
Recent changes to branch protection rules for the develop branch have…
JohnHalleyGotway Feb 15, 2024
b558794
Feature #2280 ens_prob (#2823)
JohnHalleyGotway Feb 22, 2024
069cdbd
Merge remote-tracking branch 'origin/develop' into feature_2673_sonar…
Feb 22, 2024
7f513eb
#2673 Change 0 to nullptr
Feb 27, 2024
7483636
#2673 Change 0 to nullptr
Feb 27, 2024
f33de8e
#2673 Change 0 to nullptr
Feb 27, 2024
c1e99ea
#2673 Change 0 to nullptr
Feb 27, 2024
6c30e49
#2673 Change 0 to nullptr
Feb 27, 2024
5cca97e
Merge pull request #2827 from dtcenter/feature_2673_sonarqube_beta3_n…
hsoh-u Feb 27, 2024
83730cf
#2673 Removed the redundant parentheses with return
Feb 28, 2024
4d60e06
#2673 Removed the redundant parentheses with return
Feb 28, 2024
3ff3767
#2673 Removed the redundant parentheses with return
Feb 28, 2024
55f5d3e
#2673 Removed the redundant parentheses with return
Feb 28, 2024
6bb41bc
#2673 Removed the redundant parentheses with return
Feb 28, 2024
d82a979
#2673 Merged develop branch
Feb 28, 2024
481bb15
#2673 restored return statement
Feb 28, 2024
00b162b
Merge pull request #2828 from dtcenter/feature_2673_sonarqube_beta3_r…
hsoh-u Feb 28, 2024
bc7af99
#2673 Added std namespace
Feb 28, 2024
e872917
#2673 Moved down 'using namespace' statement. Removed trailing spaces
Feb 28, 2024
3eb4367
#2673 Moved down 'using namespace' statement.
Mar 1, 2024
3f92f6a
#2673 Moved down 'using namespace' statement.
Mar 1, 2024
a00c7be
#2673 Moved down 'using namespace' statement.
Mar 1, 2024
5706e97
#2673 Moved down 'using namespace' statement.
Mar 1, 2024
4821c37
Merge remote-tracking branch 'origin/develop' into feature_2673_sonar…
Mar 1, 2024
2509f7c
#2673 Added std namespace
Mar 5, 2024
ca64f00
#2673 Added std namespace
Mar 5, 2024
a7f0e06
#2673 Added std namespace
Mar 5, 2024
0b2a7da
Merge pull request #2831 from dtcenter/feature_2673_sonarqube_beta3_n…
hsoh-u Mar 6, 2024
0ab2466
#2673 Changed literal 1 to boolean value, true
Mar 6, 2024
4d7d4a2
Merge pull request #2832 from dtcenter/feature_2673_sonarqube_1_to_true
hsoh-u Mar 7, 2024
a6f7646
Feature #2673 enum_to_string (#2835)
JohnHalleyGotway Mar 14, 2024
108a895
Feature #2583 ecnt (#2825)
JohnHalleyGotway Mar 14, 2024
4c322aa
Revert #2825 since more documentation and testing is needed (#2837)
JohnHalleyGotway Mar 14, 2024
fd1b250
Feature #2583 ecnt fix IGN_OERR_CORR (#2838)
JohnHalleyGotway Mar 14, 2024
f113181
Update the pull request template to include a question about expected…
JohnHalleyGotway Mar 14, 2024
be3ce26
#2830 Changed enum Builtin to enum class
Mar 19, 2024
0153110
#2830 Converted enum to enum class at config_constants.h
Mar 19, 2024
0a771d4
Feature #2830 bootstrap enum (#2843)
JohnHalleyGotway Mar 23, 2024
98af717
Bugfix #2833 develop azimuth (#2840)
JohnHalleyGotway Mar 27, 2024
1c97607
#2830 Changed enum PadSize to enum class
Mar 27, 2024
40b67d4
#2830 Removed redundant parantheses
Mar 27, 2024
79f81af
#2830 Removed commenyted out code
Mar 27, 2024
cef8aad
Merge remote-tracking branch 'origin/develop' into feature_2830_sonar…
Mar 27, 2024
8cc667c
#2830 Use auto
Mar 27, 2024
d6cba7d
#2830 Changed enum to enum class for DistType, InterpMthd, GridTempla…
Mar 28, 2024
15987a1
#2830 Moved enum_class_as_integer from header file to cc files
Mar 28, 2024
8a277fa
#2830 Added enum_as_int.hpp
Apr 1, 2024
fa41fa3
#2830 Added enum_as_int.hpp
Apr 1, 2024
5c95525
Deleted enum_class_as_integer and renamed it to enum_class_as_int
Apr 1, 2024
62acda7
Removed redundant paranthese
Apr 1, 2024
6ac387f
#2830 Changed enum to enumclass
Apr 1, 2024
175f4ed
#2830 Changed enum_class_as_integer to enum_class_as_int
Apr 1, 2024
2c72a1b
Feature #2379 sonarqube gha (#2847)
JohnHalleyGotway Apr 2, 2024
a72e8c5
Hotfix related to #2379. The sonar.newCode.referenceBranch and sonar.…
JohnHalleyGotway Apr 2, 2024
2bef141
#2830 Changed enum STATJobType to enum class
Apr 3, 2024
9e0cd6d
#2830 Changed STATLineType to enum class
Apr 5, 2024
8fad8f2
#2830 Changed Action to enum class
Apr 5, 2024
6d8a3c7
#2830 Changed ModeDataType to enum class
Apr 5, 2024
df25b86
#2830 Changed StepCase to enum class
Apr 5, 2024
1f1d525
#2830 Changed enum to enum class
Apr 5, 2024
aebdd2a
#2830 Changed GenesisPairCategory to enum class
Apr 5, 2024
00380dc
#2830 Removed rediundabt parenrthese
Apr 5, 2024
42c453e
#2830 Reduced same if checking
Apr 5, 2024
2bd5dcf
#2830 Cleanup
Apr 5, 2024
1f32746
#2830 USe empty() instead of lebgth checking
Apr 5, 2024
0811740
#2830 Adjusted indentations
Apr 5, 2024
e71debf
Feature #2379 develop sonarqube updates (#2850)
JohnHalleyGotway Apr 8, 2024
78f1824
Merge remote-tracking branch 'origin/develop' into feature_2830_sonar…
JohnHalleyGotway Apr 8, 2024
3d543fc
Merge pull request #2849 from dtcenter/feature_2830_sonarqube_enum
hsoh-u Apr 8, 2024
2a26d59
Feature 2654 ascii2nc polar buoy support (#2846)
davidalbo Apr 10, 2024
f78720b
Feature #2786 rpss_from_prob (#2861)
JohnHalleyGotway Apr 17, 2024
947b061
Feature #2862 v12.0.0-beta4 (#2864)
JohnHalleyGotway Apr 17, 2024
406d991
Feature #2379 develop single_sq_project (#2865)
JohnHalleyGotway Apr 18, 2024
0a219b5
Hotfix to the documentation in the develop branch. Issue #2858 was cl…
JohnHalleyGotway Apr 18, 2024
d4c4eba
Feature 2842 ugrid config (#2852)
hsoh-u Apr 25, 2024
3caffb4
Feature 2753 comp script config (#2868)
jprestop Apr 29, 2024
d3ecc87
Feature #2795 level_mismatch_warning (#2873)
JohnHalleyGotway Apr 30, 2024
ccd1061
Feature #2870 removing_MISSING_warning (#2872)
JohnHalleyGotway May 1, 2024
7f9bf9c
Feature 2842 ugrid config (#2875)
hsoh-u May 1, 2024
566d4fb
Hotfix to develop branch to remove duplicate test named 'point_stat_u…
JohnHalleyGotway May 1, 2024
542b4ba
Feature 2748 document ugrid (#2869)
DanielAdriaansen May 7, 2024
79ac568
Feature #2781 Convert MET NetCDF point obs to Pandas DataFrame (#2877)
georgemccabe May 8, 2024
148ddb9
Merge remote-tracking branch 'origin/develop-ref' into update_truth_f…
metplus-bot May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ make.log
make_install.log
.idea
cmake-build-debug

__pycache__
87 changes: 87 additions & 0 deletions docs/Users_Guide/appendixH.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
.. _appendixH:

*****************************
Appendix H Unstructured Grids
*****************************

Introduction
============

METv12.0.0+ includes limited support for using datasets on unstructured grids (UGRIDs) in the PointStat and GridStat tools. This support includes verifying UGRID forecasts against point observations (PointStat), and verifying UGRID forecasts regridded to a structured grid against gridded observations on a structured grid (GridStat). The implementation of UGRID support in METv12.0.0+ provides a mechanism for a user to describe the topology of their unstructured grid. Thus far, development to support datasets on unstructured grids has been driven by the LFRic (“elfrick”) NWP model (:ref:`Adams et al. 2019 <Adams-2019>`), and the Model for Prediction Across Scales (MPAS) NWP model (:ref:`Skamarock et al., 2012 <Skamarock-2012>`). However, the support for unstructured grids was implemented in such a way that additional unstructured grids can be utilized, with the appropriate mapping of the user's topology to the elements that MET requires.

Unstructured Grid Files
=======================

Support for UGRID files in NetCDF format is provided. MET will attempt to auto-detect UGRID files. If the file is CF-compliant and the “Conventions” global attribute is “UGRID” or “MPAS”, or if the global attribute “mesh_spec” is present, MET recognizes the file as a UGRID file. If the user is not using a supported UGRID, or a UGRID file that does not contain the required global attributes for autodetection, the user should set the **file_type** configuration entry to **NETCDF_UGRID**. In some cases, the UGRID topology is provided in an ancillary file separate from forecast variables. This is controlled via the **ugrid_coordinates_file** configuration entry. This file is checked first, and then the UGRID data file. If the same elements are found in both files, the information from the data file takes precedence, and thus it is recommended to leave **ugrid_coordinates_file** unset if all required elements are found in the data file. If both a data and coordinates file are provided, the shape of the latitude and longitude dimensions are cross-referenced as a limited enforcement measure that the coordinates file and data file belong to the same UGRID.

Required Unstructured Grid Metadata
===================================

To correctly parse the UGRID topology, MET needs the following information that must be contained within the UGRID coordinates file or the UGRID data file. It is often the case that the variable names for these elements differ between UGRIDs. If the user is not using one of the supported UGRIDs, they will need to define the **ugrid_metadata_map** in a custom configuration file that they provide on the command line using the **-ugrid_config** command line argument, which tells MET the variable names that correspond to the following elements:

.. _table_ugrid_metadata:

.. list-table:: Required UGRID Metadata
:widths: auto
:header-rows: 1

* - Metadata Map Key
- Description
- Required
* - dim_face
- Dimension name for UGRID cells
- Required
* - lat_face
- Coordinate variable name for the latitude of each UGRID cell
- Required
* - lon_face
- Coordinate variable name for the longitude of each UGRID cell
- Required
* - dim_time
- Dimension name for the time coordinate
- Required
* - time
- Coordinate variable for time
- Required
* - dim_vert
- Dimension name for the vertical coordinate, if present
- Optional
* - vert_face
- Coordinate variable name for the vertical coordinate
- Optional

Unstructured Grid Configuration Entries
=======================================

In the PointStat and GridStat config files, a user can control aspects of the UGRID capability. Since the UGRID support in MET is optional, these items are not included in the default MET config files. If the user requires modification for any of the following, they must add them to their MET config file.

ugrid_dataset
-------------

If the UGRID dataset is supported by MET, then this item is set to the string identifying the UGRID. Currently supported ugrid_dataset options include “lfric”, and “mpas”. If this item is not set, the user must provide a separate UGRID configuration file on the command line using the **-ugrid_config** command line argument.

ugrid_max_distance_km
---------------------

For PointStat, this is the distance from each UGRID cell center that PointStat will search outward to collect observations to use for verification. The default is 0 km, which by default will use the closest observation to the UGRID cell for verification. For GridStat, this is the distance from each forecast grid point to search for observation grid cells to include when interpolating to the forecast grid point locations. Currently, only the nearest point observation or gridded observation cell is used. See `Unstructured Grid Limitations`_ for additional details about interpolation when using GridStat.

ugrid_coordinates_file
----------------------

The absolute path to the ancillary NetCDF file that describes the UGRID topology. This file is checked for the required UGRID metadata first, and the data file is checked second and takes precedence over this file if the same elements are found in both files.

ugrid_metadata_map
------------------

The mapping dictionary which allows a user to specify the variable names of the required UGRID topology elements that are required by MET. For "lfric" and "mpas", **ugrid_metadata_map** comes pre-configured with MET and a user can simply set **ugrid_dataset**. Otherwise, the user must create a separate UGRID configuration file containing the **ugrid_metadata_map** containing the elements from :numref:`table_ugrid_metadata` and provide it on the command line using the **-ugrid_config** command line argument.

Unstructured Grid Limitations
=============================

We anticipate expanding the UGRID capabilities in MET in the near future. Until then, users are encouraged to be mindful of the following limitations:

1. In GridStat, there is no support for verifying directly on a UGRID. The UGRID (either forecast, obs, or both) must be regridded to a structured verification grid prior to verification being performed. In most cases, gridded observations are on a structured grid and so the users are encouraged to regrid their UGRID forecast to the structured observation grid. If the user wishes to verify a UGRID observation against a UGRID forecast (for example, a UGRID model analysis), the user must define a custom verification grid tailored to their UGRID characteristics, being mindful that the regridding can be slow for large verification grids. The user is referred to :ref:`appendixB` for guidance on defining a structured verification grid.

2. Data at cell edges are currently not supported, only those variables which have data at the cell centers are supported. Users should note in particular that wind components that are typically derived using data at cell edges are currently unsupported.

3. No aggregation methods of point observations within the **ugrid_max_distance_km** are supported except NEAREST, and no aggregation methods of gridded observations within the **ugrid_max_distance_km** are supported except NEAREST.
2 changes: 2 additions & 0 deletions docs/Users_Guide/config_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,8 @@ to be verified. This dictionary may include the following entries:
single model level.
file_type = NETCDF_NCCF; NetCDF following the Climate Forecast
(CF) convention.
file_type = NETCDF_UGRID; NetCDF containing data on an
unstructured grid.
file_type = PYTHON_NUMPY; Run a Python script to load data into
a NumPy array.
file_type = PYTHON_XARRAY; Run a Python script to load data into
Expand Down
11 changes: 7 additions & 4 deletions docs/Users_Guide/grid-stat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ The usage statement for the Grid-Stat tool is listed below:
fcst_file
obs_file
config_file
[-ugrid_config config_file]
[-outdir path]
[-log file]
[-v level]
Expand All @@ -191,13 +192,15 @@ Required Arguments for grid_stat
Optional Arguments for grid_stat
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

4. The **-outdir path** indicates the directory where output files should be written.
4. The **-ugrid_config** option provides a way for a user to provide a separate config file with metadata about their UGRID.

5. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file.
5. The **-outdir path** indicates the directory where output files should be written.

6. The **-v level** option indicates the desired level of verbosity. The contents of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging.
6. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file.

7. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression.
7. The **-v level** option indicates the desired level of verbosity. The contents of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging.

8. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression.

An example of the grid_stat calling sequence is listed below:

Expand Down
1 change: 1 addition & 0 deletions docs/Users_Guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The National Center for Atmospheric Research (NCAR) is sponsored by NSF. The DTC
appendixE
appendixF
appendixG
appendixH

.. only:: html

Expand Down
15 changes: 9 additions & 6 deletions docs/Users_Guide/point-stat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ The usage statement for the Point-Stat tool is shown below:
fcst_file
obs_file
config_file
[-ugrid_config config_file]
[-point_obs file]
[-obs_valid_beg time]
[-obs_valid_end time]
Expand All @@ -298,17 +299,19 @@ Required Arguments for point_stat
Optional Arguments for point_stat
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

4. The **-point_obs** file may be used to pass additional NetCDF point observation files to be used in the verification. Python embedding for point observations is also supported, as described in :numref:`pyembed-point-obs-data`.
5. The **-ugrid_config** option provides a way for a user to provide a separate config file with metadata about their UGRID.

5. The **-obs_valid_beg** time option in YYYYMMDD[_HH[MMSS]] format sets the beginning of the observation matching time window, overriding the configuration file setting.
5. The **-point_obs** file may be used to pass additional NetCDF point observation files to be used in the verification. Python embedding for point observations is also supported, as described in :numref:`pyembed-point-obs-data`.

6. The **-obs_valid_end** time option in YYYYMMDD[_HH[MMSS]] format sets the end of the observation matching time window, overriding the configuration file setting.
6. The **-obs_valid_beg** time option in YYYYMMDD[_HH[MMSS]] format sets the beginning of the observation matching time window, overriding the configuration file setting.

7. The **-outdir path** indicates the directory where output files should be written.
7. The **-obs_valid_end** time option in YYYYMMDD[_HH[MMSS]] format sets the end of the observation matching time window, overriding the configuration file setting.

8. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file.
8. The **-outdir path** indicates the directory where output files should be written.

9. The **-v level** option indicates the desired level of verbosity. The value of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity will increase the amount of logging.
9. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file.

10. The **-v level** option indicates the desired level of verbosity. The value of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity will increase the amount of logging.

An example of the point_stat calling sequence is shown below:

Expand Down
16 changes: 16 additions & 0 deletions docs/Users_Guide/refs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ References
| Atlantic Basin. *Weather and Forecasting*, 13, 1005-1015.
|

.. _Adams-2019:

| Adams, S. V., R. W. Ford, M. Hambley, J.M. Hobson, I. Kavčič, C. M. Maynard,
| T. Melvin, E. H. Müller, S. Mullerworth, A. R. Porter, M. Rezny, B. J. Shipway,
| and R. Wong, 2019: LFRic: Meeting the challenges of scalability and performance
| portability in Weather and Climate models. *Journal of Parallel and Distributed Computing*,
| **132**, 383-396, doi: https://doi.org/10.1016/j.jpdc.2019.02.007.

.. _Ahijevych-2009:

| Ahijevych, D., E. Gilleland, B.G. Brown, and E.E. Ebert, 2009: Application of
Expand Down Expand Up @@ -333,6 +341,14 @@ References
| and Recommendations. *Monthly Weather Review*, 145, 3397-3418.
|

.. _Skamarock-2012:

| Skamarock, W. C., J. B. Klemp, M. G. Duda, L. D. Fowler, S. Park, and
| T. Ringler, 2012: A Multiscale Nonhydrostatic Atmospheric Model Using
| Centroidal Voronoi Tesselations and C-Grid Staggering. *Mon. Wea. Rev.*,
| **140**, 3090-3105, doi: https://doi.org/10.1175/MWR-D-11-00215.1.
|

.. _Stephenson-2000:

| Stephenson, D.B., 2000: Use of the "Odds Ratio" for diagnosing
Expand Down
14 changes: 14 additions & 0 deletions internal/test_unit/xml/unit_python.xml
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,20 @@
</output>
</test>

<test name="python_plot_point_obs_met_nc_to_pandas">
<exec>&MET_BIN;/plot_point_obs</exec>
<param> \
'PYTHON_NUMPY=&MET_BASE;/python/examples/read_met_point_obs_pandas.py &OUTPUT_DIR;/pb2nc/ndas.20120409.t12z.prepbufr.tm00.nc' \
&OUTPUT_DIR;/python/ndas.20120409.t12z.prepbufr.tm00.nr_met_nc_to_pandas.ps \
-data_file &DATA_DIR_MODEL;/grib2/nam/nam_2012040900_F012.grib2 \
-dotsize 2.0 \
-v 1
</param>
<output>
<ps>&OUTPUT_DIR;/python/ndas.20120409.t12z.prepbufr.tm00.nr_met_nc_to_pandas.ps</ps>
</output>
</test>

<test name="python_ensemble_stat_FILE_LIST">
<exec>echo "&DATA_DIR_MODEL;/grib1/arw-fer-gep1/arw-fer-gep1_2012040912_F024.grib \
&DATA_DIR_MODEL;/grib1/arw-fer-gep5/arw-fer-gep5_2012040912_F024.grib \
Expand Down
3 changes: 2 additions & 1 deletion scripts/python/examples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ pythonexamples_DATA = \
read_ascii_numpy.py \
read_ascii_point.py \
read_ascii_xarray.py \
read_met_point_obs.py
read_met_point_obs.py \
read_met_point_obs_pandas.py

EXTRA_DIST = ${pythonexamples_DATA}

Expand Down
3 changes: 2 additions & 1 deletion scripts/python/examples/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ pythonexamples_DATA = \
read_ascii_numpy.py \
read_ascii_point.py \
read_ascii_xarray.py \
read_met_point_obs.py
read_met_point_obs.py \
read_met_point_obs_pandas.py

EXTRA_DIST = ${pythonexamples_DATA}
MAINTAINERCLEANFILES = Makefile.in
Expand Down
52 changes: 52 additions & 0 deletions scripts/python/examples/read_met_point_obs_pandas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
import sys

from met.point_nc import nc_point_obs

# Description: Reads a point observation NetCDF file created by MET and passes
# the data to another MET tool via Python Embedding. This script can be copied
# to perform modifications to the data before it is passed to MET.
# Example: plot_point_obs "PYTHON_NUMPY=pyembed_met_point_nc.py in.nc" out.ps
# Contact: George McCabe <[email protected]>

# Read and format the input 11-column observations:
# (1) string: Message_Type
# (2) string: Station_ID
# (3) string: Valid_Time(YYYYMMDD_HHMMSS)
# (4) numeric: Lat(Deg North)
# (5) numeric: Lon(Deg East)
# (6) numeric: Elevation(msl)
# (7) string: Var_Name(or GRIB_Code)
# (8) numeric: Level
# (9) numeric: Height(msl or agl)
# (10) string: QC_String
# (11) numeric: Observation_Value

print(f"Python Script:\t{sys.argv[0]}")

if len(sys.argv) != 2:
print("ERROR: pyembed_met_point_nc.py -> Specify only 1 input file")
sys.exit(1)

# Read the input file as the first argument
input_file = os.path.expandvars(sys.argv[1])
print("Input File:\t" + repr(input_file))

# Read MET point observation NetCDF file
try:
point_obs = nc_point_obs(input_file)
except TypeError:
print(f"ERROR: Could not read MET point data file {input_file}")
sys.exit(1)

# convert point observation data to a pandas DataFrame
df = point_obs.to_pandas()

##################################################
# perform any modifications to the data here #
##################################################

# convert pandas DataFrame to list format that is expected by MET
point_data = df.values.tolist()
print(f" point_data: Data Length:\t{len(point_data)}")
print(f" point_data: Data Type:\t{type(point_data)}")
2 changes: 1 addition & 1 deletion scripts/python/met/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def check_point_data(self):
# return met_point_tools.convert_to_ndarray(value_list)

def dump(self):
met_base_point.print_point_data(self.get_point_data())
met_point_tools.print_point_data(self.get_point_data())

def get_count_string(self):
return f' nobs={self.nobs} nhdr={self.nhdr} ntyp={self.nhdr_typ} nsid={self.nhdr_sid} nvld={self.nhdr_vld} nqty={self.nobs_qty} nvar={self.nobs_var}'
Expand Down
Loading