Skip to content

Commit

Permalink
Actually lets just keep all FRE tools separate in their own function
Browse files Browse the repository at this point in the history
  • Loading branch information
ashjbarnes committed Sep 6, 2023
1 parent c9c52f0 commit b98f0f4
Showing 1 changed file with 27 additions and 37 deletions.
64 changes: 27 additions & 37 deletions regional_mom6/regional_mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,7 @@ def bathymetry(
fill_channels=False,
minimum_layers=3,
maketopog=True,
positivedown=False,
run_fretools = True
positivedown=False
):
"""Cuts out and interpolates chosen bathymetry, then fills
inland lakes.
Expand All @@ -857,11 +856,7 @@ def bathymetry(
make topography (if true), or read an existing file.
positivedown (Optional[bool]): If true, assumes that
bathymetry vertical coordinate is positive down.
run_fretools (Optional[bool]): If true, runs FREtools to
generate mosaic & masks. Set to false for testing purposes
if you don't have FRE tools compiled. Otherwise should be
set to true to ensure that the masks are updated with changes
to topography.
"""

Expand Down Expand Up @@ -1099,41 +1094,13 @@ def bathymetry(
"mv topog_deseas.nc topog.nc", shell=True, cwd=self.mom_input_dir
)

if run_fretools == True:

## FINAL STEP: run the remaining FRE tools to construct masks based on our topography

args = "--num_tiles 1 --dir . --mosaic_name ocean_mosaic --tile_file hgrid.nc".split(
" "
)
print(
"MAKE SOLO MOSAIC",
subprocess.run(
self.toolpath
+ "make_solo_mosaic/make_solo_mosaic --num_tiles 1 --dir . --mosaic_name ocean_mosaic --tile_file hgrid.nc",
shell=True,
cwd=self.mom_input_dir,
),
sep="\n\n",
)

print(
"QUICK MOSAIC",
subprocess.run(
self.toolpath
+ "make_quick_mosaic/make_quick_mosaic --input_mosaic ocean_mosaic.nc --mosaic_name grid_spec --ocean_topog topog.nc",
shell=True,
cwd=self.mom_input_dir,
),
sep="\n\n",
)

self.topog = topog
return

def processor_mask(self, layout):
def FRE_tools(self, layout):
"""
Just a wrapper for FRE Tools check_mask. User provides processor layout tuple of processing units.
Just a wrapper for FRE Tools check_mask, make_solo_mosaic and make_quick_mosaic. User provides processor layout tuple of processing units.
"""

if "topog.nc" not in os.listdir(self.mom_input_dir):
Expand All @@ -1145,6 +1112,29 @@ def processor_mask(self, layout):
) ## Removes old mask table so as not to clog up inputdir
except:
pass

print(
"MAKE SOLO MOSAIC",
subprocess.run(
self.toolpath
+ "make_solo_mosaic/make_solo_mosaic --num_tiles 1 --dir . --mosaic_name ocean_mosaic --tile_file hgrid.nc",
shell=True,
cwd=self.mom_input_dir,
),
sep="\n\n",
)

print(
"QUICK MOSAIC",
subprocess.run(
self.toolpath
+ "make_quick_mosaic/make_quick_mosaic --input_mosaic ocean_mosaic.nc --mosaic_name grid_spec --ocean_topog topog.nc",
shell=True,
cwd=self.mom_input_dir,
),
sep="\n\n",
)

print(
"CHECK MASK",
subprocess.run(
Expand Down

0 comments on commit b98f0f4

Please sign in to comment.