-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose residuals from the SSO API (sHG1G2 model) (#666)
* Expose residuals from the SSO API (sHG1G2 model) * Update documentation * PEP8 * Rewrite the logic for SSO * Fix syntax * Propage names * Rewrite the logic * Return empty structure if the status code is not 200. Closes #667 * Restore comet query * PEP8 * Fix comet search * Better error handling * Avoid overwriting sso_name and sso_number * Expand the test suite * PEP8
- Loading branch information
1 parent
9e22992
commit 95c1c33
Showing
8 changed files
with
288 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright 2024 AstroLab Software | ||
# Author: Julien Peloton | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
import requests | ||
|
||
import numpy as np | ||
import rocks | ||
|
||
|
||
def resolve_sso_name_to_ssnamenr(sso_name): | ||
"""Find corresponding ZTF ssnamenr from user input | ||
Parameters | ||
---------- | ||
sso_name: str | ||
SSO name or number | ||
Returns | ||
------- | ||
out: list of str | ||
List of corresponding ZTF ssnamenr | ||
""" | ||
# search all ssnamenr corresponding quaero -> ssnamenr | ||
r = requests.post( | ||
"https://fink-portal.org/api/v1/resolver", | ||
json={"resolver": "ssodnet", "name": sso_name}, | ||
) | ||
if r.status_code != 200: | ||
return [] | ||
|
||
ssnamenrs = np.unique([i["i:ssnamenr"] for i in r.json()]) | ||
|
||
return ssnamenrs | ||
|
||
|
||
def resolve_sso_name(sso_name): | ||
"""Find corresponding UAI name and number using quaero | ||
Parameters | ||
---------- | ||
sso_name: str | ||
SSO name or number | ||
Returns | ||
------- | ||
name: str | ||
UAI name. NaN if does not exist. | ||
number: str | ||
UAI number. NaN if does not exist. | ||
""" | ||
sso_name, sso_number = rocks.identify(sso_name) | ||
return sso_name, sso_number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.