-
Notifications
You must be signed in to change notification settings - Fork 24
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
Feature 1954 semilatlon #2262
Merged
Merged
Feature 1954 semilatlon #2262
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
a445afb
Per #1954, adding initial unstructured grid library code.
JohnHalleyGotway cd6e32f
Per #1954, since I'm adding new files to the vx_grid library, I had t…
JohnHalleyGotway 775ffed
Per #1954, adding operator== and serialize() functions to the NumArra…
JohnHalleyGotway 88afd03
Merge branch 'feature_1954_ugrid' of https://github.com/dtcenter/MET …
JohnHalleyGotway d32c648
Per #1954, switch from storing times in TimeArray to NumArray to simp…
JohnHalleyGotway 8966e39
Per #1954, when the compilation fails add the full make_install.log f…
JohnHalleyGotway 70361a9
Per #1954, update python embedding to parse the unstructured grid type.
JohnHalleyGotway b63e821
Per #1954, instantiate unstructured grid from data.
JohnHalleyGotway e447a19
Per #1954, fix up unstructured grid code.
JohnHalleyGotway d3ec1b6
Merge remote-tracking branch 'origin/develop' into feature_1954_ugrid
JohnHalleyGotway 424a6f1
Merge remote-tracking branch 'origin/develop' into feature_1954_ugrid
JohnHalleyGotway 083487d
Per #1954, rename Dim1/Dim2 to xDim/yDim for greater clarity.
JohnHalleyGotway 4a1a2d4
Per #1954, UnstructuredData structs require a deep copy rather than j…
JohnHalleyGotway 1914219
Per #1954, fix the logic to skip the plotting of map data for unstruc…
JohnHalleyGotway eb17db0
Per #1954, move the logic for skipping the plotting of map data from …
JohnHalleyGotway d8c3b84
Per #1954, link -lvx_cal into the compilation of test_grid_area utili…
JohnHalleyGotway 36611f6
Merge branch 'develop' into feature_1954_semilatlon
JohnHalleyGotway 76dafdb
Per #1954, rename from unstructured grid to semilatlon grid to avoid …
JohnHalleyGotway 95d9bdf
Per #1954, add NumArray::summarize() function and update the SemiLatL…
JohnHalleyGotway ed85c8a
Per #1954, switch flag from Is2Dim to IsLatLon to avoid confusion.
JohnHalleyGotway 7d3efaf
Merge remote-tracking branch 'origin/develop' into feature_1954_semil…
JohnHalleyGotway 4b22445
Merge remote-tracking branch 'origin/develop' into feature_1954_semil…
JohnHalleyGotway 803d01b
Per #1954, define new semilatlon projection type string.
JohnHalleyGotway b7db013
Per #1954, define logic to read semilatlon data via python embedding …
JohnHalleyGotway f544c1e
Per #1954, update the library code to have the write_netcdf_proj() fu…
JohnHalleyGotway aec6c45
Per #1954, update all the application code to remove the creation of …
JohnHalleyGotway d2019aa
Per #1954, fix login in met_file.cc to define x_dim_name and y_dim_na…
JohnHalleyGotway d4605af
Merge remote-tracking branch 'origin/develop' into feature_1954_semil…
JohnHalleyGotway 82ec2f7
Per #1954, trying to debug difference in behavior on my Mac vs Seneca.
JohnHalleyGotway eac02b7
Per #1954, unrelated to development, but correcting an apparent typo …
JohnHalleyGotway 9528d82
Per #1954, removing development print statement.
JohnHalleyGotway 95fea19
Per #1954, update the grid_from_python_dict.cc logic to parse the lat…
JohnHalleyGotway 092bd34
Merge remote-tracking branch 'origin/develop' into feature_1954_semil…
JohnHalleyGotway a3bc30c
Per #1954, ci-run-unit add unit tests to demonstrate the newly added …
JohnHalleyGotway c60dd6b
ci-run-unit Fix expected file type
JohnHalleyGotway c164c34
Per #1954, fix quote in log message.
JohnHalleyGotway fe6b03d
Per #1954, ci-run-unit fix failure from unit_point2grid.xml. Had to a…
JohnHalleyGotway 2f92e78
Per #1954, GHA doesn't allow for colons in output file names. Switchi…
JohnHalleyGotway 0631729
Per #1954, add documentation about the semilatlon grid.
JohnHalleyGotway 9c9858b
Small grammar update
j-opatz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ test_grid_area_LDADD = -lvx_grid \ | |
-lvx_util_math \ | ||
-lvx_util \ | ||
-lvx_math \ | ||
-lvx_cal \ | ||
-lvx_log \ | ||
-lz \ | ||
-lm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
from __future__ import print_function | ||
|
||
import os | ||
import sys | ||
import numpy as np | ||
import datetime as dt | ||
from netCDF4 import Dataset,chartostring | ||
|
||
########################################### | ||
|
||
## | ||
## input file specified on the command line | ||
## load the data into the numpy array | ||
## | ||
|
||
if len(sys.argv) == 4: | ||
# Read the input file as the first argument | ||
input_file = os.path.expandvars(sys.argv[1]) | ||
var_name = sys.argv[2] | ||
axis = sys.argv[3] | ||
|
||
try: | ||
# Print some output to verify that this script ran | ||
print("Input File: " + repr(input_file)) | ||
print("Variable: " + repr(var_name)) | ||
print("Axis: " + repr(axis)) | ||
|
||
# Read input file | ||
f = Dataset(input_file, 'r') | ||
|
||
data = np.float64(f.variables[var_name][0,:,:,:]) | ||
data[data > 1.0e30] = np.nan | ||
|
||
pvals = list(np.float64(f.variables["pressure"][:])) | ||
|
||
if axis == "lon": | ||
met_data = np.nanmean(data[::-1], axis=1).copy() | ||
elif axis == "lat": | ||
met_data = np.nanmean(data[::-1], axis=2).transpose().copy() | ||
elif axis == "latlon": | ||
met_data = np.nanmean(data[::-1], axis=1).copy() | ||
else: | ||
print("ERROR: Unsupported axis type: " + axis) | ||
sys.exit(1) | ||
|
||
print("Data Shape: " + repr(met_data.shape)) | ||
print("Data Type: " + repr(met_data.dtype)) | ||
except NameError: | ||
print("Trouble reading data from input file") | ||
else: | ||
print("Must specify exactly one input file, variable name, and summary axis (lat, lon, latlon).") | ||
sys.exit(1) | ||
|
||
########################################### | ||
|
||
## | ||
## create the metadata dictionary | ||
## | ||
|
||
init = dt.datetime.strptime(getattr(f, "START_DATE"), "%Y-%m-%d_%H:%M:%S") | ||
valid_ref = dt.datetime.strptime(getattr(f.variables["Time"], "units"), "hours since %Y-%m-%d %H:%M:%S") | ||
add_hours = float(f.variables["Time"][:]) | ||
valid = valid_ref + dt.timedelta(hours=add_hours) | ||
lead, rem = divmod((valid-init).total_seconds(), 3600) | ||
accum = "00" | ||
|
||
# Use the first column of lats | ||
|
||
if axis == "lon": | ||
lats = list() | ||
lons = list(np.float64(f.variables["XLONG"][0,0,:])) | ||
elif axis == "lat": | ||
lats = list(np.float64(f.variables["XLAT"][0,:,0])) | ||
lons = list() | ||
elif axis == "latlon": | ||
lats = list(np.float64(f.variables["XLONG"][0,0,:])) | ||
lons = list(np.float64(f.variables["XLAT"][0,0,:])) | ||
|
||
levels = list(pvals) | ||
times = list() | ||
|
||
attrs = { | ||
'valid': valid.strftime("%Y%m%d_%H%M%S"), | ||
'init': init.strftime("%Y%m%d_%H%M%S"), | ||
'lead': str(int(lead)), | ||
'accum': accum, | ||
|
||
'name': var_name, | ||
'long_name': str(getattr(f.variables[var_name], "description")), | ||
'level': axis + "_mean", | ||
'units': str(getattr(f.variables[var_name], "units")), | ||
|
||
'grid': { | ||
'type' : "SemiLatLon", | ||
'name' : axis + "_mean", | ||
'lats' : lats, | ||
'lons' : lons, | ||
'levels' : levels, | ||
'times' : times | ||
} | ||
} | ||
|
||
print("Attributes: " + repr(attrs)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think I know the answer, but just clarifying: when it's stated "Two Semi Lat/Lon grids are equal when their lats, lons, levels, and times arrays match.", that means the values of the arrays match, correct? Didn't want the confusion of "equal" meaning lengths of the arrays match.
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.
That's correct, the code checks that the arrays have the same length and all the array values match.