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

Generalize ungrib driver #688

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ clean:

docs:
$(MAKE) html
linkchecker --check-extern --no-warnings build/html/index.html
linkchecker --check-extern --no-warnings --user-agent Mozilla/5.0 build/html/index.html

examples:
COLUMNS=80 $(MAKE) -C sections
Expand Down
12 changes: 6 additions & 6 deletions docs/sections/user_guide/yaml/components/ungrib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ execution:

See :ref:`this page <execution_yaml>` for details.

gfs_files:
gribfiles:
^^^^^^^^^^

Describes the GRIB-formatted files to be processed by ``ungrib``.

**forecast_length:**
**interval_hours:**

Frequency interval of the given files, in integer hours.

**max_leadtime:**

The length of the forecast in integer hours.

**offset:**

How many hours earlier the external model used for boundary conditions started compared to the desired forecast cycle, in integer hours.

**interval_hours:**

Frequency interval of the given files, in integer hours.

**path:**

An absolute-path template to the GRIB-formatted files to be processed by ``ungrib``. The Python ``int`` variables ``cycle_hour`` and ``forecast_hour`` will be interpolated into, e.g., ``/path/to/gfs.t{cycle_hour:02d}z.pgrb2.0p25.f{forecast_hour:03d}``. Note that this is a Python string template rather than a Jinja2 template.
Expand Down
4 changes: 2 additions & 2 deletions docs/shared/ungrib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ ungrib:
cores: 1
walltime: "00:01:00"
executable: /path/to/ungrib.exe
gfs_files:
forecast_length: 24
gribfiles:
interval_hours: 6
max_leadtime: 24
offset: 0
path: /path/to/dir/gfs.t{cycle_hour:02d}z.pgrb2.0p25.f{forecast_hour:03d}
rundir: /path/to/run/dir
Expand Down
16 changes: 8 additions & 8 deletions src/uwtools/drivers/ungrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def gribfiles(self):
Symlinks to all the GRIB files.
"""
yield self.taskname("GRIB files")
gfs_files = self.config["gfs_files"]
offset = abs(gfs_files["offset"])
endhour = gfs_files["forecast_length"] + offset
interval = gfs_files["interval_hours"]
gribfiles = self.config["gribfiles"]
offset = abs(gribfiles["offset"])
endhour = gribfiles["max_leadtime"] + offset
interval = gribfiles["interval_hours"]
cycle_hour = int((self._cycle - timedelta(hours=offset)).strftime("%H"))
links = []
for n, boundary_hour in enumerate(range(offset, endhour + 1, interval)):
infile = Path(
gfs_files["path"].format(cycle_hour=cycle_hour, forecast_hour=boundary_hour)
gribfiles["path"].format(cycle_hour=cycle_hour, forecast_hour=boundary_hour)
)
link_name = self.rundir / f"GRIBFILE.{_ext(n)}"
links.append((infile, link_name))
Expand All @@ -47,10 +47,10 @@ def namelist_file(self):
The namelist file.
"""
# Do not use offset here. It's relative to the MPAS fcst to run.
gfs_files = self.config["gfs_files"]
endhour = gfs_files["forecast_length"]
gribfiles = self.config["gribfiles"]
endhour = gribfiles["max_leadtime"]
end_date = self._cycle + timedelta(hours=endhour)
interval = int(gfs_files["interval_hours"]) * 3600 # hour to sec
interval = int(gribfiles["interval_hours"]) * 3600 # hour to sec
d = {
"update_values": {
"share": {
Expand Down
10 changes: 5 additions & 5 deletions src/uwtools/resources/jsonschema/ungrib.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"execution": {
"$ref": "urn:uwtools:execution-parallel"
},
"gfs_files": {
"gribfiles": {
"additionalProperties": false,
"properties": {
"forecast_length": {
"interval_hours": {
"minimum": 1,
"type": "integer"
},
"interval_hours": {
"max_leadtime": {
"minimum": 1,
"type": "integer"
},
Expand All @@ -26,8 +26,8 @@
}
},
"required": [
"forecast_length",
"interval_hours",
"max_leadtime",
"offset",
"path"
],
Expand All @@ -42,7 +42,7 @@
},
"required": [
"execution",
"gfs_files",
"gribfiles",
"rundir",
"vtable"
],
Expand Down
4 changes: 2 additions & 2 deletions src/uwtools/tests/drivers/test_ungrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def config(tmp_path):
},
"executable": str(tmp_path / "ungrib.exe"),
},
"gfs_files": {
"forecast_length": 12,
"gribfiles": {
"interval_hours": 6,
"max_leadtime": 12,
"offset": 6,
"path": str(tmp_path / "gfs.t{cycle_hour:02d}z.pgrb2.0p25.f{forecast_hour:03d}"),
},
Expand Down
6 changes: 3 additions & 3 deletions src/uwtools/tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1960,9 +1960,9 @@ def test_schema_shave_rundir(shave_prop):
def test_schema_ungrib():
config = {
"execution": {"executable": "/tmp/ungrib.exe"},
"gfs_files": {
"forecast_length": 24,
"gribfiles": {
"interval_hours": 6,
"max_leadtime": 24,
"offset": 0,
"path": "/tmp/gfs.t12z.pgrb2.0p25.f000",
},
Expand All @@ -1973,7 +1973,7 @@ def test_schema_ungrib():
# Basic correctness:
assert not errors(config)
# All top-level keys are required:
for key in ("execution", "gfs_files", "rundir", "vtable"):
for key in ("execution", "gribfiles", "rundir", "vtable"):
assert f"'{key}' is a required property" in errors(with_del(config, key))
# Additional top-level keys are not allowed:
assert "Additional properties are not allowed" in errors({**config, "foo": "bar"})
Expand Down