Skip to content
Snippets Groups Projects
Commit c91600c9 authored by Chad Hanna's avatar Chad Hanna
Browse files

inspiral.py: remove subdir option from the T050017 filename function and move...

inspiral.py: remove subdir option from the T050017 filename function and move it to a separate function
parent 0d8e7009
No related branches found
No related tags found
No related merge requests found
......@@ -263,6 +263,15 @@ def parse_iirbank_files(iir_banks, verbose, snr_threshold = 4.0):
return banks
def subdir_from_T050017_filename(fname):
path = str(fname.split("-")[2])[:5]
try:
os.mkdir(path)
except OSError:
pass
return path
#
# =============================================================================
#
......@@ -459,17 +468,9 @@ class CoincsDocument(object):
return self.sngl_inspiral_table.get_next_id()
def T050017_filename(self, description, extension, subdir = False):
def T050017_filename(self, description, extension):
start, end = self.search_summary_outseg
start, end = int(math.floor(start)), int(math.ceil(end))
if subdir:
path = str(start)[:5]
try:
os.mkdir(path)
except OSError:
pass
return "%s/%s-%s-%d-%d.%s" % ("".join(sorted(self.process.get_ifos())), description, start, end - start, extension)
return "%s-%s-%d-%d.%s" % ("".join(sorted(self.process.get_ifos())), description, start, end - start, extension)
......@@ -1007,8 +1008,11 @@ class Data(object):
tmp_likelihood_file = os.path.join(path, 'tmp_%s' % filename)
ligolw_utils.write_filename(self.__get_likelihood_file(), tmp_likelihood_file, gz = (filename or "stdout").endswith(".gz"), verbose = verbose, trap_signals = None)
shutil.move(tmp_likelihood_file, os.path.join(path,filename))
# Snapshots get their own custom file and path
if snapshot:
shutil.copy(os.path.join(path,filename), os.path.join(path, self.coincs_document.T050017_filename(description + '_DISTSTATS', 'xml.gz', dir = True, verbose = verbose)))
fname = self.coincs_document.T050017_filename(description + '_DISTSTATS', 'xml.gz', verbose = verbose)
path = subdir_from_T050017_filename(fname)
shutil.copy(os.path.join(path,filename), os.path.join(path, fname))
def write_output_file(self, filename = None, description = "", verbose = False):
with self.lock:
......@@ -1024,8 +1028,10 @@ class Data(object):
coincs_document = self.coincs_document.get_another()
# We require the likelihood file to have the same name
# as the input to this program to accumulate statistics
# as we go
self.__write_output_file(filename = self.coincs_document.T050017_filename(description, extension), verbose = verbose, dir = True)
# as we go
fname = self.coincs_document.T050017_filename(description, extension)
fname = os.path.join(subdir_from_T050017_filename(fname), fname)
self.__write_output_file(filename = fname, verbose = verbose)
if self.likelihood_files_namedtuple.likelihood_file:
self.__write_likelihood_file(self.likelihood_files_namedtuple.likelihood_file, description, snapshot = True, verbose = verbose)
......
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