fre.cmor.cmor_mixer module

python module housing the metadata processing routines utilizing the cmor module, in addition to click API entry points see README.md for additional information on fre cmor run (cmor_mixer.py) usage

fre.cmor.cmor_mixer.cmor_run_subtool(indir=None, json_var_list=None, json_table_config=None, json_exp_config=None, outdir=None, opt_var_name=None)
primary steering function for the cmor_mixer tool, i.e essentially main. Accepts six args:
indir: string, directory containing netCDF files. keys specified in json_var_list are local

variable names used for targeting specific files

json_var_list: string, path pointing to a json file containing directory of key/value

pairs. the keys are the “local” names used in the filename, and the values pointed to by those keys are strings representing the name of the variable contained in targeted files. the key and value are often the same, but it is not required.

json_table_config: json file containing CMIP-compliant per-variable/metadata for specific

MIP table. The MIP table can generally be identified by the specific filename (e.g. “Omon”)

json_exp_config: json file containing metadata dictionary for CMORization. this metadata is effectively

appended to the final output file’s header

outdir: string, directory root that will contain the full output and output directory

structure generated by the cmor module upon request.

opt_var_name: string, optional, specify a variable name to specifically process only filenames matching

that variable name. I.e., this string help target local_vars, not target_vars.

fre.cmor.cmor_mixer.cmorize_target_var_files(indir=None, target_var=None, local_var=None, iso_datetime_arr=None, name_of_set=None, json_exp_config=None, outdir=None, proj_table_vars=None, json_table_config=None)

processes a target directory/file this routine is almost entirely exposed data movement before/after calling rewrite_netcdf_file_var it is also the most hopelessly opaque routine in this entire dang macro. this badboy right here accepts… lord help us… !!!NINE!!! arguments, NINE.

indir: string, path to target directories containing netcdf files to cmorize target_var: string, name of variable inside the netcdf file to cmorize local_var: string, value of the variable name in the filename, right before the .nc

extension. often identical to target_var but not always.

iso_datetime_arr: list of strings, each one a unique ISO datetime string found in targeted

netcdf filenames

name_of_set: string, representing the post-processing component (GFDL convention) of the

targeted files.

json_exp_config: see cmor_run_subtool arg desc outdir: string, path to output directory root to move the cmor module output to, including

the whole directory structure

proj_table_vars: an opened json file object, read from json_table_config json_table_config: see cmor_run_subtool arg desc

fre.cmor.cmor_mixer.rewrite_netcdf_file_var(proj_table_vars=None, local_var=None, netcdf_file=None, target_var=None, json_exp_config=None, json_table_config=None, prev_path=None)

rewrite the input netcdf file nc_fl containing target_var in a CMIP-compliant manner. accepts six arguments, all required:

proj_table_vars: json dictionary object, variable table read from json_table_config. local_var: string, variable name used for finding files locally containing target_var,

this argument is often equal to target_var.

netcdf_file: string, representing path to intput netcdf file. target_var: string, representing the variable name attached to the data object in the netcdf file. json_exp_config: string, representing path to json configuration file holding metadata for appending to output

this argument is most used for making sure the right grid label is getting attached to the right output

json_table_config: string, representing path to json configuration file holding variable names for a given table.

proj_table_vars is read from this file, but both are passed anyways.