Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing temporary database functionality. #704

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions src/sorcha/modules/PPCommandLineParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@ def PPCommandLineParser(args):
if cmd_args_dict["output_ephemeris_file"]:
warn_or_remove_file(cmd_args_dict["output_ephemeris_file"], args.f, pplogger)

if args.dw == "default":
oifpath_split = os.path.split(cmd_args_dict["oifoutput"])
stem_name = oifpath_split[1].split(".")[0] + ".db"
cmd_args_dict["makeTemporaryEphemerisDatabase"] = os.path.join(oifpath_split[0], "temp_" + stem_name)
elif args.dw:
_ = PPFindDirectoryOrExit(os.path.dirname(args.dw), "-dw")
cmd_args_dict["makeTemporaryEphemerisDatabase"] = args.dw
else:
cmd_args_dict["makeTemporaryEphemerisDatabase"] = False

cmd_args_dict["readTemporaryEphemerisDatabase"] = args.dr
cmd_args_dict["deleteTemporaryEphemerisDatabase"] = bool(args.dl)
cmd_args_dict["surveyname"] = args.s
cmd_args_dict["outfilestem"] = args.t
cmd_args_dict["verbose"] = args.v
Expand All @@ -101,29 +89,6 @@ def PPCommandLineParser(args):
os.path.join(cmd_args_dict["outpath"], cmd_args_dict["outfilestem"] + ".*"), args.f, pplogger
)

if args.dr and args.dw:
pplogger.error("ERROR: both -dr and -dw flags set at command line. Please use only one.")
sys.exit("ERROR: both -dr and -dw flags set at command line. Please use only one.")

if args.dl and not args.dr and not args.dw:
pplogger.error("ERROR: -dl flag set without either -dr or -dw.")
sys.exit("ERROR: -dl flag set without either -dr or -dw.")

if args.dr and not os.path.exists(args.dr):
pplogger.error(
"ERROR: temporary ephemeris database not found at "
+ args.dr
+ ". Rerun with command line flag -dw to create one."
)
sys.exit(
"ERROR: temporary ephemeris database not found at "
+ args.dr
+ ". Rerun with command line flag -dw to create one."
)

if args.dw:
warn_or_remove_file(cmd_args_dict["makeTemporaryEphemerisDatabase"], args.f, pplogger)

# Log all the command line settings to INFO.
for flag, value in cmd_args_dict.items():
pplogger.info(f"Using commandline setting {flag} = {value}")
Expand Down
14 changes: 0 additions & 14 deletions src/sorcha/modules/PPConfigParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,20 +735,6 @@ def PPPrintConfigsToLog(configs, cmd_args):
pplogger.info("The output ephemerides file is located " + cmd_args.output_ephemeris_file)
pplogger.info("The survey selected is: " + cmd_args.surveyname)

if cmd_args.makeTemporaryEphemerisDatabase:
pplogger.info(
"Creating of temporary ephemeris database at: " + str(cmd_args.makeTemporaryEphemerisDatabase)
)

if cmd_args.readTemporaryEphemerisDatabase:
pplogger.info(
"Reading from existing temporary ephemeris database at "
+ str(cmd_args.readTemporaryEphemerisDatabase)
)

if cmd_args.deleteTemporaryEphemerisDatabase:
pplogger.info("Temporary ephemeris database will be deleted upon code conclusion.")

if configs["comet_activity"] == "comet":
pplogger.info("Cometary activity set to: " + str(configs["comet_activity"]))
elif configs["comet_activity"] == "none":
Expand Down
47 changes: 0 additions & 47 deletions src/sorcha/modules/PPMakeTemporaryEphemerisDatabase.py

This file was deleted.

1 change: 0 additions & 1 deletion src/sorcha/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from . import PPFootprintFilter
from . import PPJoinEphemeridesAndParameters
from . import PPJoinEphemeridesAndOrbits
from . import PPMakeTemporaryEphemerisDatabase
from . import PPReadPointingDatabase
from . import PPMatchPointingToObservations
from . import PPOutput
Expand Down
3 changes: 3 additions & 0 deletions src/sorcha/readers/DatabaseReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

from sorcha.readers.ObjectDataReader import ObjectDataReader

# NOTE: this was written for a now-defunct functionality, but has been left
# in the code as a database reader class may be useful later.


class DatabaseReader(ObjectDataReader):
"""A class to read in object data stored in a sqlite database."""
Expand Down
50 changes: 8 additions & 42 deletions src/sorcha/sorcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from sorcha.modules.PPLinkingFilter import PPLinkingFilter
from sorcha.modules.PPTrailingLoss import PPTrailingLoss
from sorcha.modules.PPBrightLimit import PPBrightLimit
from sorcha.modules.PPMakeTemporaryEphemerisDatabase import PPMakeTemporaryEphemerisDatabase
from sorcha.modules.PPCalculateApparentMagnitude import PPCalculateApparentMagnitude
from sorcha.modules.PPApplyFOVFilter import PPApplyFOVFilter
from sorcha.modules.PPSNRLimit import PPSNRLimit
Expand Down Expand Up @@ -111,12 +110,6 @@ def runLSSTSimulation(args, configs, pplogger=None):

