Skip to content

Commit

Permalink
Adding JSON constructor methods. (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
astronomerritt authored and jrob93 committed Sep 24, 2024
1 parent 48c2444 commit 6d5b6bb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/adler/dataclasses/Observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,19 @@ def construct_from_dictionary(cls, ssObjectId, filter_name, data_dict):

return cls(**obs_dict)

@classmethod
def construct_from_dictionary(cls, ssObjectId, filter_name, data_dict):
obs_dict = {"ssObjectId": ssObjectId, "filter_name": filter_name, "num_obs": 1}

for obs_key, obs_type in OBSERVATIONS_KEYS.items():
obs_dict[obs_key] = get_from_dictionary(data_dict, obs_key, obs_type, "SSSource/DIASource")

obs_dict["reduced_mag"] = cls.calculate_reduced_mag(
cls, obs_dict["mag"], obs_dict["topocentricDist"], obs_dict["heliocentricDist"]
)

return cls(**obs_dict)

def calculate_reduced_mag(self, mag, topocentric_dist, heliocentric_dist):
"""
Calculates the reduced magnitude column.
Expand Down

0 comments on commit 6d5b6bb

Please sign in to comment.