Skip to content

Commit

Permalink
Remove test mode; use -b/-e instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
samsrabin committed Sep 11, 2024
1 parent 238aff7 commit dfaeb48
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
8 changes: 1 addition & 7 deletions src/landusedata/landusepft.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,9 @@ def main(args):
# Append the new dataset to the output dataset
ds_output = ds_output.merge(ds_regrid)

# Stop regridding if in test mode
if args.test:
print("-t/--test specified, so stopping here")
break

# Duplicate the 'primary' data array into a 'secondary' data array. Eventually
# this will contain different data from a future CLM landuse x pft update
if not args.test:
ds_output['frac_secnd'] = ds_output.frac_primr.copy(deep=True)
ds_output['frac_secnd'] = ds_output.frac_primr.copy(deep=True)

# ds_regrid = ds_regrid.rename({'lat':'lsmlat','lon':'lsmlon'})

Expand Down
10 changes: 2 additions & 8 deletions src/landusedata/luh2.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def main(args):
# Regrid the luh2 data to the target grid
# TO DO: provide a check for the save argument based on the input arguments
regrid_luh2,regridder_luh2 = RegridConservative(dataset, ds_regrid_target,
args.regridder_weights, regrid_reuse,
args.test)
args.regridder_weights, regrid_reuse)

# Regrid the inverted ice/water fraction data to the target grid
regrid_land_fraction = regridder_luh2(ds_luh2_static)
Expand All @@ -61,8 +60,7 @@ def main(args):
regrid_luh2 = regrid_luh2 / regrid_land_fraction.landfrac

# Correct the state sum (checks if argument passed is state file in the function)
if not args.test:
regrid_luh2 = CorrectStateSum(regrid_luh2)
regrid_luh2 = CorrectStateSum(regrid_luh2)

# Add additional required variables for the host land model
# Add 'YEAR' as a variable.
Expand Down Expand Up @@ -98,10 +96,6 @@ def main(args):
if (not(regrid_reuse)):
regrid_reuse = True

# Only process one dataset if in test mode
if args.test:
break

# Write the files
# TO DO: add check to handle if the user enters the full path
output_file = os.path.join(os.getcwd(),args.output)
Expand Down
11 changes: 3 additions & 8 deletions src/landusedata/regrid.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import xesmf as xe

def RegridConservative(ds_to_regrid, ds_regrid_target, regridder_weights, regrid_reuse, test):
def RegridConservative(ds_to_regrid, ds_regrid_target, regridder_weights, regrid_reuse):

# define the regridder transformation
regridder = GenerateRegridder(ds_to_regrid, ds_regrid_target, regridder_weights, regrid_reuse)

# Loop through the variables to regrid
ds_regrid = RegridLoop(ds_to_regrid, regridder, test)
ds_regrid = RegridLoop(ds_to_regrid, regridder)

return (ds_regrid, regridder)

Expand All @@ -27,7 +27,7 @@ def GenerateRegridder(ds_to_regrid, ds_regrid_target, regridder_weights_file, re

return(regridder)

def RegridLoop(ds_to_regrid, regridder, test):
def RegridLoop(ds_to_regrid, regridder):

# To Do: implement this with dask
print("\nRegridding")
Expand Down Expand Up @@ -62,9 +62,4 @@ def RegridLoop(ds_to_regrid, regridder, test):
# so we pass it in as a copy.
ds_regrid[var] = regridder(ds_to_regrid[var].copy())

# Stop regridding if in test mode
if test:
print("-t/--test specified, so stopping here")
break

return(ds_regrid)

0 comments on commit dfaeb48

Please sign in to comment.