From f75e72dcafe2de565055aff12db6423ce1db3a22 Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Thu, 28 Nov 2024 12:57:33 +0000 Subject: [PATCH 01/15] Created new config dataclass auxililaryConfigs This dataclass takes in filename and urls from the AUXILILARY section of the config file. If AUXILIARY section does not exist, default filenames and URLs are instead used. --- src/sorcha/utilities/sorchaConfigs.py | 197 ++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) diff --git a/src/sorcha/utilities/sorchaConfigs.py b/src/sorcha/utilities/sorchaConfigs.py index 40ee694f..15e2d76c 100644 --- a/src/sorcha/utilities/sorchaConfigs.py +++ b/src/sorcha/utilities/sorchaConfigs.py @@ -780,6 +780,199 @@ def _validate_expert_configs(self): self.vignetting_on = cast_as_bool_or_set_default(self.vignetting_on, "vignetting_on", True) +@dataclass +class auxililaryConfigs: + DE440S: str = None + """filename of DE440S""" + DE440S_URL: str = None + """url for De4440S""" + + EARTH_PREDICT: str = None + """filename of EARTH_PREDICT""" + EARTH_PREDICT_URL: str = None + """url for EARTH_PREDICT""" + + EARTH_HISTORICAL: str = None + """filename of EARTH_HISTOICAL""" + EARTH_HISTORICAL_URL: str = None + """url for EARTH_HISTORICAL""" + + EARTH_HIGH_PRECISION: str = None + """filename of EARTH_HIGH_PRECISION""" + EARTH_HIGH_PRECISION_URL: str = None + """url of EARTH_HIGH_PRECISION""" + + JPL_PLANETS: str = None + """filename of JPL_PLANETS""" + JPL_PLANETS_URL: str = None + """url of JPL_PLANETS""" + + JPL_SMALL_BODIES: str = None + """filename of JPL_SMALL_BODIES""" + JPL_SMALL_BODIES_URL: str = None + """url of JPL_SMALL_BODIES""" + + LEAP_SECONDS: str = None + """filename of LEAP_SECONDS""" + LEAP_SECONDS_URL: str = None + """url of LEAP_SECONDS""" + + META_KERNEL: str = None + """filename of META_KERNAL""" + + OBSERVATORY_CODES: str = None + """filename of OBSERVATORY_CODES""" + + OBSERVATORY_CODES_COMPRESSED: str = None + """filename of OBSERVATORY_CODES_COMPRESSED""" + OBSERVATORY_CODES_COMPRESSED_URL: str = None + """url of OBSERVATORY_CODES_COMPRESSED""" + + ORIENTATION_CONSTANTS: str = None + """filename of OBSERVATORY_CONSTANTS""" + ORIENTATION_CONSTANTS_URL: str = None + """url of OBSERVATORY_CONSTANTS""" + + DATA_FILE_LIST: list = None + """Convenience list of all the file names""" + + URLS: dict = None + """Dictionary of filename: url""" + + def __post_init__(self): + """Automagically validates the auxiliary configs after initialisation.""" + self._create_URL() + # self._validate_auxiliary_configs() + + def _create_URL(self): + """ + This method takes the filename and url from either the config file or the list of default values. + """ + self._set_default() + for data_filename, default_filename in self.DATA_FILENAME_defaults.items(): + # default filename: + if getattr(self, data_filename) is None: + setattr(self, data_filename, default_filename) + if data_filename != "META_KERNEL" and data_filename != "OBSERVATORY_CODES": + # default URL + if getattr(self, data_filename + "_URL") is None: + if data_filename != "OBSERVATORY_CODES_COMPRESSED": + setattr( + self, + (data_filename + "_URL"), + self.URLS_defaults[data_filename] + default_filename, + ) + else: + setattr(self, data_filename + "_URL", self.URLS_defaults[data_filename]) + + # new URL + elif getattr(self, data_filename + "_URL") is not None: + setattr( + self, + data_filename + "_URL", + getattr(self, data_filename + "_URL") + getattr(self, data_filename), + ) + # new filename: + elif getattr(self, data_filename) is not None and ( + data_filename != "META_KERNEL" and data_filename != "OBSERVATORY_CODES" + ): + # default URL + if getattr(self, data_filename + "_URL") is None: + if data_filename != "OBSERVATORY_CODES_COMPRESSED": + setattr( + self, + (data_filename + "_URL"), + self.URLS_defaults[data_filename] + getattr(self, data_filename), + ) + else: + setattr(self, data_filename + "_URL", self.URLS_defaults[data_filename]) + + # new URL + elif getattr(self, data_filename + "_URL") is not None: + setattr( + self, + (data_filename + "_URL"), + getattr(self, data_filename + "_URL") + getattr(self, data_filename), + ) + + def _set_default(self): + """ + creates an attribute list of the default values that this version of sorcha uses. + + Parameters + ----------- + None. + + Returns + ---------- + None + """ + self.DATA_FILENAME_defaults = { + "DE440S": "de440s.bsp", + "EARTH_PREDICT": "earth_200101_990827_predict.bpc", + "EARTH_HISTORICAL": "earth_620120_240827.bpc", + "EARTH_HIGH_PRECISION": "earth_latest_high_prec.bpc", + "JPL_PLANETS": "linux_p1550p2650.440", + "JPL_SMALL_BODIES": "sb441-n16.bsp", + "LEAP_SECONDS": "naif0012.tls", + "META_KERNEL": "meta_kernel.txt", + "OBSERVATORY_CODES": "ObsCodes.json", + "OBSERVATORY_CODES_COMPRESSED": "ObsCodes.json.gz", + "ORIENTATION_CONSTANTS": "pck00010.pck", + } + + self.URLS_defaults = { + "DE440S": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/", + "EARTH_PREDICT": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/", + "EARTH_HISTORICAL": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/", + "EARTH_HIGH_PRECISION": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/", + "JPL_PLANETS": "https://ssd.jpl.nasa.gov/ftp/eph/planets/Linux/de440/", + "JPL_SMALL_BODIES": "https://ssd.jpl.nasa.gov/ftp/eph/small_bodies/asteroids_de441/", + "LEAP_SECONDS": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/", + "OBSERVATORY_CODES_COMPRESSED": "https://minorplanetcenter.net/Extended_Files/obscodes_extended.json.gz", + "ORIENTATION_CONSTANTS": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/", + } + + def _validate_auxiliary_configs(self): + """ + Validates the auxililary config attributes after initialisation. + + Parameters + ----------- + None. + + Returns + ---------- + None + """ + + self.URLS = { + self.DE440S: self.DE440S_URL, + self.EARTH_PREDICT: self.EARTH_PREDICT_URL, + self.EARTH_HISTORICAL: self.EARTH_HISTORICAL_URL, + self.EARTH_HIGH_PRECISION: self.EARTH_HIGH_PRECISION_URL, + self.JPL_PLANETS: self.JPL_PLANETS_URL, + self.JPL_SMALL_BODIES: self.JPL_SMALL_BODIES_URL, + self.LEAP_SECONDS: self.LEAP_SECONDS_URL, + self.OBSERVATORY_CODES_COMPRESSED: self.OBSERVATORY_CODES_COMPRESSED_URL, + self.ORIENTATION_CONSTANTS: self.ORIENTATION_CONSTANTS_URL, + } + + self.DATA_FILE_LIST = [ + self.DE440S, + self.EARTH_PREDICT, + self.EARTH_HISTORICAL, + self.EARTH_HIGH_PRECISION, + self.JPL_PLANETS, + self.JPL_SMALL_BODIES, + self.LEAP_SECONDS, + self.META_KERNEL, + self.OBSERVATORY_CODES, + self.OBSERVATORY_CODES_COMPRESSED, + self.ORIENTATION_CONSTANTS, + ] + + @dataclass class sorchaConfigs: """Dataclass which stores configuration file keywords in dataclasses.""" @@ -820,6 +1013,9 @@ class sorchaConfigs: expert: expertConfigs = None """expertConfigs dataclass which stores the keywords from the EXPERT section of the config file.""" + auxililary: auxililaryConfigs = None + """auxililaryConfigs dataclass which stores the keywords from the AUXILILARY section of the config file.""" + pplogger: None = None """The Python logger instance""" @@ -873,6 +1069,7 @@ def _read_configs_from_object(self, config_object): "LIGHTCURVE": lightcurveConfigs, "ACTIVITY": activityConfigs, "EXPERT": expertConfigs, + "AUXILILARY": auxililaryConfigs, } # when adding new sections in config file this general function needs the name of the section in uppercase # to be the same as the attributes defined above in lowercase e.g. section INPUT has attribute input From 22e1663f64c728f8c91b2c3aa4ae3eb95022926a Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Thu, 28 Nov 2024 16:23:51 +0000 Subject: [PATCH 02/15] cleaned up the if statements in auxililaryConfigs --- src/sorcha/utilities/sorchaConfigs.py | 66 +++++++++++---------------- 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/src/sorcha/utilities/sorchaConfigs.py b/src/sorcha/utilities/sorchaConfigs.py index 15e2d76c..ec856ee3 100644 --- a/src/sorcha/utilities/sorchaConfigs.py +++ b/src/sorcha/utilities/sorchaConfigs.py @@ -850,50 +850,36 @@ def _create_URL(self): """ self._set_default() for data_filename, default_filename in self.DATA_FILENAME_defaults.items(): - # default filename: - if getattr(self, data_filename) is None: + + file_attr = getattr(self, data_filename) + # sets default filename + if file_attr is None: setattr(self, data_filename, default_filename) - if data_filename != "META_KERNEL" and data_filename != "OBSERVATORY_CODES": - # default URL - if getattr(self, data_filename + "_URL") is None: - if data_filename != "OBSERVATORY_CODES_COMPRESSED": - setattr( - self, - (data_filename + "_URL"), - self.URLS_defaults[data_filename] + default_filename, - ) - else: - setattr(self, data_filename + "_URL", self.URLS_defaults[data_filename]) - - # new URL - elif getattr(self, data_filename + "_URL") is not None: - setattr( - self, - data_filename + "_URL", - getattr(self, data_filename + "_URL") + getattr(self, data_filename), - ) - # new filename: - elif getattr(self, data_filename) is not None and ( - data_filename != "META_KERNEL" and data_filename != "OBSERVATORY_CODES" - ): - # default URL - if getattr(self, data_filename + "_URL") is None: - if data_filename != "OBSERVATORY_CODES_COMPRESSED": - setattr( - self, - (data_filename + "_URL"), - self.URLS_defaults[data_filename] + getattr(self, data_filename), - ) - else: - setattr(self, data_filename + "_URL", self.URLS_defaults[data_filename]) - - # new URL - elif getattr(self, data_filename + "_URL") is not None: + file_attr = getattr(self, data_filename) + + # skips these two as they have no URL attribute + if data_filename == "META_KERNEL" or data_filename == "OBSERVATORY_CODES": + continue + + url_attr = data_filename + "_URL" + # for default URL + if getattr(self, url_attr) is None: + # OBSERVATORY_CODES_COMPRESSED does not need the filename appended I think + if data_filename != "OBSERVATORY_CODES_COMPRESSED": setattr( self, - (data_filename + "_URL"), - getattr(self, data_filename + "_URL") + getattr(self, data_filename), + url_attr, + self.URLS_defaults[data_filename] + file_attr, ) + else: + setattr(self, url_attr, self.URLS_defaults[data_filename]) + # for new URL + else: + setattr( + self, + url_attr, + getattr(self, url_attr) + file_attr, + ) def _set_default(self): """ From 6768188b2a9ee6baf4bea4bead73784eefe66aaa Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Tue, 3 Dec 2024 10:45:14 +0000 Subject: [PATCH 03/15] changing the auxililary dataclass and making first unit test --- src/sorcha/utilities/sorchaConfigs.py | 278 ++++++++++++-------------- tests/sorcha/test_sorchaConfigs.py | 31 ++- 2 files changed, 153 insertions(+), 156 deletions(-) diff --git a/src/sorcha/utilities/sorchaConfigs.py b/src/sorcha/utilities/sorchaConfigs.py index ec856ee3..401149c9 100644 --- a/src/sorcha/utilities/sorchaConfigs.py +++ b/src/sorcha/utilities/sorchaConfigs.py @@ -782,146 +782,93 @@ def _validate_expert_configs(self): @dataclass class auxililaryConfigs: - DE440S: str = None - """filename of DE440S""" - DE440S_URL: str = None - """url for De4440S""" - - EARTH_PREDICT: str = None - """filename of EARTH_PREDICT""" - EARTH_PREDICT_URL: str = None - """url for EARTH_PREDICT""" - - EARTH_HISTORICAL: str = None - """filename of EARTH_HISTOICAL""" - EARTH_HISTORICAL_URL: str = None - """url for EARTH_HISTORICAL""" - - EARTH_HIGH_PRECISION: str = None - """filename of EARTH_HIGH_PRECISION""" - EARTH_HIGH_PRECISION_URL: str = None - """url of EARTH_HIGH_PRECISION""" - - JPL_PLANETS: str = None - """filename of JPL_PLANETS""" - JPL_PLANETS_URL: str = None - """url of JPL_PLANETS""" - - JPL_SMALL_BODIES: str = None - """filename of JPL_SMALL_BODIES""" - JPL_SMALL_BODIES_URL: str = None - """url of JPL_SMALL_BODIES""" - - LEAP_SECONDS: str = None - """filename of LEAP_SECONDS""" - LEAP_SECONDS_URL: str = None - """url of LEAP_SECONDS""" - - META_KERNEL: str = None - """filename of META_KERNAL""" - - OBSERVATORY_CODES: str = None - """filename of OBSERVATORY_CODES""" - - OBSERVATORY_CODES_COMPRESSED: str = None - """filename of OBSERVATORY_CODES_COMPRESSED""" - OBSERVATORY_CODES_COMPRESSED_URL: str = None - """url of OBSERVATORY_CODES_COMPRESSED""" - - ORIENTATION_CONSTANTS: str = None - """filename of OBSERVATORY_CONSTANTS""" - ORIENTATION_CONSTANTS_URL: str = None - """url of OBSERVATORY_CONSTANTS""" - - DATA_FILE_LIST: list = None - """Convenience list of all the file names""" - - URLS: dict = None - """Dictionary of filename: url""" + de440s: str = "de440s.bsp" + """filename of de440s""" + de440s_url: str = "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de440s.bsp" + """url for de4440s""" + + earth_predict: str = "earth_200101_990827_predict.bpc" + """filename of earth_predict""" + earth_predict_url: str = ( + "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/earth_200101_990827_predict.bpc" + ) + """url for earth_predict""" - def __post_init__(self): - """Automagically validates the auxiliary configs after initialisation.""" - self._create_URL() - # self._validate_auxiliary_configs() + earth_historical: str = "earth_620120_240827.bpc" + """filename of earth_histoical""" + earth_historical_url: str = ( + "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/earth_620120_240827.bpc" + ) + """url for earth_historical""" - def _create_URL(self): - """ - This method takes the filename and url from either the config file or the list of default values. - """ - self._set_default() - for data_filename, default_filename in self.DATA_FILENAME_defaults.items(): - - file_attr = getattr(self, data_filename) - # sets default filename - if file_attr is None: - setattr(self, data_filename, default_filename) - file_attr = getattr(self, data_filename) - - # skips these two as they have no URL attribute - if data_filename == "META_KERNEL" or data_filename == "OBSERVATORY_CODES": - continue - - url_attr = data_filename + "_URL" - # for default URL - if getattr(self, url_attr) is None: - # OBSERVATORY_CODES_COMPRESSED does not need the filename appended I think - if data_filename != "OBSERVATORY_CODES_COMPRESSED": - setattr( - self, - url_attr, - self.URLS_defaults[data_filename] + file_attr, - ) - else: - setattr(self, url_attr, self.URLS_defaults[data_filename]) - # for new URL - else: - setattr( - self, - url_attr, - getattr(self, url_attr) + file_attr, - ) + earth_high_precision: str = "earth_latest_high_prec.bpc" + """filename of earth_high_precision""" + earth_high_precision_url: str = ( + "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/earth_latest_high_prec.bpc" + ) + """url of earth_high_precision""" - def _set_default(self): - """ - creates an attribute list of the default values that this version of sorcha uses. + jpl_planets: str = "linux_p1550p2650.440" + """filename of jpl_planets""" + jpl_planets_url: str = "https://ssd.jpl.nasa.gov/ftp/eph/planets/Linux/de440/linux_p1550p2650.440" + """url of jpl_planets""" - Parameters - ----------- - None. + jpl_small_bodies: str = "sb441-n16.bsp" + """filename of jpl_small_bodies""" + jpl_small_bodies_url: str = "https://ssd.jpl.nasa.gov/ftp/eph/small_bodies/asteroids_de441/sb441-n16.bsp" + """url of jpl_small_bodies""" - Returns - ---------- - None - """ - self.DATA_FILENAME_defaults = { - "DE440S": "de440s.bsp", - "EARTH_PREDICT": "earth_200101_990827_predict.bpc", - "EARTH_HISTORICAL": "earth_620120_240827.bpc", - "EARTH_HIGH_PRECISION": "earth_latest_high_prec.bpc", - "JPL_PLANETS": "linux_p1550p2650.440", - "JPL_SMALL_BODIES": "sb441-n16.bsp", - "LEAP_SECONDS": "naif0012.tls", - "META_KERNEL": "meta_kernel.txt", - "OBSERVATORY_CODES": "ObsCodes.json", - "OBSERVATORY_CODES_COMPRESSED": "ObsCodes.json.gz", - "ORIENTATION_CONSTANTS": "pck00010.pck", - } + leap_seconds: str = "naif0012.tls" + """filename of leap_seconds""" + leap_seconds_url: str = "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls" + """url of leap_seconds""" - self.URLS_defaults = { - "DE440S": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/", - "EARTH_PREDICT": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/", - "EARTH_HISTORICAL": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/", - "EARTH_HIGH_PRECISION": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/", - "JPL_PLANETS": "https://ssd.jpl.nasa.gov/ftp/eph/planets/Linux/de440/", - "JPL_SMALL_BODIES": "https://ssd.jpl.nasa.gov/ftp/eph/small_bodies/asteroids_de441/", - "LEAP_SECONDS": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/", - "OBSERVATORY_CODES_COMPRESSED": "https://minorplanetcenter.net/Extended_Files/obscodes_extended.json.gz", - "ORIENTATION_CONSTANTS": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/", - } + meta_kernel: str = "meta_kernel.txt" + """filename of meta_kernal""" + + observatory_codes: str = "ObsCodes.json" + """filename of observatory_codes""" + + observatory_codes_compressed: str = "ObsCodes.json.gz" + """filename of observatory_codes_compressed""" + observatory_codes_compressed_url: str = ( + "https://minorplanetcenter.net/Extended_Files/obscodes_extended.json.gz" + ) + """url of observatory_codes_compressed""" + + orientation_constants: str = "pck00010.pck" + """filename of observatory_constants""" + orientation_constants_url: str = "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/pck00010.tpc" + """url of observatory_constants""" + + data_file_list: list = None + """convenience list of all the file names""" + + urls: dict = None + """dictionary of filename: url""" + + _data_files_to_download: list = None + """list of files that need to be downloaded""" + + _ordered_kernel_files: list = None + """list of kernels ordered from least to most precise - used to assemble meta_kernel file""" + + REGISTRY: list = None + """Default Pooch registry to define which files will be tracked and retrievable""" + + def __post_init__(self): + """Automagically validates the auxiliary configs after initialisation.""" + self._create_lists_auxiliary_configs() + self._validate_auxiliary_configs() def _validate_auxiliary_configs(self): """ - Validates the auxililary config attributes after initialisation. + validates the auxililary config attributes after initialisation. + """ + + def _create_lists_auxiliary_configs(self): + """ + creates lists of the auxililary config attributes after initialisation. Parameters ----------- @@ -932,32 +879,55 @@ def _validate_auxiliary_configs(self): None """ - self.URLS = { - self.DE440S: self.DE440S_URL, - self.EARTH_PREDICT: self.EARTH_PREDICT_URL, - self.EARTH_HISTORICAL: self.EARTH_HISTORICAL_URL, - self.EARTH_HIGH_PRECISION: self.EARTH_HIGH_PRECISION_URL, - self.JPL_PLANETS: self.JPL_PLANETS_URL, - self.JPL_SMALL_BODIES: self.JPL_SMALL_BODIES_URL, - self.LEAP_SECONDS: self.LEAP_SECONDS_URL, - self.OBSERVATORY_CODES_COMPRESSED: self.OBSERVATORY_CODES_COMPRESSED_URL, - self.ORIENTATION_CONSTANTS: self.ORIENTATION_CONSTANTS_URL, + self.urls = { + self.de440s: self.de440s_url, + self.earth_predict: self.earth_predict_url, + self.earth_historical: self.earth_historical_url, + self.earth_high_precision: self.earth_high_precision_url, + self.jpl_planets: self.jpl_planets_url, + self.jpl_small_bodies: self.jpl_small_bodies_url, + self.leap_seconds: self.leap_seconds_url, + self.observatory_codes_compressed: self.observatory_codes_compressed_url, + self.orientation_constants: self.orientation_constants_url, } - self.DATA_FILE_LIST = [ - self.DE440S, - self.EARTH_PREDICT, - self.EARTH_HISTORICAL, - self.EARTH_HIGH_PRECISION, - self.JPL_PLANETS, - self.JPL_SMALL_BODIES, - self.LEAP_SECONDS, - self.META_KERNEL, - self.OBSERVATORY_CODES, - self.OBSERVATORY_CODES_COMPRESSED, - self.ORIENTATION_CONSTANTS, + self.data_file_list = [ + self.de440s, + self.earth_predict, + self.earth_historical, + self.earth_high_precision, + self.jpl_planets, + self.jpl_small_bodies, + self.leap_seconds, + self.meta_kernel, + self.observatory_codes, + self.observatory_codes_compressed, + self.orientation_constants, ] + self._data_files_to_download = [ + self.de440s, + self.earth_predict, + self.earth_historical, + self.earth_high_precision, + self.jpl_planets, + self.jpl_small_bodies, + self.leap_seconds, + self.observatory_codes_compressed, + self.orientation_constants, + ] + + self._ordered_kernel_files = [ + self.leap_seconds, + self.earth_historical, + self.earth_predict, + self.orientation_constants, + self.de440s, + self.earth_high_precision, + ] + + self.REGISTRY = {data_file: None for data_file in self.data_file_list} + @dataclass class sorchaConfigs: @@ -1343,7 +1313,7 @@ def PrintConfigsToLog(sconfigs, cmd_args): if sconfigs.activity.comet_activity == "comet": pplogger.info("Cometary activity set to: " + str(sconfigs.activity.comet_activity)) - elif sconfigs.activity.comet_activity == "none": + elif sconfigs.activity.comet_activity == None: pplogger.info("No cometary activity selected.") pplogger.info("Format of ephemerides file is: " + sconfigs.input.eph_format) diff --git a/tests/sorcha/test_sorchaConfigs.py b/tests/sorcha/test_sorchaConfigs.py index a6a2f254..7cde63f7 100644 --- a/tests/sorcha/test_sorchaConfigs.py +++ b/tests/sorcha/test_sorchaConfigs.py @@ -17,6 +17,7 @@ lightcurveConfigs, activityConfigs, expertConfigs, + auxililaryConfigs, ) # these are the results we expect from sorcha_config_demo.ini @@ -103,6 +104,31 @@ "randomization_on": True, "vignetting_on": True, } + +correct_auxciliary_URLs = { + "de440s.bsp": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de440s.bsp", + "earth_200101_990827_predict.bpc": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/earth_200101_990827_predict.bpc", + "earth_620120_240827.bpc": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/earth_620120_240827.bpc", + "earth_latest_high_prec.bpc": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/earth_latest_high_prec.bpc", + "linux_p1550p2650.440": "https://ssd.jpl.nasa.gov/ftp/eph/planets/Linux/de440/linux_p1550p2650.440", + "sb441-n16.bsp": "https://ssd.jpl.nasa.gov/ftp/eph/small_bodies/asteroids_de441/sb441-n16.bsp", + "naif0012.tls": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls", + "ObsCodes.json.gz": "https://minorplanetcenter.net/Extended_Files/obscodes_extended.json.gz", + "pck00010.pck": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/pck00010.tpc", + } +correct_auxciliary_filenames = [ + "de440s.bsp", + "earth_200101_990827_predict.bpc", + "earth_620120_240827.bpc", + "earth_latest_high_prec.bpc", + "linux_p1550p2650.440", + "sb441-n16.bsp", + "naif0012.tls", + "meta_kernel.txt", + "ObsCodes.json", + "ObsCodes.json.gz", + "pck00010.pck", +] ################################################################################################################################## # SORCHA Configs test @@ -119,8 +145,6 @@ def test_sorchaConfigs(): # check each section to make sure you get what you expect assert correct_inputs == test_configs.input.__dict__ assert correct_simulation == test_configs.simulation.__dict__ - print(correct_filters) - print(test_configs.filters.__dict__) assert correct_filters == test_configs.filters.__dict__ assert correct_saturation == test_configs.saturation.__dict__ assert correct_phasecurve == test_configs.phasecurves.__dict__ @@ -131,6 +155,9 @@ def test_sorchaConfigs(): assert correct_lc_model == test_configs.lightcurve.__dict__ assert correct_activity == test_configs.activity.__dict__ assert correct_expert == test_configs.expert.__dict__ + assert correct_auxciliary_URLs == test_configs.auxililary.__dict__["URLS"] + assert correct_auxciliary_filenames == test_configs.auxililary.__dict__["DATA_FILE_LIST"] + ################################################################################################################################## From ab2b214e4cd53f320633fac4b595c6badc8ecbb2 Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Tue, 3 Dec 2024 13:52:12 +0000 Subject: [PATCH 04/15] made changes to auxiliaryConfigs and to it's unit test --- src/sorcha/utilities/sorchaConfigs.py | 53 +++++++++++++++++++++++---- tests/sorcha/test_sorchaConfigs.py | 8 ++-- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/sorcha/utilities/sorchaConfigs.py b/src/sorcha/utilities/sorchaConfigs.py index 401149c9..97bcb674 100644 --- a/src/sorcha/utilities/sorchaConfigs.py +++ b/src/sorcha/utilities/sorchaConfigs.py @@ -781,7 +781,7 @@ def _validate_expert_configs(self): @dataclass -class auxililaryConfigs: +class auxiliaryConfigs: de440s: str = "de440s.bsp" """filename of de440s""" de440s_url: str = "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de440s.bsp" @@ -853,9 +853,41 @@ class auxililaryConfigs: _ordered_kernel_files: list = None """list of kernels ordered from least to most precise - used to assemble meta_kernel file""" - REGISTRY: list = None + registry: list = None """Default Pooch registry to define which files will be tracked and retrievable""" + @property + def default_url(self): + """returns a dictionary of the default urls used in this version of sorcha""" + return { + "de440s": self.__class__.de440s_url, + "earth_predict": self.__class__.earth_predict_url, + "earth_historical": self.__class__.earth_historical_url, + "earth_high_precision": self.__class__.earth_high_precision_url, + "jpl_planets": self.__class__.jpl_planets_url, + "jpl_small_bodies": self.__class__.jpl_small_bodies_url, + "leap_seconds": self.__class__.leap_seconds_url, + "observatory_codes_compressed": self.__class__.observatory_codes_compressed_url, + "orientation_constants": self.__class__.orientation_constants_url, + } + + @property + def default_filenames(self): + """returns a dictionary of the default filenames used in this version""" + return { + "de440s": self.__class__.de440s, + "earth_predict": self.__class__.earth_predict, + "earth_historical": self.__class__.earth_historical, + "earth_high_precision": self.__class__.earth_high_precision, + "jpl_planets": self.__class__.jpl_planets, + "jpl_small_bodies": self.__class__.jpl_small_bodies, + "leap_seconds": self.__class__.leap_seconds, + "meta_kernel": self.__class__.meta_kernel, + "observatory_codes": self.__class__.observatory_codes, + "observatory_codes_compressed": self.__class__.observatory_codes_compressed, + "orientation_constants": self.__class__.orientation_constants, + } + def __post_init__(self): """Automagically validates the auxiliary configs after initialisation.""" self._create_lists_auxiliary_configs() @@ -865,7 +897,14 @@ def _validate_auxiliary_configs(self): """ validates the auxililary config attributes after initialisation. """ - + for file in self.default_filenames: + if file != "meta_kernel" and file != "observatory_codes": + if self.default_filenames[file] == getattr(self, file) and getattr(self,file+"_url") != self.default_url[file]: + + print("error") + + elif self.default_filenames[file] != getattr(self, file) and getattr(self,file+"_url") == self.default_url[file]: + setattr(self,file+"_url", None) def _create_lists_auxiliary_configs(self): """ creates lists of the auxililary config attributes after initialisation. @@ -926,7 +965,7 @@ def _create_lists_auxiliary_configs(self): self.earth_high_precision, ] - self.REGISTRY = {data_file: None for data_file in self.data_file_list} + self.registry = {data_file: None for data_file in self.data_file_list} @dataclass @@ -969,8 +1008,8 @@ class sorchaConfigs: expert: expertConfigs = None """expertConfigs dataclass which stores the keywords from the EXPERT section of the config file.""" - auxililary: auxililaryConfigs = None - """auxililaryConfigs dataclass which stores the keywords from the AUXILILARY section of the config file.""" + auxiliary: auxiliaryConfigs = None + """auxiliaryConfigs dataclass which stores the keywords from the AUXILILARY section of the config file.""" pplogger: None = None """The Python logger instance""" @@ -1025,7 +1064,7 @@ def _read_configs_from_object(self, config_object): "LIGHTCURVE": lightcurveConfigs, "ACTIVITY": activityConfigs, "EXPERT": expertConfigs, - "AUXILILARY": auxililaryConfigs, + "AUXILIARY": auxiliaryConfigs, } # when adding new sections in config file this general function needs the name of the section in uppercase # to be the same as the attributes defined above in lowercase e.g. section INPUT has attribute input diff --git a/tests/sorcha/test_sorchaConfigs.py b/tests/sorcha/test_sorchaConfigs.py index 7cde63f7..c27ae8a8 100644 --- a/tests/sorcha/test_sorchaConfigs.py +++ b/tests/sorcha/test_sorchaConfigs.py @@ -17,7 +17,7 @@ lightcurveConfigs, activityConfigs, expertConfigs, - auxililaryConfigs, + auxiliaryConfigs, ) # these are the results we expect from sorcha_config_demo.ini @@ -155,11 +155,11 @@ def test_sorchaConfigs(): assert correct_lc_model == test_configs.lightcurve.__dict__ assert correct_activity == test_configs.activity.__dict__ assert correct_expert == test_configs.expert.__dict__ - assert correct_auxciliary_URLs == test_configs.auxililary.__dict__["URLS"] - assert correct_auxciliary_filenames == test_configs.auxililary.__dict__["DATA_FILE_LIST"] - + assert correct_auxciliary_URLs == test_configs.auxiliary.__dict__["urls"] + assert correct_auxciliary_filenames == test_configs.auxiliary.__dict__["data_file_list"] +test_sorchaConfigs() ################################################################################################################################## # Inputs section test From dba96ff7e144fc2639f0711ce66cb7f5549ba08d Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Tue, 3 Dec 2024 21:31:31 +0000 Subject: [PATCH 05/15] Created unit tests for auxiliaryConfigs --- src/sorcha/utilities/sorchaConfigs.py | 17 +++++++--- tests/sorcha/test_sorchaConfigs.py | 47 +++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/src/sorcha/utilities/sorchaConfigs.py b/src/sorcha/utilities/sorchaConfigs.py index 97bcb674..e46bd088 100644 --- a/src/sorcha/utilities/sorchaConfigs.py +++ b/src/sorcha/utilities/sorchaConfigs.py @@ -899,12 +899,19 @@ def _validate_auxiliary_configs(self): """ for file in self.default_filenames: if file != "meta_kernel" and file != "observatory_codes": - if self.default_filenames[file] == getattr(self, file) and getattr(self,file+"_url") != self.default_url[file]: - - print("error") + if ( + self.default_filenames[file] == getattr(self, file) + and getattr(self, file + "_url") != self.default_url[file] + ): + logging.error(f"ERROR: url for {file} given but filename for {file} not given") + sys.exit(f"ERROR: url for {file} given but filename for {file} not given") + + elif ( + self.default_filenames[file] != getattr(self, file) + and getattr(self, file + "_url") == self.default_url[file] + ): + setattr(self, file + "_url", None) - elif self.default_filenames[file] != getattr(self, file) and getattr(self,file+"_url") == self.default_url[file]: - setattr(self,file+"_url", None) def _create_lists_auxiliary_configs(self): """ creates lists of the auxililary config attributes after initialisation. diff --git a/tests/sorcha/test_sorchaConfigs.py b/tests/sorcha/test_sorchaConfigs.py index c27ae8a8..7007582d 100644 --- a/tests/sorcha/test_sorchaConfigs.py +++ b/tests/sorcha/test_sorchaConfigs.py @@ -115,7 +115,7 @@ "naif0012.tls": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls", "ObsCodes.json.gz": "https://minorplanetcenter.net/Extended_Files/obscodes_extended.json.gz", "pck00010.pck": "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/pck00010.tpc", - } +} correct_auxciliary_filenames = [ "de440s.bsp", "earth_200101_990827_predict.bpc", @@ -159,7 +159,6 @@ def test_sorchaConfigs(): assert correct_auxciliary_filenames == test_configs.auxiliary.__dict__["data_file_list"] -test_sorchaConfigs() ################################################################################################################################## # Inputs section test @@ -1013,3 +1012,47 @@ def test_expertConfig_bool(key_name): error_text.value.code == f"ERROR: expected a bool for config parameter {key_name}. Check value in config file." ) + + +################################################################################################################################## + +# auxiliary config test + + +@pytest.mark.parametrize( + "file", + [ + "de440s", + "earth_predict", + "earth_historical", + "jpl_planets", + "leap_seconds", + "observatory_codes_compressed", + "orientation_constants", + ], +) +def test_auxiliary_config_url_given_filename_not(file): + + aux_configs = {file + "_url": "new_url"} + with pytest.raises(SystemExit) as error_text: + test_configs = auxiliaryConfigs(**aux_configs) + assert error_text.value.code == f"ERROR: url for {file} given but filename for {file} not given" + + +@pytest.mark.parametrize( + "file", + [ + "de440s", + "earth_predict", + "earth_historical", + "jpl_planets", + "leap_seconds", + "observatory_codes_compressed", + "orientation_constants", + ], +) +def test_auxiliary_config_making_url_none(file): + aux_configs = {file: "new_filename"} + + test_configs = auxiliaryConfigs(**aux_configs) + assert getattr(test_configs, file + "_url") == None From dd4dde20c0b04f9f58409a6649ff3f479a4cce90 Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Tue, 3 Dec 2024 21:32:18 +0000 Subject: [PATCH 06/15] changed make_retriever function to work with dataclasses --- src/sorcha/ephemeris/simulation_data_files.py | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/sorcha/ephemeris/simulation_data_files.py b/src/sorcha/ephemeris/simulation_data_files.py index dddd7697..953acc84 100644 --- a/src/sorcha/ephemeris/simulation_data_files.py +++ b/src/sorcha/ephemeris/simulation_data_files.py @@ -79,7 +79,6 @@ def make_retriever(directory_path: str = None, registry: dict = REGISTRY) -> poo registry : dictionary, optional A dictionary of file names to SHA hashes. Generally we'll not use SHA=None because the files we're tracking change frequently. Default = REGISTRY - Returns ------- : pooch @@ -96,3 +95,32 @@ def make_retriever(directory_path: str = None, registry: dict = REGISTRY) -> poo registry=registry, retry_if_failed=25, ) + +def make_retriever_notusedyet(sconfigs, directory_path: str = None) -> pooch.Pooch: + """Helper function that will create a Pooch object to track and retrieve files. + + Parameters + ---------- + directory_path : string, optional + The base directory to place all downloaded files. Default = None + registry : dictionary, optional + A dictionary of file names to SHA hashes. Generally we'll not use SHA=None + because the files we're tracking change frequently. Default = REGISTRY + sconfigs: dataclass + Dataclass of configuration file arguments. + Returns + ------- + : pooch + The instance of a Pooch object used to track and retrieve files. + """ + dir_path = pooch.os_cache("sorcha") + if directory_path: + dir_path = directory_path + + return pooch.create( + path=dir_path, + base_url="", + urls=sconfigs.auxiliary.urls, + registry=sconfigs.auxiliary.registry, + retry_if_failed=25, + ) From 82c92d94dae50343325351cf16681c35788c5f19 Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Wed, 4 Dec 2024 17:35:22 +0000 Subject: [PATCH 07/15] Update sorchaConfigs.py --- src/sorcha/utilities/sorchaConfigs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sorcha/utilities/sorchaConfigs.py b/src/sorcha/utilities/sorchaConfigs.py index e46bd088..c8b78809 100644 --- a/src/sorcha/utilities/sorchaConfigs.py +++ b/src/sorcha/utilities/sorchaConfigs.py @@ -847,10 +847,10 @@ class auxiliaryConfigs: urls: dict = None """dictionary of filename: url""" - _data_files_to_download: list = None + data_files_to_download: list = None """list of files that need to be downloaded""" - _ordered_kernel_files: list = None + ordered_kernel_files: list = None """list of kernels ordered from least to most precise - used to assemble meta_kernel file""" registry: list = None @@ -951,7 +951,7 @@ def _create_lists_auxiliary_configs(self): self.orientation_constants, ] - self._data_files_to_download = [ + self.data_files_to_download = [ self.de440s, self.earth_predict, self.earth_historical, @@ -963,7 +963,7 @@ def _create_lists_auxiliary_configs(self): self.orientation_constants, ] - self._ordered_kernel_files = [ + self.ordered_kernel_files = [ self.leap_seconds, self.earth_historical, self.earth_predict, From 3098b600b90a7029768eb957f3c21f839f81b7e7 Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Wed, 4 Dec 2024 19:01:29 +0000 Subject: [PATCH 08/15] changed function make_retriever and updated code changed function make_retriever use the config dataclass auxiliary. Went through the ephemeris files and updated this funtion. Completely removed all the global variables in similation_data_files.py. --- src/sorcha/ephemeris/__init__.py | 4 - src/sorcha/ephemeris/simulation_data_files.py | 96 +------------------ src/sorcha/ephemeris/simulation_driver.py | 6 +- src/sorcha/ephemeris/simulation_parsing.py | 23 +++-- src/sorcha/ephemeris/simulation_setup.py | 43 +++++---- src/sorcha/utilities/generate_meta_kernel.py | 10 +- .../retrieve_ephemeris_data_files.py | 6 +- src/sorcha_cmdline/bootstrap.py | 19 ++-- tests/ephemeris/test_pixdict.py | 6 +- tests/ephemeris/test_simulation_parsing.py | 10 +- 10 files changed, 64 insertions(+), 159 deletions(-) diff --git a/src/sorcha/ephemeris/__init__.py b/src/sorcha/ephemeris/__init__.py index 95b04531..47428b31 100644 --- a/src/sorcha/ephemeris/__init__.py +++ b/src/sorcha/ephemeris/__init__.py @@ -7,10 +7,6 @@ create_ecl_to_eq_rotation_matrix, ) from .simulation_data_files import ( - DATA_FILE_LIST, - JPL_PLANETS, - JPL_SMALL_BODIES, - DE440S, make_retriever, ) from .simulation_geometry import ( diff --git a/src/sorcha/ephemeris/simulation_data_files.py b/src/sorcha/ephemeris/simulation_data_files.py index 953acc84..b2ff932b 100644 --- a/src/sorcha/ephemeris/simulation_data_files.py +++ b/src/sorcha/ephemeris/simulation_data_files.py @@ -1,102 +1,8 @@ import pooch -# Define variables for the file names -DE440S = "de440s.bsp" -EARTH_PREDICT = "earth_200101_990827_predict.bpc" -EARTH_HISTORICAL = "earth_620120_240827.bpc" -EARTH_HIGH_PRECISION = "earth_latest_high_prec.bpc" -JPL_PLANETS = "linux_p1550p2650.440" -JPL_SMALL_BODIES = "sb441-n16.bsp" -LEAP_SECONDS = "naif0012.tls" -META_KERNEL = "meta_kernel.txt" -OBSERVATORY_CODES = "ObsCodes.json" -OBSERVATORY_CODES_COMPRESSED = "ObsCodes.json.gz" -ORIENTATION_CONSTANTS = "pck00010.pck" -# Dictionary of filename: url -URLS = { - DE440S: "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de440s.bsp", - EARTH_PREDICT: "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/earth_200101_990827_predict.bpc", - EARTH_HISTORICAL: "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/earth_620120_240827.bpc", - EARTH_HIGH_PRECISION: "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/earth_latest_high_prec.bpc", - JPL_PLANETS: "https://ssd.jpl.nasa.gov/ftp/eph/planets/Linux/de440/linux_p1550p2650.440", - JPL_SMALL_BODIES: "https://ssd.jpl.nasa.gov/ftp/eph/small_bodies/asteroids_de441/sb441-n16.bsp", - LEAP_SECONDS: "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls", - OBSERVATORY_CODES_COMPRESSED: "https://minorplanetcenter.net/Extended_Files/obscodes_extended.json.gz", - ORIENTATION_CONSTANTS: "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/pck00010.tpc", -} - -# Convenience list of all the file names -DATA_FILE_LIST = [ - DE440S, - EARTH_PREDICT, - EARTH_HISTORICAL, - EARTH_HIGH_PRECISION, - JPL_PLANETS, - JPL_SMALL_BODIES, - LEAP_SECONDS, - META_KERNEL, - OBSERVATORY_CODES, - OBSERVATORY_CODES_COMPRESSED, - ORIENTATION_CONSTANTS, -] - -# List of files that need to be downloaded -DATA_FILES_TO_DOWNLOAD = [ - DE440S, - EARTH_PREDICT, - EARTH_HISTORICAL, - EARTH_HIGH_PRECISION, - JPL_PLANETS, - JPL_SMALL_BODIES, - LEAP_SECONDS, - OBSERVATORY_CODES_COMPRESSED, - ORIENTATION_CONSTANTS, -] - -# List of kernels ordered from least to most precise - used to assemble META_KERNEL file -ORDERED_KERNEL_FILES = [ - LEAP_SECONDS, - EARTH_HISTORICAL, - EARTH_PREDICT, - ORIENTATION_CONSTANTS, - DE440S, - EARTH_HIGH_PRECISION, -] - -# Default Pooch registry to define which files will be tracked and retrievable -REGISTRY = {data_file: None for data_file in DATA_FILE_LIST} - - -def make_retriever(directory_path: str = None, registry: dict = REGISTRY) -> pooch.Pooch: - """Helper function that will create a Pooch object to track and retrieve files. - - Parameters - ---------- - directory_path : string, optional - The base directory to place all downloaded files. Default = None - registry : dictionary, optional - A dictionary of file names to SHA hashes. Generally we'll not use SHA=None - because the files we're tracking change frequently. Default = REGISTRY - Returns - ------- - : pooch - The instance of a Pooch object used to track and retrieve files. - """ - dir_path = pooch.os_cache("sorcha") - if directory_path: - dir_path = directory_path - - return pooch.create( - path=dir_path, - base_url="", - urls=URLS, - registry=registry, - retry_if_failed=25, - ) - -def make_retriever_notusedyet(sconfigs, directory_path: str = None) -> pooch.Pooch: +def make_retriever(sconfigs, directory_path: str = None) -> pooch.Pooch: """Helper function that will create a Pooch object to track and retrieve files. Parameters diff --git a/src/sorcha/ephemeris/simulation_driver.py b/src/sorcha/ephemeris/simulation_driver.py index 7521c9c9..667d02a4 100644 --- a/src/sorcha/ephemeris/simulation_driver.py +++ b/src/sorcha/ephemeris/simulation_driver.py @@ -116,13 +116,13 @@ def create_ephemeris(orbits_df, pointings_df, args, sconfigs): ephemeris_csv_filename = os.path.join(args.outpath, args.output_ephemeris_file) verboselog("Building ASSIST ephemeris object.") - ephem, gm_sun, gm_total = create_assist_ephemeris(args) + ephem, gm_sun, gm_total = create_assist_ephemeris(args,sconfigs) verboselog("Furnishing SPICE kernels.") - furnish_spiceypy(args) + furnish_spiceypy(args,sconfigs) verboselog("Generating ASSIST+REBOUND simulations.") sim_dict = generate_simulations(ephem, gm_sun, gm_total, orbits_df, args) pixel_dict = defaultdict(list) - observatories = Observatory(args) + observatories = Observatory(args,sconfigs) output = StringIO() in_memory_csv = writer(output) diff --git a/src/sorcha/ephemeris/simulation_parsing.py b/src/sorcha/ephemeris/simulation_parsing.py index ef458e16..ec0bce36 100644 --- a/src/sorcha/ephemeris/simulation_parsing.py +++ b/src/sorcha/ephemeris/simulation_parsing.py @@ -3,14 +3,10 @@ import numpy as np import spiceypy as spice from pooch import Decompress - +from sorcha.utilities.sorchaConfigs import sorchaConfigs, auxiliaryConfigs from sorcha.ephemeris.simulation_constants import RADIUS_EARTH_KM from sorcha.ephemeris.simulation_geometry import ecliptic_to_equatorial -from sorcha.ephemeris.simulation_data_files import ( - OBSERVATORY_CODES, - OBSERVATORY_CODES_COMPRESSED, - make_retriever, -) +from sorcha.ephemeris.simulation_data_files import make_retriever from sorcha.ephemeris.orbit_conversion_utilities import universal_cartesian @@ -129,12 +125,15 @@ def parse_orbit_row(row, epochJD_TDB, ephem, sun_dict, gm_sun, gm_total): return tuple(np.concatenate([equatorial_coords, equatorial_velocities])) +default = sorchaConfigs() +default.auxiliary = auxiliaryConfigs() #using the default observatory_codes in the auxiliaryConfigs class + class Observatory: """ Class containing various utility tools related to the calculation of the observatory position """ - def __init__(self, args, oc_file=OBSERVATORY_CODES): + def __init__(self, args, sconfigs, oc_file=default.auxiliary.observatory_codes): """ Initialization method @@ -147,17 +146,17 @@ def __init__(self, args, oc_file=OBSERVATORY_CODES): """ self.observatoryPositionCache = {} # previously calculated positions to speed up the process - if oc_file == OBSERVATORY_CODES: - retriever = make_retriever(args.ar_data_file_path) + if oc_file == sconfigs.auxiliary.observatory_codes: + retriever = make_retriever(sconfigs, args.ar_data_file_path) # is the file available locally, if so, return the full path - if os.path.isfile(os.path.join(retriever.abspath, OBSERVATORY_CODES)): - obs_file_path = retriever.fetch(OBSERVATORY_CODES) + if os.path.isfile(os.path.join(retriever.abspath, sconfigs.auxiliary.observatory_codes)): + obs_file_path = retriever.fetch(sconfigs.auxiliary.observatory_codes) # if the file is not local, download, and decompress it, then return the path. else: obs_file_path = retriever.fetch( - OBSERVATORY_CODES_COMPRESSED, processor=Decompress(name=OBSERVATORY_CODES) + sconfigs.auxiliary.observatory_codes_compressed, processor=Decompress(name=sconfigs.auxiliary.observatory_codes) ) else: diff --git a/src/sorcha/ephemeris/simulation_setup.py b/src/sorcha/ephemeris/simulation_setup.py index 3a21782c..52bfa64f 100644 --- a/src/sorcha/ephemeris/simulation_setup.py +++ b/src/sorcha/ephemeris/simulation_setup.py @@ -11,13 +11,7 @@ import numpy as np from sorcha.ephemeris.simulation_constants import * -from sorcha.ephemeris.simulation_data_files import ( - make_retriever, - JPL_PLANETS, - JPL_SMALL_BODIES, - META_KERNEL, - ORDERED_KERNEL_FILES, -) +from sorcha.ephemeris.simulation_data_files import make_retriever from sorcha.ephemeris.simulation_geometry import ( barycentricObservatoryRates, @@ -32,9 +26,12 @@ from sorcha.utilities.generate_meta_kernel import build_meta_kernel_file -def create_assist_ephemeris(args) -> tuple: +def create_assist_ephemeris(args,sconfigs) -> tuple: """Build the ASSIST ephemeris object - + Parameter + --------- + sconfigs: dataclass + Dataclass of configuration file arguments. Returns --------- Ephem : ASSIST ephemeris obejct @@ -46,9 +43,9 @@ def create_assist_ephemeris(args) -> tuple: """ pplogger = logging.getLogger(__name__) - retriever = make_retriever(args.ar_data_file_path) - planets_file_path = retriever.fetch(JPL_PLANETS) - small_bodies_file_path = retriever.fetch(JPL_SMALL_BODIES) + retriever = make_retriever(sconfigs,args.ar_data_file_path) + planets_file_path = retriever.fetch(sconfigs.auxiliary.jpl_planets) + small_bodies_file_path = retriever.fetch(sconfigs.auxiliary.jpl_small_bodies) ephem = Ephem(planets_path=planets_file_path, asteroids_path=small_bodies_file_path) gm_sun = ephem.get_particle("Sun", 0).m gm_total = sum(sorted([ephem.get_particle(i, 0).m for i in range(27)])) @@ -59,27 +56,31 @@ def create_assist_ephemeris(args) -> tuple: return ephem, gm_sun, gm_total -def furnish_spiceypy(args): +def furnish_spiceypy(args,sconfigs): """ Builds the SPICE kernel, downloading the required files if needed + Parameters + ----------- + sconfigs: dataclass + Dataclass of configuration file arguments. """ # The goal here would be to download the spice kernel files (if needed) # Then call spice.furnish() on each of those files. pplogger = logging.getLogger(__name__) - retriever = make_retriever(args.ar_data_file_path) + retriever = make_retriever(sconfigs,args.ar_data_file_path) - for kernel_file in ORDERED_KERNEL_FILES: + for kernel_file in sconfigs.auxiliary.ordered_kernel_files: retriever.fetch(kernel_file) # check if the META_KERNEL file exists. If it doesn't exist, create it. - if not os.path.exists(os.path.join(retriever.abspath, META_KERNEL)): - build_meta_kernel_file(retriever) + if not os.path.exists(os.path.join(retriever.abspath, sconfigs.auxiliary.meta_kernel)): + build_meta_kernel_file(sconfigs,retriever) # try to get the META_KERNEL file. If it's not there, error out. try: - meta_kernel = retriever.fetch(META_KERNEL) + meta_kernel = retriever.fetch(sconfigs.auxiliary.meta_kernel) except ValueError: pplogger.error( "ERROR: furnish_spiceypy: Must create meta_kernel.txt by running `bootstrap_sorcha_data_files` on the command line." @@ -181,11 +182,11 @@ def precompute_pointing_information(pointings_df, args, sconfigs): pointings_df : pandas dataframe The original dataframe with several additional columns of precomputed values. """ - ephem, _, _ = create_assist_ephemeris(args) + ephem, _, _ = create_assist_ephemeris(args,sconfigs) - furnish_spiceypy(args) + furnish_spiceypy(args,sconfigs) obsCode = sconfigs.simulation.ar_obs_code - observatories = Observatory(args) + observatories = Observatory(args,sconfigs) # vectorize the calculation to get x,y,z vector from ra/dec vectors = ra_dec2vec( diff --git a/src/sorcha/utilities/generate_meta_kernel.py b/src/sorcha/utilities/generate_meta_kernel.py index 45a5d34a..381a4781 100644 --- a/src/sorcha/utilities/generate_meta_kernel.py +++ b/src/sorcha/utilities/generate_meta_kernel.py @@ -1,10 +1,6 @@ import os import pooch -from sorcha.ephemeris.simulation_data_files import ( - META_KERNEL, - ORDERED_KERNEL_FILES, -) """ An example output from running `build_meta_kernel_file` might look like @@ -29,7 +25,7 @@ """ -def build_meta_kernel_file(retriever: pooch.Pooch) -> None: +def build_meta_kernel_file(sconfigs,retriever: pooch.Pooch) -> None: """Builds a specific text file that will be fed into `spiceypy` that defines the list of spice kernel to load, as well as the order to load them. @@ -43,7 +39,7 @@ def build_meta_kernel_file(retriever: pooch.Pooch) -> None: None """ # build meta_kernel file path - meta_kernel_file_path = os.path.join(retriever.abspath, META_KERNEL) + meta_kernel_file_path = os.path.join(retriever.abspath, sconfigs.auxiliary.meta_kernel) # build a meta_kernel.txt file with open(meta_kernel_file_path, "w") as meta_file: @@ -51,7 +47,7 @@ def build_meta_kernel_file(retriever: pooch.Pooch) -> None: meta_file.write(f"PATH_VALUES = ('{retriever.abspath}')\n\n") meta_file.write("PATH_SYMBOLS = ('A')\n\n") meta_file.write("KERNELS_TO_LOAD=(\n") - for file_name in ORDERED_KERNEL_FILES: + for file_name in sconfigs.auxiliary.ordered_kernel_files: shortened_file_name = _build_file_name(retriever.abspath, retriever.fetch(file_name)) meta_file.write(f" '{shortened_file_name}',\n") meta_file.write(")\n\n") diff --git a/src/sorcha/utilities/retrieve_ephemeris_data_files.py b/src/sorcha/utilities/retrieve_ephemeris_data_files.py index 85d06a3a..b3e06c4a 100644 --- a/src/sorcha/utilities/retrieve_ephemeris_data_files.py +++ b/src/sorcha/utilities/retrieve_ephemeris_data_files.py @@ -35,7 +35,7 @@ def _decompress(fname, action, pup): # pragma: no cover pooch.Decompress(method="auto", name=os.path.splitext(fname)[0]).__call__(fname, action, pup) -def _remove_files(retriever: pooch.Pooch) -> None: # pragma: no cover +def _remove_files(sconfigs,retriever: pooch.Pooch) -> None: # pragma: no cover """Utility to remove all the files tracked by the pooch retriever. This includes the decompressed ObservatoryCodes.json file as well as the META_KERNEL file that are created after downloading the files in the DATA_FILES_TO_DOWNLOAD @@ -45,9 +45,11 @@ def _remove_files(retriever: pooch.Pooch) -> None: # pragma: no cover ------------ retriever : pooch Pooch object that maintains the registry of files to download. + sconfigs: dataclass + Dataclass of configuration file arguments. """ - for file_name in DATA_FILE_LIST: + for file_name in sconfigs.auxiliary.data_file_list: file_path = retriever.fetch(file_name) print(f"Deleting file: {file_path}") os.remove(file_path) diff --git a/src/sorcha_cmdline/bootstrap.py b/src/sorcha_cmdline/bootstrap.py index edbcb908..7970dd36 100644 --- a/src/sorcha_cmdline/bootstrap.py +++ b/src/sorcha_cmdline/bootstrap.py @@ -39,8 +39,6 @@ def execute(args): # from sorcha.utilities.retrieve_ephemeris_data_files import ( make_retriever, - DATA_FILE_LIST, - DATA_FILES_TO_DOWNLOAD, _check_for_existing_files, _decompress, _remove_files, @@ -48,17 +46,20 @@ def execute(args): ) from functools import partial import concurrent.futures - + from sorcha.utilities.sorchaConfigs import sorchaConfigs, auxiliaryConfigs + #default files that are downloaded (stored in auxiliaryConfigs) + default_files = sorchaConfigs() + default_files.auxiliary = auxiliaryConfigs() # create the Pooch retriever that tracks and retrieves the requested files - retriever = make_retriever(args.cache) + retriever = make_retriever(default_files,args.cache) # determine if we should attempt to download or create any files. found_all_files = False if args.force: - _remove_files(retriever) + _remove_files(default_files,retriever) else: print("Checking cache for existing files.") - found_all_files = _check_for_existing_files(retriever, DATA_FILE_LIST) + found_all_files = _check_for_existing_files(retriever, default_files.auxiliary.data_file_list) if not found_all_files: # create a partial function of `Pooch.fetch` including the `_decompress` method @@ -66,13 +67,13 @@ def execute(args): # download the data files in parallel with concurrent.futures.ThreadPoolExecutor() as executor: - executor.map(fetch_partial, DATA_FILES_TO_DOWNLOAD) + executor.map(fetch_partial, default_files.auxiliary.data_files_to_download) # build the meta_kernel.txt file - build_meta_kernel_file(retriever) + build_meta_kernel_file(default_files,retriever) print("Checking cache after attempting to download and create files.") - _check_for_existing_files(retriever, DATA_FILE_LIST) + _check_for_existing_files(retriever, default_files.auxiliary.data_file_list) if __name__ == "__main__": diff --git a/tests/ephemeris/test_pixdict.py b/tests/ephemeris/test_pixdict.py index ac8331bd..59765441 100644 --- a/tests/ephemeris/test_pixdict.py +++ b/tests/ephemeris/test_pixdict.py @@ -80,11 +80,11 @@ def test_pixeldict(tmp_path): filterpointing = precompute_pointing_information(filterpointing, args, configs) args = sorchaArguments(cmd_args_dict) - ephem, gm_sun, gm_total = create_assist_ephemeris(args) - furnish_spiceypy(args) + ephem, gm_sun, gm_total = create_assist_ephemeris(args,configs) + furnish_spiceypy(args,configs) sim_dict = generate_simulations(ephem, gm_sun, gm_total, orbits_df, args) - observatory = Observatory(args=None, oc_file=get_test_filepath("ObsCodes_test.json")) + observatory = Observatory(sconfigs=configs,args=None, oc_file=get_test_filepath("ObsCodes_test.json")) pixdict = PixelDict(54800.0 + 2400000.5, sim_dict, ephem, "Z20", observatory, picket_interval=1, nside=32) diff --git a/tests/ephemeris/test_simulation_parsing.py b/tests/ephemeris/test_simulation_parsing.py index 73807347..4d6988f6 100644 --- a/tests/ephemeris/test_simulation_parsing.py +++ b/tests/ephemeris/test_simulation_parsing.py @@ -2,10 +2,12 @@ import numpy as np import sorcha.ephemeris.simulation_parsing as sp from sorcha.utilities.dataUtilitiesForTests import get_test_filepath - +from sorcha.utilities.sorchaConfigs import sorchaConfigs, auxiliaryConfigs def test_observatory_compared_to_original(): - observatory = sp.Observatory(args=None, oc_file=get_test_filepath("ObsCodes_test.json")) + sconfigs = sorchaConfigs() + sconfigs.auxiliary = auxiliaryConfigs() + observatory = sp.Observatory(sconfigs=sconfigs,args=None, oc_file=get_test_filepath("ObsCodes_test.json")) obs = observatory.ObservatoryXYZ # Reference tuples were taken from Matt Holman's original notebook @@ -17,7 +19,9 @@ def test_observatory_compared_to_original(): def test_observatory_for_moving_observatories(): - observatory = sp.Observatory(args=None, oc_file=get_test_filepath("ObsCodes_test.json")) + sconfigs = sorchaConfigs() + sconfigs.auxiliary = auxiliaryConfigs() + observatory = sp.Observatory(sconfigs=sconfigs,args=None, oc_file=get_test_filepath("ObsCodes_test.json")) obs = observatory.ObservatoryXYZ assert obs["250"] == (None, None, None) From 2345ca5a463dd5521477f082f90b5fad225db63b Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Wed, 4 Dec 2024 19:08:34 +0000 Subject: [PATCH 09/15] added docs for some functions --- src/sorcha/ephemeris/simulation_parsing.py | 2 ++ src/sorcha/utilities/generate_meta_kernel.py | 3 ++- src/sorcha_cmdline/bootstrap.py | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sorcha/ephemeris/simulation_parsing.py b/src/sorcha/ephemeris/simulation_parsing.py index ec0bce36..631443b3 100644 --- a/src/sorcha/ephemeris/simulation_parsing.py +++ b/src/sorcha/ephemeris/simulation_parsing.py @@ -141,6 +141,8 @@ def __init__(self, args, sconfigs, oc_file=default.auxiliary.observatory_codes): ---------- args : dictionary or `sorchaArguments` object dictionary of command-line arguments. + sconfigs: dataclass + Dataclass of configuration file arguments. oc_file : str Path for the file with observatory codes """ diff --git a/src/sorcha/utilities/generate_meta_kernel.py b/src/sorcha/utilities/generate_meta_kernel.py index 381a4781..4910499f 100644 --- a/src/sorcha/utilities/generate_meta_kernel.py +++ b/src/sorcha/utilities/generate_meta_kernel.py @@ -33,7 +33,8 @@ def build_meta_kernel_file(sconfigs,retriever: pooch.Pooch) -> None: ---------- retriever : pooch Pooch object that maintains the registry of files to download - + sconfigs: dataclass + Dataclass of configuration file arguments. Returns --------- None diff --git a/src/sorcha_cmdline/bootstrap.py b/src/sorcha_cmdline/bootstrap.py index 7970dd36..9f6cf137 100644 --- a/src/sorcha_cmdline/bootstrap.py +++ b/src/sorcha_cmdline/bootstrap.py @@ -47,7 +47,8 @@ def execute(args): from functools import partial import concurrent.futures from sorcha.utilities.sorchaConfigs import sorchaConfigs, auxiliaryConfigs - #default files that are downloaded (stored in auxiliaryConfigs) + + #default file names and urls (stored in auxiliaryConfigs) default_files = sorchaConfigs() default_files.auxiliary = auxiliaryConfigs() # create the Pooch retriever that tracks and retrieves the requested files From c8578577a136837fcb856c3d57ec79bc27b89d79 Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Wed, 4 Dec 2024 19:19:06 +0000 Subject: [PATCH 10/15] black reformatting --- src/sorcha/ephemeris/simulation_data_files.py | 1 - src/sorcha/ephemeris/simulation_driver.py | 6 +++--- src/sorcha/ephemeris/simulation_parsing.py | 6 ++++-- src/sorcha/ephemeris/simulation_setup.py | 16 ++++++++-------- src/sorcha/utilities/generate_meta_kernel.py | 2 +- .../utilities/retrieve_ephemeris_data_files.py | 2 +- src/sorcha_cmdline/bootstrap.py | 8 ++++---- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/sorcha/ephemeris/simulation_data_files.py b/src/sorcha/ephemeris/simulation_data_files.py index b2ff932b..9bfc6a39 100644 --- a/src/sorcha/ephemeris/simulation_data_files.py +++ b/src/sorcha/ephemeris/simulation_data_files.py @@ -1,7 +1,6 @@ import pooch - def make_retriever(sconfigs, directory_path: str = None) -> pooch.Pooch: """Helper function that will create a Pooch object to track and retrieve files. diff --git a/src/sorcha/ephemeris/simulation_driver.py b/src/sorcha/ephemeris/simulation_driver.py index 667d02a4..a008798c 100644 --- a/src/sorcha/ephemeris/simulation_driver.py +++ b/src/sorcha/ephemeris/simulation_driver.py @@ -116,13 +116,13 @@ def create_ephemeris(orbits_df, pointings_df, args, sconfigs): ephemeris_csv_filename = os.path.join(args.outpath, args.output_ephemeris_file) verboselog("Building ASSIST ephemeris object.") - ephem, gm_sun, gm_total = create_assist_ephemeris(args,sconfigs) + ephem, gm_sun, gm_total = create_assist_ephemeris(args, sconfigs) verboselog("Furnishing SPICE kernels.") - furnish_spiceypy(args,sconfigs) + furnish_spiceypy(args, sconfigs) verboselog("Generating ASSIST+REBOUND simulations.") sim_dict = generate_simulations(ephem, gm_sun, gm_total, orbits_df, args) pixel_dict = defaultdict(list) - observatories = Observatory(args,sconfigs) + observatories = Observatory(args, sconfigs) output = StringIO() in_memory_csv = writer(output) diff --git a/src/sorcha/ephemeris/simulation_parsing.py b/src/sorcha/ephemeris/simulation_parsing.py index 631443b3..c3e229c2 100644 --- a/src/sorcha/ephemeris/simulation_parsing.py +++ b/src/sorcha/ephemeris/simulation_parsing.py @@ -126,7 +126,8 @@ def parse_orbit_row(row, epochJD_TDB, ephem, sun_dict, gm_sun, gm_total): default = sorchaConfigs() -default.auxiliary = auxiliaryConfigs() #using the default observatory_codes in the auxiliaryConfigs class +default.auxiliary = auxiliaryConfigs() # using the default observatory_codes in the auxiliaryConfigs class + class Observatory: """ @@ -158,7 +159,8 @@ def __init__(self, args, sconfigs, oc_file=default.auxiliary.observatory_codes): # if the file is not local, download, and decompress it, then return the path. else: obs_file_path = retriever.fetch( - sconfigs.auxiliary.observatory_codes_compressed, processor=Decompress(name=sconfigs.auxiliary.observatory_codes) + sconfigs.auxiliary.observatory_codes_compressed, + processor=Decompress(name=sconfigs.auxiliary.observatory_codes), ) else: diff --git a/src/sorcha/ephemeris/simulation_setup.py b/src/sorcha/ephemeris/simulation_setup.py index 52bfa64f..268325a6 100644 --- a/src/sorcha/ephemeris/simulation_setup.py +++ b/src/sorcha/ephemeris/simulation_setup.py @@ -26,7 +26,7 @@ from sorcha.utilities.generate_meta_kernel import build_meta_kernel_file -def create_assist_ephemeris(args,sconfigs) -> tuple: +def create_assist_ephemeris(args, sconfigs) -> tuple: """Build the ASSIST ephemeris object Parameter --------- @@ -43,7 +43,7 @@ def create_assist_ephemeris(args,sconfigs) -> tuple: """ pplogger = logging.getLogger(__name__) - retriever = make_retriever(sconfigs,args.ar_data_file_path) + retriever = make_retriever(sconfigs, args.ar_data_file_path) planets_file_path = retriever.fetch(sconfigs.auxiliary.jpl_planets) small_bodies_file_path = retriever.fetch(sconfigs.auxiliary.jpl_small_bodies) ephem = Ephem(planets_path=planets_file_path, asteroids_path=small_bodies_file_path) @@ -56,7 +56,7 @@ def create_assist_ephemeris(args,sconfigs) -> tuple: return ephem, gm_sun, gm_total -def furnish_spiceypy(args,sconfigs): +def furnish_spiceypy(args, sconfigs): """ Builds the SPICE kernel, downloading the required files if needed Parameters @@ -69,14 +69,14 @@ def furnish_spiceypy(args,sconfigs): pplogger = logging.getLogger(__name__) - retriever = make_retriever(sconfigs,args.ar_data_file_path) + retriever = make_retriever(sconfigs, args.ar_data_file_path) for kernel_file in sconfigs.auxiliary.ordered_kernel_files: retriever.fetch(kernel_file) # check if the META_KERNEL file exists. If it doesn't exist, create it. if not os.path.exists(os.path.join(retriever.abspath, sconfigs.auxiliary.meta_kernel)): - build_meta_kernel_file(sconfigs,retriever) + build_meta_kernel_file(sconfigs, retriever) # try to get the META_KERNEL file. If it's not there, error out. try: @@ -182,11 +182,11 @@ def precompute_pointing_information(pointings_df, args, sconfigs): pointings_df : pandas dataframe The original dataframe with several additional columns of precomputed values. """ - ephem, _, _ = create_assist_ephemeris(args,sconfigs) + ephem, _, _ = create_assist_ephemeris(args, sconfigs) - furnish_spiceypy(args,sconfigs) + furnish_spiceypy(args, sconfigs) obsCode = sconfigs.simulation.ar_obs_code - observatories = Observatory(args,sconfigs) + observatories = Observatory(args, sconfigs) # vectorize the calculation to get x,y,z vector from ra/dec vectors = ra_dec2vec( diff --git a/src/sorcha/utilities/generate_meta_kernel.py b/src/sorcha/utilities/generate_meta_kernel.py index 4910499f..c67520a6 100644 --- a/src/sorcha/utilities/generate_meta_kernel.py +++ b/src/sorcha/utilities/generate_meta_kernel.py @@ -25,7 +25,7 @@ """ -def build_meta_kernel_file(sconfigs,retriever: pooch.Pooch) -> None: +def build_meta_kernel_file(sconfigs, retriever: pooch.Pooch) -> None: """Builds a specific text file that will be fed into `spiceypy` that defines the list of spice kernel to load, as well as the order to load them. diff --git a/src/sorcha/utilities/retrieve_ephemeris_data_files.py b/src/sorcha/utilities/retrieve_ephemeris_data_files.py index b3e06c4a..df306e2c 100644 --- a/src/sorcha/utilities/retrieve_ephemeris_data_files.py +++ b/src/sorcha/utilities/retrieve_ephemeris_data_files.py @@ -35,7 +35,7 @@ def _decompress(fname, action, pup): # pragma: no cover pooch.Decompress(method="auto", name=os.path.splitext(fname)[0]).__call__(fname, action, pup) -def _remove_files(sconfigs,retriever: pooch.Pooch) -> None: # pragma: no cover +def _remove_files(sconfigs, retriever: pooch.Pooch) -> None: # pragma: no cover """Utility to remove all the files tracked by the pooch retriever. This includes the decompressed ObservatoryCodes.json file as well as the META_KERNEL file that are created after downloading the files in the DATA_FILES_TO_DOWNLOAD diff --git a/src/sorcha_cmdline/bootstrap.py b/src/sorcha_cmdline/bootstrap.py index 9f6cf137..dbb527e5 100644 --- a/src/sorcha_cmdline/bootstrap.py +++ b/src/sorcha_cmdline/bootstrap.py @@ -48,16 +48,16 @@ def execute(args): import concurrent.futures from sorcha.utilities.sorchaConfigs import sorchaConfigs, auxiliaryConfigs - #default file names and urls (stored in auxiliaryConfigs) + # default file names and urls (stored in auxiliaryConfigs) default_files = sorchaConfigs() default_files.auxiliary = auxiliaryConfigs() # create the Pooch retriever that tracks and retrieves the requested files - retriever = make_retriever(default_files,args.cache) + retriever = make_retriever(default_files, args.cache) # determine if we should attempt to download or create any files. found_all_files = False if args.force: - _remove_files(default_files,retriever) + _remove_files(default_files, retriever) else: print("Checking cache for existing files.") found_all_files = _check_for_existing_files(retriever, default_files.auxiliary.data_file_list) @@ -71,7 +71,7 @@ def execute(args): executor.map(fetch_partial, default_files.auxiliary.data_files_to_download) # build the meta_kernel.txt file - build_meta_kernel_file(default_files,retriever) + build_meta_kernel_file(default_files, retriever) print("Checking cache after attempting to download and create files.") _check_for_existing_files(retriever, default_files.auxiliary.data_file_list) From d4cf4826e9e428a12440eba95d407db2e5f320b4 Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Thu, 5 Dec 2024 13:48:30 +0000 Subject: [PATCH 11/15] Update retrieve_ephemeris_data_files.py removed global variables being imported --- src/sorcha/utilities/retrieve_ephemeris_data_files.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/sorcha/utilities/retrieve_ephemeris_data_files.py b/src/sorcha/utilities/retrieve_ephemeris_data_files.py index df306e2c..9371dd9e 100644 --- a/src/sorcha/utilities/retrieve_ephemeris_data_files.py +++ b/src/sorcha/utilities/retrieve_ephemeris_data_files.py @@ -4,11 +4,7 @@ import pooch from functools import partial -from sorcha.ephemeris.simulation_data_files import ( - make_retriever, - DATA_FILES_TO_DOWNLOAD, - DATA_FILE_LIST, -) +from sorcha.ephemeris.simulation_data_files import make_retriever from sorcha.utilities.generate_meta_kernel import build_meta_kernel_file From 7e006bcc4aaba796bb64fb22d575eebc13a46b99 Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Thu, 12 Dec 2024 14:38:45 +0000 Subject: [PATCH 12/15] fixed typo --- src/sorcha/utilities/sorchaConfigs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sorcha/utilities/sorchaConfigs.py b/src/sorcha/utilities/sorchaConfigs.py index c8b78809..5730a71f 100644 --- a/src/sorcha/utilities/sorchaConfigs.py +++ b/src/sorcha/utilities/sorchaConfigs.py @@ -1016,7 +1016,7 @@ class sorchaConfigs: """expertConfigs dataclass which stores the keywords from the EXPERT section of the config file.""" auxiliary: auxiliaryConfigs = None - """auxiliaryConfigs dataclass which stores the keywords from the AUXILILARY section of the config file.""" + """auxiliaryConfigs dataclass which stores the keywords from the AUXILIARY section of the config file.""" pplogger: None = None """The Python logger instance""" From 331b122b95cc7a6ea794c47afc90a5ce03157743 Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Fri, 13 Dec 2024 14:21:10 +0000 Subject: [PATCH 13/15] Changed make_retriever to only take aux config attributes Changed make_retriever to only take aux config. Removed global variable in for class Observatory. --- src/sorcha/ephemeris/simulation_data_files.py | 10 +++++----- src/sorcha/ephemeris/simulation_parsing.py | 11 +++-------- src/sorcha/ephemeris/simulation_setup.py | 6 +++--- src/sorcha/utilities/generate_meta_kernel.py | 10 +++++----- .../utilities/retrieve_ephemeris_data_files.py | 8 ++++---- src/sorcha_cmdline/bootstrap.py | 12 ++++++------ 6 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/sorcha/ephemeris/simulation_data_files.py b/src/sorcha/ephemeris/simulation_data_files.py index 9bfc6a39..6184731c 100644 --- a/src/sorcha/ephemeris/simulation_data_files.py +++ b/src/sorcha/ephemeris/simulation_data_files.py @@ -1,7 +1,7 @@ import pooch -def make_retriever(sconfigs, directory_path: str = None) -> pooch.Pooch: +def make_retriever(auxconfigs, directory_path: str = None) -> pooch.Pooch: """Helper function that will create a Pooch object to track and retrieve files. Parameters @@ -11,8 +11,8 @@ def make_retriever(sconfigs, directory_path: str = None) -> pooch.Pooch: registry : dictionary, optional A dictionary of file names to SHA hashes. Generally we'll not use SHA=None because the files we're tracking change frequently. Default = REGISTRY - sconfigs: dataclass - Dataclass of configuration file arguments. + auxconfigs: dataclass + Dataclass of auxiliary configuration file arguments. Returns ------- : pooch @@ -25,7 +25,7 @@ def make_retriever(sconfigs, directory_path: str = None) -> pooch.Pooch: return pooch.create( path=dir_path, base_url="", - urls=sconfigs.auxiliary.urls, - registry=sconfigs.auxiliary.registry, + urls=auxconfigs.urls, + registry=auxconfigs.registry, retry_if_failed=25, ) diff --git a/src/sorcha/ephemeris/simulation_parsing.py b/src/sorcha/ephemeris/simulation_parsing.py index c3e229c2..930f0803 100644 --- a/src/sorcha/ephemeris/simulation_parsing.py +++ b/src/sorcha/ephemeris/simulation_parsing.py @@ -3,7 +3,6 @@ import numpy as np import spiceypy as spice from pooch import Decompress -from sorcha.utilities.sorchaConfigs import sorchaConfigs, auxiliaryConfigs from sorcha.ephemeris.simulation_constants import RADIUS_EARTH_KM from sorcha.ephemeris.simulation_geometry import ecliptic_to_equatorial from sorcha.ephemeris.simulation_data_files import make_retriever @@ -125,16 +124,12 @@ def parse_orbit_row(row, epochJD_TDB, ephem, sun_dict, gm_sun, gm_total): return tuple(np.concatenate([equatorial_coords, equatorial_velocities])) -default = sorchaConfigs() -default.auxiliary = auxiliaryConfigs() # using the default observatory_codes in the auxiliaryConfigs class - - class Observatory: """ Class containing various utility tools related to the calculation of the observatory position """ - def __init__(self, args, sconfigs, oc_file=default.auxiliary.observatory_codes): + def __init__(self, args, sconfigs, oc_file=None): """ Initialization method @@ -149,8 +144,8 @@ def __init__(self, args, sconfigs, oc_file=default.auxiliary.observatory_codes): """ self.observatoryPositionCache = {} # previously calculated positions to speed up the process - if oc_file == sconfigs.auxiliary.observatory_codes: - retriever = make_retriever(sconfigs, args.ar_data_file_path) + if oc_file == None: + retriever = make_retriever(sconfigs.auxiliary, args.ar_data_file_path) # is the file available locally, if so, return the full path if os.path.isfile(os.path.join(retriever.abspath, sconfigs.auxiliary.observatory_codes)): diff --git a/src/sorcha/ephemeris/simulation_setup.py b/src/sorcha/ephemeris/simulation_setup.py index 268325a6..d5522616 100644 --- a/src/sorcha/ephemeris/simulation_setup.py +++ b/src/sorcha/ephemeris/simulation_setup.py @@ -43,7 +43,7 @@ def create_assist_ephemeris(args, sconfigs) -> tuple: """ pplogger = logging.getLogger(__name__) - retriever = make_retriever(sconfigs, args.ar_data_file_path) + retriever = make_retriever(sconfigs.auxiliary, args.ar_data_file_path) planets_file_path = retriever.fetch(sconfigs.auxiliary.jpl_planets) small_bodies_file_path = retriever.fetch(sconfigs.auxiliary.jpl_small_bodies) ephem = Ephem(planets_path=planets_file_path, asteroids_path=small_bodies_file_path) @@ -69,14 +69,14 @@ def furnish_spiceypy(args, sconfigs): pplogger = logging.getLogger(__name__) - retriever = make_retriever(sconfigs, args.ar_data_file_path) + retriever = make_retriever(sconfigs.auxiliary, args.ar_data_file_path) for kernel_file in sconfigs.auxiliary.ordered_kernel_files: retriever.fetch(kernel_file) # check if the META_KERNEL file exists. If it doesn't exist, create it. if not os.path.exists(os.path.join(retriever.abspath, sconfigs.auxiliary.meta_kernel)): - build_meta_kernel_file(sconfigs, retriever) + build_meta_kernel_file(sconfigs.auxiliary, retriever) # try to get the META_KERNEL file. If it's not there, error out. try: diff --git a/src/sorcha/utilities/generate_meta_kernel.py b/src/sorcha/utilities/generate_meta_kernel.py index c67520a6..c38a92c4 100644 --- a/src/sorcha/utilities/generate_meta_kernel.py +++ b/src/sorcha/utilities/generate_meta_kernel.py @@ -25,7 +25,7 @@ """ -def build_meta_kernel_file(sconfigs, retriever: pooch.Pooch) -> None: +def build_meta_kernel_file(auxconfigs, retriever: pooch.Pooch) -> None: """Builds a specific text file that will be fed into `spiceypy` that defines the list of spice kernel to load, as well as the order to load them. @@ -33,14 +33,14 @@ def build_meta_kernel_file(sconfigs, retriever: pooch.Pooch) -> None: ---------- retriever : pooch Pooch object that maintains the registry of files to download - sconfigs: dataclass - Dataclass of configuration file arguments. + auxconfigs: dataclass + Dataclass of auxiliary configuration file arguments. Returns --------- None """ # build meta_kernel file path - meta_kernel_file_path = os.path.join(retriever.abspath, sconfigs.auxiliary.meta_kernel) + meta_kernel_file_path = os.path.join(retriever.abspath, auxconfigs.meta_kernel) # build a meta_kernel.txt file with open(meta_kernel_file_path, "w") as meta_file: @@ -48,7 +48,7 @@ def build_meta_kernel_file(sconfigs, retriever: pooch.Pooch) -> None: meta_file.write(f"PATH_VALUES = ('{retriever.abspath}')\n\n") meta_file.write("PATH_SYMBOLS = ('A')\n\n") meta_file.write("KERNELS_TO_LOAD=(\n") - for file_name in sconfigs.auxiliary.ordered_kernel_files: + for file_name in auxconfigs.ordered_kernel_files: shortened_file_name = _build_file_name(retriever.abspath, retriever.fetch(file_name)) meta_file.write(f" '{shortened_file_name}',\n") meta_file.write(")\n\n") diff --git a/src/sorcha/utilities/retrieve_ephemeris_data_files.py b/src/sorcha/utilities/retrieve_ephemeris_data_files.py index 9371dd9e..9696c0d5 100644 --- a/src/sorcha/utilities/retrieve_ephemeris_data_files.py +++ b/src/sorcha/utilities/retrieve_ephemeris_data_files.py @@ -31,7 +31,7 @@ def _decompress(fname, action, pup): # pragma: no cover pooch.Decompress(method="auto", name=os.path.splitext(fname)[0]).__call__(fname, action, pup) -def _remove_files(sconfigs, retriever: pooch.Pooch) -> None: # pragma: no cover +def _remove_files(auxconfigs, retriever: pooch.Pooch) -> None: # pragma: no cover """Utility to remove all the files tracked by the pooch retriever. This includes the decompressed ObservatoryCodes.json file as well as the META_KERNEL file that are created after downloading the files in the DATA_FILES_TO_DOWNLOAD @@ -41,11 +41,11 @@ def _remove_files(sconfigs, retriever: pooch.Pooch) -> None: # pragma: no cover ------------ retriever : pooch Pooch object that maintains the registry of files to download. - sconfigs: dataclass - Dataclass of configuration file arguments. + auxconfigs: dataclass + Dataclass of auxiliary configuration file arguments. """ - for file_name in sconfigs.auxiliary.data_file_list: + for file_name in auxconfigs.data_file_list: file_path = retriever.fetch(file_name) print(f"Deleting file: {file_path}") os.remove(file_path) diff --git a/src/sorcha_cmdline/bootstrap.py b/src/sorcha_cmdline/bootstrap.py index b3545b7c..6a127d81 100644 --- a/src/sorcha_cmdline/bootstrap.py +++ b/src/sorcha_cmdline/bootstrap.py @@ -48,11 +48,11 @@ def execute(args): ) from functools import partial import concurrent.futures - from sorcha.utilities.sorchaConfigs import sorchaConfigs, auxiliaryConfigs + from sorcha.utilities.sorchaConfigs import auxiliaryConfigs # default file names and urls (stored in auxiliaryConfigs) - default_files = sorchaConfigs() - default_files.auxiliary = auxiliaryConfigs() + + default_files = auxiliaryConfigs() # create the Pooch retriever that tracks and retrieves the requested files retriever = make_retriever(default_files, args.cache) @@ -62,7 +62,7 @@ def execute(args): _remove_files(default_files, retriever) else: print("Checking cache for existing files.") - found_all_files = _check_for_existing_files(retriever, default_files.auxiliary.data_file_list) + found_all_files = _check_for_existing_files(retriever, default_files.data_file_list) if not found_all_files: # create a partial function of `Pooch.fetch` including the `_decompress` method @@ -70,13 +70,13 @@ def execute(args): # download the data files in parallel with concurrent.futures.ThreadPoolExecutor() as executor: - executor.map(fetch_partial, default_files.auxiliary.data_files_to_download) + executor.map(fetch_partial, default_files.data_files_to_download) # build the meta_kernel.txt file build_meta_kernel_file(default_files, retriever) print("Checking cache after attempting to download and create files.") - _check_for_existing_files(retriever, default_files.auxiliary.data_file_list) + _check_for_existing_files(retriever, default_files.data_file_list) if __name__ == "__main__": From c1d880d6637540f72edb46c536d2f9adb98aed79 Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Fri, 13 Dec 2024 16:25:35 +0000 Subject: [PATCH 14/15] Changed Observatory class to only get aux data class --- src/sorcha/ephemeris/simulation_driver.py | 2 +- src/sorcha/ephemeris/simulation_parsing.py | 14 +++++++------- src/sorcha/ephemeris/simulation_setup.py | 2 +- tests/ephemeris/test_pixdict.py | 2 +- tests/ephemeris/test_simulation_parsing.py | 10 ++++------ 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/sorcha/ephemeris/simulation_driver.py b/src/sorcha/ephemeris/simulation_driver.py index a008798c..39f1ab8c 100644 --- a/src/sorcha/ephemeris/simulation_driver.py +++ b/src/sorcha/ephemeris/simulation_driver.py @@ -122,7 +122,7 @@ def create_ephemeris(orbits_df, pointings_df, args, sconfigs): verboselog("Generating ASSIST+REBOUND simulations.") sim_dict = generate_simulations(ephem, gm_sun, gm_total, orbits_df, args) pixel_dict = defaultdict(list) - observatories = Observatory(args, sconfigs) + observatories = Observatory(args, sconfigs.auxiliary) output = StringIO() in_memory_csv = writer(output) diff --git a/src/sorcha/ephemeris/simulation_parsing.py b/src/sorcha/ephemeris/simulation_parsing.py index 930f0803..d09890f8 100644 --- a/src/sorcha/ephemeris/simulation_parsing.py +++ b/src/sorcha/ephemeris/simulation_parsing.py @@ -129,7 +129,7 @@ class Observatory: Class containing various utility tools related to the calculation of the observatory position """ - def __init__(self, args, sconfigs, oc_file=None): + def __init__(self, args, auxconfigs, oc_file=None): """ Initialization method @@ -137,7 +137,7 @@ def __init__(self, args, sconfigs, oc_file=None): ---------- args : dictionary or `sorchaArguments` object dictionary of command-line arguments. - sconfigs: dataclass + auxconfigs: dataclass Dataclass of configuration file arguments. oc_file : str Path for the file with observatory codes @@ -145,17 +145,17 @@ def __init__(self, args, sconfigs, oc_file=None): self.observatoryPositionCache = {} # previously calculated positions to speed up the process if oc_file == None: - retriever = make_retriever(sconfigs.auxiliary, args.ar_data_file_path) + retriever = make_retriever(auxconfigs, args.ar_data_file_path) # is the file available locally, if so, return the full path - if os.path.isfile(os.path.join(retriever.abspath, sconfigs.auxiliary.observatory_codes)): - obs_file_path = retriever.fetch(sconfigs.auxiliary.observatory_codes) + if os.path.isfile(os.path.join(retriever.abspath, auxconfigs.observatory_codes)): + obs_file_path = retriever.fetch(auxconfigs.observatory_codes) # if the file is not local, download, and decompress it, then return the path. else: obs_file_path = retriever.fetch( - sconfigs.auxiliary.observatory_codes_compressed, - processor=Decompress(name=sconfigs.auxiliary.observatory_codes), + auxconfigs.observatory_codes_compressed, + processor=Decompress(name=auxconfigs.observatory_codes), ) else: diff --git a/src/sorcha/ephemeris/simulation_setup.py b/src/sorcha/ephemeris/simulation_setup.py index d5522616..e825c869 100644 --- a/src/sorcha/ephemeris/simulation_setup.py +++ b/src/sorcha/ephemeris/simulation_setup.py @@ -186,7 +186,7 @@ def precompute_pointing_information(pointings_df, args, sconfigs): furnish_spiceypy(args, sconfigs) obsCode = sconfigs.simulation.ar_obs_code - observatories = Observatory(args, sconfigs) + observatories = Observatory(args, sconfigs.auxiliary) # vectorize the calculation to get x,y,z vector from ra/dec vectors = ra_dec2vec( diff --git a/tests/ephemeris/test_pixdict.py b/tests/ephemeris/test_pixdict.py index 59765441..4c404efb 100644 --- a/tests/ephemeris/test_pixdict.py +++ b/tests/ephemeris/test_pixdict.py @@ -84,7 +84,7 @@ def test_pixeldict(tmp_path): furnish_spiceypy(args,configs) sim_dict = generate_simulations(ephem, gm_sun, gm_total, orbits_df, args) - observatory = Observatory(sconfigs=configs,args=None, oc_file=get_test_filepath("ObsCodes_test.json")) + observatory = Observatory(auxconfigs=configs.auxiliary,args=None, oc_file=get_test_filepath("ObsCodes_test.json")) pixdict = PixelDict(54800.0 + 2400000.5, sim_dict, ephem, "Z20", observatory, picket_interval=1, nside=32) diff --git a/tests/ephemeris/test_simulation_parsing.py b/tests/ephemeris/test_simulation_parsing.py index 4d6988f6..a136e784 100644 --- a/tests/ephemeris/test_simulation_parsing.py +++ b/tests/ephemeris/test_simulation_parsing.py @@ -5,9 +5,8 @@ from sorcha.utilities.sorchaConfigs import sorchaConfigs, auxiliaryConfigs def test_observatory_compared_to_original(): - sconfigs = sorchaConfigs() - sconfigs.auxiliary = auxiliaryConfigs() - observatory = sp.Observatory(sconfigs=sconfigs,args=None, oc_file=get_test_filepath("ObsCodes_test.json")) + auxconfigs = auxiliaryConfigs() + observatory = sp.Observatory(auxconfigs=auxconfigs,args=None, oc_file=get_test_filepath("ObsCodes_test.json")) obs = observatory.ObservatoryXYZ # Reference tuples were taken from Matt Holman's original notebook @@ -19,9 +18,8 @@ def test_observatory_compared_to_original(): def test_observatory_for_moving_observatories(): - sconfigs = sorchaConfigs() - sconfigs.auxiliary = auxiliaryConfigs() - observatory = sp.Observatory(sconfigs=sconfigs,args=None, oc_file=get_test_filepath("ObsCodes_test.json")) + auxconfigs = auxiliaryConfigs() + observatory = sp.Observatory(auxconfigs=auxconfigs,args=None, oc_file=get_test_filepath("ObsCodes_test.json")) obs = observatory.ObservatoryXYZ assert obs["250"] == (None, None, None) From 914398b1267de86b5f3e19b30c82e646d7a0f029 Mon Sep 17 00:00:00 2001 From: Ryan Lyttle Date: Fri, 13 Dec 2024 16:55:31 +0000 Subject: [PATCH 15/15] Changed more functions to only get aux data class changed functions create_assist_ephemeris and furnish_spiceypy to only get the aux data class. Also added comment in bootstrap.py on how to download new files --- src/sorcha/ephemeris/simulation_driver.py | 4 +-- src/sorcha/ephemeris/simulation_setup.py | 32 +++++++++++------------ src/sorcha_cmdline/bootstrap.py | 3 ++- tests/ephemeris/test_pixdict.py | 4 +-- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/sorcha/ephemeris/simulation_driver.py b/src/sorcha/ephemeris/simulation_driver.py index 39f1ab8c..e3846efe 100644 --- a/src/sorcha/ephemeris/simulation_driver.py +++ b/src/sorcha/ephemeris/simulation_driver.py @@ -116,9 +116,9 @@ def create_ephemeris(orbits_df, pointings_df, args, sconfigs): ephemeris_csv_filename = os.path.join(args.outpath, args.output_ephemeris_file) verboselog("Building ASSIST ephemeris object.") - ephem, gm_sun, gm_total = create_assist_ephemeris(args, sconfigs) + ephem, gm_sun, gm_total = create_assist_ephemeris(args, sconfigs.auxiliary) verboselog("Furnishing SPICE kernels.") - furnish_spiceypy(args, sconfigs) + furnish_spiceypy(args, sconfigs.auxiliary) verboselog("Generating ASSIST+REBOUND simulations.") sim_dict = generate_simulations(ephem, gm_sun, gm_total, orbits_df, args) pixel_dict = defaultdict(list) diff --git a/src/sorcha/ephemeris/simulation_setup.py b/src/sorcha/ephemeris/simulation_setup.py index e825c869..6a75d396 100644 --- a/src/sorcha/ephemeris/simulation_setup.py +++ b/src/sorcha/ephemeris/simulation_setup.py @@ -26,12 +26,12 @@ from sorcha.utilities.generate_meta_kernel import build_meta_kernel_file -def create_assist_ephemeris(args, sconfigs) -> tuple: +def create_assist_ephemeris(args, auxconfigs) -> tuple: """Build the ASSIST ephemeris object Parameter --------- - sconfigs: dataclass - Dataclass of configuration file arguments. + auxconfigs: dataclass + Dataclass of auxiliary configuration file arguments. Returns --------- Ephem : ASSIST ephemeris obejct @@ -43,9 +43,9 @@ def create_assist_ephemeris(args, sconfigs) -> tuple: """ pplogger = logging.getLogger(__name__) - retriever = make_retriever(sconfigs.auxiliary, args.ar_data_file_path) - planets_file_path = retriever.fetch(sconfigs.auxiliary.jpl_planets) - small_bodies_file_path = retriever.fetch(sconfigs.auxiliary.jpl_small_bodies) + retriever = make_retriever(auxconfigs, args.ar_data_file_path) + planets_file_path = retriever.fetch(auxconfigs.jpl_planets) + small_bodies_file_path = retriever.fetch(auxconfigs.jpl_small_bodies) ephem = Ephem(planets_path=planets_file_path, asteroids_path=small_bodies_file_path) gm_sun = ephem.get_particle("Sun", 0).m gm_total = sum(sorted([ephem.get_particle(i, 0).m for i in range(27)])) @@ -56,31 +56,31 @@ def create_assist_ephemeris(args, sconfigs) -> tuple: return ephem, gm_sun, gm_total -def furnish_spiceypy(args, sconfigs): +def furnish_spiceypy(args, auxconfigs): """ Builds the SPICE kernel, downloading the required files if needed Parameters ----------- - sconfigs: dataclass - Dataclass of configuration file arguments. + auxconfigs: dataclass + Dataclass of auxiliary configuration file arguments. """ # The goal here would be to download the spice kernel files (if needed) # Then call spice.furnish() on each of those files. pplogger = logging.getLogger(__name__) - retriever = make_retriever(sconfigs.auxiliary, args.ar_data_file_path) + retriever = make_retriever(auxconfigs, args.ar_data_file_path) - for kernel_file in sconfigs.auxiliary.ordered_kernel_files: + for kernel_file in auxconfigs.ordered_kernel_files: retriever.fetch(kernel_file) # check if the META_KERNEL file exists. If it doesn't exist, create it. - if not os.path.exists(os.path.join(retriever.abspath, sconfigs.auxiliary.meta_kernel)): - build_meta_kernel_file(sconfigs.auxiliary, retriever) + if not os.path.exists(os.path.join(retriever.abspath, auxconfigs.meta_kernel)): + build_meta_kernel_file(auxconfigs, retriever) # try to get the META_KERNEL file. If it's not there, error out. try: - meta_kernel = retriever.fetch(sconfigs.auxiliary.meta_kernel) + meta_kernel = retriever.fetch(auxconfigs.meta_kernel) except ValueError: pplogger.error( "ERROR: furnish_spiceypy: Must create meta_kernel.txt by running `bootstrap_sorcha_data_files` on the command line." @@ -182,9 +182,9 @@ def precompute_pointing_information(pointings_df, args, sconfigs): pointings_df : pandas dataframe The original dataframe with several additional columns of precomputed values. """ - ephem, _, _ = create_assist_ephemeris(args, sconfigs) + ephem, _, _ = create_assist_ephemeris(args, sconfigs.auxiliary) - furnish_spiceypy(args, sconfigs) + furnish_spiceypy(args, sconfigs.auxiliary) obsCode = sconfigs.simulation.ar_obs_code observatories = Observatory(args, sconfigs.auxiliary) diff --git a/src/sorcha_cmdline/bootstrap.py b/src/sorcha_cmdline/bootstrap.py index 6a127d81..0a566140 100644 --- a/src/sorcha_cmdline/bootstrap.py +++ b/src/sorcha_cmdline/bootstrap.py @@ -50,7 +50,8 @@ def execute(args): import concurrent.futures from sorcha.utilities.sorchaConfigs import auxiliaryConfigs - # default file names and urls (stored in auxiliaryConfigs) + # Bootstrap will always take the default filenames and urls (stored in auxiliaryConfigs) for the current version of sorcha. + # A user can download new files by running sorcha and specifying in the config file under the section [AUXILIARY] a new filename and url. default_files = auxiliaryConfigs() # create the Pooch retriever that tracks and retrieves the requested files diff --git a/tests/ephemeris/test_pixdict.py b/tests/ephemeris/test_pixdict.py index 4c404efb..83026838 100644 --- a/tests/ephemeris/test_pixdict.py +++ b/tests/ephemeris/test_pixdict.py @@ -80,8 +80,8 @@ def test_pixeldict(tmp_path): filterpointing = precompute_pointing_information(filterpointing, args, configs) args = sorchaArguments(cmd_args_dict) - ephem, gm_sun, gm_total = create_assist_ephemeris(args,configs) - furnish_spiceypy(args,configs) + ephem, gm_sun, gm_total = create_assist_ephemeris(args,configs.auxiliary) + furnish_spiceypy(args,configs.auxiliary) sim_dict = generate_simulations(ephem, gm_sun, gm_total, orbits_df, args) observatory = Observatory(auxconfigs=configs.auxiliary,args=None, oc_file=get_test_filepath("ObsCodes_test.json"))