Skip to content
Snippets Groups Projects
Commit 48fd3786 authored by Patrick Godwin's avatar Patrick Godwin
Browse files

datafind.py: allow multiple subtypes to be passed into DataCache methods

parent 3e1d8562
No related branches found
No related tags found
No related merge requests found
......@@ -134,6 +134,8 @@ class DataCache:
ifos = [ifos]
if svd_bins and isinstance(svd_bins, str):
svd_bins = [svd_bins]
if subtype is None or isinstance(subtype, str):
subtype = [subtype]
if not time_bins:
time_bins = segmentlist([segment(0, 0)])
elif isinstance(time_bins, segment):
......@@ -145,11 +147,13 @@ class DataCache:
path = cls._data_path(str(name).lower(), span[0], create=create_dirs)
if svd_bins:
for svd_bin in svd_bins:
filename = name.filename(ifo, span, svd_bin=svd_bin, subtype=subtype)
cache.append(os.path.join(path, filename))
for stype in subtype:
filename = name.filename(ifo, span, svd_bin=svd_bin, subtype=stype)
cache.append(os.path.join(path, filename))
else:
filename = name.filename(ifo, span, subtype=subtype)
cache.append(os.path.join(path, filename))
for stype in subtype:
filename = name.filename(ifo, span, subtype=stype)
cache.append(os.path.join(path, filename))
if root:
cache = [os.path.join(root, entry) for entry in cache]
......@@ -162,9 +166,12 @@ class DataCache:
svd_bins = set([svd_bins]) if isinstance(svd_bins, str) else set(svd_bins)
else:
svd_bins = [None]
if subtype is None or isinstance(subtype, str):
subtype = [subtype]
for svd_bin in svd_bins:
cache.extend(glob.glob(cls._glob_path(name, root, svd_bin, subtype)))
cache.extend(glob.glob(cls._glob_path(name, root, svd_bin, subtype, gps_dir=False)))
for stype in subtype:
cache.extend(glob.glob(cls._glob_path(name, root, svd_bin, stype)))
cache.extend(glob.glob(cls._glob_path(name, root, svd_bin, stype, gps_dir=False)))
return cls(name, [CacheEntry.from_T050017(entry) for entry in cache])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment