Skip to content

Commit

Permalink
Add list of time series files to CaseClass
Browse files Browse the repository at this point in the history
  • Loading branch information
mnlevy1981 committed Oct 5, 2020
1 parent 390ecc2 commit 5309e40
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
26 changes: 26 additions & 0 deletions notebooks/utils/CaseClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .config import (
add_first_date_and_reformat,
get_archive_log_dir,
get_campaign_popseries_dir,
get_archive_pophist_dir,
get_rundir,
)
Expand All @@ -32,6 +33,7 @@ def __init__(self, casenames, verbose=False):
self._casenames = casenames
self._verbose = verbose
self._log_filenames = self._find_log_files()
self._timeseries_filenames = self._find_timeseries_files()
self._history_filenames = self._find_hist_files()

self.log_contents = dict()
Expand Down Expand Up @@ -78,6 +80,30 @@ def _find_log_files(self):

############################################################################

def _find_timeseries_files(self):
"""
Look in campaign_dir for pop history files
"""
files = dict()
subdirs = dict()
subdirs["pop.h"] = "month_1"
subdirs["pop.h.nday1"] = "day_1"
subdirs["pop.h.nyear1"] = "year_1"
for stream in ["pop.h", "pop.h.nday1"]:
files[stream] = []
for casename in self._casenames:
files[stream] += glob.glob(
os.path.join(
get_campaign_popseries_dir(casename),
subdirs[stream],
f"{casename}.{stream}.*.nc",
)
)
files[stream].sort()
return files

############################################################################

def _find_hist_files(self):
"""
Look in rundir and archive for pop history files
Expand Down
23 changes: 23 additions & 0 deletions notebooks/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@ def get_rundir(casename):
################################################################################


def get_campaign_popseries_dir(casename):
freq_name = dict()
return os.path.join(
os.sep,
"glade",
"campaign",
"cesm",
"development",
"bgcwg",
"projects",
"hi-res_JRA",
"cases",
casename,
"output",
"ocn",
"proc",
"tseries",
)


################################################################################


def get_archive_pophist_dir(casename):
return os.path.join(
os.sep, "glade", "scratch", user, "archive", casename, "ocn", "hist"
Expand Down

0 comments on commit 5309e40

Please sign in to comment.