Skip to content

Commit

Permalink
#2428 Support a MET point obs NetCDF
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard Soh committed Feb 13, 2023
1 parent 6e02849 commit b56e34e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions data/wrappers/write_tmp_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
import sys
import importlib.util

print("Python Script:\t" + repr(sys.argv[0]))
print("User Command:\t" + repr(' '.join(sys.argv[2:])))
print("Temporary File:\t" + repr(sys.argv[1]))
from met_point_obs import get_prompt
from met_point_obs_nc import nc_point_obs

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

tmp_filename = sys.argv[1]
pyembed_module_name = sys.argv[2]
Expand All @@ -34,6 +37,14 @@
met_in = importlib.util.module_from_spec(spec)
spec.loader.exec_module(met_in)

f = open(tmp_filename, 'w')
for line in met_in.point_data:
f.write(str(line) + '\n')
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=get_prompt(), f=tmp_filename))

0 comments on commit b56e34e

Please sign in to comment.