From b98f0f4219becdd889f5d6075cea0ac093d90309 Mon Sep 17 00:00:00 2001 From: ashjbarnes Date: Wed, 6 Sep 2023 12:19:18 +1000 Subject: [PATCH] Actually lets just keep all FRE tools separate in their own function --- regional_mom6/regional_mom6.py | 64 ++++++++++++++-------------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/regional_mom6/regional_mom6.py b/regional_mom6/regional_mom6.py index cce2196c..427f2b9f 100644 --- a/regional_mom6/regional_mom6.py +++ b/regional_mom6/regional_mom6.py @@ -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. @@ -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. + """ @@ -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): @@ -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(