Skip to content

Commit

Permalink
MOBT-430: Synthetic data utilities for creating spot-cubes (#1993)
Browse files Browse the repository at this point in the history
* Synthetic spot data creation utilities added.

Adds the ability to generate spot-data cubes for use in unit tests.
Fixes up calls to the existing gridded synthetic data functions that did not use the keyword arguments explicitly.
Adds unit tests for the new spot-data utilities.
One unit test partially modified as an example.

* Centralise the datetime format definition that corresponds to our typical format.

* Some unit tests that use spot-cubes adapted as a demonstration.

* Fix doc-string indentation issue for sphinx.

* Review response. Improved doc-strings and use of global variables.

* Typo correction.

* Corrects typos highlighted in review.
  • Loading branch information
bayliffe authored May 14, 2024
1 parent 48b072d commit ccdc68f
Show file tree
Hide file tree
Showing 20 changed files with 872 additions and 339 deletions.
4 changes: 2 additions & 2 deletions improver/blending/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
MANDATORY_ATTRIBUTE_DEFAULTS,
MANDATORY_ATTRIBUTES,
)
from improver.metadata.constants.time_types import TIME_COORDS
from improver.metadata.constants.time_types import DT_FORMAT, TIME_COORDS
from improver.metadata.forecast_times import add_blend_time, forecast_period_coord
from improver.utilities.round import round_close
from improver.utilities.temporal import cycletime_to_number
Expand Down Expand Up @@ -334,7 +334,7 @@ def store_record_run_as_coord(
cycle = datetime.utcfromtimestamp(
cube.coord("forecast_reference_time").points[0]
)
cycle_str = cycle.strftime("%Y%m%dT%H%MZ")
cycle_str = cycle.strftime(DT_FORMAT)

blending_weight = 1
run_attr = (
Expand Down
2 changes: 2 additions & 0 deletions improver/metadata/constants/time_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

TimeSpec = namedtuple("TimeSpec", ("calendar", "dtype", "units"))

DT_FORMAT = "%Y%m%dT%H%MZ"

_TIME_REFERENCE_SPEC = TimeSpec(
calendar="gregorian", dtype=np.int64, units="seconds since 1970-01-01 00:00:00"
)
Expand Down
Loading

0 comments on commit ccdc68f

Please sign in to comment.