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

Making n sub intervals a config class parameter #1090

Merged
merged 3 commits into from
Jan 11, 2025
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
4 changes: 3 additions & 1 deletion src/sorcha/ephemeris/simulation_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def create_ephemeris(orbits_df, pointings_df, args, sconfigs):
nside : integer
The nside value used for the HEALPIx calculations. Must be a
power of 2 (1, 2, 4, ...) nside=64 is current default.
n_sub_intervals: int
Number of sub-intervals for the Lagrange interpolation (default: 101)

Returns
-------
Expand Down Expand Up @@ -109,7 +111,7 @@ def create_ephemeris(orbits_df, pointings_df, args, sconfigs):
picket_interval = sconfigs.simulation.ar_picket
obsCode = sconfigs.simulation.ar_obs_code
nside = 2**sconfigs.simulation.ar_healpix_order
n_sub_intervals = 101 # configs["n_sub_intervals"]
n_sub_intervals = sconfigs.simulation.ar_n_sub_intervals

ephemeris_csv_filename = None
if args.output_ephemeris_file and args.outpath:
Expand Down
5 changes: 5 additions & 0 deletions src/sorcha/utilities/sorchaConfigs.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class simulationConfigs:
ar_healpix_order: int = None
"""the order of healpix which we will use for the healpy portions of the code."""

ar_n_sub_intervals: int = 101
"""Number of sub-intervals for the Lagrange ephemerides interpolation (default: 101)"""

_ephemerides_type: str = None
"""Simulation used for ephemeris input."""

Expand Down Expand Up @@ -111,6 +114,7 @@ def _validate_simulation_configs(self):
self.ar_fov_buffer = cast_as_float(self.ar_fov_buffer, "ar_fov_buffer")
self.ar_picket = cast_as_int(self.ar_picket, "ar_picket")
self.ar_healpix_order = cast_as_int(self.ar_healpix_order, "ar_healpix_order")
self.ar_n_sub_intervals = cast_as_int(self.ar_n_sub_intervals, "ar_n_sub_intervals")
elif self._ephemerides_type == "external":
# makes sure when these are not needed that they are not populated
check_key_doesnt_exist(self.ar_ang_fov, "ar_ang_fov", "but ephemerides type is external")
Expand Down Expand Up @@ -1512,6 +1516,7 @@ def PrintConfigsToLog(sconfigs, cmd_args):
pplogger.info("...the picket interval is: " + str(sconfigs.simulation.ar_picket))
pplogger.info("...the observatory code is: " + str(sconfigs.simulation.ar_obs_code))
pplogger.info("...the healpix order is: " + str(sconfigs.simulation.ar_healpix_order))
pplogger.info("...the number of sub-intervals is: " + str(sconfigs.simulation.ar_n_sub_intervals))
else:
pplogger.info("ASSIST+REBOUND Simulation is turned OFF.")

Expand Down
1 change: 1 addition & 0 deletions tests/data/test_PrintConfigsToLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ sorcha.utilities.sorchaConfigs INFO ...the buffer around the FOV is: 0.2
sorcha.utilities.sorchaConfigs INFO ...the picket interval is: 1
sorcha.utilities.sorchaConfigs INFO ...the observatory code is: X05
sorcha.utilities.sorchaConfigs INFO ...the healpix order is: 6
sorcha.utilities.sorchaConfigs INFO ...the number of sub-intervals is: 101
sorcha.utilities.sorchaConfigs INFO No lightcurve model is being applied.
sorcha.utilities.sorchaConfigs INFO Output files will be saved in path: ./ with filestem testout
sorcha.utilities.sorchaConfigs INFO Output files will be saved as format: csv
Expand Down
3 changes: 2 additions & 1 deletion tests/sorcha/test_sorchaConfigs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"ar_picket": 1,
"ar_obs_code": "X05",
"ar_healpix_order": 6,
"ar_n_sub_intervals": 101
}

correct_filters_read = {"observing_filters": "r,g,i,z,u,y", "survey_name": "rubin_sim"}
Expand Down Expand Up @@ -261,7 +262,7 @@ def test_simulationConfigs_float(key_name):
)


@pytest.mark.parametrize("key_name", ["ar_picket", "ar_healpix_order"])
@pytest.mark.parametrize("key_name", ["ar_picket", "ar_healpix_order","ar_n_sub_intervals"])
def test_simulationConfigs_int(key_name):
"""
Tests that wrong inputs for simulationConfigs int attributes is caught correctly
Expand Down
Loading