# End of config parsing

if args.makeTemporaryEphemerisDatabase:
verboselog("Creating temporary ephemeris database...")
args.readTemporaryEphemerisDatabase = PPMakeTemporaryEphemerisDatabase(
args.oifoutput, args.makeTemporaryEphemerisDatabase, configs["eph_format"]
)

verboselog("Reading pointing database...")

filterpointing = PPReadPointingDatabase(
Expand All @@ -136,17 +129,14 @@ def runLSSTSimulation(args, configs, pplogger=None):
ephem_primary = True
reader = CombinedDataReader(ephem_primary=ephem_primary, verbose=True)

if args.makeTemporaryEphemerisDatabase or args.readTemporaryEphemerisDatabase:
reader.add_ephem_reader(DatabaseReader(args.readTemporaryEphemerisDatabase))
else:
# TODO: Once more ephemerides_types are added this should be wrapped in a EphemerisDataReader
# That does the selection and checks. We are holding off adding this level of indirection until there
# is a second ephemerides_type.
if ephem_type.casefold() not in ["ar", "external"]: # pragma: no cover
pplogger.error(f"PPReadAllInput: Unsupported value for ephemerides_type {ephem_type}")
sys.exit(f"PPReadAllInput: Unsupported value for ephemerides_type {ephem_type}")
if ephem_type.casefold() == "external":
reader.add_ephem_reader(OIFDataReader(args.oifoutput, configs["eph_format"]))
# TODO: Once more ephemerides_types are added this should be wrapped in a EphemerisDataReader
# That does the selection and checks. We are holding off adding this level of indirection until there
# is a second ephemerides_type.
if ephem_type.casefold() not in ["ar", "external"]: # pragma: no cover
pplogger.error(f"PPReadAllInput: Unsupported value for ephemerides_type {ephem_type}")
sys.exit(f"PPReadAllInput: Unsupported value for ephemerides_type {ephem_type}")
if ephem_type.casefold() == "external":
reader.add_ephem_reader(OIFDataReader(args.oifoutput, configs["eph_format"]))

reader.add_aux_data_reader(OrbitAuxReader(args.orbinfile, configs["aux_format"]))
reader.add_aux_data_reader(CSVDataReader(args.paramsinput, configs["aux_format"]))
Expand Down Expand Up @@ -305,10 +295,6 @@ def runLSSTSimulation(args, configs, pplogger=None):
startChunk = startChunk + configs["size_serial_chunk"]
# end for

if args.deleteTemporaryEphemerisDatabase:
verboselog("Deleting the temporary ephemeris database...")
os.remove(args.readTemporaryEphemerisDatabase)

pplogger.info("Sorcha process is completed.")


Expand Down Expand Up @@ -423,26 +409,6 @@ def main():
type=str,
dest="cp",
)
optional.add_argument(
"-dl",
help="Delete the temporary ephemeris database after code has completed.",
action="store_true",
default=False,
)
optional.add_argument(
"-dr",
help="Location of existing/previous temporary ephemeris database to read from if wanted.",
dest="dr",
type=str,
)
optional.add_argument(
"-dw",
help="Make temporary ephemeris database. If no filepath/name supplied, default name and ephemeris input location used.",
dest="dw",
nargs="?",
const="default",
type=str,
)
optional.add_argument(
"-f",
"--force",
Expand Down
11 changes: 0 additions & 11 deletions src/sorcha/utilities/sorchaArguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ class sorchaArguments:
verbose: bool = False
"""logger verbosity"""

makeTemporaryEphemerisDatabase: bool = False
"""whether or not to make ephemeris database"""
readTemporaryEphemerisDatabase = False
"""path to ephemeris database or `False`"""
deleteTemporaryEphemerisDatabase: bool = False
"""whether or not to delete ephemeris database"""

surveyname: str = ""
"""name of the survey (`lsst` is only one implemented currently)"""

Expand Down Expand Up @@ -64,10 +57,6 @@ def read_from_dict(self, args):
self.ar_data_file_path = args.get("ar_data_path")
self.verbose = args["verbose"]

self.makeTemporaryEphemerisDatabase = args["makeTemporaryEphemerisDatabase"]
self.readTemporaryEphemerisDatabase = args["readTemporaryEphemerisDatabase"]
self.deleteTemporaryEphemerisDatabase = args["deleteTemporaryEphemerisDatabase"]

self.surveyname = args["surveyname"]

if "complex_physical_parameters" in args.keys():
Expand Down
2 changes: 0 additions & 2 deletions tests/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ Used by:
Example OIF output, whitespace-separated.
Used by:
- test_createResultsSQLDatabase.py
- test_createTemporaryDatabases.py
- test_makeConfigOIF.py
- test_PPJoinEphemeridesAndOrbits.py
- test_PPMakeTemporaryEphemerisDatabase.py
- test_PPReadEphemerides.py
- test_PPReadOif.py

Expand Down
Binary file added tests/data/testdb_PPIntermDB.db
Binary file not shown.
Loading