Skip to content

Commit c27038f

Browse files
authored
Merge branch 'main' into copilot/improve-branded-variable-handling
2 parents f688662 + ef228ea commit c27038f

31 files changed

+1983
-1383
lines changed

.github/workflows/create_test_conda_env.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,3 @@ jobs:
6565
with:
6666
token: ${{ secrets.CODECOV_TOKEN }}
6767
verbose: true
68-
69-
- name: Run pylint
70-
if: ${{ always() }}
71-
run: |
72-
pylint --rcfile pylintrc fremorizer/

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ cython_debug/
155155
*.nc
156156
tmp/
157157

158+
# experiment-config JSONs are generated by conftest fixtures at test time
159+
fremorizer/tests/test_files/CMOR_input_example.json
160+
fremorizer/tests/test_files/CMOR_CMIP7_input_example.json
161+
158162
# QA results
159163
wcrp_compliance_reports/
160164

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![readthedocs](https://app.readthedocs.org/projects/fremorizer/badge/?version=latest&style=flat)](https://fremorizer.readthedocs.io/en/latest/)
1111

1212
[![pylint](https://github.com/ilaflott/fremorizer/actions/workflows/pylint.yml/badge.svg?branch=main)](https://github.com/ilaflott/fremorizer/actions/workflows/pylint.yml)
13-
[![pylint](https://img.shields.io/badge/pylint-%E2%89%A59.6-brightgreen)](https://github.com/NOAA-GFDL/epmt/actions/workflows/build_and_test_epmt.yml)
13+
[![pylint](https://img.shields.io/badge/pylint-%E2%89%A59.7-brightgreen)](https://github.com/NOAA-GFDL/epmt/actions/workflows/build_and_test_epmt.yml)
1414
[![codecov](https://codecov.io/gh/ilaflott/fremorizer/branch/main/graph/badge.svg)](https://codecov.io/gh/ilaflott/fremorizer)
1515

1616

fremorizer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
fre_logger = logging.getLogger(__name__)
1010

11-
FORMAT = "[%(levelname)5s:%(filename)24s:%(funcName)24s] %(message)s"
11+
FORMAT = '[%(levelname)5s:%(filename)24s:%(funcName)24s] %(message)s'
1212
logging.basicConfig( level = logging.WARNING,
1313
format = FORMAT,
1414
filename = None,

fremorizer/cli.py

Lines changed: 96 additions & 96 deletions
Large diffs are not rendered by default.

fremorizer/cmor_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def cmor_config_subtool(
215215
lines.append(f" - component_name: '{component_name}'")
216216
lines.append(f" variable_list: '{variable_list}'")
217217
lines.append(" data_series_type: 'ts'")
218-
lines.append(" chunk: *PP_CMIP_CHUNK")
218+
lines.append(' chunk: *PP_CMIP_CHUNK')
219219

220220

221221
# ---- write output YAML ----

fremorizer/cmor_constants.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@
2828
# Vertical-coordinate classification (used by cmor_mixer)
2929
# ---------------------------------------------------------------------------
3030
ACCEPTED_VERT_DIMS = [
31-
"z_l", "landuse",
32-
"plev39", "plev30", "plev19", "plev8",
33-
"height2m",
34-
"level", "lev", "levhalf",
31+
'z_l', 'landuse',
32+
'plev39', 'plev30', 'plev19', 'plev8',
33+
'height2m',
34+
'level', 'lev', 'levhalf',
3535
]
3636

3737
NON_HYBRID_SIGMA_COORDS = [
38-
"landuse",
39-
"plev39", "plev30", "plev19", "plev8",
40-
"height2m",
38+
'landuse',
39+
'plev39', 'plev30', 'plev19', 'plev8',
40+
'height2m',
4141
]
4242

43-
ALT_HYBRID_SIGMA_COORDS = ["level", "lev", "levhalf"]
43+
ALT_HYBRID_SIGMA_COORDS = ['level', 'lev', 'levhalf']
4444

45-
DEPTH_COORDS = ["z_l"]
45+
DEPTH_COORDS = ['z_l']
4646

4747

4848
# ---------------------------------------------------------------------------
@@ -62,10 +62,10 @@
6262
# equivalents. Dimensions whose names already match (e.g. plev39, height2m)
6363
# need no entry; the look-up falls back to using the input name directly.
6464
INPUT_TO_MIP_VERT_DIM = {
65-
"z_l": "olevel",
66-
"level": "alevel",
67-
"lev": "alevel",
68-
"levhalf": "alevhalf",
65+
'z_l': 'olevel',
66+
'level': 'alevel',
67+
'lev': 'alevel',
68+
'levhalf': 'alevhalf',
6969
}
7070

7171

fremorizer/cmor_finder.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ def print_var_content(table_config_file: IO[str],
5353

5454
table_name = None
5555
try:
56-
table_name = proj_table_vars["Header"].get('table_id').split(' ')[1]
56+
table_name = proj_table_vars['Header'].get('table_id').split(' ')[1]
5757
except KeyError:
58-
fre_logger.warning("couldn't get header and table_name field")
58+
fre_logger.warning('couldn\'t get header and table_name field')
5959

6060
if table_name is not None:
6161
fre_logger.info('looking for %s data in table %s!', var_name, table_name)
6262
else:
6363
fre_logger.info('looking for %s data in table %s, but could not find its table_name!',
6464
var_name, table_config_file.name)
6565

66-
var_content = proj_table_vars.get("variable_entry", {}).get(var_name)
66+
var_content = proj_table_vars.get('variable_entry', {}).get(var_name)
6767
if var_content is None:
6868
fre_logger.debug('variable %s not found in %s, moving on!', var_name, Path(table_config_file.name).name)
6969
return
@@ -107,7 +107,7 @@ def cmor_find_subtool( json_var_list: Optional[str] = None,
107107

108108
var_list = None
109109
if json_var_list is not None:
110-
with open(json_var_list, "r", encoding="utf-8") as var_list_file:
110+
with open(json_var_list, 'r', encoding='utf-8') as var_list_file:
111111
var_list = json.load(var_list_file)
112112

113113
if opt_var_name is None and var_list is None:
@@ -116,14 +116,14 @@ def cmor_find_subtool( json_var_list: Optional[str] = None,
116116
if opt_var_name is not None:
117117
fre_logger.info('opt_var_name is not None: looking for only ONE variables worth of info!')
118118
for json_table_config in json_table_configs:
119-
with open(json_table_config, "r", encoding="utf-8") as table_config_file:
119+
with open(json_table_config, 'r', encoding='utf-8') as table_config_file:
120120
print_var_content(table_config_file, opt_var_name)
121121

122122
elif var_list is not None:
123123
fre_logger.info('opt_var_name is None, and var_list is not None, looking for many variables worth of info!')
124124
for var in var_list:
125125
for json_table_config in json_table_configs:
126-
with open(json_table_config, "r", encoding="utf-8") as table_config_file:
126+
with open(json_table_config, 'r', encoding='utf-8') as table_config_file:
127127
print_var_content(table_config_file, str(var_list[var]))
128128

129129

@@ -132,7 +132,7 @@ def make_simple_varlist( dir_targ: str,
132132
json_mip_table: Optional[str] = None) -> Optional[Dict[str, str]]:
133133
"""
134134
Generate a JSON file containing a list of variable names from NetCDF files in a specified directory.
135-
This function searches for NetCDF files in the given directory, or a subdirectory, "ts/monthly/5yr",
135+
This function searches for NetCDF files in the given directory, or a subdirectory, 'ts/monthly/5yr',
136136
if not already included. It then extracts variable names from the filenames, and writes these variable
137137
names to a JSON file.
138138
@@ -154,22 +154,22 @@ def make_simple_varlist( dir_targ: str,
154154
155155
"""
156156
# if the variable is in the filename, it's likely delimited by another period.
157-
all_nc_files = glob.glob(os.path.join(dir_targ, "*.*.nc"))
157+
all_nc_files = glob.glob(os.path.join(dir_targ, '*.*.nc'))
158158
if not all_nc_files:
159-
fre_logger.error("No files found in the directory.") #uncovered
159+
fre_logger.error('No files found in the directory.') #uncovered
160160
return None
161161

162162
if len(all_nc_files) == 1:
163-
fre_logger.warning("Warning: Only one file found matching the pattern.")
163+
fre_logger.warning('Warning: Only one file found matching the pattern.')
164164

165-
fre_logger.info("Files found matching pattern. Number of files: %d", len(all_nc_files))
165+
fre_logger.info('Files found matching pattern. Number of files: %d', len(all_nc_files))
166166

167167
mip_vars = None
168168
if json_mip_table is not None:
169169
try:
170170
# read in mip vars to check against later
171171
fre_logger.debug('attempting to read in variable entries in specified mip table')
172-
full_mip_vars_list=get_json_file_data(json_mip_table)["variable_entry"].keys()
172+
full_mip_vars_list=get_json_file_data(json_mip_table)['variable_entry'].keys()
173173

174174
except Exception as exc:
175175
raise Exception( 'problem opening mip table and getting variable entry data.'

0 commit comments

Comments
 (0)