Skip to content

Commit

Permalink
Switch to list concatenation for variables specification.
Browse files Browse the repository at this point in the history
Add the list of requested variables to the `args` list by concating.
Previously I was manually creating the space seperated list (i.e string)
when a list of variables was passed to the girdded inerpolator function.
This space seperated string was not correctly parsed by the
`mpas_tool.logging.check_call` function resulting in the variables not
being inerpolated.
  • Loading branch information
andrewdnolan committed Sep 13, 2024
1 parent 6a0cee8 commit b281644
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions compass/landice/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,11 +1050,12 @@ def __guess_scrip_name(filename):
source_scrip = __guess_scrip_name(os.path.basename(source_file))
weights_filename = "gridded_to_MPAS_weights.nc"

if variables != "all":
# make sure this is a list

# if list, then join the list making it a space seprated list for cli
variables = " ".join(variables)
# make sure variables is a list, encompasses the variables="all" case
if isinstance(variables, str):
variables = [variables]
if not isinstance(variables, list):
raise TypeError("Arugment 'variables' is of incorrect type, must"
" either the string 'all' or a list string")

logger.info('creating scrip file for source dataset')
# Note: writing scrip file to workdir
Expand Down Expand Up @@ -1085,7 +1086,7 @@ def __guess_scrip_name(filename):
'-d', dest_file,
'-m', 'e',
'-w', weights_filename,
'-v', variables]
'-v'] + variables

check_call(args, logger=logger)

Expand Down

0 comments on commit b281644

Please sign in to comment.