blastwave 1.0.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.
Files changed (45) hide show
  1. blastwave-1.0.0/.github/workflows/black.yml +23 -0
  2. blastwave-1.0.0/.github/workflows/continuous_integration.yml +81 -0
  3. blastwave-1.0.0/.github/workflows/isort.yml +23 -0
  4. blastwave-1.0.0/.github/workflows/mypy.yml +23 -0
  5. blastwave-1.0.0/.github/workflows/pylint.yml +23 -0
  6. blastwave-1.0.0/.gitignore +223 -0
  7. blastwave-1.0.0/.pre-commit-config.yaml +48 -0
  8. blastwave-1.0.0/LICENSE +21 -0
  9. blastwave-1.0.0/PKG-INFO +87 -0
  10. blastwave-1.0.0/README.md +42 -0
  11. blastwave-1.0.0/blastwave/__init__.py +7 -0
  12. blastwave-1.0.0/blastwave/errors.py +9 -0
  13. blastwave-1.0.0/blastwave/models/__init__.py +8 -0
  14. blastwave-1.0.0/blastwave/models/constants.py +0 -0
  15. blastwave-1.0.0/blastwave/models/observation.py +61 -0
  16. blastwave-1.0.0/blastwave/models/parquet.py +55 -0
  17. blastwave-1.0.0/blastwave/models/query.py +38 -0
  18. blastwave-1.0.0/blastwave/models/source.py +432 -0
  19. blastwave-1.0.0/blastwave/projections/__init__.py +6 -0
  20. blastwave-1.0.0/blastwave/projections/lsst.py +27 -0
  21. blastwave-1.0.0/blastwave/projections/ztf.py +34 -0
  22. blastwave-1.0.0/blastwave/query/__init__.py +8 -0
  23. blastwave-1.0.0/blastwave/query/alert.py +252 -0
  24. blastwave-1.0.0/blastwave/query/boom.py +339 -0
  25. blastwave-1.0.0/blastwave/query/lsst.py +16 -0
  26. blastwave-1.0.0/blastwave/query/timeout.py +32 -0
  27. blastwave-1.0.0/blastwave/query/ztf.py +16 -0
  28. blastwave-1.0.0/blastwave/utils/__init__.py +12 -0
  29. blastwave-1.0.0/blastwave/utils/cache.py +100 -0
  30. blastwave-1.0.0/blastwave/utils/combine.py +35 -0
  31. blastwave-1.0.0/blastwave/utils/photometry.py +108 -0
  32. blastwave-1.0.0/blastwave/utils/plot.py +42 -0
  33. blastwave-1.0.0/blastwave.egg-info/PKG-INFO +87 -0
  34. blastwave-1.0.0/blastwave.egg-info/SOURCES.txt +43 -0
  35. blastwave-1.0.0/blastwave.egg-info/dependency_links.txt +1 -0
  36. blastwave-1.0.0/blastwave.egg-info/requires.txt +19 -0
  37. blastwave-1.0.0/blastwave.egg-info/top_level.txt +1 -0
  38. blastwave-1.0.0/example.env +3 -0
  39. blastwave-1.0.0/notebooks/1-boom_client.ipynb +428 -0
  40. blastwave-1.0.0/notebooks/2-ZTF_client.ipynb +3179 -0
  41. blastwave-1.0.0/notebooks/3-LSST_client.ipynb +5513 -0
  42. blastwave-1.0.0/notebooks/4-Reading_cache.ipynb +906 -0
  43. blastwave-1.0.0/pyproject.toml +78 -0
  44. blastwave-1.0.0/setup.cfg +4 -0
  45. blastwave-1.0.0/tests/test_boom.py +61 -0
