thuban 0.0.4__tar.gz → 0.0.5__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. {thuban-0.0.4 → thuban-0.0.5}/.pre-commit-config.yaml +3 -3
  2. {thuban-0.0.4/thuban.egg-info → thuban-0.0.5}/PKG-INFO +2 -1
  3. {thuban-0.0.4 → thuban-0.0.5}/docs/conf.py +9 -1
  4. {thuban-0.0.4 → thuban-0.0.5}/pyproject.toml +1 -1
  5. {thuban-0.0.4 → thuban-0.0.5}/thuban/pointing.py +32 -8
  6. {thuban-0.0.4 → thuban-0.0.5/thuban.egg-info}/PKG-INFO +2 -1
  7. {thuban-0.0.4 → thuban-0.0.5}/thuban.egg-info/SOURCES.txt +0 -1
  8. {thuban-0.0.4 → thuban-0.0.5}/thuban.egg-info/requires.txt +1 -0
  9. thuban-0.0.4/.github/workflows/docs.yaml +0 -36
  10. {thuban-0.0.4 → thuban-0.0.5}/.github/workflows/ci.yaml +0 -0
  11. {thuban-0.0.4 → thuban-0.0.5}/.github/workflows/ci_fixed.yaml +0 -0
  12. {thuban-0.0.4 → thuban-0.0.5}/.github/workflows/publish.yaml +0 -0
  13. {thuban-0.0.4 → thuban-0.0.5}/.gitignore +0 -0
  14. {thuban-0.0.4 → thuban-0.0.5}/.readthedocs.yaml +0 -0
  15. {thuban-0.0.4 → thuban-0.0.5}/CITATION.cff +0 -0
  16. {thuban-0.0.4 → thuban-0.0.5}/LICENSE +0 -0
  17. {thuban-0.0.4 → thuban-0.0.5}/MANIFEST.in +0 -0
  18. {thuban-0.0.4 → thuban-0.0.5}/README.md +0 -0
  19. {thuban-0.0.4 → thuban-0.0.5}/codecov.yaml +0 -0
  20. {thuban-0.0.4 → thuban-0.0.5}/docs/Makefile +0 -0
  21. {thuban-0.0.4 → thuban-0.0.5}/docs/_static/favicon.ico +0 -0
  22. {thuban-0.0.4 → thuban-0.0.5}/docs/_static/logo.png +0 -0
  23. {thuban-0.0.4 → thuban-0.0.5}/docs/index.rst +0 -0
  24. {thuban-0.0.4 → thuban-0.0.5}/docs/make.bat +0 -0
  25. {thuban-0.0.4 → thuban-0.0.5}/scripts/prepare_reduced_hip.py +0 -0
  26. {thuban-0.0.4 → thuban-0.0.5}/setup.cfg +0 -0
  27. {thuban-0.0.4 → thuban-0.0.5}/tests/__init__.py +0 -0
  28. {thuban-0.0.4 → thuban-0.0.5}/tests/test_catalog.py +0 -0
  29. {thuban-0.0.4 → thuban-0.0.5}/tests/test_cli.py +0 -0
  30. {thuban-0.0.4 → thuban-0.0.5}/tests/test_distortion.py +0 -0
  31. {thuban-0.0.4 → thuban-0.0.5}/tests/test_pointing.py +0 -0
  32. {thuban-0.0.4 → thuban-0.0.5}/tests/test_util.py +0 -0
  33. {thuban-0.0.4 → thuban-0.0.5}/tests/test_visualize.py +0 -0
  34. {thuban-0.0.4 → thuban-0.0.5}/thuban/__init__.py +0 -0
  35. {thuban-0.0.4 → thuban-0.0.5}/thuban/catalog.py +0 -0
  36. {thuban-0.0.4 → thuban-0.0.5}/thuban/cli.py +0 -0
  37. {thuban-0.0.4 → thuban-0.0.5}/thuban/data/reduced_hip.csv +0 -0
  38. {thuban-0.0.4 → thuban-0.0.5}/thuban/distortion.py +0 -0
  39. {thuban-0.0.4 → thuban-0.0.5}/thuban/error.py +0 -0
  40. {thuban-0.0.4 → thuban-0.0.5}/thuban/simulate.py +0 -0
  41. {thuban-0.0.4 → thuban-0.0.5}/thuban/util.py +0 -0
  42. {thuban-0.0.4 → thuban-0.0.5}/thuban/visualize.py +0 -0
  43. {thuban-0.0.4 → thuban-0.0.5}/thuban.egg-info/dependency_links.txt +0 -0
  44. {thuban-0.0.4 → thuban-0.0.5}/thuban.egg-info/entry_points.txt +0 -0
  45. {thuban-0.0.4 → thuban-0.0.5}/thuban.egg-info/top_level.txt +0 -0
