fre.app.regrid_xy.regrid_xy module
- fre.app.regrid_xy.regrid_xy.get_grid_spec(datadict: dict) str
Gets the grid_spec.nc file from the tar file specified in yaml[“postprocess”][“settings”][“pp_grid_spec”]
- Parameters:
datadict (dict) – dictionary containing relevant regrid parameters
- Raises:
IOError – Error if grid_spec.nc file cannot be found in the current directory
- Returns:
grid_spec filename
- Return type:
str
Note
All grid_spec files are expected to be named “grid_spec.nc”. The grid_spec file is required in order to determine the input mosaic filename
- fre.app.regrid_xy.regrid_xy.get_input_file(datadict: dict, source: str) str
Formats the input file name where the input file contains the variable data that will be regridded.
- Parameters:
datadict (dict) – dictionary containing relevant regrid parameters
source (str) – history file type
- Returns:
formatted input file name
- Return type:
str
Note
The input filename is a required argument for fregrid and refer to the history files containing the data that will be regridded. A history file is typically named, for example, as 20250805.atmos_daily_cmip.tile1.nc, 20250805.atmos_daily_cmip.tile2.nc, …, The yaml configuration does not contain the exact history filenames and the filenames need to be constructed by: (1) extracting the history file “type” from the yaml configuration. This type corresponds to the field value of yaml[“postprocess”][“components”][“sources”][“source”] and, for example, be “atmos_daily_cmip” (2) prepending YYYYMMDD to the filename. This function will prepend the date if the date string was passed to the entrypoint function regrid_xy of this module: i.e., this function will return “20250805.atmos_daily_cmip” (3) Fregrid will append the tile numbers (“tile1.nc”) for reading in the data
- fre.app.regrid_xy.regrid_xy.get_input_mosaic(datadict: dict) str
Gets the input mosaic filename from the grid_spec file.
- Parameters:
datadict (dict) – dictionary containing relevant regrid parameters
- Raises:
IOError – Error if the input mosaic file cannot be found in the current work directory
- Returns:
input_mosaic file
- Return type:
str
Note
The input mosaic filename is a required input argument for fregrid. The input mosaic contains the input grid information.
- fre.app.regrid_xy.regrid_xy.get_remap_file(datadict: dict) str
Determines the remap filename based on the input mosaic filename, output grid size, and conservative order. For example, this function will return the name C96_mosaicX180x288_conserve_order1.nc where the input mosaic filename is C96_mosaic.nc and the output grid size has 180 longitude cells and 288 latitude cells.
The remap_file will be read from, or outputted to the remap_dir.
- Parameters:
datadict (dict) – dictionary containing relevant regrid parameters
- Returns:
remap filename
- Return type:
str
Note
remap_file is a required fregrid argument. If the remap_file exists, then fregrid will read in the remapping parameters (the exchange grid for conservative methods) from the remap_file for regridding the variables. If the remap_file does not exist, fregrid will compute the remapping parameters and save them to the remap_file for future use.
- fre.app.regrid_xy.regrid_xy.get_scalar_fields(datadict: dict) tuple[str, bool]
Returns the scalar_fields argument for fregrid. Scalar_fields is a string of comma separated list of variables that will be regridded
- Parameters:
datadict (dict) – dictionary containing relevant regrid parameters
- Returns:
(string of scalar fields, boolean indicating whether regridding is needed)
- Return type:
tuple[str, bool]
Note
With the exception of the variables in the list non_regriddable_variables, all variables will be regridded.
- fre.app.regrid_xy.regrid_xy.regrid_xy(yamlfile: str, input_dir: str, output_dir: str, work_dir: str, remap_dir: str, source: str, input_date: str = None)
Calls fregrid to regrid data in the specified source data file.
- Parameters:
yamlfile (str) – yaml file containing specifications for yaml[“postprocess”][“settings”][“pp_grid_spec”] and yaml[“postprocess”][“components”]
input_dir (str) – Name of the input directory containing the input/history files, Fregrid will look for all input history files in input_dir.
output_dir (str) – Name of the output directory where fregrid outputs will be saved
work_dir (str) – Directory that will contain the extracted files from the grid_spec tar
remap_dir (str) – Directory that will contain the generated remap file
source (str) – The stem of the history file to regrid
input_date (str) – Datestring where the first 8 characters correspond to YYYYMMDD Input_date[:8] represents the date prefix in the history files, e.g., input_date=20250730T0000Z where the history filename is 20250730.atmos_month_aer.tile1.nc
Note
All directories should be in absolute paths
- fre.app.regrid_xy.regrid_xy.write_summary(datadict)
Logs a summary of the component that will be regridded in a human-readable format This function will log only if the logging level is set to INFO or lower
- Parameters:
datadict (dict) – dictionary containing relevant regrid parameters