-
Notifications
You must be signed in to change notification settings - Fork 12
fix type issues surfaced from pace integration #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| import datetime | ||
| import re | ||
| from pathlib import Path | ||
| from typing import Union | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. modern typing uses |
||
|
|
||
| import numpy as np | ||
|
|
||
|
|
@@ -65,7 +64,7 @@ def date_to_julian(iyear: int, imonth: int, iday: int) -> int: | |
|
|
||
| def read_NOAA_solar_file( | ||
| solar_fname: Path, | ||
| ) -> dict[str : Union[float, int, dict[str : Union[int, float, dict[str:float]]]]]: | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the format for typing dictionaries is |
||
| ) -> dict[str, float | int | dict[str, int | float | dict[str, float]]]: | ||
| """ | ||
| function to read in a file of solar constants structured as: | ||
| first_year last_year first_cycle last_cycle mean_value info_string | ||
|
|
@@ -98,7 +97,7 @@ def read_NOAA_solar_file( | |
| solar_constant_data["icy1"] = int(table_dat[2]) | ||
| solar_constant_data["icy2"] = int(table_dat[3]) | ||
| solar_constant_data["smean"] = float(table_dat[4]) | ||
| elif re.fullmatch(r"^(\*)\1{1,}$", table_dat[0]): | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. always use |
||
| elif re.fullmatch(r"^(\*)\1{1,}$", table_dat[0]) is not None: | ||
| break # end at the asterisks | ||
| else: | ||
| year = int(table_dat[0]) | ||
|
|
@@ -350,7 +349,7 @@ def solar_update( | |
| deltim: float, | ||
| lsol_chg: bool, | ||
| iyr_sav: int, | ||
| isolflg: bool, | ||
| isolflg: int, | ||
| solar_constant_data: dict = None, | ||
| ) -> tuple[float, float, float, float, float, float, int, int]: | ||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| import os | ||
| import re | ||
| from pathlib import Path | ||
| from typing import Union | ||
|
|
||
| import numpy as np | ||
|
|
||
|
|
@@ -32,7 +31,7 @@ | |
| F113VMR_DEF = 8.2000e-11 # gfdl 1999 value | ||
|
|
||
|
|
||
| def read_global_annual_co2(co2gbl_file: Path) -> dict[str : Union[Float, Int]]: | ||
| def read_global_annual_co2(co2gbl_file: Path) -> dict[str, Float | Int]: | ||
| """ | ||
| Function to read a text file of CO2 global half-yearly means | ||
| and growth rates into a model. | ||
|
|
@@ -62,7 +61,7 @@ def read_global_annual_co2(co2gbl_file: Path) -> dict[str : Union[Float, Int]]: | |
|
|
||
| def read_monthly_resolved_co2( | ||
| co2dat_file: Path, | ||
| ) -> tuple[int, dict[Union[str, Int] : Union[Float, list[Float]]]]: | ||
| ) -> tuple[int, dict[str | Int, Float | list[Float]]]: | ||
| """ | ||
| Function to read a text file of 15-degree CO2 monthly means into a model. | ||
| Assumes a format of: | ||
|
|
@@ -103,7 +102,7 @@ def read_monthly_resolved_co2( | |
|
|
||
| def read_monthly_cycle_co2( | ||
| co2cyc_file: Path, | ||
| ) -> dict[Union[str, Int] : Union[Int, Float, dict[str : Union[Float, list[Float]]]]]: | ||
| ) -> dict[str | Int, Int | Float | dict[str, Float | list[Float]]]: | ||
| """ | ||
| Function to read a text file of 15-degree CO2 monthly deviations into a model. | ||
| Assumes a format of: | ||
|
|
@@ -175,7 +174,6 @@ def read_co2_files(input_dir: Path, prefix="") -> tuple[dict, dict, dict]: | |
| if co2_glob_file.is_file(): | ||
| co2_glb_data = read_global_annual_co2(co2_glob_file) | ||
| if monthly_co2_files: | ||
| co2_mvr_data = {} | ||
| for monthly_file in monthly_co2_files: | ||
| year, data = read_monthly_resolved_co2(input_dir.joinpath(monthly_file)) | ||
| co2_mvr_data[year] = data | ||
|
|
@@ -242,6 +240,7 @@ def gas_init( | |
| float, | ||
| float, | ||
| float, | ||
| float, | ||
| np.ndarray, | ||
| np.ndarray, | ||
| dict, | ||
|
|
@@ -336,6 +335,7 @@ def gas_init( | |
| cfc11, | ||
| cfc12, | ||
| cfc22, | ||
| cfc113, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there was an inconsistency with those 14 or 15 return values. From usage, I inferred that the 15 one is probably what we want ... please double-check
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like that's the missing one to me too based off of RTE_RRTMGPDriver in rte_rrtmgp.py.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol that's correct, whoops! Now I'm worried how that isn't causing issues currently
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ccl4, | ||
| co2_glb, | ||
| co2_arr, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are already defined below with a comment (same default values)