@@ -3,19 +3,19 @@ repos:
3
3
  # This should be before any formatting hooks like isort
4
4
  - repo: https://github.com/astral-sh/ruff-pre-commit
5
5
  # Ruff version.
6
- rev: v0.6.1
6
+ rev: v0.7.3
7
7
  hooks:
8
8
  # Run the linter.
9
9
  - id: ruff
10
10
  types_or: [ python, pyi ]
11
11
  args: [ --fix ]
12
12
  - repo: https://github.com/PyCQA/isort
13
- rev: 5.13.0
13
+ rev: 5.13.2
14
14
  hooks:
15
15
  - id: isort
16
16
  exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|sunpy/extern)$"
17
17
  - repo: https://github.com/pre-commit/pre-commit-hooks
18
- rev: v4.5.0
18
+ rev: v5.0.0
19
19
  hooks:
20
20
  - id: check-ast
21
21
  - id: check-case-conflict
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: thuban
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: High precision and accuracy astrometric image solving from a guess
5
5
  Author-email: "J. Marcus Hughes" <hughes.jmb@gmail.com>
6
6
  Maintainer-email: "J. Marcus Hughes" <hughes.jmb@gmail.com>
@@ -38,6 +38,7 @@ Requires-Dist: sphinx-automodapi; extra == "docs"
38
38
  Requires-Dist: pydata-sphinx-theme; extra == "docs"
39
39
  Requires-Dist: sphinx-favicon; extra == "docs"
40
40
  Requires-Dist: ipython; extra == "docs"
41
+ Requires-Dist: packaging; extra == "docs"
41
42
 
42
43
  # thuban
43
44
 
@@ -2,6 +2,9 @@
2
2
  #
3
3
  # For the full list of built-in configuration values, see the documentation:
4
4
  # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+ from importlib.metadata import version as get_version
6
+
7
+ from packaging.version import Version
5
8
 
6
9
  # -- Project information -----------------------------------------------------
7
10
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
@@ -9,7 +12,12 @@
9
12
  project = "thuban"
10
13
  copyright = "2024, PUNCH Science Operations Center"
11
14
  author = "PUNCH Science Operations Center"
12
- release = "0.0.3"
15
+
16
+ release: str = get_version("thuban")
17
+ version: str = release
18
+ _version = Version(release)
19
+ if _version.is_devrelease:
20
+ version = release = f"{_version.base_version}.dev{_version.dev}"
13
21
 
14
22
  # -- General configuration ---------------------------------------------------
