Skip to content

Commit

Permalink
Merge pull request #896 from dirac-institute/rename_survey
Browse files Browse the repository at this point in the history
switch survey name to rubin_sim
  • Loading branch information
mschwamb authored Apr 11, 2024
2 parents f630f09 + 3dd8872 commit 65e7845
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 31 deletions.
2 changes: 1 addition & 1 deletion benchmarks/bench_cProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"outpath": os.path.join(path_to_sorcha, "tests/out"),
"outfilestem": os.path.join(path_to_sorcha, f"out_{args.object_type}"),
"verbose": False,
"surveyname": "lsst",
"surveyname": "rubin_sim",
}

args_obj = sorchaArguments(cmd_args_dict)
Expand Down
2 changes: 1 addition & 1 deletion docs/example_files/help_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ Optional arguments:
-cp CP, --complex_physical_parameters CP
Complex physical parameters file name (default: None)
-f, --force Force deletion/overwrite of existing output file(s). Default False. (default: False)
-s S, --survey S Survey to simulate (default: LSST)
-s S, --survey S Survey to simulate (default: rubin_sim)
-t T, --stem T Output file name stem. (default: SSPPOutput)
-v, --verbose Verbosity. Default currently true; include to turn off verbosity. (default: True)
4 changes: 2 additions & 2 deletions src/sorcha/modules/PPConfigParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def PPCheckFiltersForSurvey(survey_name, observing_filters):

pplogger = logging.getLogger(__name__)

if survey_name in ["LSST", "lsst"]:
if survey_name in ["rubin_sim", "RUBIN_SIM"]:
lsst_filters = ["u", "g", "r", "i", "z", "y"]
filters_ok = all(elem in lsst_filters for elem in observing_filters)

Expand Down Expand Up @@ -476,7 +476,7 @@ def PPConfigFileParser(configfile, survey_name):
)
if external_file:
PPFindFileOrExit(config_dict["footprint_path"], "footprint_path")
elif survey_name.lower() != "lsst":
elif survey_name.lower() not in ["lsst", "rubin_sim"]:
log_error_and_exit(
"a default detector footprint is currently only provided for LSST; please provide your own footprint file."
)
Expand Down
4 changes: 2 additions & 2 deletions src/sorcha/modules/PPLinkingFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def PPLinkingFilter(
tracklet_interval,
minimum_separation,
maximum_time,
survey_name="lsst",
survey_name="rubin_sim",
):
"""
A function which mimics the effects of the SSP linking process by looking
Expand Down Expand Up @@ -38,7 +38,7 @@ def PPLinkingFilter(
rng (numpy Generator object): numpy random number generator object.
survey_name (str): a string with the survey name. used for time-zone purposes.
Currently only accepts "lsst", "LSST".
Currently only accepts "rubin_sim", "RUBIN_SIM", "lsst", "LSST".
Returns:
-----------
Expand Down
2 changes: 1 addition & 1 deletion src/sorcha/modules/PPReadPointingDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def PPReadPointingDatabase(bsdbname, observing_filters, dbquery, surveyname):
# once we have the actual pointings this check could be changed to, eg,
# lsst_sim for the RubinSim pointings, and 'lsst' would produce different
# behaviour.
if surveyname in ["lsst", "LSST"]:
if surveyname in ["rubin_sim", "RUBIN_SIM"]:
dfo["observationMidpointMJD_TAI"] = dfo["observationStartMJD_TAI"] + (
(dfo["visitTime"] / 2.0) / 86400.0
)
Expand Down
27 changes: 22 additions & 5 deletions src/sorcha/sorcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def main():
-cp CP, --complex_physical_parameters CP
Complex physical parameters file name (default: None)
-f, --force Force deletion/overwrite of existing output file(s). Default False. (default: False)
-s S, --survey S Survey to simulate (default: LSST)
-s S, --survey S Survey to simulate (default: rubin_sim)
-t T, --stem T Output file name stem. (default: SSPPOutput)
-v, --verbose Verbosity. Default currently true; include to turn off verbosity. (default: True)
"""
Expand Down Expand Up @@ -441,7 +441,9 @@ def main():
action="store_true",
default=False,
)
optional.add_argument("-s", "--survey", help="Survey to simulate", type=str, dest="s", default="LSST")
optional.add_argument(
"-s", "--survey", help="Survey to simulate", type=str, dest="s", default="rubin_sim"
)
optional.add_argument(
"-t", "--stem", help="Output file name stem.", type=str, dest="t", default="SSPPOutput"
)
Expand Down Expand Up @@ -484,7 +486,7 @@ def main():
cmd_args["seed"] = int(os.environ["SORCHA_SEED"])
pplogger.info(f"Random seed overridden via environmental variable, SORCHA_SEED={cmd_args['seed']}")

