atlasapiclient 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atlasapiclient-0.2.0/.github/workflows/docs.yml +27 -0
- atlasapiclient-0.2.0/.github/workflows/publish.yml +115 -0
- atlasapiclient-0.2.0/.github/workflows/testing.yml +31 -0
- atlasapiclient-0.2.0/.gitignore +121 -0
- atlasapiclient-0.2.0/PKG-INFO +145 -0
- atlasapiclient-0.2.0/README.md +124 -0
- atlasapiclient-0.2.0/atlasapiclient/__init__.py +6 -0
- atlasapiclient-0.2.0/atlasapiclient/client.py +632 -0
- atlasapiclient-0.2.0/atlasapiclient/config_files/api_config_template.yaml +2 -0
- atlasapiclient-0.2.0/atlasapiclient/exceptions.py +28 -0
- atlasapiclient-0.2.0/atlasapiclient/utils.py +26 -0
- atlasapiclient-0.2.0/atlasapiclient.egg-info/PKG-INFO +145 -0
- atlasapiclient-0.2.0/atlasapiclient.egg-info/SOURCES.txt +29 -0
- atlasapiclient-0.2.0/atlasapiclient.egg-info/dependency_links.txt +1 -0
- atlasapiclient-0.2.0/atlasapiclient.egg-info/requires.txt +15 -0
- atlasapiclient-0.2.0/atlasapiclient.egg-info/top_level.txt +1 -0
- atlasapiclient-0.2.0/docs/Makefile +20 -0
- atlasapiclient-0.2.0/docs/make.bat +35 -0
- atlasapiclient-0.2.0/docs/requirements.txt +2 -0
- atlasapiclient-0.2.0/docs/source/api-reference.rst +19 -0
- atlasapiclient-0.2.0/docs/source/conf.py +37 -0
- atlasapiclient-0.2.0/docs/source/index.rst +18 -0
- atlasapiclient-0.2.0/pyproject.toml +46 -0
- atlasapiclient-0.2.0/setup.cfg +4 -0
- atlasapiclient-0.2.0/test/__init__.py +0 -0
- atlasapiclient-0.2.0/test/integration/__init__.py +0 -0
- atlasapiclient-0.2.0/test/integration/test_api_read.py +132 -0
- atlasapiclient-0.2.0/test/integration/test_api_write.py +118 -0
- atlasapiclient-0.2.0/test/test_client.py +293 -0
- atlasapiclient-0.2.0/test/test_exceptions.py +9 -0
- atlasapiclient-0.2.0/test/test_utils.py +23 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Github action to build docs and, if on main, deploy to the gh-pages branch
|
|
2
|
+
name: docs
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
jobs:
|
|
5
|
+
sphinx:
|
|
6
|
+
runs-on: ubuntu-latest
|
|
7
|
+
steps:
|
|
8
|
+
# Checkout and build the docs with sphinx
|
|
9
|
+
- name: Checkout
|
|
10
|
+
uses: actions/checkout@v4
|
|
11
|
+
- name: Build HTML
|
|
12
|
+
uses: ammaraskar/sphinx-action@7.4.7
|
|
13
|
+
with:
|
|
14
|
+
docs-folder: "docs/"
|
|
15
|
+
- name: Upload artifacts
|
|
16
|
+
uses: actions/upload-artifact@v4
|
|
17
|
+
with:
|
|
18
|
+
name: html-docs
|
|
19
|
+
path: docs/build/html/
|
|
20
|
+
# Deploys to the gh-pages branch if the commit was made to main, the
|
|
21
|
+
# gh-pages then takes over serving the html
|
|
22
|
+
- name: Deploy
|
|
23
|
+
uses: peaceiris/actions-gh-pages@v4
|
|
24
|
+
if: github.ref == 'refs/heads/main'
|
|
25
|
+
with:
|
|
26
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
27
|
+
publish_dir: docs/build/html
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Following this page:
|
|
2
|
+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
|
|
3
|
+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
|
|
4
|
+
on: push
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
name: Build distribution 📦
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- name: Set up Python
|
|
13
|
+
uses: actions/setup-python@v5
|
|
14
|
+
with:
|
|
15
|
+
python-version: "3.x"
|
|
16
|
+
- name: Install pypa/build
|
|
17
|
+
run: >-
|
|
18
|
+
python3 -m
|
|
19
|
+
pip install
|
|
20
|
+
build
|
|
21
|
+
--user
|
|
22
|
+
- name: Build a binary wheel and a source tarball
|
|
23
|
+
run: python3 -m build
|
|
24
|
+
- name: Store the distribution packages
|
|
25
|
+
uses: actions/upload-artifact@v4
|
|
26
|
+
with:
|
|
27
|
+
name: python-package-distributions
|
|
28
|
+
path: dist/
|
|
29
|
+
|
|
30
|
+
publish-to-pypi:
|
|
31
|
+
name: >-
|
|
32
|
+
Publish Python 🐍 distribution 📦 to PyPI
|
|
33
|
+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes (i.e when the version number changes)
|
|
34
|
+
needs:
|
|
35
|
+
- build
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
environment:
|
|
38
|
+
name: pypi
|
|
39
|
+
url: https://pypi.org/p/atlasapiclient
|
|
40
|
+
permissions:
|
|
41
|
+
id-token: write # IMPORTANT: mandatory for trusted publishing
|
|
42
|
+
steps:
|
|
43
|
+
- name: Download all the dists
|
|
44
|
+
uses: actions/download-artifact@v4
|
|
45
|
+
with:
|
|
46
|
+
name: python-package-distributions
|
|
47
|
+
path: dist/
|
|
48
|
+
- name: Publish distribution 📦 to PyPI
|
|
49
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
50
|
+
|
|
51
|
+
github-release:
|
|
52
|
+
name: >-
|
|
53
|
+
Sign the Python 🐍 distribution 📦 with Sigstore
|
|
54
|
+
and upload them to GitHub Release
|
|
55
|
+
needs:
|
|
56
|
+
- publish-to-pypi
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
permissions:
|
|
59
|
+
contents: write # IMPORTANT: mandatory for making GitHub Releases
|
|
60
|
+
id-token: write # IMPORTANT: mandatory for sigstore
|
|
61
|
+
steps:
|
|
62
|
+
- name: Download all the dists
|
|
63
|
+
uses: actions/download-artifact@v4
|
|
64
|
+
with:
|
|
65
|
+
name: python-package-distributions
|
|
66
|
+
path: dist/
|
|
67
|
+
- name: Sign the dists with Sigstore
|
|
68
|
+
uses: sigstore/gh-action-sigstore-python@v3.0.0
|
|
69
|
+
with:
|
|
70
|
+
inputs: >-
|
|
71
|
+
./dist/*.tar.gz
|
|
72
|
+
./dist/*.whl
|
|
73
|
+
- name: Create GitHub Release
|
|
74
|
+
env:
|
|
75
|
+
GITHUB_TOKEN: ${{ github.token }}
|
|
76
|
+
run: >-
|
|
77
|
+
gh release create
|
|
78
|
+
'${{ github.ref_name }}'
|
|
79
|
+
--repo '${{ github.repository }}'
|
|
80
|
+
--notes ""
|
|
81
|
+
- name: Upload artifact signatures to GitHub Release
|
|
82
|
+
env:
|
|
83
|
+
GITHUB_TOKEN: ${{ github.token }}
|
|
84
|
+
# Upload to GitHub Release using the `gh` CLI.
|
|
85
|
+
# `dist/` contains the built packages, and the
|
|
86
|
+
# sigstore-produced signatures and certificates.
|
|
87
|
+
run: >-
|
|
88
|
+
gh release upload
|
|
89
|
+
'${{ github.ref_name }}' dist/**
|
|
90
|
+
--repo '${{ github.repository }}'
|
|
91
|
+
|
|
92
|
+
# Publishing to test pypi
|
|
93
|
+
publish-to-testpypi:
|
|
94
|
+
name: Publish Python 🐍 distribution 📦 to TestPyPI
|
|
95
|
+
needs:
|
|
96
|
+
- build
|
|
97
|
+
runs-on: ubuntu-latest
|
|
98
|
+
|
|
99
|
+
environment:
|
|
100
|
+
name: testpypi
|
|
101
|
+
url: https://test.pypi.org/p/atlasapiclient
|
|
102
|
+
|
|
103
|
+
permissions:
|
|
104
|
+
id-token: write # IMPORTANT: mandatory for trusted publishing
|
|
105
|
+
|
|
106
|
+
steps:
|
|
107
|
+
- name: Download all the dists
|
|
108
|
+
uses: actions/download-artifact@v4
|
|
109
|
+
with:
|
|
110
|
+
name: python-package-distributions
|
|
111
|
+
path: dist/
|
|
112
|
+
- name: Publish distribution 📦 to TestPyPI
|
|
113
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
114
|
+
with:
|
|
115
|
+
repository-url: https://test.pypi.org/legacy/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# write a github action to run the tests
|
|
2
|
+
|
|
3
|
+
name: Testing
|
|
4
|
+
on: [push, pull_request]
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
strategy:
|
|
9
|
+
fail-fast: false
|
|
10
|
+
matrix:
|
|
11
|
+
python-version: ["3.9", "3.10", "3.11"]
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- name: Set up Python
|
|
15
|
+
uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: ${{ matrix.python-version }}
|
|
18
|
+
- name: Install dependencies
|
|
19
|
+
run: |
|
|
20
|
+
python -m pip install --upgrade pip
|
|
21
|
+
python -m pip install flake8
|
|
22
|
+
python -m pip install -e '.[test]'
|
|
23
|
+
- name: Lint with flake8
|
|
24
|
+
run: |
|
|
25
|
+
# stop the build if there are Python syntax errors or undefined names
|
|
26
|
+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
27
|
+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
|
28
|
+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
29
|
+
- name: Test with pytest
|
|
30
|
+
run: |
|
|
31
|
+
python -m pytest -k 'not integration'
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
.venv
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
# Usually these files are written by a python script from a template
|
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
33
|
+
*.manifest
|
|
34
|
+
*.spec
|
|
35
|
+
|
|
36
|
+
# Installer logs
|
|
37
|
+
pip-log.txt
|
|
38
|
+
pip-delete-this-directory.txt
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
.cache
|
|
47
|
+
nosetests.xml
|
|
48
|
+
coverage.xml
|
|
49
|
+
*.cover
|
|
50
|
+
*.py,cover
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# IDE stuff
|
|
87
|
+
.idea
|
|
88
|
+
.vscode
|
|
89
|
+
|
|
90
|
+
# MY CONFIG FILE WITH MY TOKEN
|
|
91
|
+
api_config_MINE.yaml
|
|
92
|
+
api_config_dev.yaml
|
|
93
|
+
api_config_staging.yaml
|
|
94
|
+
api_config_prod.yaml
|
|
95
|
+
|
|
96
|
+
# pyenv
|
|
97
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
98
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
99
|
+
.python-version
|
|
100
|
+
|
|
101
|
+
# pipenv
|
|
102
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
103
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
104
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
105
|
+
# install all needed dependencies.
|
|
106
|
+
#Pipfile.lock
|
|
107
|
+
|
|
108
|
+
# poetry
|
|
109
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
110
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
111
|
+
# commonly ignored for libraries.
|
|
112
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
113
|
+
#poetry.lock
|
|
114
|
+
|
|
115
|
+
# pdm
|
|
116
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
117
|
+
#pdm.lock
|
|
118
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
119
|
+
# in version control.
|
|
120
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
121
|
+
.pdm.toml
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: atlasapiclient
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: API Client utility package for the ATLAS Transient Server
|
|
5
|
+
Author-email: Heloise Stevance <hfstevance@gmail.com>, Jack Leland <jack.leland@dtc.ox.ac.uk>, Ken Smith <ken.w.smith@gmail.com>
|
|
6
|
+
License: BSD-3-Clause
|
|
7
|
+
Keywords: astronomy,ATLAS API
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: numpy
|
|
11
|
+
Requires-Dist: pandas
|
|
12
|
+
Requires-Dist: requests
|
|
13
|
+
Requires-Dist: tqdm
|
|
14
|
+
Requires-Dist: pyyaml
|
|
15
|
+
Requires-Dist: importlib-metadata; python_version > "3.9"
|
|
16
|
+
Provides-Extra: test
|
|
17
|
+
Requires-Dist: pytest; extra == "test"
|
|
18
|
+
Provides-Extra: docs
|
|
19
|
+
Requires-Dist: sphinx==7.4.7; extra == "docs"
|
|
20
|
+
Requires-Dist: sphinx_rtd_theme==3.0.2; extra == "docs"
|
|
21
|
+
|
|
22
|
+
# ATLAS API Client
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
This Python client facilitates the use of the ATLAS API.
|
|
26
|
+
Some general use cases are shown below - feel free to reach out to request additional documentation or features.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
### Pypi
|
|
31
|
+
```
|
|
32
|
+
UPCOMING
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Clone Github
|
|
36
|
+
```
|
|
37
|
+
git clone git@github.com:HeloiseS/atlasapiclient.git
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Configuration
|
|
41
|
+
The client requires a config ile that contains the base url of the ATLAS transient web servers and your token for the ATLAS API.
|
|
42
|
+
In the directory `atlasapiclient/config_files` you will find the `api_config_template.yaml` file.
|
|
43
|
+
1) Copy it **in the same directory** to a file named `api_config_MINE.yaml`. **YES - THE NAME MATTERS**
|
|
44
|
+
```
|
|
45
|
+
cd atlasapiclient/config_files
|
|
46
|
+
cp api_config_template.yaml api_config_MINE.yaml
|
|
47
|
+
```
|
|
48
|
+
2) Update your token (if you don't have a token see below)
|
|
49
|
+
3) Update the url to "https://psweb.mp.qub.ac.uk/sne/atlas4/api/"
|
|
50
|
+
|
|
51
|
+
#### How do I get a token?
|
|
52
|
+
For now, you ask Ken, the wizard in charge the ATLAS transient servers.
|
|
53
|
+
Email: k.w.smith@qub.ac.uk
|
|
54
|
+
|
|
55
|
+
# User Cheat Sheet
|
|
56
|
+
## Cone Search
|
|
57
|
+
|
|
58
|
+
The cone search requires **four parameters**:
|
|
59
|
+
* RA
|
|
60
|
+
* Dec
|
|
61
|
+
* Search radius in **arcseconds**
|
|
62
|
+
* Request type: All, Nearest or Count (case insensitive)
|
|
63
|
+
```
|
|
64
|
+
from atlasapiclient import client as atlaspaiclient
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
client = atlaspaiclient.ConeSearch(payload={'ra': 150,
|
|
68
|
+
'dec': 60,
|
|
69
|
+
'radius': 60,
|
|
70
|
+
'requestType': 'nearest'},
|
|
71
|
+
get_response=True)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Get data for one or more ATLAS\_IDs
|
|
75
|
+
|
|
76
|
+
### Get a Single object data
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
from atlasapiclient import client as atlaspaiclient
|
|
80
|
+
|
|
81
|
+
atlas_id = '1121846241331952000'
|
|
82
|
+
client = atlaspaiclient.RequestSingleSourceData(atlas_id=atlas_id, get_response=True)
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
Note: Here we don't parse the config file because we __assume you have named yours `api_config_MINE.yaml`__.
|
|
86
|
+
The path to that file is encoded in the `API_CONFIG_FILE` variable in the `atlasapiclient/utils.py` file and parsed by default to the classes.
|
|
87
|
+
|
|
88
|
+
If you feel fancy and want to name your config file differently you have to keep track of its location and parse it with the argument `api_config_file`.
|
|
89
|
+
|
|
90
|
+
Your data can be found in the `client.response` attribute. Note that it is a `list` so if you only have one object you
|
|
91
|
+
want to do `client.response[0]` to get the JSON data.
|
|
92
|
+
|
|
93
|
+
### Get Multiple objects
|
|
94
|
+
If you want to query the ATLAS API for multiple objects you're going to encounter the rate limit, which is 100 per query.
|
|
95
|
+
To handle this, there is a class to chunk stuff for you:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
from atlasapiclient import client as atlaspaiclient
|
|
99
|
+
|
|
100
|
+
client = RequestMultipleSourceData(atlas_ids=MY_LIST_OF_IDS, mjdthreshold = LOWER_MJD_THRESHOLD)
|
|
101
|
+
client.chunk_get_response() # Chunks the list of IDs into a bunch of payloads and colates the responses.
|
|
102
|
+
```
|
|
103
|
+
You can then get the data just as you would for a single object.
|
|
104
|
+
|
|
105
|
+
## Data Structure
|
|
106
|
+
The ATLAS API gives you back _everything_ (or nearly). The schema can be explored on this page:
|
|
107
|
+
[ATLAS Json Schema](https://psweb.mp.qub.ac.uk/misc/api/atlas/)
|
|
108
|
+
|
|
109
|
+
Here is a couple of handy recipes...
|
|
110
|
+
|
|
111
|
+
#### Getting the lightcurves
|
|
112
|
+
|
|
113
|
+
The detections and non-detections are in separate dictionaries with different columns names so we put them in two separate dictionaries.
|
|
114
|
+
```
|
|
115
|
+
import pandas as pd
|
|
116
|
+
detections = pd.DataFrame(client.response[0]['lc'])
|
|
117
|
+
non_detections = pd.DataFrame(client.response[0]['lcnondets'])
|
|
118
|
+
```
|
|
119
|
+
If concatenate them together we recommend ordering by `mjd` .
|
|
120
|
+
|
|
121
|
+
[Should the JsonData object from atlasvras actually live in this package so people cna use it?]
|
|
122
|
+
|
|
123
|
+
#### Getting the Sherlock crossmatches
|
|
124
|
+
The first crossmatch (if any) is a merged entry which cherry picks the best information from all catalogues (so if a galaxy has info in 3 catalogues it will be cross matched 3 times and the info from these catalogues will appear as separate entries in our list of dictionaries - the first entry in the list will be the combination of all the best info in those 3 entries)
|
|
125
|
+
The following entries are the individual crossmatches.
|
|
126
|
+
```
|
|
127
|
+
summary_crossmatch = client.response[0]['sherlock_crossmatches'][0]
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### Is that ATLAS\_ID object in TNS?
|
|
131
|
+
You can check the crossmatches using:
|
|
132
|
+
```
|
|
133
|
+
client.response[0]['tns_crossmatches']
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
# FAQ
|
|
137
|
+
* **Can I query by TNS/ZTF name?**:
|
|
138
|
+
No. Do a cone search.
|
|
139
|
+
* **WHY?**: Because it's too low on our priority list and we don't have the time.
|
|
140
|
+
If it's a really big deal for you and you might have working hours to help us with this, get in touch.
|
|
141
|
+
* **Can I do a cone search?** :
|
|
142
|
+
Not yet. Poke us if we've not done it by February 2025.
|
|
143
|
+
* **Why does the API return so much data**?:
|
|
144
|
+
Because it'd take forever to refactor and it's low on the priority list.
|
|
145
|
+
If it's a big deal for you talk to us, it might bump it further up the to-do list.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# ATLAS API Client
|
|
2
|
+
---
|
|
3
|
+
|
|
4
|
+
This Python client facilitates the use of the ATLAS API.
|
|
5
|
+
Some general use cases are shown below - feel free to reach out to request additional documentation or features.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### Pypi
|
|
10
|
+
```
|
|
11
|
+
UPCOMING
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Clone Github
|
|
15
|
+
```
|
|
16
|
+
git clone git@github.com:HeloiseS/atlasapiclient.git
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Configuration
|
|
20
|
+
The client requires a config ile that contains the base url of the ATLAS transient web servers and your token for the ATLAS API.
|
|
21
|
+
In the directory `atlasapiclient/config_files` you will find the `api_config_template.yaml` file.
|
|
22
|
+
1) Copy it **in the same directory** to a file named `api_config_MINE.yaml`. **YES - THE NAME MATTERS**
|
|
23
|
+
```
|
|
24
|
+
cd atlasapiclient/config_files
|
|
25
|
+
cp api_config_template.yaml api_config_MINE.yaml
|
|
26
|
+
```
|
|
27
|
+
2) Update your token (if you don't have a token see below)
|
|
28
|
+
3) Update the url to "https://psweb.mp.qub.ac.uk/sne/atlas4/api/"
|
|
29
|
+
|
|
30
|
+
#### How do I get a token?
|
|
31
|
+
For now, you ask Ken, the wizard in charge the ATLAS transient servers.
|
|
32
|
+
Email: k.w.smith@qub.ac.uk
|
|
33
|
+
|
|
34
|
+
# User Cheat Sheet
|
|
35
|
+
## Cone Search
|
|
36
|
+
|
|
37
|
+
The cone search requires **four parameters**:
|
|
38
|
+
* RA
|
|
39
|
+
* Dec
|
|
40
|
+
* Search radius in **arcseconds**
|
|
41
|
+
* Request type: All, Nearest or Count (case insensitive)
|
|
42
|
+
```
|
|
43
|
+
from atlasapiclient import client as atlaspaiclient
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
client = atlaspaiclient.ConeSearch(payload={'ra': 150,
|
|
47
|
+
'dec': 60,
|
|
48
|
+
'radius': 60,
|
|
49
|
+
'requestType': 'nearest'},
|
|
50
|
+
get_response=True)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Get data for one or more ATLAS\_IDs
|
|
54
|
+
|
|
55
|
+
### Get a Single object data
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
from atlasapiclient import client as atlaspaiclient
|
|
59
|
+
|
|
60
|
+
atlas_id = '1121846241331952000'
|
|
61
|
+
client = atlaspaiclient.RequestSingleSourceData(atlas_id=atlas_id, get_response=True)
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
Note: Here we don't parse the config file because we __assume you have named yours `api_config_MINE.yaml`__.
|
|
65
|
+
The path to that file is encoded in the `API_CONFIG_FILE` variable in the `atlasapiclient/utils.py` file and parsed by default to the classes.
|
|
66
|
+
|
|
67
|
+
If you feel fancy and want to name your config file differently you have to keep track of its location and parse it with the argument `api_config_file`.
|
|
68
|
+
|
|
69
|
+
Your data can be found in the `client.response` attribute. Note that it is a `list` so if you only have one object you
|
|
70
|
+
want to do `client.response[0]` to get the JSON data.
|
|
71
|
+
|
|
72
|
+
### Get Multiple objects
|
|
73
|
+
If you want to query the ATLAS API for multiple objects you're going to encounter the rate limit, which is 100 per query.
|
|
74
|
+
To handle this, there is a class to chunk stuff for you:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
from atlasapiclient import client as atlaspaiclient
|
|
78
|
+
|
|
79
|
+
client = RequestMultipleSourceData(atlas_ids=MY_LIST_OF_IDS, mjdthreshold = LOWER_MJD_THRESHOLD)
|
|
80
|
+
client.chunk_get_response() # Chunks the list of IDs into a bunch of payloads and colates the responses.
|
|
81
|
+
```
|
|
82
|
+
You can then get the data just as you would for a single object.
|
|
83
|
+
|
|
84
|
+
## Data Structure
|
|
85
|
+
The ATLAS API gives you back _everything_ (or nearly). The schema can be explored on this page:
|
|
86
|
+
[ATLAS Json Schema](https://psweb.mp.qub.ac.uk/misc/api/atlas/)
|
|
87
|
+
|
|
88
|
+
Here is a couple of handy recipes...
|
|
89
|
+
|
|
90
|
+
#### Getting the lightcurves
|
|
91
|
+
|
|
92
|
+
The detections and non-detections are in separate dictionaries with different columns names so we put them in two separate dictionaries.
|
|
93
|
+
```
|
|
94
|
+
import pandas as pd
|
|
95
|
+
detections = pd.DataFrame(client.response[0]['lc'])
|
|
96
|
+
non_detections = pd.DataFrame(client.response[0]['lcnondets'])
|
|
97
|
+
```
|
|
98
|
+
If concatenate them together we recommend ordering by `mjd` .
|
|
99
|
+
|
|
100
|
+
[Should the JsonData object from atlasvras actually live in this package so people cna use it?]
|
|
101
|
+
|
|
102
|
+
#### Getting the Sherlock crossmatches
|
|
103
|
+
The first crossmatch (if any) is a merged entry which cherry picks the best information from all catalogues (so if a galaxy has info in 3 catalogues it will be cross matched 3 times and the info from these catalogues will appear as separate entries in our list of dictionaries - the first entry in the list will be the combination of all the best info in those 3 entries)
|
|
104
|
+
The following entries are the individual crossmatches.
|
|
105
|
+
```
|
|
106
|
+
summary_crossmatch = client.response[0]['sherlock_crossmatches'][0]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Is that ATLAS\_ID object in TNS?
|
|
110
|
+
You can check the crossmatches using:
|
|
111
|
+
```
|
|
112
|
+
client.response[0]['tns_crossmatches']
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
# FAQ
|
|
116
|
+
* **Can I query by TNS/ZTF name?**:
|
|
117
|
+
No. Do a cone search.
|
|
118
|
+
* **WHY?**: Because it's too low on our priority list and we don't have the time.
|
|
119
|
+
If it's a really big deal for you and you might have working hours to help us with this, get in touch.
|
|
120
|
+
* **Can I do a cone search?** :
|
|
121
|
+
Not yet. Poke us if we've not done it by February 2025.
|
|
122
|
+
* **Why does the API return so much data**?:
|
|
123
|
+
Because it'd take forever to refactor and it's low on the priority list.
|
|
124
|
+
If it's a big deal for you talk to us, it might bump it further up the to-do list.
|