Skip to content

Commit

Permalink
added error message for when dset isnt found in merra data file.
Browse files Browse the repository at this point in the history
  • Loading branch information
bnb32 committed Feb 28, 2025
1 parent 3b38bc8 commit 2dbf55f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions nsrdb/data_model/merra.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def next_pattern(self):
self.file_set,
'*{}*'.format(self.next_date_stamp),
)

return pat

def _get_date_stamp(self, key):
Expand Down Expand Up @@ -231,7 +230,14 @@ def _get_data(self, file):
data = np.where(ctype == 6, 250.0, data)

else:
data = f[self.dset_name][:]
try:
data = f[self.dset_name][:]
except Exception as e:
msg = 'Could not find {} in {}'.format(
self.dset_name, file
)
logger.error(msg)
raise OSError(msg) from e

# make the data a flat 2d array
data = self._format_2d(data)
Expand Down
5 changes: 4 additions & 1 deletion nsrdb/preprocessing/nasa_data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ def run_jobs(input_pattern, output_pattern, max_workers=None):
default_output_pattern += '/{doy}/nacomposite_{timestamp}.nc'
parser = argparse.ArgumentParser()
parser.add_argument(
'input_pattern', type=str, help='File pattern for input_files.'
'input_pattern',
type=str,
help="""File pattern for input_files. e.g.
/projects/pxs/nasa_polar/2023/*/*/*.nc""",
)
parser.add_argument(
'-output_pattern',
Expand Down

0 comments on commit 2dbf55f

Please sign in to comment.