Skip to content

Commit

Permalink
changes to step
Browse files Browse the repository at this point in the history
  • Loading branch information
AlxEnashi committed Jan 2, 2024
1 parent 58a3617 commit fcd34d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion magstats_step/magstats_step/core/magstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
4 changes: 2 additions & 2 deletions magstats_step/magstats_step/core/objstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class ObjectStatistics(BaseStatistics):
_JOIN = "aid"
_JOIN = "oid"

def __init__(self, detections: List[dict]):
super().__init__(detections)
Expand Down Expand Up @@ -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),
Expand Down
20 changes: 10 additions & 10 deletions magstats_step/magstats_step/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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": {
Expand Down

0 comments on commit fcd34d5

Please sign in to comment.