Skip to content

Commit

Permalink
Fix bug with comet designation name (#684)
Browse files Browse the repository at this point in the history
* Fix bug with comet designation name

* PEP8

* PEP8
  • Loading branch information
JulienPeloton authored Oct 24, 2024
1 parent 7fc3e74 commit cec6f57
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
15 changes: 14 additions & 1 deletion apps/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,20 @@ def return_sso_pdf(payload: dict) -> pd.DataFrame:
ssnamenr_to_sso_name = {}
ssnamenr_to_sso_number = {}
for id_ in ids:
if id_.startswith("C/") or id_.endswith("P"):
if id_.startswith("C/"):
start = id_[0:6]
stop = id_[6:]
r = requests.get(
"https://api.ssodnet.imcce.fr/quaero/1/sso?q={} {}&type=Comet".format(
start, stop
)
)
if r.status_code == 200 and r.json() != []:
sso_name = r.json()["data"][0]["name"]
else:
sso_name = id_
sso_number = None
elif id_.endswith("P"):
sso_name = id_
sso_number = None
else:
Expand Down
10 changes: 5 additions & 5 deletions apps/sso/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_sso_data(ssnamenr):
if data.id_ == "":
if ssnamenr.startswith("C/"):
kind = "comet"
ssnamenr = ssnamenr[:-2] + " " + ssnamenr[-2:]
ssnamenr = ssnamenr[0:6] + " " + ssnamenr[6:]
data = query_mpc(ssnamenr, kind=kind)
elif ssnamenr[-1] == "P":
kind = "comet"
Expand All @@ -56,7 +56,7 @@ def get_sso_data(ssnamenr):
return data, None


def card_sso_left(ssnamenr):
def card_sso_left(ssnamenr, sso_name):
""" """
ssnamenr_ = str(ssnamenr)

Expand Down Expand Up @@ -241,7 +241,7 @@ def card_sso_left(ssnamenr):
outline=True,
id="MPC",
target="_blank",
href=f"https://minorplanetcenter.net/db_search/show_object?utf8=%E2%9C%93&object_id={ssnamenr_}",
href=f"https://minorplanetcenter.net/db_search/show_object?utf8=%E2%9C%93&object_id={sso_name}",
),
width=4,
),
Expand All @@ -256,7 +256,7 @@ def card_sso_left(ssnamenr):
outline=True,
id="JPL",
target="_blank",
href=f"https://ssd.jpl.nasa.gov/tools/sbdb_lookup.html#/?sstr={ssnamenr_}",
href=f"https://ssd.jpl.nasa.gov/tools/sbdb_lookup.html#/?sstr={sso_name}",
),
width=4,
),
Expand Down Expand Up @@ -537,11 +537,11 @@ def card_sso_rocks_params(data):
Orbital period (day): `{data.parameters.dynamical.orbital_elements.orbital_period.value}`
Jupiter Tisserand parameter: `{data.parameters.dynamical.tisserand_parameters.jupiter.value}`
"""
text = textwrap.dedent(text) # Remove indentation

if (data.parameters.physical.spin is not None) and (
data.parameters.physical.spin != []
):
text = textwrap.dedent(text) # Remove indentation
text += "\n"
text += "###### Spin parameters\n"

Expand Down
4 changes: 3 additions & 1 deletion apps/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,10 @@ def tab5_content(object_soo):
pdf = pd.read_json(object_soo)
if pdf.empty:
ssnamenr = "null"
sso_name = "null"
else:
ssnamenr = pdf["i:ssnamenr"].to_numpy()[0]
sso_name = pdf["sso_name"].to_numpy()[0]

msg = """
Alert data from ZTF (filled circle) in g (blue) and r (orange) filters, with ephemerides provided by the
Expand Down Expand Up @@ -449,7 +451,7 @@ def tab5_content(object_soo):
),
dbc.Col(
[
card_sso_left(ssnamenr),
card_sso_left(ssnamenr, sso_name),
],
md=4,
),
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ Werkzeug==3.0.1
wrapt==1.16.0
yarl==1.9.4
zipp==3.17.0
git+https://github.com/astrolabsoftware/fink-science@5.17.4
git+https://github.com/astrolabsoftware/fink-science@5.21.1

0 comments on commit cec6f57

Please sign in to comment.