Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
ashjbarnes committed Aug 21, 2024
1 parent 3d39300 commit 7c45afd
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions regional_mom6/regional_mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,18 @@ def longitude_slicer(data, longitude_extent, longitude_coords):

return data


from pathlib import Path


def get_glorys_data(
longitude_extent,
latitude_extent,
timerange,
segment_name,
download_path,
modify_existing = True,
buffer = 1
download_path,
modify_existing=True,
buffer=1,
):
"""
Generates a bash script to download all of the required ocean forcing data.
Expand All @@ -168,20 +170,14 @@ def get_glorys_data(
buffer (int): number of degrees to add to pad the file with to ensure that interpolation onto desired domain doesn't fail.
"""
path = Path(download_path)
file = open(
path / "get_glorysdata.sh",
"r"
)
file = open(path / "get_glorysdata.sh", "r")

if modify_existing:
lines = file.readlines()
else:
lines = ["#!/bin/bash\ncopernicusmarine login"]
file.close()
file = open(
path / "get_glorysdata.sh",
"w"
)
file = open(path / "get_glorysdata.sh", "w")

lines.append(
f"""
Expand All @@ -190,7 +186,7 @@ def get_glorys_data(
)
file.writelines(lines)
file.close()
return
return


def hyperbolictan_thickness_profile(nlayers, ratio, total_depth):
Expand Down Expand Up @@ -948,9 +944,7 @@ def initial_condition(
return

def get_glorys_rectangular(
self,
raw_boundaries_path,
boundaries=["south", "north", "west", "east"]
self, raw_boundaries_path, boundaries=["south", "north", "west", "east"]
):
"""
This function is a wrapper for `get_glorys_data`, calling this function once for each of the rectangular boundary segments and the initial condition. For more complex boundary shapes, call `get_glorys_data` directly for each of your boundaries that aren't parallel to lines of constant latitude or longitude.
Expand All @@ -965,45 +959,51 @@ def get_glorys_rectangular(
get_glorys_data(
self.longitude_extent,
self.latitude_extent,
[self.date_range[0],datetime.datetime.strptime(self.date_range[0], "%Y-%m-%d %H:%M:%S") + datetime.timedelta(days=1)],
[
self.date_range[0],
datetime.datetime.strptime(self.date_range[0], "%Y-%m-%d %H:%M:%S")
+ datetime.timedelta(days=1),
],
"ic_unprocessed",
raw_boundaries_path,
modify_existing=False
)
modify_existing=False,
)
if "east" in boundaries:
get_glorys_data(
[self.longitude_extent[1] - 1,self.longitude_extent[1] + 1],
[self.latitude_extent[0] -1, self.latitude_extent[1] + 1],
[self.longitude_extent[1] - 1, self.longitude_extent[1] + 1],
[self.latitude_extent[0] - 1, self.latitude_extent[1] + 1],
self.date_range,
"east_unprocessed",
raw_boundaries_path,
)
if "west" in boundaries:
get_glorys_data(
[self.longitude_extent[0] - 1,self.longitude_extent[0] + 1],
[self.latitude_extent[0] -1, self.latitude_extent[1] + 1],
[self.longitude_extent[0] - 1, self.longitude_extent[0] + 1],
[self.latitude_extent[0] - 1, self.latitude_extent[1] + 1],
self.date_range,
"west_unprocessed",
raw_boundaries_path,
)
if "north" in boundaries:
get_glorys_data(
[self.longitude_extent[0] - 1,self.longitude_extent[1] + 1],
[self.latitude_extent[1] -1, self.latitude_extent[1] + 1],
[self.longitude_extent[0] - 1, self.longitude_extent[1] + 1],
[self.latitude_extent[1] - 1, self.latitude_extent[1] + 1],
self.date_range,
"north_unprocessed",
raw_boundaries_path,
)
if "south" in boundaries:
get_glorys_data(
[self.longitude_extent[0] - 1,self.longitude_extent[1] + 1],
[self.latitude_extent[0] -1, self.latitude_extent[0] + 1],
[self.longitude_extent[0] - 1, self.longitude_extent[1] + 1],
[self.latitude_extent[0] - 1, self.latitude_extent[0] + 1],
self.date_range,
"south_unprocessed",
raw_boundaries_path,
)

print(f"script `get_glorys_data.sh` has been greated at {raw_boundaries_path}. Run this script via bash to download the data from a terminal with internet access. You will need to enter your Copernicus Marine username and password. If you don't have an account, make one here:\nhttps://data.marine.copernicus.eu/register")
print(
f"script `get_glorys_data.sh` has been greated at {raw_boundaries_path}. Run this script via bash to download the data from a terminal with internet access. You will need to enter your Copernicus Marine username and password. If you don't have an account, make one here:\nhttps://data.marine.copernicus.eu/register"
)
return

def rectangular_boundaries(
Expand Down

0 comments on commit 7c45afd

Please sign in to comment.