improver.utilities.filename module

Module for generating IMPROVER-compliant file names.

improver.utilities.filename.generate_file_name(cube, parameter=None, include_period=False)[source]

From a forecast cube, generate an IMPROVER-suitable file name using the correct lead time. Based on existing StaGE functionality. Requires a “time” coordinate. If the cube has no “forecast_period” coordinate (for example if the input is a radar composite or other observation), this function creates a dummy string representing a forecast period of zero.

The filename generated will be of the format: 20180806T2300Z-PT0012H00M-lwe_precip_rate.nc. If a period is included, the filename will become: 20180806T2300Z-PT0012H00M-lwe_precip_accumulation-PT03H.nc

Parameters
  • cube (iris.cube.Cube) – Cube containing nowcast data

  • parameter (str) – Optional parameter name to use in the output filename rather than taking the name of the cube diagnostic.

  • include_period (bool) – Optional argument to indicate whether a period, accumulation or time window identifier should be included within the filename.

Returns

File base name to which to write

Return type

str

Raises
  • ValueError – In order to calculate the period, either the forecast_period or the time coordinate must have bounds.

  • ValueError – The period deduced by the coordinate bounds must be either less than 1 hour or in terms of whole hours.