STCI 0.1.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.
@@ -0,0 +1,77 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ import astropy.units as u
6
+ import numpy as np
7
+ from astropy.coordinates import SkyCoord
8
+ from astropy.io import fits
9
+ from astroquery.esa.euclid.core import EuclidClass
10
+
11
+
12
+ BANDS = ("VIS", "NIR_Y", "NIR_J", "NIR_H")
13
+
14
+
15
+ def _query(ra: float, dec: float) -> str:
16
+ return (
17
+ "SELECT file_name, file_path, filter_name, product_id "
18
+ "FROM dr1.mosaic_product "
19
+ "WHERE (product_type like '%Mer%Mosaic%') "
20
+ "AND ((instrument_name='VIS' AND filter_name='VIS') "
21
+ "OR (instrument_name='NISP' AND filter_name IN ('NIR_Y','NIR_J','NIR_H'))) "
22
+ "AND category='SCIENCE' AND fov IS NOT NULL AND "
23
+ f"INTERSECTS(CIRCLE('ICRS',{ra},{dec},0.0166667),fov)=1 "
24
+ "ORDER BY product_id ASC"
25
+ )
26
+
27
+
28
+ def _is_all_zero(path: Path) -> bool:
29
+ with fits.open(path, memmap=False) as hdul:
30
+ data = next(hdu.data for hdu in hdul if hdu.data is not None)
31
+ return np.count_nonzero(np.nan_to_num(data, nan=0.0)) == 0
32
+
33
+
34
+ def EUC_download(ra, dec, size, path, cred):
35
+ """
36
+ Download Euclid DR1 VIS/Y/J/H FITS cutouts.
37
+
38
+ Parameters
39
+ ----------
40
+ ra, dec : float
41
+ Target coordinates in degrees.
42
+ size : float
43
+ Cutout radius in arcsec.
44
+ path : str or Path
45
+ Output directory.
46
+ cred : str or Path
47
+ Euclid credentials file.
48
+ """
49
+
50
+ outdir = Path(path)
51
+ outdir.mkdir(parents=True, exist_ok=True)
52
+ coord = SkyCoord(float(ra), float(dec), unit="deg")
53
+
54
+ euclid = EuclidClass(environment="IDR")
55
+ euclid.login(credentials_file=str(cred))
56
+
57
+ rows = euclid.launch_job(_query(float(ra), float(dec)), verbose=False).get_results()
58
+ outputs = {}
59
+
60
+ for band in BANDS:
61
+ for i, row in enumerate(rows[rows["filter_name"] == band], start=1):
62
+ outfile = outdir / f"{band}_tile{i}.fits"
63
+ euclid.get_cutout(
64
+ file_path=f"{row['file_path']}/{row['file_name']}",
65
+ instrument="None",
66
+ id=str(row["product_id"]),
67
+ coordinate=coord,
68
+ radius=u.Quantity(float(size), u.arcsec),
69
+ output_file=str(outfile),
70
+ )
71
+ if outfile.stat().st_size > 0 and not _is_all_zero(outfile):
72
+ outputs[band] = outfile
73
+ break
74
+ if band not in outputs:
75
+ raise RuntimeError(f"No non-zero {band} cutout found.")
76
+
77
+ return outputs
stci-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tian Li
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.
stci-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: STCI
3
+ Version: 0.1.0
4
+ Summary: SpaceTelescopeColorImage tools for astronomy cutouts.
5
+ Author: Tian Li
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/astroskylee/STCI
8
+ Project-URL: Repository, https://github.com/astroskylee/STCI
9
+ Keywords: astronomy,euclid,fits,image-processing,color-image
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: astropy
21
+ Requires-Dist: astroquery
22
+ Requires-Dist: numpy
23
+ Requires-Dist: pillow
24
+ Requires-Dist: tifffile
25
+ Dynamic: license-file
26
+
27
+ # STCI
28
+
29
+ STCI stands for **SpaceTelescopeColorImage**.
30
+
31
+ STCI is a small astronomy image-composition tool for making display-ready
32
+ color JPEGs from space telescope cutouts and other aligned mono images.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install STCI
38
+ ```
39
+
40
+ The installed Python import module is `STCI`.
41
+
42
+ ## Example usage
43
+
44
+ `mk_colorimg` creates one color JPEG from either a 3-channel RGB array or three mono images in `(R, G, B)` order. For Euclid-style color images, the default mapping is `NIR_J`, `NIR_Y`, `VIS`.
45
+
46
+ ```python
47
+ from STCI import mk_colorimg
48
+
49
+ mk_colorimg(
50
+ [
51
+ "cutout_H.fits", # R channel
52
+ "cutout_VIS.fits", # G channel
53
+ "cutout_Y.fits", # B channel
54
+ ],
55
+ output_jpg="target_mtf_vis_y_h.jpg",
56
+ input_mode="raw",
57
+ )
58
+ ```
59
+
60
+ For a NumPy RGB cube:
61
+
62
+ ```python
63
+ from STCI import mk_colorimg
64
+
65
+ mk_colorimg(rgb_array, output_jpg="target_color.jpg", input_mode="normalized")
66
+ ```
67
+
68
+ ## Download a Euclid Color Image
69
+
70
+ `Euclidimg` downloads Euclid DR1 `VIS`, `NIR_Y`, `NIR_J`, and `NIR_H` FITS cutouts, then renders one color JPEG using the `NIR_J / NIR_Y / VIS` channel order.
71
+
72
+ ```python
73
+ from STCI import Euclidimg
74
+
75
+ result = Euclidimg(
76
+ ra=50.7163333,
77
+ dec=-39.7693889,
78
+ size=5.0,
79
+ path="euclid_color",
80
+ cred="Euclid/cred.txt",
81
+ output_jpg="EUCLJ032251.92-394609.8.jpg",
82
+ )
83
+
84
+ print(result["jpg"])
85
+ print(result["fits"])
86
+ ```
87
+
88
+ Arguments:
89
+
90
+ - `ra`, `dec`: target coordinates in degrees.
91
+ - `size`: cutout radius in arcsec. For example, `size=5.0` makes a `10" x 10"` image.
92
+ - `path`: output directory for the FITS files and JPEG.
93
+ - `cred`: Euclid credentials file passed to `astroquery.esa.euclid`.
94
+ - `output_jpg`: optional JPEG filename written inside `path`.
95
+
96
+ The returned dictionary contains the selected FITS paths and the final JPEG path. If the first overlapping mosaic tile for a band is empty or all zero, the downloader tries the next matching tile.
97
+
98
+ ## Download Euclid FITS Only
99
+
100
+ ```python
101
+ from Download_Euclid import EUC_download
102
+
103
+ fits_paths = EUC_download(
104
+ ra=50.7163333,
105
+ dec=-39.7693889,
106
+ size=5.0,
107
+ path="euclid_fits",
108
+ cred="Euclid/cred.txt",
109
+ )
110
+ ```
stci-0.1.0/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # STCI
2
+
3
+ STCI stands for **SpaceTelescopeColorImage**.
4
+
5
+ STCI is a small astronomy image-composition tool for making display-ready
6
+ color JPEGs from space telescope cutouts and other aligned mono images.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ pip install STCI
12
+ ```
13
+
14
+ The installed Python import module is `STCI`.
15
+
16
+ ## Example usage
17
+
18
+ `mk_colorimg` creates one color JPEG from either a 3-channel RGB array or three mono images in `(R, G, B)` order. For Euclid-style color images, the default mapping is `NIR_J`, `NIR_Y`, `VIS`.
19
+
20
+ ```python
21
+ from STCI import mk_colorimg
22
+
23
+ mk_colorimg(
24
+ [
25
+ "cutout_H.fits", # R channel
26
+ "cutout_VIS.fits", # G channel
27
+ "cutout_Y.fits", # B channel
28
+ ],
29
+ output_jpg="target_mtf_vis_y_h.jpg",
30
+ input_mode="raw",
31
+ )
32
+ ```
33
+
34
+ For a NumPy RGB cube:
35
+
36
+ ```python
37
+ from STCI import mk_colorimg
38
+
39
+ mk_colorimg(rgb_array, output_jpg="target_color.jpg", input_mode="normalized")
40
+ ```
41
+
42
+ ## Download a Euclid Color Image
43
+
44
+ `Euclidimg` downloads Euclid DR1 `VIS`, `NIR_Y`, `NIR_J`, and `NIR_H` FITS cutouts, then renders one color JPEG using the `NIR_J / NIR_Y / VIS` channel order.
45
+
46
+ ```python
47
+ from STCI import Euclidimg
48
+
49
+ result = Euclidimg(
50
+ ra=50.7163333,
51
+ dec=-39.7693889,
52
+ size=5.0,
53
+ path="euclid_color",
54
+ cred="Euclid/cred.txt",
55
+ output_jpg="EUCLJ032251.92-394609.8.jpg",
56
+ )
57
+
58
+ print(result["jpg"])
59
+ print(result["fits"])
60
+ ```
61
+
62
+ Arguments:
63
+
64
+ - `ra`, `dec`: target coordinates in degrees.
65
+ - `size`: cutout radius in arcsec. For example, `size=5.0` makes a `10" x 10"` image.
66
+ - `path`: output directory for the FITS files and JPEG.
67
+ - `cred`: Euclid credentials file passed to `astroquery.esa.euclid`.
68
+ - `output_jpg`: optional JPEG filename written inside `path`.
69
+
70
+ The returned dictionary contains the selected FITS paths and the final JPEG path. If the first overlapping mosaic tile for a band is empty or all zero, the downloader tries the next matching tile.
71
+
72
+ ## Download Euclid FITS Only
73
+
74
+ ```python
75
+ from Download_Euclid import EUC_download
76
+
77
+ fits_paths = EUC_download(
78
+ ra=50.7163333,
79
+ dec=-39.7693889,
80
+ size=5.0,
81
+ path="euclid_fits",
82
+ cred="Euclid/cred.txt",
83
+ )
84
+ ```
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: STCI
3
+ Version: 0.1.0
4
+ Summary: SpaceTelescopeColorImage tools for astronomy cutouts.
5
+ Author: Tian Li
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/astroskylee/STCI
8
+ Project-URL: Repository, https://github.com/astroskylee/STCI
9
+ Keywords: astronomy,euclid,fits,image-processing,color-image
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: astropy
21
+ Requires-Dist: astroquery
22
+ Requires-Dist: numpy
23
+ Requires-Dist: pillow
24
+ Requires-Dist: tifffile
25
+ Dynamic: license-file
26
+
27
+ # STCI
28
+
29
+ STCI stands for **SpaceTelescopeColorImage**.
30
+
31
+ STCI is a small astronomy image-composition tool for making display-ready
32
+ color JPEGs from space telescope cutouts and other aligned mono images.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install STCI
38
+ ```
39
+
40
+ The installed Python import module is `STCI`.
41
+
42
+ ## Example usage
43
+
44
+ `mk_colorimg` creates one color JPEG from either a 3-channel RGB array or three mono images in `(R, G, B)` order. For Euclid-style color images, the default mapping is `NIR_J`, `NIR_Y`, `VIS`.
45
+
46
+ ```python
47
+ from STCI import mk_colorimg
48
+
49
+ mk_colorimg(
50
+ [
51
+ "cutout_H.fits", # R channel
52
+ "cutout_VIS.fits", # G channel
53
+ "cutout_Y.fits", # B channel
54
+ ],
55
+ output_jpg="target_mtf_vis_y_h.jpg",
56
+ input_mode="raw",
57
+ )
58
+ ```
59
+
60
+ For a NumPy RGB cube:
61
+
62
+ ```python
63
+ from STCI import mk_colorimg
64
+
65
+ mk_colorimg(rgb_array, output_jpg="target_color.jpg", input_mode="normalized")
66
+ ```
67
+
68
+ ## Download a Euclid Color Image
69
+
70
+ `Euclidimg` downloads Euclid DR1 `VIS`, `NIR_Y`, `NIR_J`, and `NIR_H` FITS cutouts, then renders one color JPEG using the `NIR_J / NIR_Y / VIS` channel order.
71
+
72
+ ```python
73
+ from STCI import Euclidimg
74
+
75
+ result = Euclidimg(
76
+ ra=50.7163333,
77
+ dec=-39.7693889,
78
+ size=5.0,
79
+ path="euclid_color",
80
+ cred="Euclid/cred.txt",
81
+ output_jpg="EUCLJ032251.92-394609.8.jpg",
82
+ )
83
+
84
+ print(result["jpg"])
85
+ print(result["fits"])
86
+ ```
87
+
88
+ Arguments:
89
+
90
+ - `ra`, `dec`: target coordinates in degrees.
91
+ - `size`: cutout radius in arcsec. For example, `size=5.0` makes a `10" x 10"` image.
92
+ - `path`: output directory for the FITS files and JPEG.
93
+ - `cred`: Euclid credentials file passed to `astroquery.esa.euclid`.
94
+ - `output_jpg`: optional JPEG filename written inside `path`.
95
+
96
+ The returned dictionary contains the selected FITS paths and the final JPEG path. If the first overlapping mosaic tile for a band is empty or all zero, the downloader tries the next matching tile.
97
+
98
+ ## Download Euclid FITS Only
99
+
100
+ ```python
101
+ from Download_Euclid import EUC_download
102
+
103
+ fits_paths = EUC_download(
104
+ ra=50.7163333,
105
+ dec=-39.7693889,
106
+ size=5.0,
107
+ path="euclid_fits",
108
+ cred="Euclid/cred.txt",
109
+ )
110
+ ```
@@ -0,0 +1,11 @@
1
+ Download_Euclid.py
2
+ LICENSE
3
+ README.md
4
+ STCI.py
5
+ Tian_color.py
6
+ pyproject.toml
7
+ STCI.egg-info/PKG-INFO
8
+ STCI.egg-info/SOURCES.txt
9
+ STCI.egg-info/dependency_links.txt
10
+ STCI.egg-info/requires.txt
11
+ STCI.egg-info/top_level.txt
@@ -0,0 +1,5 @@
1
+ astropy
2
+ astroquery
3
+ numpy
4
+ pillow
5
+ tifffile
@@ -0,0 +1,3 @@
1
+ Download_Euclid
2
+ STCI
3
+ Tian_color
stci-0.1.0/STCI.py ADDED
@@ -0,0 +1,21 @@
1
+ """Public entry point for STCI."""
2
+
3
+ from pathlib import Path
4
+
5
+ from Tian_color import * # noqa: F401,F403
6
+
7
+
8
+ def Euclidimg(ra, dec, size, path, cred, output_jpg="Euclid_color.jpg"):
9
+ """Download Euclid FITS cutouts and render one color JPEG."""
10
+
11
+ from Download_Euclid import EUC_download
12
+
13
+ outdir = Path(path)
14
+ fits_paths = EUC_download(ra, dec, size, outdir, cred)
15
+ jpg_path = outdir / output_jpg
16
+ mk_colorimg(
17
+ [fits_paths["NIR_J"], fits_paths["NIR_Y"], fits_paths["VIS"]],
18
+ output_jpg=jpg_path,
19
+ input_mode="raw",
20
+ )
21
+ return {"fits": fits_paths, "jpg": jpg_path}