@@ -0,0 +1,23 @@
1
+ name: Black
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ black:
7
+
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v3
11
+ - name: Set up Python 3.14
12
+ uses: actions/setup-python@v4
13
+ with:
14
+ python-version: 3.14
15
+ cache: 'pip'
16
+ cache-dependency-path: pyproject.toml
17
+ - name: Install dependencies
18
+ run: |
19
+ pip install --upgrade pip
20
+ pip install --editable ".[dev]"
21
+ - name: Reformat the code with black
22
+ run: |
23
+ black . --check
@@ -0,0 +1,81 @@
1
+ # This is a basic workflow to help you get started with Actions
2
+
3
+ name: CI
4
+
5
+ # Controls when the action will run.
6
+ on:
7
+ # Triggers the workflow on push or pull request events
8
+ push:
9
+
10
+ pull_request:
11
+
12
+ # Allows you to run this workflow manually from the Actions tab
13
+ workflow_dispatch:
14
+
15
+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
16
+ jobs:
17
+ # This workflow contains a single job called "build"
18
+ build:
19
+ # The type of runner that the job will run on
20
+ runs-on: ubuntu-latest
21
+
22
+ permissions:
23
+ # IMPORTANT: this permission is mandatory for Trusted Publishing
24
+ id-token: write
25
+
26
+ # Specify the python versions to test
27
+ strategy:
28
+ matrix:
29
+ python-version: ["3.11", "3.12", "3.13", "3.14"]
30
+
31
+ # Steps represent a sequence of tasks that will be executed as part of the job
32
+ steps:
33
+ - uses: actions/checkout@v3
34
+
35
+ # Set up the python versions
36
+ - name: Set up Python ${{ matrix.python-version }}
37
+ uses: actions/setup-python@v4
38
+ with:
39
+ python-version: ${{ matrix.python-version }}
40
+ cache: 'pip'
41
+ cache-dependency-path: pyproject.toml
42
+
43
+ - name: install packages
44
+ run: |
45
+ pip install --editable ".[dev]"
46
+
47
+ - name: Run tests
48
+ env:
49
+ BOOM_API_USER: ${{ secrets.BOOM_API_USER }}
50
+ BOOM_API_PASSWORD: ${{ secrets.BOOM_API_PASSWORD }}
51
+ run: coverage run -m unittest discover tests
52
+
53
+ - name: Run Coveralls
54
+ continue-on-error: true
55
+ if: ${{ success() }}
56
+ run: |
57
+ coveralls --service=github
58
+ env:
59
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60
+
61
+ - name: Echo tag name
62
+ run: echo "Tag is ${{ github.ref }}, Tagged is ${{ startsWith(github.ref, 'refs/tags/')}}, Python Check is ${{matrix.python-version == 3.11}}, Deploy is ${{ startsWith(github.ref, 'refs/tags/') && matrix.python-version == 3.11}}"
63
+
64
+ - name: Install pypa/build
65
+ run: >-
66
+ python -m
67
+ pip install
68
+ build
69
+ --user
70
+ - name: Build a binary wheel and a source tarball
71
+ run: >-
72
+ python -m
73
+ build
74
+ --sdist
75
+ --wheel
76
+ --outdir dist/
77
+ .
78
+
79
+ - name: Publish distribution 📦 to PyPI
80
+ if: ${{ startsWith(github.ref, 'refs/tags/') && success() && matrix.python-version == 3.11 && github.event_name == 'push'}}
81
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,23 @@
1
+ name: isort
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ isort:
7
+
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v3
11
+ - name: Set up Python 3.14
12
+ uses: actions/setup-python@v4
13
+ with:
14
+ python-version: 3.14
15
+ cache: 'pip'
16
+ cache-dependency-path: pyproject.toml
17
+ - name: Install dependencies
18
+ run: |
19
+ pip install --upgrade pip
20
+ pip install --editable ".[dev]"
21
+ - name: Reformat the code with isort
22
+ run: |
23
+ isort . --check
@@ -0,0 +1,23 @@
1
+ name: mypy
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ mypy:
7
+
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v3
11
+ - name: Set up Python 3.14
12
+ uses: actions/setup-python@v4
13
+ with:
14
+ python-version: 3.14
15
+ cache: 'pip'
16
+ cache-dependency-path: pyproject.toml
17
+ - name: Install dependencies
18
+ run: |
19
+ pip install --upgrade pip
20
+ pip install --editable ".[dev]"
21
+ - name: Run mypy
22
+ run: |
23
+ mypy blastwave --ignore-missing-imports
@@ -0,0 +1,23 @@
1
+ name: pylint
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ pylint:
7
+
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v3
11
+ - name: Set up Python 3.14
12
+ uses: actions/setup-python@v4
13
+ with:
14
+ python-version: 3.14
15
+ cache: 'pip'
16
+ cache-dependency-path: pyproject.toml
17
+ - name: Install dependencies
18
+ run: |
19
+ pip install --upgrade pip
20
+ pip install --editable ".[dev]"
21
+ - name: Run pylint
22
+ run: |
23
+ pylint blastwave
@@ -0,0 +1,223 @@
1
+ *.idea
2
+ */*.DS_Store
3
+ */*.egg-info
4
+ */*.egg
5
+
6
+ # Byte-compiled / optimized / DLL files
7
+ __pycache__/
8
+ *.py[codz]
9
+ *$py.class
10
+
11
+ # C extensions
12
+ *.so
13
+
14
+ # Distribution / packaging
15
+ .Python
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ downloads/
20
+ eggs/
21
+ .eggs/
22
+ lib/
23
+ lib64/
24
+ parts/
25
+ sdist/
26
+ var/
27
+ wheels/
28
+ share/python-wheels/
29
+ *.egg-info/
30
+ .installed.cfg
31
+ *.egg
32
+ MANIFEST
33
+
34
+ # PyInstaller
35
+ # Usually these files are written by a python script from a template
36
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
37
+ *.manifest
38
+ *.spec
39
+
40
+ # Installer logs
41
+ pip-log.txt
42
+ pip-delete-this-directory.txt
43
+
44
+ # Unit test / coverage reports
45
+ htmlcov/
46
+ .tox/
47
+ .nox/
48
+ .coverage
49
+ .coverage.*
50
+ .cache
51
+ nosetests.xml
52
+ coverage.xml
53
+ *.cover
54
+ *.py.cover
55
+ .hypothesis/
56
+ .pytest_cache/
57
+ cover/
58
+
59
+ # Translations
60
+ *.mo
61
+ *.pot
62
+
63
+ # Django stuff:
64
+ *.log
65
+ local_settings.py
66
+ db.sqlite3
67
+ db.sqlite3-journal
68
+
69
+ # Flask stuff:
70
+ instance/
71
+ .webassets-cache
72
+
73
+ # Scrapy stuff:
74
+ .scrapy
75
+
76
+ # Sphinx documentation
77
+ docs/_build/
78
+
79
+ # PyBuilder
80
+ .pybuilder/
81
+ target/
82
+
83
+ # Jupyter Notebook
84
+ .ipynb_checkpoints
85
+
86
+ # IPython
87
+ profile_default/
88
+ ipython_config.py
89
+
90
+ # pyenv
91
+ # For a library or package, you might want to ignore these files since the code is
92
+ # intended to run in multiple environments; otherwise, check them in:
93
+ # .python-version
94
+
95
+ # pipenv
96
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
97
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
98
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
99
+ # install all needed dependencies.
100
+ # Pipfile.lock
101
+
102
+ # UV
103
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
104
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
105
+ # commonly ignored for libraries.
106
+ # uv.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
+ # poetry.toml
115
+
116
+ # pdm
117
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
118
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
119
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
120
+ # pdm.lock
121
+ # pdm.toml
122
+ .pdm-python
123
+ .pdm-build/
124
+
125
+ # pixi
126
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
127
+ # pixi.lock
128
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
129
+ # in the .venv directory. It is recommended not to include this directory in version control.
130
+ .pixi
131
+
132
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
133
+ __pypackages__/
134
+
135
+ # Celery stuff
136
+ celerybeat-schedule
137
+ celerybeat.pid
138
+
139
+ # Redis
140
+ *.rdb
141
+ *.aof
142
+ *.pid
143
+
144
+ # RabbitMQ
145
+ mnesia/
146
+ rabbitmq/
147
+ rabbitmq-data/
148
+
149
+ # ActiveMQ
150
+ activemq-data/
151
+
152
+ # SageMath parsed files
153
+ *.sage.py
154
+
155
+ # Environments
156
+ .env
157
+ .envrc
158
+ .venv
159
+ env/
160
+ venv/
161
+ ENV/
162
+ env.bak/
163
+ venv.bak/
164
+
165
+ # Spyder project settings
166
+ .spyderproject
167
+ .spyproject
168
+
169
+ # Rope project settings
170
+ .ropeproject
171
+
172
+ # mkdocs documentation
173
+ /site
174
+
175
+ # mypy
176
+ .mypy_cache/
177
+ .dmypy.json
178
+ dmypy.json
179
+
180
+ # Pyre type checker
181
+ .pyre/
182
+
183
+ # pytype static type analyzer
184
+ .pytype/
185
+
186
+ # Cython debug symbols
187
+ cython_debug/
188
+
189
+ # PyCharm
190
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
191
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
192
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
193
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
194
+ # .idea/
195
+
196
+ # Abstra
197
+ # Abstra is an AI-powered process automation framework.
198
+ # Ignore directories containing user credentials, local state, and settings.
199
+ # Learn more at https://abstra.io/docs
200
+ .abstra/
201
+
202
+ # Visual Studio Code
203
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
204
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
205
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
206
+ # you could uncomment the following to ignore the entire vscode folder
207
+ # .vscode/
208
+ # Temporary file for partial code execution
209
+ tempCodeRunnerFile.py
210
+
211
+ # Ruff stuff:
212
+ .ruff_cache/
213
+
214
+ # PyPI configuration file
215
+ .pypirc
216
+
217
+ # Marimo
218
+ marimo/_static/
219
+ marimo/_lsp/
220
+ __marimo__/
221
+
222
+ # Streamlit
223
+ .streamlit/secrets.toml
@@ -0,0 +1,48 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v2.3.0
4
+ hooks:
5
+ - id: check-yaml
6
+ - id: end-of-file-fixer
7
+ - repo: local
8
+ hooks:
9
+ - id: black
10
+ name: black
11
+ entry: black
12
+ language: system
13
+ types: [ python ]
14
+ - repo: local
15
+ hooks:
16
+ - id: isort
17
+ name: isort (python)
18
+ entry: isort
19
+ language: system
20
+ types: [ python ]
21
+ - repo: local
22
+ hooks:
23
+ - id: mypy
24
+ name: mypy
25
+ entry: mypy
26
+ language: system
27
+ types: [python]
28
+ - repo: local
29
+ hooks:
30
+ - id: autotyping
31
+ name: autotyping
32
+ entry: autotyping
33
+ language: system
34
+ # args: ["--aggressive"]
35
+ types: [python]
36
+ - repo: local
37
+ hooks:
38
+ - id: pylint
39
+ name: pylint
40
+ entry: pylint
41
+ language: system
42
+ types: [python]
43
+ args:
44
+ [
45
+ "-rn", # Only display messages
46
+ "-sn", # Don't display the score
47
+ ]
48
+ verbose: true
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Robert David Stein
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,87 @@
1
+ Metadata-Version: 2.4
2
+ Name: blastwave
3
+ Version: 1.0.0
4
+ Author-email: Robert Stein <rdstein@umd.edu>
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/robertdstein/blastwave
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: End Users/Desktop
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Natural Language :: English
17
+ Classifier: Topic :: Scientific/Engineering
18
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
19
+ Classifier: Topic :: Scientific/Engineering :: Physics
20
+ Classifier: Operating System :: POSIX
21
+ Classifier: Operating System :: Unix
22
+ Classifier: Operating System :: MacOS
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: backoff
27
+ Requires-Dist: dotenv
28
+ Requires-Dist: babamul
29
+ Requires-Dist: polars
30
+ Requires-Dist: matplotlib
31
+ Requires-Dist: pandas
32
+ Requires-Dist: pyarrow
33
+ Provides-Extra: dev
34
+ Requires-Dist: pre-commit; extra == "dev"
35
+ Requires-Dist: black; extra == "dev"
36
+ Requires-Dist: isort; extra == "dev"
37
+ Requires-Dist: pylint; extra == "dev"
38
+ Requires-Dist: coveralls; extra == "dev"
39
+ Requires-Dist: autotyping; extra == "dev"
40
+ Requires-Dist: mypy; extra == "dev"
41
+ Requires-Dist: jupyter; extra == "dev"
42
+ Requires-Dist: tqdm; extra == "dev"
43
+ Requires-Dist: astropy; extra == "dev"
44
+ Dynamic: license-file
45
+
46
+ # blastwave
47
+
48
+ Python client for BOOM queries, similar to [penquins](https://github.com/dmitryduev/penquins).
49
+
50
+ # Installation
51
+
52
+ # Install blastwave with pip:
53
+
54
+ The simplest way to install blastwave is via pip:
55
+
56
+ ```bash
57
+ pip install blastwave
58
+ ```
59
+
60
+ or, if you want to edit the code yourself:
61
+
62
+ ```bash
63
+ git clone git@github.com:robertdstein/blastwave.git
64
+ cd blastwave
65
+ pip install -e ".[dev]"
66
+ ```
67
+
68
+ # Credentials
69
+
70
+ Set your credentials in the environment:
71
+
72
+ ```bash
73
+ export BOOM_USERNAME="your_username"
74
+ export BOOM_PASSWORD="your_password"
75
+ ```
76
+
77
+ or by copying the `.env.example` file to `.env` and filling in your credentials there.
78
+
79
+ If you want to use the parquet cache, you should also set this in the same way via env:
80
+
81
+ ```bash
82
+ export BLASTWAVE_DATA_DIR="/path/to/cache/dir"
83
+ ```
84
+
85
+ # Usage
86
+
87
+ See example Jupyter notebooks for usage examples.
@@ -0,0 +1,42 @@
1
+ # blastwave
2
+
3
+ Python client for BOOM queries, similar to [penquins](https://github.com/dmitryduev/penquins).
4
+
5
+ # Installation
6
+
7
+ # Install blastwave with pip:
8
+
9
+ The simplest way to install blastwave is via pip:
10
+
11
+ ```bash
12
+ pip install blastwave
13
+ ```
14
+
15
+ or, if you want to edit the code yourself:
16
+
17
+ ```bash
18
+ git clone git@github.com:robertdstein/blastwave.git
19
+ cd blastwave
20
+ pip install -e ".[dev]"
21
+ ```
22
+
23
+ # Credentials
24
+
25
+ Set your credentials in the environment:
26
+
27
+ ```bash
28
+ export BOOM_USERNAME="your_username"
29
+ export BOOM_PASSWORD="your_password"
30
+ ```
31
+
32
+ or by copying the `.env.example` file to `.env` and filling in your credentials there.
33
+
34
+ If you want to use the parquet cache, you should also set this in the same way via env:
35
+
36
+ ```bash
37
+ export BLASTWAVE_DATA_DIR="/path/to/cache/dir"
38
+ ```
39
+
40
+ # Usage
41
+
42
+ See example Jupyter notebooks for usage examples.
@@ -0,0 +1,7 @@
1
+ """
2
+ blastwave is a python client for querying BOOM
3
+ """
4
+
5
+ from blastwave.errors import BOOMCredentialsError
6
+ from blastwave.models import BOOMQuery, CatalogQuery, FilterQuery, Observation, Source
7
+ from blastwave.query import BoomClient, LSSTClient, ZTFClient
@@ -0,0 +1,9 @@
1
+ """
2
+ Custom Exceptions for blastwave
3
+ """
4
+
5
+
6
+ class BOOMCredentialsError(Exception):
7
+ """
8
+ Exception raised when no credentials are provided.
9
+ """
@@ -0,0 +1,8 @@
1
+ """
2
+ Module for various models
3
+ """
4
+
5
+ from blastwave.models.observation import Observation
6
+ from blastwave.models.parquet import pydantic_to_arrow_schema
7
+ from blastwave.models.query import BOOMQuery, CatalogQuery, FilterQuery
8
+ from blastwave.models.source import Source
File without changes
@@ -0,0 +1,61 @@
1
+ """
2
+ Observation model
3
+ """
4
+
5
+ import logging
6
+ from typing import Literal
7
+
8
+ import numpy as np
9
+ import pyarrow as pa
10
+ from pydantic import BaseModel, computed_field
11
+
12
+ from blastwave.models.parquet import pydantic_to_arrow_schema
13
+
14
+ logger = logging.getLogger(__name__)
15
+
16
+ ObsClass = Literal["alert", "fp", "ul"]
17
+
18
+
19
+ class Observation(BaseModel):
20
+ """
21
+ Model for an observation
22
+ """
23
+
24
+ jd: float
25
+ magpsf: float
26
+ sigmapsf: float
27
+ diffmaglim: float
28
+ ra: float | None
29
+ dec: float | None
30
+ snr: float
31
+ band: str
32
+ survey: str
33
+ det_type: ObsClass = "alert"
34
+ isdiffpos: bool
35
+
36
+ @computed_field()
37
+ @property
38
+ def estdiffmaglim(self) -> float:
39
+ """
40
+ Estimate the difference magnitude limit based on snr and magpsf
41
+
42
+ :return:
43
+ """
44
+ return self.magpsf - 2.5 * float(np.log10(5.0 / self.snr))
45
+
46
+ @computed_field()
47
+ @property
48
+ def mjd(self) -> float:
49
+ """
50
+ Convert JD to MJD
51
+ """
52
+ return self.jd - 2400000.5
53
+
54
+ @classmethod
55
+ def get_arrow_schema(cls) -> pa.Schema:
56
+ """
57
+ Get arrow schema from pydantic model
58
+
59
+ :return: Arrow schema
60
+ """
61
+ return pydantic_to_arrow_schema(cls)