Skip to content

Commit

Permalink
Merge pull request #31 from spencerkclark/one_dir_freq
Browse files Browse the repository at this point in the history
Add 'one_dir_freq' file read-in option
  • Loading branch information
Spencer Hill committed Nov 12, 2015
2 parents 3892986 + dfe10b9 commit a55ee82
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions aospy/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,27 @@ def __init__(self, calc_interface):

self.data_out = {}

def _data_in_files_one_dir(self, name, n=0):
"""Get the file names of the files in a single directory"""
if self.intvl_in in self.data_in_files[n]:
if isinstance(self.data_in_files[n][self.intvl_in][name], str):
data_in_files = [self.data_in_files[n][self.intvl_in][name]]
else:
data_in_files = self.data_in_files[n][self.intvl_in][name]
else:
if isinstance(self.data_in_files[n][name], str):
data_in_files = [self.data_in_files[n][name]]
else:
data_in_files = self.data_in_files[n][name]
return data_in_files

def _get_input_data_paths_one_dir(self, name, data_in_direc, n=0):
"""Get the names of netCDF files when all in same directory."""
if isinstance(self.data_in_files[n][name], str):
data_in_files = [self.data_in_files[n][name]]
else:
data_in_files = self.data_in_files[n][name]
data_in_files = self._data_in_files_one_dir(name, n)
# data_in_files may hold absolute or relative paths
paths = []
for nc in data_in_files:
full = '/'.join([data_in_direc, nc]).replace('//', '/')
full = os.path.join(data_in_direc, nc)
if os.path.isfile(nc):
paths.append(nc)
elif os.path.isfile(full):
Expand Down

0 comments on commit a55ee82

Please sign in to comment.