if cmd_args["surveyname"] in ["LSST", "lsst"]:
if cmd_args["surveyname"] in ["rubin_sim", "RUBIN_SIM"]:
try:
args = sorchaArguments(cmd_args)
except Exception as err:
Expand All @@ -496,12 +498,27 @@ def main():
pplogger.error(err)
sys.exit(err)
runLSSTSimulation(args, configs)
elif cmd_args["surveyname"] in ["LSST", "lsst"]:
pplogger.error(
"ERROR: The LSST has not started yet Current allowed surveys are: {}".format(
["rubin_sim", "RUBIN_SIM"]
)
)
sys.exit(
"ERROR: The LSST has not started. Current allowed surveys are: {}".format(
["rubin_sim", "RUBIN_SIM"]
)
)
else:
pplogger.error(
"ERROR: Survey name not recognised. Current allowed surveys are: {}".format(["LSST", "lsst"])
"ERROR: Survey name not recognised. Current allowed surveys are: {}".format(
["rubin_sim", "RUBIN_SIM"]
)
)
sys.exit(
"ERROR: Survey name not recognised. Current allowed surveys are: {}".format(["LSST", "lsst"])
"ERROR: Survey name not recognised. Current allowed surveys are: {}".format(
["rubin_sim", "RUBIN_SIM"]
)
)


Expand Down
4 changes: 2 additions & 2 deletions src/sorcha/utilities/diffTestUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def compare_result_files(test_output, golden_output):
"oifoutput": get_demo_filepath("example_oif_output.txt"),
"configfile": get_demo_filepath("PPConfig_test.ini"),
"pointing_database": get_demo_filepath("baseline_v2.0_1yr.db"),
"surveyname": "LSST",
"surveyname": "rubin_sim",
"outfilestem": f"out_end2end",
"verbose": False,
}
Expand All @@ -62,7 +62,7 @@ def compare_result_files(test_output, golden_output):
"configfile": get_demo_filepath("config_for_ephemeris_unit_test.ini"),
"pointing_database": get_demo_filepath("baseline_v2.0_1yr.db"),
"output_ephemeris_file": "sorcha_ephemeris.csv",
"surveyname": "LSST",
"surveyname": "rubin_sim",
"outfilestem": f"out_end2end_with_ephemeris_generation",
"verbose": False,
}
Expand Down
2 changes: 1 addition & 1 deletion src/sorcha/utilities/sorchaArguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class sorchaArguments:
"""logger verbosity"""

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

complex_parameters: str = ""
"""optional, extra complex physical parameter input files"""
Expand Down
2 changes: 1 addition & 1 deletion tests/data/test_PPPrintConfigsToLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sorcha.modules.PPConfigParser INFO The config file used is located at test_P
sorcha.modules.PPConfigParser INFO The physical parameters file used is located at testcolour.txt
sorcha.modules.PPConfigParser INFO The orbits file used is located at testorb.des
sorcha.modules.PPConfigParser INFO The ephemerides file used is located at oiftestoutput.txt
sorcha.modules.PPConfigParser INFO The survey selected is: lsst
sorcha.modules.PPConfigParser INFO The survey selected is: rubin_sim
sorcha.modules.PPConfigParser INFO No cometary activity selected.
sorcha.modules.PPConfigParser INFO Format of ephemerides file is: csv
sorcha.modules.PPConfigParser INFO Format of auxiliary files is: whitespace
Expand Down
4 changes: 2 additions & 2 deletions tests/ephemeris/test_ephemeris_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_ephemeris_end2end(single_synthetic_pointing, tmp_path):
"configfile": get_test_filepath("test_ephem_config.ini"),
"pointing_database": get_demo_filepath("baseline_v2.0_1yr.db"),
"outpath": tmp_path,
"surveyname": "LSST",
"surveyname": "rubin_sim",
"outfilestem": f"out_400k",
"verbose": False,
}
Expand All @@ -64,7 +64,7 @@ def test_ephemeris_end2end(single_synthetic_pointing, tmp_path):
configs["seed"] = 24601

filterpointing = PPReadPointingDatabase(
args.pointing_database, configs["observing_filters"], configs["pointing_sql_query"], "lsst"
args.pointing_database, configs["observing_filters"], configs["pointing_sql_query"], "rubin_sim"
)

filterpointing = precompute_pointing_information(filterpointing, args, configs)
Expand Down
6 changes: 3 additions & 3 deletions tests/sorcha/test_PPCommandLineParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, cp, t="testout", o="./", f=False):
self.pd = get_test_filepath("baseline_10klines_2.0.db")
self.o = o
self.cp = cp
self.s = "lsst"
self.s = "rubin_sim"
self.t = t
self.v = True
self.f = f
Expand All @@ -34,7 +34,7 @@ def test_PPCommandLineParser():
"configfile": get_test_filepath("test_PPConfig.ini"),
"pointing_database": get_test_filepath("baseline_10klines_2.0.db"),
"outpath": "./",
"surveyname": "lsst",
"surveyname": "rubin_sim",
"outfilestem": "testout",
"verbose": True,
"ar_data_path": None,
Expand All @@ -50,7 +50,7 @@ def test_PPCommandLineParser():
"pointing_database": get_test_filepath("baseline_10klines_2.0.db"),
"outpath": "./",
"complex_physical_parameters": get_test_filepath("testcomet.txt"),
"surveyname": "lsst",
"surveyname": "rubin_sim",
"outfilestem": "testout",
"verbose": True,
"ar_data_path": None,
Expand Down
8 changes: 4 additions & 4 deletions tests/sorcha/test_PPConfigParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def setup_and_teardown_for_PPConfigFileParser(tmp_path):
def test_PPConfigFileParser(setup_and_teardown_for_PPConfigFileParser):
from sorcha.modules.PPConfigParser import PPConfigFileParser

