From e064fe9a2da0f9972bc491332aa340b7e2181aff Mon Sep 17 00:00:00 2001 From: Adrien Thob Date: Thu, 30 Nov 2023 13:21:46 -0500 Subject: [PATCH] Hox fix fixing issue with error models driver and with extinction driver --- py-Galaxia-ananke | 2 +- src/ananke/ErrorModelDriver.py | 2 +- src/ananke/ExtinctionDriver.py | 13 +++++++++++-- src/ananke/__metadata__.py | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/py-Galaxia-ananke b/py-Galaxia-ananke index bf7d338..7c3836c 160000 --- a/py-Galaxia-ananke +++ b/py-Galaxia-ananke @@ -1 +1 @@ -Subproject commit bf7d33806e177f09848b6702d121ebb55e153306 +Subproject commit 7c3836cc80f095e28871c7c5881214a99ef5807e diff --git a/src/ananke/ErrorModelDriver.py b/src/ananke/ErrorModelDriver.py index 517f330..ee99e43 100644 --- a/src/ananke/ErrorModelDriver.py +++ b/src/ananke/ErrorModelDriver.py @@ -80,7 +80,7 @@ def _test_error_model(self): dummy_err = self._expand_and_apply_error_model(dummy_df) except KeyError as KE: raise KE # TODO make it more informative - utils.compare_given_and_required(dummy_err.keys(), self.ananke.galaxia_catalogue_mag_and_astrometrics, set(self.ananke.galaxia_catalogue_keys)-set(self.ananke.galaxia_catalogue_mag_and_astrometrics), error_message="Given error model function returns wrong set of keys") + utils.compare_given_and_required(dummy_err.keys(), set(), self.ananke.galaxia_catalogue_mag_and_astrometrics, error_message="Given error model function returns wrong set of keys") @property def _sigma_keys(self): diff --git a/src/ananke/ExtinctionDriver.py b/src/ananke/ExtinctionDriver.py index 00ed0aa..fd61a25 100644 --- a/src/ananke/ExtinctionDriver.py +++ b/src/ananke/ExtinctionDriver.py @@ -137,7 +137,16 @@ def _expand_and_apply_extinction_coeff(self, df, A0): extinction_coeff = self.extinction_coeff if not isinstance(extinction_coeff, Iterable): extinction_coeff = [extinction_coeff] - return {key: A0 * coeff for coeff_dict in [(ext_coeff(df) if callable(ext_coeff) else ext_coeff) for ext_coeff in extinction_coeff] for key,coeff in coeff_dict.items()} # TODO adapt to dataframe type of output? + return { + key: (coeff * A0.to_numpy() + if isinstance(coeff, np.ndarray) + else coeff * A0) # TODO temporary fix while waiting issue https://github.com/vaexio/vaex/issues/2405 to be fixed + for coeff_dict in [ + (ext_coeff(df) if callable(ext_coeff) else ext_coeff) + for ext_coeff in extinction_coeff + ] + for key,coeff in coeff_dict.items() + } # TODO adapt to dataframe type of output? def _test_extinction_coeff(self): dummy_df = utils.RecordingDataFrame([], columns = self.ananke.galaxia_catalogue_keys + self._extra_output_keys) # TODO make use of dummy_df.record_of_all_used_keys @@ -159,7 +168,7 @@ def extinctions(self): # assign the column of the extinction values for filter mag_name in the final catalogue output self.galaxia_output[self._extinction_template(mag_name)] = extinction # add the extinction value to the existing photometric magnitude for filter mag_name - self.galaxia_output[mag_name] += extinction + self.galaxia_output[mag_name] += self.galaxia_output[self._extinction_template(mag_name)] self.galaxia_output.flush_extra_columns_to_hdf5(with_columns=self.ananke.galaxia_catalogue_mag_names) return self.galaxia_output[list(self._extinction_keys)] diff --git a/src/ananke/__metadata__.py b/src/ananke/__metadata__.py index 90833b7..7b7bec9 100644 --- a/src/ananke/__metadata__.py +++ b/src/ananke/__metadata__.py @@ -8,7 +8,7 @@ __copyright__ = None __credits__ = ["Adrien Thob", "Robyn Sanderson", "Andrew Eden"] __license__ = "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)" -__version__ = "0.1.0b1" +__version__ = "0.1.1.dev1" __maintainer__ = "Adrien Thob" __email__ = "athob@sas.upenn.edu" __url__ = "https://github.com/athob/py-ananke"