roman-snpit-snappl 0.3.0__tar.gz → 0.4.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.
Potentially problematic release.
This version of roman-snpit-snappl might be problematic. Click here for more details.
- {roman_snpit_snappl-0.3.0/roman_snpit_snappl.egg-info → roman_snpit_snappl-0.4.0}/PKG-INFO +1 -1
- roman_snpit_snappl-0.4.0/changes/18.feature.rst +1 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0/roman_snpit_snappl.egg-info}/PKG-INFO +1 -1
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/roman_snpit_snappl.egg-info/SOURCES.txt +1 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/snappl/_version.py +2 -2
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/snappl/image.py +51 -1
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/snappl/psf.py +89 -4
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.cruft.json +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/CODEOWNERS +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/ISSUE_TEMPLATE/PR_TEMPLATE.md +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/dependabot.yml +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/labeler.yml +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/workflows/changelog.yml +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/workflows/run_labeler.yml +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/workflows/run_snappl_tests.yml +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/workflows/sphinx-deploy.yml +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/workflows/sub_package_update.yml +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.gitignore +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.pre-commit-config.yaml +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/CHANGES.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/CITATION.cff +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/CODE_OF_CONDUCT.md +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/CONTRIBUTING.md +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/LICENSE +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/MANIFEST.in +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/README.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/changes/.gitkeep +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/changes/10.snappl.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/changes/13.bugfix.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/changes/14.snappl.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/changes/15.feature.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/changes/16.feature.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/changes/3.snappl.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/changes/5.snappl.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/changes/8.snappl.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/changes/9.snappl.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/codespell-ignore.txt +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/docs/Makefile +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/docs/_static/logo_black_filled.png +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/docs/changes.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/docs/conf.py +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/docs/index.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/docs/installation.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/docs/make.bat +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/docs/usage.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/licenses/.DS_Store +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/licenses/LICENSE.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/licenses/README.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/licenses/TEMPLATE_LICENSE.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/pyproject.toml +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/roman_snpit_snappl.egg-info/dependency_links.txt +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/roman_snpit_snappl.egg-info/not-zip-safe +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/roman_snpit_snappl.egg-info/requires.txt +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/roman_snpit_snappl.egg-info/top_level.txt +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/setup.cfg +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/setup.py +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/snappl/__init__.py +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/snappl/_dev/__init__.py +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/snappl/_dev/scm_version.py +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/snappl/data/README.rst +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/snappl/wcs.py +0 -0
- {roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/tox.ini +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Add a few properties (sca, zeropoint, etc.) to Image ; add ou2024PSF.
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import types
|
|
2
|
+
import pathlib
|
|
2
3
|
|
|
3
4
|
import numpy as np
|
|
4
5
|
from astropy.io import fits
|
|
5
6
|
from astropy.nddata.utils import Cutout2D
|
|
6
7
|
# from astropy.coordinates import SkyCoord
|
|
7
8
|
|
|
9
|
+
import galsim.roman
|
|
10
|
+
|
|
8
11
|
from snpit_utils.logger import SNLogger
|
|
9
12
|
from snappl.wcs import AstropyWCS, GalsimWCS
|
|
10
13
|
|
|
@@ -63,11 +66,12 @@ class Image:
|
|
|
63
66
|
|
|
64
67
|
"""
|
|
65
68
|
self.inputs = types.SimpleNamespace()
|
|
66
|
-
self.inputs.path = path
|
|
69
|
+
self.inputs.path = pathlib.Path( path )
|
|
67
70
|
self.inputs.exposure = exposure
|
|
68
71
|
self.inputs.sca = sca
|
|
69
72
|
self._wcs = None # a BaseWCS object (in wcs.py)
|
|
70
73
|
self._is_cutout = False
|
|
74
|
+
self._zeropoint = None
|
|
71
75
|
|
|
72
76
|
@property
|
|
73
77
|
def data( self ):
|
|
@@ -101,6 +105,18 @@ class Image:
|
|
|
101
105
|
"""Tuple: (ny, nx) pixel size of image."""
|
|
102
106
|
raise NotImplementedError( f"{self.__class__.__name__} needs to implement image_shape" )
|
|
103
107
|
|
|
108
|
+
@property
|
|
109
|
+
def sca( self ):
|
|
110
|
+
return self.inputs.sca
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def path( self ):
|
|
114
|
+
return self.inputs.path
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def name( self ):
|
|
118
|
+
return self.inputs.path.name
|
|
119
|
+
|
|
104
120
|
@property
|
|
105
121
|
def sky_level( self ):
|
|
106
122
|
"""Estimate of the sky level in ADU."""
|
|
@@ -116,6 +132,24 @@ class Image:
|
|
|
116
132
|
"""Band (str)"""
|
|
117
133
|
raise NotImplementedError( f"{self.__class__.__name__} needs to implement band" )
|
|
118
134
|
|
|
135
|
+
@property
|
|
136
|
+
def zeropoint( self ):
|
|
137
|
+
"""Image zeropoint for AB magnitudes.
|
|
138
|
+
|
|
139
|
+
The zeropoint zp is defined so that an object with total counts
|
|
140
|
+
c has magnitude m:
|
|
141
|
+
|
|
142
|
+
m = -2.5 * log(10) + zp
|
|
143
|
+
|
|
144
|
+
"""
|
|
145
|
+
if self._zeropoint is None:
|
|
146
|
+
self._get_zeropoint()
|
|
147
|
+
return self._zeropoint
|
|
148
|
+
|
|
149
|
+
@zeropoint.setter
|
|
150
|
+
def zeropoint( self, val ):
|
|
151
|
+
self._zeropoint = val
|
|
152
|
+
|
|
119
153
|
@property
|
|
120
154
|
def mjd( self ):
|
|
121
155
|
"""MJD of the start of the image (defined how? TAI?)"""
|
|
@@ -192,7 +226,12 @@ class Image:
|
|
|
192
226
|
"""
|
|
193
227
|
raise NotImplementedError( f"{self.__class__.__name__} needs to implement get_wcs" )
|
|
194
228
|
|
|
229
|
+
def _get_zeropoint( self ):
|
|
230
|
+
"""Set self._zeropoint; see "zeropoint" property above."""
|
|
231
|
+
raise NotImplementedError( f"{self.__class__.__name__} needs to implement _get_zeropoint" )
|
|
232
|
+
|
|
195
233
|
def get_cutout(self, ra, dec, size):
|
|
234
|
+
|
|
196
235
|
"""Make a cutout of the image at the given RA and DEC.
|
|
197
236
|
|
|
198
237
|
Returns
|
|
@@ -504,3 +543,14 @@ class OpenUniverse2024FITSImage( FITSImage ):
|
|
|
504
543
|
"""The band the image is taken in (str)."""
|
|
505
544
|
header = self._get_header()
|
|
506
545
|
return header['FILTER'].strip()
|
|
546
|
+
|
|
547
|
+
@property
|
|
548
|
+
def mjd(self):
|
|
549
|
+
"""The mjd of the image."""
|
|
550
|
+
header = self._get_header()
|
|
551
|
+
return float( header['MJD-OBS'] )
|
|
552
|
+
|
|
553
|
+
@property
|
|
554
|
+
def _get_zeropoint( self ):
|
|
555
|
+
header = self._get_header()
|
|
556
|
+
return galsim.roman.getBandpasses()[self.band].zeropoint + header['ZPTMAG']
|
|
@@ -3,10 +3,17 @@ import base64
|
|
|
3
3
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
|
|
6
|
+
from roman_imsim.utils import roman_utils
|
|
7
|
+
import galsim
|
|
8
|
+
|
|
9
|
+
from snpit_utils.config import Config
|
|
10
|
+
from snpit_utils.logger import SNLogger
|
|
11
|
+
|
|
6
12
|
|
|
7
13
|
class PSF:
|
|
14
|
+
# Thought required: how to deal with oversampling.
|
|
15
|
+
|
|
8
16
|
def __init__( self, *args, **kwargs ):
|
|
9
|
-
# Will define a PSF with a nominal position
|
|
10
17
|
pass
|
|
11
18
|
|
|
12
19
|
def get_stamp( self, x, y, flux=1. ):
|
|
@@ -35,11 +42,39 @@ class PSF:
|
|
|
35
42
|
"""
|
|
36
43
|
raise NotImplementedError( f"{self.__class__.__name__} needs to implement get_stamp" )
|
|
37
44
|
|
|
45
|
+
@classmethod
|
|
46
|
+
def get_psf_object( cls, psfclass, **kwargs ):
|
|
47
|
+
"""Return a PSF object whose type is specified by psfclass.
|
|
48
|
+
|
|
49
|
+
Parameters
|
|
50
|
+
----------
|
|
51
|
+
psfclass : str
|
|
52
|
+
The name of the class of the PSF to instantiate.
|
|
53
|
+
|
|
54
|
+
**kwargs : further keyword arguments
|
|
55
|
+
TODO : we need to standardize on these so that things can
|
|
56
|
+
just call PSF.get_psf_object() without having to have their
|
|
57
|
+
own if statements on the type to figure out what kwargs to
|
|
58
|
+
pass!
|
|
59
|
+
|
|
60
|
+
"""
|
|
61
|
+
if psfclass == "OversampledImagePSF":
|
|
62
|
+
return OversampledImagePSF.create( **kwargs )
|
|
63
|
+
|
|
64
|
+
if psfclass == "YamlSerialized_OversampledImagePSF":
|
|
65
|
+
return YamlSerialized_OversampledImagePSF( **kwargs )
|
|
66
|
+
|
|
67
|
+
if psfclass == "ou24PSF":
|
|
68
|
+
return ou24PSF( **kwargs )
|
|
69
|
+
|
|
70
|
+
raise ValueError( f"Unknown PSF class {psfclass}" )
|
|
38
71
|
|
|
39
72
|
|
|
40
73
|
class OversampledImagePSF( PSF ):
|
|
41
74
|
@classmethod
|
|
42
|
-
def create( cls, data, x0, y0, oversample_factor=1., enforce_odd=True, normalize=True
|
|
75
|
+
def create( cls, data=None, x0=None, y0=None, oversample_factor=1., enforce_odd=True, normalize=True,
|
|
76
|
+
**kwargs ):
|
|
77
|
+
|
|
43
78
|
"""Parameters
|
|
44
79
|
----------
|
|
45
80
|
data: 2d numpy array
|
|
@@ -61,9 +96,19 @@ class OversampledImagePSF( PSF ):
|
|
|
61
96
|
object of type cls
|
|
62
97
|
|
|
63
98
|
"""
|
|
99
|
+
|
|
100
|
+
if len(kwargs) > 0:
|
|
101
|
+
SNLogger.warning( f"Unused arguments to OversampledImagePSF.create: {[k for k in kwargs]}" )
|
|
102
|
+
|
|
64
103
|
# TODO : implement enforce_odd
|
|
65
104
|
# TODO : enforce square
|
|
66
105
|
|
|
106
|
+
if not isinstance( data, np.ndarray ) or ( len(data.shape) != 2 ):
|
|
107
|
+
raise TypeError( "data must be a 2d numpy array" )
|
|
108
|
+
|
|
109
|
+
x0 = float( x0 )
|
|
110
|
+
y0 = float( y0 )
|
|
111
|
+
|
|
67
112
|
psf = cls()
|
|
68
113
|
psf._data = data
|
|
69
114
|
if normalize:
|
|
@@ -203,5 +248,45 @@ class YamlSerialized_OversampledImagePSF( OversampledImagePSF ):
|
|
|
203
248
|
yaml.dump( out, open( filepath, 'w' ) )
|
|
204
249
|
|
|
205
250
|
|
|
206
|
-
class
|
|
207
|
-
|
|
251
|
+
class ou24PSF( PSF ):
|
|
252
|
+
# Currently, does not support any oversampling, because SFFT doesn't
|
|
253
|
+
# TODO: support oversampling!
|
|
254
|
+
|
|
255
|
+
def __init__( self, pointing=None, sca=None, config_file=None, size=201, include_photonOps=True, **kwargs ):
|
|
256
|
+
if len(kwargs) > 0:
|
|
257
|
+
SNLogger.warning( f"Unused arguments to ou24PSF.__init__: {[k for k in kwargs]}" )
|
|
258
|
+
|
|
259
|
+
if ( pointing is None ) or ( sca is None ):
|
|
260
|
+
raise ValueError( "Need a pointing and an sca to make an ou24PSF" )
|
|
261
|
+
if config_file is None:
|
|
262
|
+
config_file = Config.get().value( 'ou24psf.config_file' )
|
|
263
|
+
self.config_file = config_file
|
|
264
|
+
self.pointing = pointing
|
|
265
|
+
self.sca = sca
|
|
266
|
+
self.size = size
|
|
267
|
+
self.include_photonOps = include_photonOps
|
|
268
|
+
self._stamps = {}
|
|
269
|
+
|
|
270
|
+
def get_stamp( self, x, y, flux=1., seed=None ):
|
|
271
|
+
"""Return a 2d numpy image of the PSF at the image resolution.
|
|
272
|
+
|
|
273
|
+
Parameters are as in PSF.get_stamp, plus:
|
|
274
|
+
|
|
275
|
+
Parameters
|
|
276
|
+
----------
|
|
277
|
+
seed : int
|
|
278
|
+
A random seed to pass to galsim.BaseDeviate for photonOps.
|
|
279
|
+
NOTE: this is not part of the base PSF interface (at least,
|
|
280
|
+
as of yet), so don't use it in production pipeline code.
|
|
281
|
+
However, it will be useful in tests for purposes of testing
|
|
282
|
+
reproducibility.
|
|
283
|
+
|
|
284
|
+
"""
|
|
285
|
+
if (x, y) not in self._stamps:
|
|
286
|
+
rmutils = roman_utils( self.config_file, self.pointing, self.sca )
|
|
287
|
+
if seed is not None:
|
|
288
|
+
rmutils.rng = galsim.BaseDeviate( seed )
|
|
289
|
+
self._stamps[(x, y)] = rmutils.getPSF_Image( self.size, x, y,
|
|
290
|
+
include_photonOps=self.include_photonOps ).array
|
|
291
|
+
self._stamps[(x, y)] *= flux / self._stamps[(x, y)].sum()
|
|
292
|
+
return self._stamps[(x, y)]
|
|
File without changes
|
|
File without changes
|
{roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
RENAMED
|
File without changes
|
{roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/workflows/run_snappl_tests.yml
RENAMED
|
File without changes
|
|
File without changes
|
{roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/.github/workflows/sub_package_update.yml
RENAMED
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/roman_snpit_snappl.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/roman_snpit_snappl.egg-info/requires.txt
RENAMED
|
File without changes
|
{roman_snpit_snappl-0.3.0 → roman_snpit_snappl-0.4.0}/roman_snpit_snappl.egg-info/top_level.txt
RENAMED
|
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
|