Skip to content

Commit

Permalink
Add GFDL Rotation Code and minor tides debugging in setup_run_directory
Browse files Browse the repository at this point in the history
The GFDL rotation code was commented out🙈
  • Loading branch information
manishvenu committed Oct 25, 2024
1 parent 90e90a6 commit b9ee4ba
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions regional_mom6/regional_mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -2251,12 +2251,13 @@ def setup_run_directory(

# Check if we can implement tides
if with_tides:
if not (self.mom_input_dir / "forcing").exists():
all_files = os.listdir(Path(self.mom_input_dir))
else:
all_files = os.listdir(Path(self.mom_input_dir / "forcing"))+ os.listdir(Path(self.mom_input_dir))
tidal_files_exist = any(
"tidal" in filename
for filename in (
os.listdir(Path(self.mom_input_dir / "forcing"))
+ os.listdir(Path(self.mom_input_dir))
)
for filename in all_files
)
if not tidal_files_exist:
raise (
Expand Down Expand Up @@ -3439,13 +3440,22 @@ def regrid_tides(
# Convert complex u and v to ellipse,
# rotate ellipse from earth-relative to model-relative,
# and convert ellipse back to amplitude and phase.
# There is probably a complicated trig identity for this? But
# this works too.

if self.orientation in ['south', 'north']:
angle = self.coords['angle']
elif self.orientation in ['west', 'east']:
angle = self.coords['angle']

# Convert complex u and v to ellipse,
# rotate ellipse from earth-relative to model-relative,
# and convert ellipse back to amplitude and phase.
print(ucplex)
SEMA, ECC, INC, PHA = ap2ep(ucplex, vcplex)

# Rotate to the model grid by adjusting the inclination.
# Requries that angle is in radians.

ua, va, up, vp = ep2ap(SEMA, ECC, INC, PHA)

print(ua)
ds_ap = xr.Dataset(
{f"uamp_{self.segment_name}": ua, f"vamp_{self.segment_name}": va}
)
Expand Down

0 comments on commit b9ee4ba

Please sign in to comment.