Skip to content
Snippets Groups Projects
Commit 2a2e469a authored by David Keitel's avatar David Keitel
Browse files

black style fixes to preceding set of ephem-handling commits

parent 0e9d656b
Branches
Tags
1 merge request!25ephemerides handling fixes
...@@ -147,11 +147,19 @@ def get_ephemeris_files(): ...@@ -147,11 +147,19 @@ def get_ephemeris_files():
sun_ephem = None sun_ephem = None
elif env_var in list(os.environ.keys()): elif env_var in list(os.environ.keys()):
ephem_version = "DE405" ephem_version = "DE405"
earth_ephem = os.path.join(os.environ[env_var], "earth00-40-{:s}.dat.gz".format(ephem_version)) earth_ephem = os.path.join(
sun_ephem = os.path.join(os.environ[env_var], "sun00-40-{:s}.dat.gz".format(ephem_version)) os.environ[env_var], "earth00-40-{:s}.dat.gz".format(ephem_version)
)
sun_ephem = os.path.join(
os.environ[env_var], "sun00-40-{:s}.dat.gz".format(ephem_version)
)
if not (os.path.isfile(earth_ephem) and os.path.isfile(sun_ephem)): if not (os.path.isfile(earth_ephem) and os.path.isfile(sun_ephem)):
earth_ephem = os.path.join(os.environ[env_var], "earth00-19-{:s}.dat.gz".format(ephem_version)) earth_ephem = os.path.join(
sun_ephem = os.path.join(os.environ[env_var], "sun00-19-{:s}.dat.gz".format(ephem_version)) os.environ[env_var], "earth00-19-{:s}.dat.gz".format(ephem_version)
)
sun_ephem = os.path.join(
os.environ[env_var], "sun00-19-{:s}.dat.gz".format(ephem_version)
)
if not (os.path.isfile(earth_ephem) and os.path.isfile(sun_ephem)): if not (os.path.isfile(earth_ephem) and os.path.isfile(sun_ephem)):
logging.warning( logging.warning(
"Default [earth/sun]00-[19/40]-" + ephem_version + " ephemerides " "Default [earth/sun]00-[19/40]-" + ephem_version + " ephemerides "
......
...@@ -263,14 +263,18 @@ transientTau = {:10.0f}\n""" ...@@ -263,14 +263,18 @@ transientTau = {:10.0f}\n"""
logging.info("Checking if cached data good to reuse...") logging.info("Checking if cached data good to reuse...")
if os.path.isfile(self.sftfilepath) is False: if os.path.isfile(self.sftfilepath) is False:
logging.info("No SFT file matching {} found. {}".format(self.sftfilepath, need_new)) logging.info(
"No SFT file matching {} found. {}".format(self.sftfilepath, need_new)
)
return False return False
else: else:
logging.info("OK: Matching SFT file found.") logging.info("OK: Matching SFT file found.")
if "injectionSources" in cl_mfd: if "injectionSources" in cl_mfd:
if os.path.isfile(self.config_file_name): if os.path.isfile(self.config_file_name):
if os.path.getmtime(self.sftfilepath) < os.path.getmtime(self.config_file_name): if os.path.getmtime(self.sftfilepath) < os.path.getmtime(
self.config_file_name
):
logging.info( logging.info(
( (
"The config file {} has been modified since the SFT file {} " "The config file {} has been modified since the SFT file {} "
...@@ -281,20 +285,30 @@ transientTau = {:10.0f}\n""" ...@@ -281,20 +285,30 @@ transientTau = {:10.0f}\n"""
else: else:
logging.info( logging.info(
"OK: The config file {} is older than the SFT file {}".format( "OK: The config file {} is older than the SFT file {}".format(
self.config_file_name, self.sftfilepath) self.config_file_name, self.sftfilepath
)
)
# NOTE: at this point we assume it's safe to re-use, since # NOTE: at this point we assume it's safe to re-use, since
# check_if_cff_file_needs_rewritting() # check_if_cff_file_needs_rewritting()
# should have already been called before # should have already been called before
)
else: else:
raise RuntimeError("Commandline requires file '{}' but it is missing.".format(self.config_file_name)) raise RuntimeError(
"Commandline requires file '{}' but it is missing.".format(
self.config_file_name
)
)
logging.info("Checking new commandline against existing SFT header...") logging.info("Checking new commandline against existing SFT header...")
cl_dump = "lalapps_SFTdumpheader {} | head -n 20".format(self.sftfilepath) cl_dump = "lalapps_SFTdumpheader {} | head -n 20".format(self.sftfilepath)
output = helper_functions.run_commandline(cl_dump) output = helper_functions.run_commandline(cl_dump)
header_lines_lalapps = [line for line in output.split("\n") if "lalapps" in line] header_lines_lalapps = [
line for line in output.split("\n") if "lalapps" in line
]
if len(header_lines_lalapps) == 0: if len(header_lines_lalapps) == 0:
logging.info("Could not obtain comparison commandline from old SFT header. "+need_new) logging.info(
"Could not obtain comparison commandline from old SFT header. "
+ need_new
)
return False return False
cl_old = header_lines_lalapps[0] cl_old = header_lines_lalapps[0]
if not helper_functions.match_commandlines(cl_old, cl_mfd): if not helper_functions.match_commandlines(cl_old, cl_mfd):
...@@ -329,7 +343,9 @@ transientTau = {:10.0f}\n""" ...@@ -329,7 +343,9 @@ transientTau = {:10.0f}\n"""
return False return False
else: else:
logging.info( logging.info(
"File contents unmatched, updating {}.".format(self.config_file_name) "File contents unmatched, updating {}.".format(
self.config_file_name
)
) )
return True return True
...@@ -392,7 +408,7 @@ transientTau = {:10.0f}\n""" ...@@ -392,7 +408,7 @@ transientTau = {:10.0f}\n"""
self.sqrtSX, self.sqrtSX,
tempory_filename="{}.tmp".format(self.label), tempory_filename="{}.tmp".format(self.label),
earth_ephem=self.earth_ephem, earth_ephem=self.earth_ephem,
sun_ephem=self.sun_ephem sun_ephem=self.sun_ephem,
) # detectors OR IFO? ) # detectors OR IFO?
return twoF_expected return twoF_expected
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment