From fcd34d54dd651066381ccfa8bd5179ff7b4bca39 Mon Sep 17 00:00:00 2001 From: Alex Alvarez Toledo Date: Tue, 2 Jan 2024 12:24:52 -0300 Subject: [PATCH] changes to step --- magstats_step/magstats_step/core/magstats.py | 2 +- magstats_step/magstats_step/core/objstats.py | 4 ++-- magstats_step/magstats_step/step.py | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/magstats_step/magstats_step/core/magstats.py b/magstats_step/magstats_step/core/magstats.py index db960c305..e66bc1508 100644 --- a/magstats_step/magstats_step/core/magstats.py +++ b/magstats_step/magstats_step/core/magstats.py @@ -7,7 +7,7 @@ class MagnitudeStatistics(BaseStatistics): - _JOIN = ["aid", "sid", "fid"] + _JOIN = ["oid", "sid", "fid"] # Saturation threshold for each survey (only applies to corrected magnitudes) _THRESHOLD = {"ZTF": 13.2} diff --git a/magstats_step/magstats_step/core/objstats.py b/magstats_step/magstats_step/core/objstats.py index d021e7666..be96da0c8 100644 --- a/magstats_step/magstats_step/core/objstats.py +++ b/magstats_step/magstats_step/core/objstats.py @@ -7,7 +7,7 @@ class ObjectStatistics(BaseStatistics): - _JOIN = "aid" + _JOIN = "oid" def __init__(self, detections: List[dict]): super().__init__(detections) @@ -47,7 +47,7 @@ def average(series): # Needs wrapper to use the sigmas in the agg call return self._weighted_mean(series, sigmas.loc[series.index]) sigmas = self._arcsec2deg(self._detections[f"e_{label}"]) - grouped_sigmas = self._group(sigmas.set_axis(self._detections["aid"])) + grouped_sigmas = self._group(sigmas.set_axis(self._detections["oid"])) return pd.DataFrame( { f"mean{label}": self._grouped_detections()[label].agg(average), diff --git a/magstats_step/magstats_step/step.py b/magstats_step/magstats_step/step.py index 9ff9431be..752d495fb 100644 --- a/magstats_step/magstats_step/step.py +++ b/magstats_step/magstats_step/step.py @@ -35,12 +35,12 @@ def _execute(self, messages: dict): magstats = magstats_calculator.generate_statistics( self.excluded ).reset_index() - magstats = magstats.set_index("aid").replace({np.nan: None}) - for aid in stats: + magstats = magstats.set_index("oid").replace({np.nan: None}) + for oid in stats: try: - stats[aid]["magstats"] = magstats.loc[aid].to_dict("records") + stats[oid]["magstats"] = magstats.loc[oid].to_dict("records") except TypeError: - stats[aid]["magstats"] = [magstats.loc[aid].to_dict()] + stats[oid]["magstats"] = [magstats.loc[oid].to_dict()] return stats @@ -63,12 +63,12 @@ def _execute_ztf(self, messages: dict): magstats = magstats_calculator.generate_statistics( self.excluded ).reset_index() - magstats = magstats.set_index("aid").replace({np.nan: None}) - for aid in stats: + magstats = magstats.set_index("oid").replace({np.nan: None}) + for oid in stats: try: - stats[aid]["magstats"] = magstats.loc[aid].to_dict("records") + stats[oid]["magstats"] = magstats.loc[oid].to_dict("records") except TypeError: - stats[aid]["magstats"] = [magstats.loc[aid].to_dict()] + stats[oid]["magstats"] = [magstats.loc[oid].to_dict()] return stats @@ -80,11 +80,11 @@ def execute(self, messages: dict): # it seems that we'll have to produce different commands in this def produce_scribe(self, result: dict): - for aid, stats in result.items(): + for oid, stats in result.items(): command = { "collection": "object", "type": "update", - "criteria": {"_id": aid}, + "criteria": {"oid": oid}, "data": stats | { "loc": {