Skip to content

Commit

Permalink
Update develop-ref after #2462 (#2470)
Browse files Browse the repository at this point in the history
Co-authored-by: johnhg <johnhg@ucar.edu>
Co-authored-by: Lisa Goodrich <lisag@seneca.rap.ucar.edu>
Co-authored-by: jprestop <jpresto@ucar.edu>
Co-authored-by: Seth Linden <linden@seneca.rap.ucar.edu>
Co-authored-by: Howard Soh <hsoh@seneca.rap.ucar.edu>
Co-authored-by: John Halley Gotway <johnhg@ucar.edu>
Co-authored-by: MET Tools Test Account <met_test@seneca.rap.ucar.edu>
Co-authored-by: Dave Albo <dave@seneca.rap.ucar.edu>
Co-authored-by: j-opatz <59586397+j-opatz@users.noreply.github.com>
Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com>
Co-authored-by: Julie Prestopnik <jpresto@seneca.rap.ucar.edu>
Co-authored-by: Jonathan Vigh <jvigh@ucar.edu>
Co-authored-by: lisagoodrich <33230218+lisagoodrich@users.noreply.github.com>
Co-authored-by: Seth Linden <linden@ucar.edu>
Co-authored-by: hsoh-u <hsoh@ucar.edu>
Co-authored-by: davidalbo <dave@ucar.edu>
Co-authored-by: Daniel Adriaansen <dadriaan@ucar.edu>
fix 2238 link error (#2255)
fix #2271 develop nbrctc (#2272)
fix #2309 develop tcmpr (#2310)
fix #2306 ascii2nc airnow hourly (#2314)
fix_spread_md (#2335)
fix #2389 develop flowchart (#2392)
Fix Python environment issue (#2407)
fix definitions of G172 and G220 based on comments in NOAA-EMC/NCEPLIBS-w3emc#157. (#2406)
fix #2380 develop override (#2382)
fix #2408 develop empty config (#2410)
fix #2390 develop compile zlib (#2404)
fix #2412 develop climo (#2422)
fix #2437 develop convert (#2439)
fix for develop, for #2437, forgot one reference to the search_parent for a dictionary lookup.
fix #2452 develop airnow (#2454)
  • Loading branch information
JohnHalleyGotway authored Feb 27, 2023
1 parent 18b170c commit 4558881
Show file tree
Hide file tree
Showing 19 changed files with 1,045 additions and 406 deletions.
2 changes: 2 additions & 0 deletions data/wrappers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ wrappers_DATA = \
set_python_env.py \
read_tmp_dataplane.py \
read_tmp_ascii.py \
read_tmp_point_nc.py \
write_tmp_dataplane.py \
write_tmp_point.py \
write_tmp_point_nc.py \
write_tmp_mpr.py

EXTRA_DIST = ${wrappers_DATA}
Expand Down
2 changes: 2 additions & 0 deletions data/wrappers/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,10 @@ wrappers_DATA = \
set_python_env.py \
read_tmp_dataplane.py \
read_tmp_ascii.py \
read_tmp_point_nc.py \
write_tmp_dataplane.py \
write_tmp_point.py \
write_tmp_point_nc.py \
write_tmp_mpr.py

EXTRA_DIST = ${wrappers_DATA}
Expand Down
26 changes: 26 additions & 0 deletions data/wrappers/read_tmp_point_nc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
########################################################################
#
# Reads temporary point obs. file into memory.
#
# usage: /path/to/python read_tmp_point_nc.py tmp_output_filename
#
########################################################################

import os
import sys

# add share/met/python directory to system path to find met_point_obs
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
os.pardir, 'python')))
from met_point_obs import met_point_obs
from met_point_obs_nc import nc_point_obs

netcdf_filename = sys.argv[1]

# read NetCDF file
print('{p} reading{f}'.format(p=met_point_obs.get_prompt(), f=netcdf_filename))
point_obs_data = nc_point_obs()
point_obs_data.read_data(netcdf_filename)

met_point_data = point_obs_data.get_point_data()
met_point_data['met_point_data'] = point_obs_data
55 changes: 55 additions & 0 deletions data/wrappers/write_tmp_point_nc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
########################################################################
#
# Adapted from a script provided by George McCabe
# Adapted by Howard Soh
#
# usage: /path/to/python write_tmp_point_nc.py \
# tmp_output_filename <user_python_script>.py <args>
#
########################################################################

import os
import sys
import importlib.util

# add share/met/python directory to system path to find met_point_obs
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
os.pardir, 'python')))

from met_point_obs import met_point_obs
from met_point_obs_nc import nc_point_obs

PROMPT = met_point_obs.get_prompt()
print("{p} Python Script:\t".format(p=PROMPT) + repr(sys.argv[0]))
print("{p} User Command:\t".format(p=PROMPT) + repr(' '.join(sys.argv[2:])))
print("{p} Temporary File:\t".format(p=PROMPT) + repr(sys.argv[1]))

tmp_filename = sys.argv[1]
pyembed_module_name = sys.argv[2]
sys.argv = sys.argv[2:]

# append user script dir to system path
pyembed_dir, pyembed_file = os.path.split(pyembed_module_name)
if pyembed_dir:
sys.path.insert(0, pyembed_dir)

if not pyembed_module_name.endswith('.py'):
pyembed_module_name += '.py'

user_base = os.path.basename(pyembed_module_name).replace('.py','')

spec = importlib.util.spec_from_file_location(user_base, pyembed_module_name)
met_in = importlib.util.module_from_spec(spec)
spec.loader.exec_module(met_in)

if hasattr(met_in, 'point_obs_data'):
met_in.point_obs_data.save_ncfile(tmp_filename)
else:
if hasattr(met_in.met_point_data, 'point_obs_data'):
met_in.met_point_data['point_obs_data'].save_ncfile(tmp_filename)
else:
tmp_point_obs = nc_point_obs()
tmp_point_obs.put_data(met_in.met_point_data)
tmp_point_obs.save_ncfile(tmp_filename)

#print('{p} writing {f}'.format(p=PROMPT, f=tmp_filename))
2 changes: 1 addition & 1 deletion docs/Users_Guide/appendixF.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ The ASCII2NC tool supports the "-format python" option. With this option, point
"MET_BASE/python/read_ascii_point.py sample_ascii_obs.txt" \
sample_ascii_obs_python.nc
The Point2Grid, Plot-Point-Obs, Ensemble-Stat, and Point-Stat tools also process point observations. They support POython embedding of point observations directly on the command line by replacing the input MET NetCDF point observation file name with the Python command to be run. The Python command must begin with the prefix 'PYTHON_NUMPY=' and be followed by the path to the User's Python script and any arguments. The full command should be enclosed in single quotes to prevent embedded whitespace from causing parsing errors. An example of this is shown below:
The Point2Grid, Plot-Point-Obs, Ensemble-Stat, and Point-Stat tools also process point observations. They support Python embedding of point observations directly on the command line by replacing the input MET NetCDF point observation file name with the Python command to be run. The Python command must begin with the prefix 'PYTHON_NUMPY=' and be followed by the path to the User's Python script and any arguments. The full command should be enclosed in single quotes to prevent embedded whitespace from causing parsing errors. An example of this is shown below:

.. code-block:: none
Expand Down
Loading

0 comments on commit 4558881

Please sign in to comment.