Skip to content

Commit

Permalink
fix table/freq ambiguity for multi-frequency variables (#252)
Browse files Browse the repository at this point in the history
* fix table/freq ambiguity for multi-frequency variables

* Update e3sm_to_cmip/__main__.py

Co-authored-by: Tom Vo <tomvothecoder@gmail.com>

* Restored ambiguous definitions for Amon rsut and rsutcs

* Restore handler defs to original ordering for ease of diff

---------

Co-authored-by: Tom Vo <tomvothecoder@gmail.com>
  • Loading branch information
TonyB9000 and tomvothecoder authored Apr 16, 2024
1 parent 9935e82 commit 3b06eee
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
10 changes: 7 additions & 3 deletions e3sm_to_cmip/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,18 +658,22 @@ def _run_info_mode(self): # noqa: C901

# if the user asked if the variable is included in the table
# but didnt ask about the files in the inpath
elif self.freq and self.tables_path and not self.input_path:
elif self.freq and self.tables_path and not self.input_path: # info mode 2
for handler in self.handlers:
table_info = _get_table_info(self.tables_path, handler["table"])
if handler["name"] not in table_info["variable_entry"]:
msg = f"Variable {handler['name']} is not included in the table {handler['table']}" # type: ignore
print_message(msg, status="error")
continue
else:
if self.freq == "mon" and handler['table'] == "CMIP6_day.json":
continue
if ( self.freq == "day" or self.freq == "3hr" ) and handler['table'] == "CMIP6_Amon.json":
continue
hand_msg = get_handler_info_msg(handler)
messages.append(hand_msg)

elif self.freq and self.tables_path and self.input_path:
elif self.freq and self.tables_path and self.input_path: # info mode 3

file_path = next(Path(self.input_path).glob("*.nc"))

Expand Down Expand Up @@ -712,7 +716,7 @@ def _run_info_mode(self): # noqa: C901

if self.freq == "mon" and handler['table'] == "CMIP6_day.json":
continue
if self.freq == "day" and handler['table'] == "CMIP6_Amon.json":
if ( self.freq == "day" or self.freq == "3hr" ) and handler['table'] == "CMIP6_Amon.json":
continue

hand_msg = None
Expand Down
16 changes: 16 additions & 0 deletions e3sm_to_cmip/cmor_handlers/handlers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,14 @@
formula: null
positive: null
levels: null
- name: huss
units: "1"
raw_variables: [QREFHT]
table: CMIP6_day.json
unit_conversion: null
formula: null
positive: null
levels: null
- name: lai
units: "1"
raw_variables: [LAISHA, LAISUN]
Expand Down Expand Up @@ -740,6 +748,14 @@
formula: null
positive: null
levels: null
- name: tas
units: K
raw_variables: [TREFHT]
table: CMIP6_day.json
unit_conversion: null
formula: null
positive: null
levels: null
- name: tasmax
units: K
raw_variables: [TREFHTMX]
Expand Down

0 comments on commit 3b06eee

Please sign in to comment.