Skip to content
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

Generalizing MITgcm read in to enabele read in of SPARC #60

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore = R0913, R0914, C0415, E0402, F401, E203, F811, W503
ignore = R0913, R0914, C0415, E0402, F401, E203, F811, W503, C901
max-line-length = 88
max-complexity = 18
select = B,C,E,F,W,T4,B9
8 changes: 6 additions & 2 deletions gcm_toolkit/core/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
These variable names are currently in sync with the naming scheme
from the cubedsphere package.
The advantage of that is that we do not need to worry about
variable naming inconsistancies with exorad data.
variable naming inconsistancies with mitgcm data.
==============================================================
"""
VARNAMES = dict(
Expand Down Expand Up @@ -62,8 +62,12 @@
P_orb="P_orb",
g="g",
R_p="R_p",
Kappa="Kappa",
cp="cp",
R="R",
R="R", # specific gas constant
p_ref="p_ref",
p0="p0",
dt="dt",
)

SUPPORTED_GCMS = ["MITgcm"]
22 changes: 12 additions & 10 deletions gcm_toolkit/core/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ def convert_pressure(dsi, current_unit, goal_unit):
.to(u.Unit(goal_unit))
.value
)
dsi.attrs.update(
{
"p_ref": (dsi.p_ref * u.Unit(current_unit))
.to(u.Unit(goal_unit))
.value
}
)
for attr in [c["p_ref"], c["p0"]]:
if attr in dsi.attrs:
dsi.attrs.update(
{
attr: (dsi.attrs[attr] * u.Unit(current_unit))
.to(u.Unit(goal_unit))
.value
}
)

# store the units in the dataset attributes
dsi.attrs["p_unit"] = goal_unit
Expand Down Expand Up @@ -90,17 +92,17 @@ def convert_time(dsi, current_unit, goal_unit):
if (
current_unit != goal_unit
and (current_unit == "iter" or goal_unit == "iter")
and dsi.attrs.get("dt") is None
and dsi.attrs.get(c["dt"]) is None
):
raise ValueError(
"You can only convert units if the timestep is known. "
)

# Convert time:
if current_unit == "iter" and goal_unit == "day":
dsi[c["time"]] = dsi.iter * dsi.attrs["dt"] / (3600 * 24)
dsi[c["time"]] = dsi.iter * dsi.attrs[c["dt"]] / (3600 * 24)
if current_unit == "day" and goal_unit == "iter":
dsi[c["time"]] = dsi.iter / dsi.attrs["dt"] * (3600 * 24)
dsi[c["time"]] = dsi.iter / dsi.attrs[c["dt"]] * (3600 * 24)

# store the units in the dataset attributes
dsi.attrs["time_unit"] = goal_unit
Expand Down
227 changes: 0 additions & 227 deletions gcm_toolkit/exorad/read_in.py

This file was deleted.

File renamed without changes.
Loading
Loading