improver.cli package
Submodules
- improver.cli.__main__ module
- improver.cli.aggregate_reliability_tables module
- improver.cli.apply_bias_correction module
- improver.cli.apply_dz_rescaling module
- improver.cli.apply_emos_coefficients module
- improver.cli.apply_height_adjustment module
- improver.cli.apply_lapse_rate module
- improver.cli.apply_night_mask module
- improver.cli.apply_rainforests_calibration module
- improver.cli.apply_reliability_calibration module
- improver.cli.between_thresholds module
- improver.cli.blend_adjacent_points module
- improver.cli.blend_cycles_and_realizations module
- improver.cli.blend_with_vicinity_and_rename module
- improver.cli.calculate_forecast_bias module
- improver.cli.categorical module
- improver.cli.categorical_modes module
- improver.cli.clip module
- improver.cli.cloud_condensation_level module
- improver.cli.cloud_top_temperature module
- improver.cli.collapse_realizations module
- improver.cli.combine module
- improver.cli.compare module
- improver.cli.construct_reliability_tables module
- improver.cli.convection_ratio module
- improver.cli.copy_attributes module
- improver.cli.create_grid_with_halo module
- improver.cli.enforce_consistent_forecasts module
- improver.cli.estimate_dz_rescaling module
- improver.cli.estimate_emos_coefficients module
- improver.cli.estimate_emos_coefficients_from_table module
- improver.cli.expected_value module
- improver.cli.extend_radar_mask module
- improver.cli.extract module
- improver.cli.feels_like_temp module
- improver.cli.field_texture module
- improver.cli.fill_radar_holes module
- improver.cli.freezing_rain module
- improver.cli.generate_clearsky_solar_radiation module
- improver.cli.generate_landmask_ancillary module
- improver.cli.generate_metadata_cube module
- improver.cli.generate_orographic_smoothing_coefficients module
- improver.cli.generate_percentiles module
- improver.cli.generate_realizations module
- improver.cli.generate_solar_time module
- improver.cli.generate_topography_bands_mask module
- improver.cli.generate_topography_bands_weights module
- improver.cli.hail_fraction module
- improver.cli.hail_size module
- improver.cli.interpolate_using_difference module
- improver.cli.interpret_metadata module
- improver.cli.lightning_from_cape_and_precip module
- improver.cli.lightning_multivariate_probability_usaf2024 module
- improver.cli.manipulate_reliability_table module
- improver.cli.max_in_height module
- improver.cli.max_in_time_window module
- improver.cli.merge module
- improver.cli.nbhood module
- improver.cli.nbhood_iterate_with_mask module
- improver.cli.nbhood_land_and_sea module
- improver.cli.neighbour_finding module
- improver.cli.normalise_to_reference module
- improver.cli.nowcast_accumulate module
- improver.cli.nowcast_extrapolate module
- improver.cli.nowcast_optical_flow module
- improver.cli.nowcast_optical_flow_from_winds module
- improver.cli.orographic_enhancement module
- improver.cli.phase_change_level module
- improver.cli.phase_mask module
- improver.cli.phase_probability module
- improver.cli.recursive_filter module
- improver.cli.regrid module
- improver.cli.relabel_to_period module
- improver.cli.remake_as_shower_condition module
- improver.cli.resolve_wind_components module
- improver.cli.shower_condition_probability module
- improver.cli.sleet_probability module
- improver.cli.snow_fraction module
- improver.cli.snow_splitter module
- improver.cli.spot_extract module
- improver.cli.standardise module
- improver.cli.temp_lapse_rate module
- improver.cli.temporal_interpolate module
- improver.cli.threshold module
- improver.cli.time_lagged_ensembles module
- improver.cli.uv_index module
- improver.cli.vertical_updraught module
- improver.cli.vicinity module
- improver.cli.visibility_combine_cloud_base module
- improver.cli.weighted_blending module
- improver.cli.wet_bulb_freezing_level module
- improver.cli.wet_bulb_temperature module
- improver.cli.wet_bulb_temperature_integral module
- improver.cli.wind_direction module
- improver.cli.wind_downscaling module
- improver.cli.wind_gust_diagnostic module
Module contents
init for cli and clize
- class DocutilizeClizeHelp(subject, owner, builder=<bound method HelpForAutodetectedDocstring.from_subject of <class 'improver.cli.HelpForNapoleonDocstring'>>)[source]
Bases:
HelpCli
Subclass to build Napoleon docstring from subject.
- class HelpForNapoleonDocstring(*args, **kwargs)[source]
Bases:
HelpForAutodetectedDocstring
Subclass to add support for google style docstrings
- class ObjectAsStr(obj, name=None)[source]
Bases:
str
Hide object under a string to pass it through Clize parser.
- original_object
- class TimeIt(verbose=False)[source]
Bases:
object
- property elapsed
Return elapsed time in seconds.
- clizefy(obj=None, helper_class=<class 'improver.cli.DocutilizeClizeHelp'>, **kwargs)[source]
Decorator for creating CLI objects.
- comma_separated_list(to_convert)[source]
Converts comma separated string to list or returns passed object.
- Parameters:
to_convert (string or list) – comma separated string or list
- Returns:
list
- comma_separated_list_of_float(to_convert)[source]
Converts comma separated string to list of floats or returns passed object.
- Parameters:
to_convert (string or list) – comma separated string or list
- Returns:
list
- command_executor(*argv, verbose=False, dry_run=False)[source]
Common entry point for straight command execution.
- create_constrained_inputcubelist_converter(*constraints)[source]
Makes function that the input constraints are used in a loop.
The function is a @value_converter, this means it is used by clize to convert strings into objects. This is a way of not using the IMPROVER load_cube which will try to merge cubes. Iris load on the other hand won’t deal with meta data properly. So an example is if you wanted to load an X cube and a Y cube from a cubelist of 2. You call this function with a list of constraints. These cubes get loaded and returned as a CubeList.
- Parameters:
*constraints (tuple of str or callable or iris.Constraint) – Constraints to be used in extracting the required cubes. Each constraint must match exactly one cube and extracted cubes will be sorted to match their order. A constraint can be an iris.Constraint object or a callable or cube name that can be used to construct one.
- Returns:
A function with the constraints used for a list comprehension.
- Return type:
callable
- execute_command(dispatcher, prog_name, *args, verbose=False, dry_run=False)[source]
Common entry point for command execution.
- inputcube(to_convert)[source]
Loads cube from file or returns passed object.
- Parameters:
to_convert (string or iris.cube.Cube) – File name or Cube object.
- Returns:
Loaded cube or passed object.
- inputcube_nolazy(to_convert)[source]
Loads cube from file or returns passed object. Where a load is performed, it will not have lazy data. :type to_convert: :param to_convert: File name or Cube object. :type to_convert: string or iris.cube.Cube
- Returns:
Loaded cube or passed object.
- inputcubelist(to_convert)[source]
Loads a cubelist from file or returns passed object. :type to_convert: :param to_convert: File name or CubeList object. :type to_convert: string or iris.cube.CubeList
- Returns:
Loaded cubelist or passed object.
- inputdatetime(to_convert)[source]
Converts string to datetime or returns passed object.
- Parameters:
to_convert (string or datetime) – datetime represented as string of the format YYYYMMDDTHHMMZ
- Returns:
datetime object
- Return type:
(datetime)
- inputjson(to_convert)[source]
Loads json from file or returns passed object.
- Parameters:
to_convert (string or dict) – File name or json dictionary.
- Returns:
Loaded json dictionary or passed object.
- inputpath(to_convert)[source]
Converts string paths to pathlib Path objects
- Parameters:
to_convert (string or pathlib.Path) – path represented as string
- Returns:
Path object
- Return type:
- main(prog_name, command, *args, profile=None, memprofile=None, verbose=False, dry_run=False)[source]
IMPROVER NWP post-processing toolbox
Results from commands can be passed into file-like arguments of other commands by surrounding them by square brackets:
improver command [ command ... ] ...
Spaces around brackets are mandatory.
- Parameters:
prog_name (
pass_name
) – The program name from argv[0].command (str) – Command to execute
args (tuple) – Command arguments
profile (str) – If given, will write profiling to the file given. To write to stdout, use a hyphen (-)
memprofile (str) – Creates 2 files by adding a suffix to the provided arguemnt - a tracemalloc snapshot at the point of highest memory consumption of your program (suffixed with _SNAPSHOT) and a track of the maximum memory used by your program over time (suffixed with _MAX_TRACKER).
verbose (bool) – Print executed commands
dry_run (bool) – Print commands to be executed
See improver help [–usage] [command] for more information on available command(s).
- maybe_coerce_with(converter, obj, **kwargs)[source]
Apply converter if str, pass through otherwise.
- unbracket(args)[source]
Convert input list with bracketed items into nested lists.
>>> unbracket('foo [ bar a b ] [ baz c ] -o z'.split()) ['foo', ['bar', 'a', 'b'], ['baz', 'c'], '-o', 'z']
- with_output(wrapped, *args, output=None, pass_through_output=False, compression_level=1, least_significant_digit=None, **kwargs)[source]
Add output keyword only argument. Add compression_level option. Add least_significant_digit option.
This is used to add extra output, compression_level and least_significant_digit CLI options. If output is provided, it saves the result of calling wrapped to file and returns None, otherwise it returns the result. If compression_level is provided, it compresses the data with the provided compression level (or not, if compression_level 0). If least_significant_digit provided, it will quantize the data to a certain number of significant figures.
- Parameters:
wrapped (obj) – The function to be wrapped.
output (str, optional) – Output file name. If not supplied, the output object will be printed instead.
pass_through_output (bool) – Pass through the output object even if saved to file. Used in pipelines of commands if intermediate output needs to be saved.
compression_level (int) – Will set the compression level (1 to 9), or disable compression (0).
least_significant_digit (int) – If specified will truncate the data to a precision given by 10**(-least_significant_digit), e.g. if least_significant_digit=2, then the data will be quantized to a precision of 0.01 (10**(-2)). See http://www.esrl.noaa.gov/psd/data/gridded/conventions/cdc_netcdf_standard.shtml for details. When used with compression level, this will result in lossy compression.
- Returns:
Result of calling wrapped or None if output is given.