Skip to content

Commit

Permalink
Hox fix fixing issue with error models driver and with extinction driver
Browse files Browse the repository at this point in the history
  • Loading branch information
athob committed Nov 30, 2023
1 parent a36c210 commit e064fe9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion py-Galaxia-ananke
2 changes: 1 addition & 1 deletion src/ananke/ErrorModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 11 additions & 2 deletions src/ananke/ExtinctionDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)]

Expand Down
2 changes: 1 addition & 1 deletion src/ananke/__metadata__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e064fe9

Please sign in to comment.