Skip to content

Commit 995921b

Browse files
committed
refactor: drop sip_tpv dependency, rely on astropy for TPV WCS
Closes #713. The only functional use of sip_tpv in shapepipe was `split_exp.create_hdus` calling `stp.pv_to_sip(h)` to rewrite each per-CCD header's TPV distortion keywords as SIP before saving. Modern astropy (>=5) parses TPV natively via WCSLIB, as do SExtractor, PSFEx, and every other downstream WCS consumer in the pipeline, so the keyword-level conversion was no longer buying us anything. Removing the conversion lets us drop sip_tpv entirely — an unmaintained 2017 package whose v1.1 imports `pkg_resources` at module load and is incompatible with setuptools>=81 (the underlying cause of the ModuleNotFoundError in #713; PR #714's setuptools<81 pin is a symptom workaround). Changes: - split_exp: remove sip_tpv import + pv_to_sip call; drop the now-dead `transf_coord` plumbing through `process` / `create_hdus`; update module docstring accordingly. - Remove sip_tpv from `depends=[...]` in split_exp_runner, python_example_runner, and find_exposures_runner (the last was a spurious declaration — find_exposures_package never imported it). - Drop sip_tpv from environment.yml, environment-dev.yml, Dockerfile, install_shapepipe, docs/source/dependencies.md, and the orphan shupe:12 BibTeX entry. - New: `src/shapepipe/tests/test_split_exp.py` — three unittests that build a synthetic multi-CCD FITS with TPV distortion, run SplitExposures, and verify (1) per-CCD header WCS matches the source for several pixel samples, (2) the saved headers .npy round-trips pixel→world→pixel, (3) flag output uses int16. `scripts/jupyter/wcs.ipynb` still imports sip_tpv; it's an exploratory notebook last touched ~2.5 years ago and left alone.
1 parent 8b59e95 commit 995921b

12 files changed

Lines changed: 169 additions & 40 deletions

File tree

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ RUN pip install --no-cache-dir --upgrade pip && \
8080
pytest-pydocstyle==2.4.0 \
8181
reproject==0.14.1 \
8282
sf_tools==2.0.4 \
83-
sip_tpv==1.1 \
8483
skaha==1.7.0 \
8584
sqlitedict==2.0.0 \
8685
termcolor==1.1.0 \

docs/source/dependencies.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ reproducibility of the results. Below we list the main packages used.
2020
| [Numpy](https://numpy.org/) | {cite:p}`harris:20` |
2121
| [Pandas](https://pandas.pydata.org/) | {cite:p}`pandas:10,pandas:20` |
2222
| [sf_tools](https://github.com/sfarrens/sf_tools) | |
23-
| [sip_tpv](https://github.com/stargaser/sip_tpv) | {cite:p}`shupe:12` |
2423
| [sqlitedict](https://github.com/RaRe-Technologies/sqlitedict) | |
2524
| [TreeCorr](https://rmjarvis.github.io/TreeCorr/_build/html/index.html) | {cite:p}`jarvis:04` |
2625

docs/source/refs.bib

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -736,22 +736,6 @@ @MISC{sheldon:15
736736
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
737737
}
738738

739-
@INPROCEEDINGS{shupe:12,
740-
author = {{Shupe}, David L. and {Laher}, Russ R. and {Storrie-Lombardi}, Lisa and {Surace}, Jason and {Grillmair}, Carl and {Levitan}, David and {Sesar}, Branimir},
741-
title = "{More flexibility in representing geometric distortion in astronomical images}",
742-
booktitle = {Software and Cyberinfrastructure for Astronomy II},
743-
year = 2012,
744-
editor = {{Radziwill}, Nicole M. and {Chiozzi}, Gianluca},
745-
series = {Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series},
746-
volume = {8451},
747-
month = sep,
748-
eid = {84511M},
749-
pages = {84511M},
750-
doi = {10.1117/12.925460},
751-
adsurl = {https://ui.adsabs.harvard.edu/abs/2012SPIE.8451E..1MS},
752-
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
753-
}
754-
755739
@article{spitzer:21,
756740
author = {{Spitzer}, I. et al.},
757741
title = "{Galaxy group and cluster masses from weak lensing in UNIONS}",

environment-dev.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ dependencies:
3131
- cs_util==0.0.5
3232
- mccd==1.2.4
3333
- modopt==1.6.1
34-
- sip_tpv==1.1
3534
- sf_tools==2.0.4
3635
- git+https://github.com/CEA-COSMIC/pysap@develop
3736
- git+https://github.com/aguinot/ngmix@stable_version

environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ dependencies:
3636
- reproject
3737
- shear_psf_leakage
3838
- skaha
39-
- sip_tpv
4039
- sf_tools
4140
- sqlitedict
4241
- termcolor

install_shapepipe

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ site-packages() {
237237
check_site_pkg "pysap"
238238
check_site_pkg "scipy"
239239
check_site_pkg "sf_tools"
240-
check_site_pkg "sip_tpv"
241240
check_site_pkg "sqlitedict"
242241
check_site_pkg "treecorr"
243242
}

src/shapepipe/modules/find_exposures_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
version="1.1",
1515
file_pattern=["image"],
1616
file_ext=".fits",
17-
depends=["numpy", "astropy", "sip_tpv"],
17+
depends=["numpy", "astropy"],
1818
numbering_scheme="_0",
1919
)
2020
def find_exposures_runner(

src/shapepipe/modules/python_example_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"pysap",
2626
"scipy",
2727
"sf_tools",
28-
"sip_tpv",
2928
"sqlitedict",
3029
"treecorr",
3130
],

src/shapepipe/modules/split_exp_package/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
``image``:
2929
3030
1. Header is saved to numpy binary file (``.npy``);
31-
2. Header WCS is saved in output FITS file header;
32-
3. Geader WCS coordinates are transformed from pv to sip using the
33-
``sip_tpv`` package
31+
2. Header WCS is saved in output FITS file header
3432
3533
``flag``: data is save as ``int16``
3634

src/shapepipe/modules/split_exp_package/split_exp.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"""
1212

1313
import numpy as np
14-
import sip_tpv as stp
1514
from astropy.io import fits
1615
from astropy.wcs import WCS
1716

@@ -62,16 +61,11 @@ def process(self):
6261
):
6362

6463
transf_int = "flag" in output_suffix
65-
transf_coord = "image" in output_suffix
6664
save_header = "image" in output_suffix
6765

68-
self.create_hdus(
69-
exp_path, output_suffix, transf_coord, transf_int, save_header
70-
)
66+
self.create_hdus(exp_path, output_suffix, transf_int, save_header)
7167

72-
def create_hdus(
73-
self, exp_path, output_suffix, transf_coord, transf_int, save_header
74-
):
68+
def create_hdus(self, exp_path, output_suffix, transf_int, save_header):
7569
"""Create HDUs.
7670
7771
Split a single exposures CCDs into separate files.
@@ -82,8 +76,6 @@ def create_hdus(
8276
Path to the single exposure
8377
output_suffix : str
8478
Suffix for the output file
85-
transf_coord : bool
86-
Transform the WCS (``pv`` to ``sip``) if ``True``
8779
transf_int : bool
8880
Set data types to int if ``True``
8981
save_header : bool
@@ -101,10 +93,7 @@ def create_hdus(
10193

10294
for idx in range(1, self._n_hdu + 1):
10395

104-
# h = fits.getheader(exp_path, idx)
10596
h = hdu_list[idx].header
106-
if transf_coord:
107-
stp.pv_to_sip(h)
10897

10998
# d = fits.getdata(exp_path, idx)
11099
try:

0 commit comments

Comments
 (0)