15
23
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
@@ -35,7 +35,7 @@ classifiers = [
35
35
 
36
36
  [project.optional-dependencies]
37
37
  test = ["pytest", "pytest-doctestplus", "pytest-cov", "ruff", "coverage"]
38
- docs = ["sphinx", "sphinx-autoapi", "sphinx-automodapi", "pydata-sphinx-theme", "sphinx-favicon", "ipython"]
38
+ docs = ["sphinx", "sphinx-autoapi", "sphinx-automodapi", "pydata-sphinx-theme", "sphinx-favicon", "ipython", "packaging"]
39
39
 
40
40
  [project.scripts]
41
41
  thuban = "thuban.cli:determine_pointing_and_distortion"
@@ -1,11 +1,11 @@
1
1
  import warnings
2
2
  from typing import Callable
3
3
 
4
+ import astropy.units as u
4
5
  import numpy as np
5
6
  import pandas as pd
6
7
  import sep_pjw as sep
7
8
  from astropy.wcs import WCS, utils
8
- import astropy.units as u
9
9
  from lmfit import Parameters, minimize
10
10
 
11
11
  from thuban.catalog import (filter_for_visible_stars, find_catalog_in_image,
@@ -63,6 +63,7 @@ def _residual(params: Parameters,
63
63
  image_shape: (int, int),
64
64
  edge: int = 100,
65
65
  sigma: float = 3.0,
66
+ max_error: float = 15,
66
67
  mask: Callable = None):
67
68
  """Residual used when optimizing the pointing
68
69
 
@@ -111,20 +112,23 @@ def _residual(params: Parameters,
111
112
  out = np.array([np.min(np.linalg.norm(observed_coords - coord, axis=-1)) for coord in refined_coords[:n]])
112
113
  median, stdev = np.median(out), np.std(out)
113
114
  out[out > median + (sigma * stdev)] = 0.0 # TODO: should this be zero?
115
+ out[out > max_error] = 0.0 # TODO: should this be zero?
114
116
  return out
115
117
 
116
118
 
117
119
  def refine_pointing_wrapper(image, guess_wcs, file_num, observed_coords=None, catalog=None,
118
120
  background_width=16, background_height=16,
119
121
  detection_threshold=5, num_stars=30, max_trials=15, chisqr_threshold=0.1,
120
- dimmest_magnitude=6.0, method='leastsq'):
122
+ dimmest_magnitude=6.0, method='leastsq', ra_tolerance=10, dec_tolerance=5, max_error=15):
121
123
  new_wcs, observed_coords, solution, trial_num = refine_pointing(image,
122
124
  guess_wcs,
123
125
  observed_coords=observed_coords, catalog=catalog,
124
126
  background_width=background_width, background_height=background_height,
125
127
  detection_threshold=detection_threshold, num_stars=num_stars, max_trials=max_trials,
126
128
  chisqr_threshold=chisqr_threshold,
127
- dimmest_magnitude=dimmest_magnitude, method=method)
129
+ dimmest_magnitude=dimmest_magnitude, method=method,
130
+ ra_tolerance=ra_tolerance,
131
+ dec_tolerance=dec_tolerance, max_error=max_error)
128
132
  return new_wcs, observed_coords, solution, trial_num, file_num
129
133
 
130
134
 
@@ -137,7 +141,8 @@ def extract_crota_from_wcs(wcs: WCS) -> tuple[float, float]:
137
141
  def refine_pointing(image, guess_wcs, observed_coords=None, catalog=None,
138
142
  background_width=16, background_height=16,
139
143
  detection_threshold=5, num_stars=30, max_trials=15, chisqr_threshold=0.1,
140
- dimmest_magnitude=6.0, method='leastsq', edge=100, sigma=3.0, mask=None):
144
+ dimmest_magnitude=6.0, method='leastsq', edge=100, sigma=3.0, mask=None,
145
+ ra_tolerance=10, dec_tolerance=5, max_error=15):
141
146
  """ Refine the pointing for an image
142
147
 
143
148
  Parameters
@@ -172,21 +177,40 @@ def refine_pointing(image, guess_wcs, observed_coords=None, catalog=None,
172
177
  observed_coords = np.stack([objects["x"], objects["y"]], axis=-1)
173
178
  if mask is not None:
174
179
  observed_coords = observed_coords[mask(objects['x'], objects['y'])]
180
+
181
+ image_shape = image.shape
182
+ reduced_catalog = find_catalog_in_image(catalog, guess_wcs, image_shape=image_shape, mask=mask)
183
+ refined_coords = np.stack([reduced_catalog['x_pix'], reduced_catalog['y_pix']], axis=-1)
184
+ # print("catalog found", len(refined_coords), refined_coords)
185
+
186
+ image_bounds = (image_shape[0] - edge, image_shape[1] - edge)
187
+ refined_coords = np.array([c for c in refined_coords
188
+ if (c[0] > edge) and (c[1] > edge) and (c[0] < image_bounds[0]) and (
189
+ c[1] < image_bounds[1])])
190
+
191
+ distances = np.array([np.min(np.linalg.norm(refined_coords - coord, axis=-1)) for coord in observed_coords])
192
+ observed_coords = observed_coords[distances < max_error]
175
193
  observed_coords = observed_coords[-3*num_stars:]
176
194
  # set up the optimization
177
195
  params = Parameters()
178
196
  initial_crota = extract_crota_from_wcs(guess_wcs)
179
197
  params.add("crota", value=initial_crota.to(u.rad).value, min=-np.pi, max=np.pi)
180
- params.add("crval1", value=guess_wcs.wcs.crval[0], min=-180, max=180, vary=True)
181
- params.add("crval2", value=guess_wcs.wcs.crval[1], min=-90, max=90, vary=True)
182
-
198
+ params.add("crval1", value=guess_wcs.wcs.crval[0],
199
+ min=guess_wcs.wcs.crval[0]-ra_tolerance,
200
+ max=guess_wcs.wcs.crval[0]+ra_tolerance, vary=True)
201
+ params.add("crval2", value=guess_wcs.wcs.crval[1],
202
+ min=guess_wcs.wcs.crval[1]-dec_tolerance,
203
+ max=guess_wcs.wcs.crval[1]+dec_tolerance, vary=True)
204
+
205
+ # return guess_wcs, observed_coords, None, None
183
206
  # optimize
184
207
  trial_num = 0
185
208
  result_wcses, result_minimizations = [], []
186
209
  while trial_num < max_trials:
187
210
  try:
188
211
  out = minimize(_residual, params, method=method,
189
- args=(observed_coords, catalog, guess_wcs, num_stars, image.shape, edge, sigma, mask))
212
+ args=(observed_coords, catalog, guess_wcs,
213
+ num_stars, image.shape, edge, sigma, max_error, mask))
190
214
  chisqr = out.chisqr
191
215
  result_minimizations.append(out)
192
216
  except IndexError:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: thuban
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: High precision and accuracy astrometric image solving from a guess
5
5
  Author-email: "J. Marcus Hughes" <hughes.jmb@gmail.com>
6
6
  Maintainer-email: "J. Marcus Hughes" <hughes.jmb@gmail.com>
@@ -38,6 +38,7 @@ Requires-Dist: sphinx-automodapi; extra == "docs"
38
38
  Requires-Dist: pydata-sphinx-theme; extra == "docs"
39
39
  Requires-Dist: sphinx-favicon; extra == "docs"
40
40
  Requires-Dist: ipython; extra == "docs"
41
+ Requires-Dist: packaging; extra == "docs"
41
42
 
42
43
  # thuban
43
44
 
@@ -9,7 +9,6 @@ codecov.yaml
9
9
  pyproject.toml
10
10
  .github/workflows/ci.yaml
11
11
  .github/workflows/ci_fixed.yaml
12
- .github/workflows/docs.yaml
13
12
  .github/workflows/publish.yaml
14
13
  docs/Makefile
15
14
  docs/conf.py
@@ -16,6 +16,7 @@ sphinx-automodapi
16
16
  pydata-sphinx-theme
17
17
  sphinx-favicon
18
18
  ipython
19
+ packaging
19
20
 
20
21
  [test]
21
22
  pytest
@@ -1,36 +0,0 @@
1
- name: deploy-docs
2
-
3
- # Only run this when the master branch changes
4
- on:
5
- push:
6
- branches:
7
- - main
8
-
9
- # This job installs dependencies, builds the book, and pushes it to `gh-pages`
10
- jobs:
11
- deploy-docs:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v2
15
-
16
- # Install dependencies
17
- - name: Set up Python 3.10
18
- uses: actions/setup-python@v2
19
- with:
20
- python-version: "3.10"
21
-
22
- - name: Install dependencies
23
- run: |
24
- pip install ".[docs]"
25
-
26
- # Build the book
27
- - name: Sphinx build
28
- run: |
29
- cd ./docs; make html; cd ..
30
-
31
- # Push the book's HTML to github-pages
32
- - name: GitHub Pages action
33
- uses: peaceiris/actions-gh-pages@v3.6.1
34
- with:
35
- github_token: ${{ secrets.GITHUB_TOKEN }}
36
- publish_dir: ./docs/_build/html
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes