Skip to content

Commit

Permalink
refactor jdhist to jdref
Browse files Browse the repository at this point in the history
  • Loading branch information
AlxEnashi committed Jun 24, 2024
1 parent b1d9ee6 commit 6bbd8f7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion magstats_step/magstats_step/core/objstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def calculate_reference_change(self) -> pd.DataFrame:
return pd.DataFrame(
{
"reference_change": self._grouped_value(
"mjdendhist", which="last"
"mjdendref", which="last"
)
> self._grouped_value("mjd", which="first")
}
Expand Down
10 changes: 5 additions & 5 deletions magstats_step/magstats_step/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ def __init__(
def pre_execute(cls, messages: List[dict]) -> dict:
detections, non_detections = [], []
for msg in messages:
# code to add mjdendhist to detections fields from extra fields
# code to add mjdendref to detections fields from extra fields
for det in msg["detections"]:
jdendhist = det["extra_fields"].get("jdendhist", None)
if jdendhist:
det["mjdendhist"] = jdendhist - 2400000.5
jdendref = det["extra_fields"].get("jdendref", None)
if jdendref:
det["mjdendref"] = jdendref - 2400000.5
detections.extend(msg["detections"])
non_detections.extend(msg["non_detections"])
return {"detections": detections, "non_detections": non_detections}
return {"detections": detections, "non_detections": non_detections}

def _calculate_object_statistics(self, detections) -> dict:
obj_calculator = ObjectStatistics(detections)
Expand Down
2 changes: 1 addition & 1 deletion magstats_step/tests/unittests/data/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
detection["oid"] = oid
detection["sid"] = sid
detection["fid"] = fid
detection["extra_fields"] = {"jdendhist": 80000}
detection["extra_fields"] = {"jdendref": 80000}

for non_detection in d["non_detections"]:
non_detection["oid"] = oid
Expand Down
8 changes: 4 additions & 4 deletions magstats_step/tests/unittests/test_objstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def test_generate_stats():
"e_dec": 1,
"dec": 10,
"isdiffpos": 1,
"mjdendhist": 60470.5,
"mjdendref": 60470.5,
},
{
"oid": "OID1",
Expand All @@ -516,7 +516,7 @@ def test_generate_stats():
"e_dec": 1,
"dec": 10,
"isdiffpos": 1,
"mjdendhist": 60470.5,
"mjdendref": 60470.5,
},
{
"oid": "OID2",
Expand All @@ -532,7 +532,7 @@ def test_generate_stats():
"e_dec": 1,
"dec": 10,
"isdiffpos": 1,
"mjdendhist": 60470.5,
"mjdendref": 60470.5,
},
{
"oid": "OID1",
Expand All @@ -548,7 +548,7 @@ def test_generate_stats():
"e_dec": 1,
"dec": 10,
"isdiffpos": 1,
"mjdendhist": 60470.5,
"mjdendref": 60470.5,
},
]
calculator = ObjectStatistics(detections)
Expand Down

0 comments on commit 6bbd8f7

Please sign in to comment.