The file_utils module.¶
This module implements utility functions specific to MONC for monc_utils.file_utils.
Detailed Module Contents¶
The entire module is documented below.
Created on Mon Aug 2 11:06:21 2021.
@author: Peter Clark and Todd Jones
- monc_utils.io.file_utils.options_database(source_dataset)¶
Convert options_database in source_dataset to dictionary.
- Parameters:
source_dataset (netCDF4 file) – MONC output file.
- Returns:
options_database
- Return type:
dict
- monc_utils.io.file_utils.path_to_resolution(inpath)¶
Pull resolution value from an encoded path as a float.
e.g., ‘BOMEX_m0020_g0800’ i.e., it should have ‘_m[0-9][0-9][0-9]’ (at least 3 integers)
- Parameters:
inpath (str) – file path
- Returns:
dx – MONC horizontal resolution [m]
- Return type:
float
- monc_utils.io.file_utils.configure_model_resolution(dataset, options=None)¶
Find model resolution from available sources.
This routine applies an order of precedence between potential pre-existing records of MONC horizontal resolutions and ensures that the options dictionary contains these values.
Files written via io/dataout.py’s setup_child_file will have the correct value listed in the file’s global attributes, as this routine is called within that space.
Repeated calls to this routine (for instance, to simply obtain dx and dy) will not modify the options contents.
- Precedence:
options_database
dataset attributes
monc_utils options
parse file path containing resolution encoding
- Parameters:
dataset (xarray dataset) – any monc_utils-compatible dataset
options (dict) – dataset-associated options dictionary
- Returns:
dx (float (expected)) – x-direction MONC resolution [m]
dy (float (expected)) – y-direction MONC resolution [m]
options (dict) – input options dictionary, possibly updated with dx and dy keys
Created on Mon Aug 2 11:21:15 2021
@author: Peter Clark