configs = PPConfigFileParser(get_test_filepath("test_PPConfig.ini"), "lsst")
configs = PPConfigFileParser(get_test_filepath("test_PPConfig.ini"), "rubin_sim")

test_configs = {
"eph_format": "csv",
Expand Down Expand Up @@ -219,10 +219,10 @@ def test_PPFindDirectoryOrExit():
def test_PPCheckFiltersForSurvey():
from sorcha.modules.PPConfigParser import PPCheckFiltersForSurvey

PPCheckFiltersForSurvey("lsst", ["u", "g", "r", "i", "z", "y"])
PPCheckFiltersForSurvey("rubin_sim", ["u", "g", "r", "i", "z", "y"])

with pytest.raises(SystemExit) as e:
PPCheckFiltersForSurvey("lsst", ["j"])
PPCheckFiltersForSurvey("rubin_sim", ["j"])

assert e.type == SystemExit

Expand All @@ -242,7 +242,7 @@ def test_PPPrintConfigsToLog(tmp_path):
"configfile": "test_PPConfig.ini",
"pointing_database": "./baseline_10klines_2.0.db",
"outpath": "./",
"surveyname": "lsst",
"surveyname": "rubin_sim",
"outfilestem": "testout",
"verbose": True,
"seed": 24601,
Expand Down
2 changes: 1 addition & 1 deletion tests/sorcha/test_PPMatchPointingToObservations.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_PPMatchPointingToObservations():
dbq = "SELECT observationId, observationStartMJD as observationStartMJD_TAI, visitTime, visitExposureTime, filter, seeingFwhmGeom as seeingFwhmGeom_arcsec, seeingFwhmEff as seeingFwhmEff_arcsec, fiveSigmaDepth as fieldFiveSigmaDepth_mag , fieldRA as fieldRA_deg, fieldDec as fieldDec_deg, rotSkyPos as fieldRotSkyPos_deg FROM observations order by observationId"

pointing_db = PPReadPointingDatabase(
get_test_filepath("baseline_10klines_2.0.db"), ["g", "r", "i"], dbq, "lsst"
get_test_filepath("baseline_10klines_2.0.db"), ["g", "r", "i"], dbq, "rubin_sim"
)

# simulate adding extra columns to the pointing db for the precomputed values
Expand Down
4 changes: 2 additions & 2 deletions tests/sorcha/test_PPReadPointingDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_PPReadPointingDatabase():
filter_list = ["u", "g", "r", "i", "z", "y"]

pointing_db = PPReadPointingDatabase(
get_test_filepath("baseline_10klines_2.0.db"), filter_list, sql_query, "lsst"
get_test_filepath("baseline_10klines_2.0.db"), filter_list, sql_query, "rubin_sim"
)

expected_first_line = np.array(
Expand Down Expand Up @@ -59,7 +59,7 @@ def test_PPReadPointingDatabase():

with pytest.raises(SystemExit) as e:
pointing_db = PPReadPointingDatabase(
get_test_filepath("baseline_10klines_2.0.db"), filter_list, bad_query, "lsst"
get_test_filepath("baseline_10klines_2.0.db"), filter_list, bad_query, "rubin_sim"
)

assert e.type == SystemExit
Expand Down
2 changes: 1 addition & 1 deletion tests/sorcha/test_combined_data_reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_PPReadAllInput():
}

filterpointing = PPReadPointingDatabase(
cmd_args["pointing_database"], configs["observing_filters"], configs["pointing_sql_query"], "lsst"
cmd_args["pointing_database"], configs["observing_filters"], configs["pointing_sql_query"], "rubin_sim"
)

reader = CombinedDataReader(verbose=True)
Expand Down
4 changes: 2 additions & 2 deletions tests/sorcha/test_sorchaArguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"oifoutput": get_demo_filepath("example_oif_output.txt"),
"configfile": get_demo_filepath("PPConfig_test.ini"),
"outpath": "./tests/out",
"surveyname": "LSST",
"surveyname": "RUBIN_SIM",
"outfilestem": f"out_end2end",
"verbose": False,
"pointing_database": get_demo_filepath("baseline_v2.0_1yr.db"),
Expand All @@ -20,7 +20,7 @@ def test_sorchaArguments():
"""make sure that valid args can be parsed"""
args = sorchaArguments(cmd_args_dict)

assert args.surveyname == "LSST"
assert args.surveyname == "RUBIN_SIM"


def test_validate_arguments():
Expand Down

0 comments on commit 65e7845

Please sign in to comment.