improver.metadata.forecast_times module
Utilities to manipulate forecast time coordinates
- _calculate_forecast_period(time_coord, frt_coord, dim_coord=False, coord_spec=TimeSpec(calendar=None, dtype=<class 'numpy.int32'>, units='seconds'))[source]
Calculate a forecast period from existing time and forecast reference time coordinates.
- Parameters:
- Return type:
- Returns:
Forecast period coordinate corresponding to the input times and forecast reference times specified
- Warns:
UserWarning – If any calculated forecast periods are negative
- _create_frt_type_coord(cube, point, name='forecast_reference_time')[source]
Create a new auxiliary coordinate based on forecast reference time
- _find_latest_cycletime(cubelist)[source]
Find the latest cycletime from the cubes in a cubelist and convert it into a datetime object.
- add_blend_time(cube, cycletime)[source]
Function to add scalar blend time coordinate to a blended cube based on current cycle time. Modifies cube in place. :rtype:
None
- Args:
- cubes:
Cube to add blend time coordinate
- cycletime:
Required blend time in a YYYYMMDDTHHMMZ format e.g. 20171122T0100Z
- forecast_period_coord(cube, force_lead_time_calculation=False)[source]
Return the lead time coordinate (forecast_period) from a cube, either by reading an existing forecast_period coordinate, or by calculating the difference between time and forecast_reference_time or blend_time.
- Parameters:
- Return type:
- Returns:
New forecast_period coord. A DimCoord is returned if the forecast_period coord is already present in the cube as a DimCoord and this coord does not need changing, otherwise it will be an AuxCoord.
- rebadge_forecasts_as_latest_cycle(cubes, cycletime=None)[source]
Function to update the forecast_reference_time and forecast_period on a list of input forecasts to match either a given cycletime, or the most recent forecast in the list (proxy for the current cycle).
- Parameters:
- Return type:
- Returns:
Updated cubes
- unify_cycletime(cubes, cycletime)[source]
Function to unify the forecast_reference_time and update forecast_period. The cycletime specified is used as the forecast_reference_time, and the forecast_period is recalculated using the time coordinate and updated forecast_reference_time.
- Parameters:
cubes (
Union
[CubeList
,List
[Cube
]]) – Cubes that will have their forecast_reference_time and forecast_period updated. Any bounds on the forecast_reference_time coordinate will be discarded.cycletime (
datetime
) – Datetime for the cycletime that will be used to replace the forecast_reference_time on the individual cubes.
- Return type:
- Returns:
Updated cubes
- Raises:
ValueError – if forecast_reference_time is a dimension coordinate