fre.cmor.cmor_finder module
fre cmor find This module provides tools to find and print information about variables in CMIP6 JSON configuration files.
- Functions:
- print_var_content(table_config_file, var_name):
Prints information about a specific variable from a given CMIP6 JSON configuration file.
- cmor_find_subtool(json_var_list, json_table_config_dir, opt_var_name):
Finds and prints information about variables in CMIP6 JSON configuration files located in a specified directory.
make_simple_varlist(dir_targ, output_variable_list):
because ian got tired of typing things like the following in bash…
varname=sos; table_files=$(ls fre/tests/test_files/cmip6-cmor-tables/Tables/CMIP6_*.json); for table_file in $table_files; do echo $table_file; cat $table_file | grep -A 10 “”$varname””; done;
- fre.cmor.cmor_finder.cmor_find_subtool(json_var_list=None, json_table_config_dir=None, opt_var_name=None)
finds tables in the CMIP json config directory containing variable data of interest. prints it out to screen, intended largely as a helper tool for cli users.
- fre.cmor.cmor_finder.make_simple_varlist(dir_targ, output_variable_list)
Generates a JSON file containing a list of variables from NetCDF files in a specified directory. This function searches for NetCDF files in the given directory (or a subdirectory “ts/monthly/5yr” if not already included), extracts variable names from the filenames, and writes these variable names to a JSON file.
- Args:
dir_targ (str): The target directory to search for NetCDF files. output_variable_list (str): The path to the output JSON file where the variable list will be saved.
- Returns:
None
- Raises:
Logs errors if no files are found in the directory or if no files match the expected pattern. Logs a warning if only one file is found matching the pattern.
- Notes:
The function assumes that the filenames of the NetCDF files contain the variable name as the second-to-last component when split by periods (‘.’) and a datetime string as the third-to-last component.
- fre.cmor.cmor_finder.print_var_content(table_config_file, var_name)
outputs info on one variable to the logger looks for info regarding var_name in table_config_file the level of the messaging is INFO, requiring the verbose flag