roman-snpit-snappl 0.9.1__tar.gz → 0.10.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 (86) hide show
  1. {roman_snpit_snappl-0.9.1/roman_snpit_snappl.egg-info → roman_snpit_snappl-0.10.0}/PKG-INFO +1 -1
  2. roman_snpit_snappl-0.10.0/changes/57.snappl.rst +1 -0
  3. roman_snpit_snappl-0.10.0/changes/58.snappl.rst +1 -0
  4. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0/roman_snpit_snappl.egg-info}/PKG-INFO +1 -1
  5. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/roman_snpit_snappl.egg-info/SOURCES.txt +2 -0
  6. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/snappl/_version.py +3 -3
  7. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/snappl/image.py +86 -46
  8. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/snappl/imagecollection.py +5 -2
  9. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.cruft.json +0 -0
  10. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.github/CODEOWNERS +0 -0
  11. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +0 -0
  12. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md +0 -0
  13. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.github/ISSUE_TEMPLATE/PR_TEMPLATE.md +0 -0
  14. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.github/dependabot.yml +0 -0
  15. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.github/labeler.yml +0 -0
  16. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.github/workflows/changelog.yml +0 -0
  17. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.github/workflows/run_labeler.yml +0 -0
  18. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.github/workflows/run_snappl_tests.yml +0 -0
  19. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.github/workflows/sphinx-deploy.yml +0 -0
  20. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.github/workflows/sub_package_update.yml +0 -0
  21. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.gitignore +0 -0
  22. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/.pre-commit-config.yaml +0 -0
  23. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/CHANGES.rst +0 -0
  24. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/CITATION.cff +0 -0
  25. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/CODE_OF_CONDUCT.md +0 -0
  26. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/CONTRIBUTING.md +0 -0
  27. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/LICENSE +0 -0
  28. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/MANIFEST.in +0 -0
  29. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/README.rst +0 -0
  30. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/.gitkeep +0 -0
  31. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/10.snappl.rst +0 -0
  32. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/13.bugfix.rst +0 -0
  33. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/14.snappl.rst +0 -0
  34. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/15.feature.rst +0 -0
  35. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/16.feature.rst +0 -0
  36. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/18.feature.rst +0 -0
  37. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/20.bugfix.rst +0 -0
  38. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/23.snappl.rst +0 -0
  39. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/26.feature.rst +0 -0
  40. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/29.feature.rst +0 -0
  41. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/3.snappl.rst +0 -0
  42. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/31.feature.rst +0 -0
  43. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/35.snappl.rst +0 -0
  44. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/36.snappl.rst +0 -0
  45. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/37.snappl.rst +0 -0
  46. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/40.snappl.rst +0 -0
  47. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/41.snappl.rst +0 -0
  48. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/43.snappl.rst +0 -0
  49. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/47.feature.rst +0 -0
  50. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/49.docs.rst +0 -0
  51. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/5.snappl.rst +0 -0
  52. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/54.snappl.rst +0 -0
  53. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/8.snappl.rst +0 -0
  54. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/changes/9.snappl.rst +0 -0
  55. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/codespell-ignore.txt +0 -0
  56. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/docs/Makefile +0 -0
  57. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/docs/_static/logo_black_filled.png +0 -0
  58. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/docs/api.rst +0 -0
  59. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/docs/changes.rst +0 -0
  60. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/docs/conf.py +0 -0
  61. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/docs/index.rst +0 -0
  62. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/docs/installation.rst +0 -0
  63. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/docs/make.bat +0 -0
  64. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/docs/usage.rst +0 -0
  65. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/experimentation/README.md +0 -0
  66. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/experimentation/play_with_photutils.py +0 -0
  67. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/licenses/.DS_Store +0 -0
  68. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/licenses/LICENSE.rst +0 -0
  69. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/licenses/README.rst +0 -0
  70. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/licenses/TEMPLATE_LICENSE.rst +0 -0
  71. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/pyproject.toml +0 -0
  72. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/roman_snpit_snappl.egg-info/dependency_links.txt +0 -0
  73. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/roman_snpit_snappl.egg-info/not-zip-safe +0 -0
  74. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/roman_snpit_snappl.egg-info/requires.txt +0 -0
  75. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/roman_snpit_snappl.egg-info/top_level.txt +0 -0
  76. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/setup.cfg +0 -0
  77. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/setup.py +0 -0
  78. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/snappl/__init__.py +0 -0
  79. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/snappl/_dev/__init__.py +0 -0
  80. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/snappl/_dev/scm_version.py +0 -0
  81. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/snappl/data/README.rst +0 -0
  82. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/snappl/diaobject.py +0 -0
  83. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/snappl/psf.py +0 -0
  84. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/snappl/sed.py +0 -0
  85. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/snappl/wcs.py +0 -0
  86. {roman_snpit_snappl-0.9.1 → roman_snpit_snappl-0.10.0}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: roman_snpit_snappl
3
- Version: 0.9.1
3
+ Version: 0.10.0
4
4
  Summary: Photometry utilities for the Roman SNPIT
5
5
  Author: Roman Supernova Project Infrastructure Team
6
6
  Maintainer-email: Roman SN PIT <raknop@lbl.gov>
@@ -0,0 +1 @@
1
+ Small imagecollection bugfixes.
@@ -0,0 +1 @@
1
+ Allow for kwargs to be passed to get_ra_dec_cutout in snappl.image.Image
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: roman_snpit_snappl
3
- Version: 0.9.1
3
+ Version: 0.10.0
4
4
  Summary: Photometry utilities for the Roman SNPIT
5
5
  Author: Roman Supernova Project Infrastructure Team
6
6
  Maintainer-email: Roman SN PIT <raknop@lbl.gov>
@@ -46,6 +46,8 @@ changes/47.feature.rst
46
46
  changes/49.docs.rst
47
47
  changes/5.snappl.rst
48
48
  changes/54.snappl.rst
49
+ changes/57.snappl.rst
50
+ changes/58.snappl.rst
49
51
  changes/8.snappl.rst
50
52
  changes/9.snappl.rst
51
53
  docs/Makefile
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.9.1'
32
- __version_tuple__ = version_tuple = (0, 9, 1)
31
+ __version__ = version = '0.10.0'
32
+ __version_tuple__ = version_tuple = (0, 10, 0)
33
33
 
34
- __commit_id__ = commit_id = 'g1b1e672b9'
34
+ __commit_id__ = commit_id = 'g4b7a8be4a'
@@ -207,6 +207,12 @@ class Image:
207
207
  """MJD of the start of the image (defined how? TAI?)"""
208
208
  raise NotImplementedError( f"{self.__class__.__name__} needs to implement mjd" )
209
209
 
210
+ @mjd.setter
211
+ def mjd( self, val ):
212
+ # We need an MJD setter so that ImageCollection can set the MJD when fetching the images, much faster than
213
+ # reading the header each time!
214
+ self._mjd = val
215
+
210
216
  @property
211
217
  def position_angle( self ):
212
218
  """Position angle in degrees east of north (or what)?"""
@@ -282,13 +288,64 @@ class Image:
282
288
  """Set self._zeropoint; see "zeropoint" property above."""
283
289
  raise NotImplementedError( f"{self.__class__.__name__} needs to implement _get_zeropoint" )
284
290
 
285
- def get_cutout(self, ra, dec, size):
291
+ def get_ra_dec_cutout(self, ra, dec, xsize, ysize=None, mode="strict", fill_value=np.nan):
292
+ """Creates a new snappl image object that is a cutout of the original image, at a location in pixel-space.
293
+
294
+ Parameters
295
+ ----------
296
+ ra : float
297
+ RA coordinate of the center of the cutout, in degrees.
298
+ dec : float
299
+ DEC coordinate of the center of the cutout, in degrees.
300
+ xsize : int
301
+ Width of the cutout in pixels.
302
+ ysize : int
303
+ Height of the cutout in pixels. If None, set to xsize.
304
+ mode : str, default 'strict'
305
+ "strict" does not allow for partial overlap between the cutout and the original image,
306
+ "partial" will fill in non-overlapping pixels with fill_value. This is identical to the
307
+ mode parameter of astropy.nddata.Cutout2D.
308
+ fill_value : float, default np.nan
309
+ Fill value for pixels that are outside the original
310
+ image when mode='partial'. This is identical to the fill_value parameter
311
+ of astropy.nddata.Cutout2D.
312
+
313
+ Returns
314
+ -------
315
+ cutout : snappl.image.Image
316
+ A new snappl image object that is a cutout of the original image.
317
+ """
318
+ raise NotImplementedError( f"{self.__class__.__name__} needs to implement get_ra_dec_cutout" )
319
+
320
+ def get_cutout(self, ra, dec, xsize, ysize=None, mode='strict', fill_value=np.nan):
286
321
 
287
322
  """Make a cutout of the image at the given RA and DEC.
323
+ This implementation assumes that the image WCS is an AstropyWCS.
324
+
325
+ Parameters
326
+ ----------
327
+ x : int
328
+ x pixel coordinate of the center of the cutout.
329
+ y : int
330
+ y pixel coordinate of the center of the cutout.
331
+ xsize : int
332
+ Width of the cutout in pixels.
333
+ ysize : int
334
+ Height of the cutout in pixels. If None, set to xsize.
335
+ mode : str, default 'strict'
336
+ "strict" does not allow for partial overlap between the cutout and the original image,
337
+ "partial" will fill in non-overlapping pixels with fill_value. This is identical to the
338
+ mode parameter of astropy.nddata.Cutout2D.
339
+ fill_value : float, default np.nan
340
+ Fill value for pixels that are outside the original
341
+ image when mode='partial'. This is identical to the fill_value parameter
342
+ of astropy.nddata.Cutout2D.
288
343
 
289
344
  Returns
290
345
  -------
291
- snappl.image.Image
346
+ cutout : snappl.image.Image
347
+ A new snappl image object that is a cutout of the original image.
348
+
292
349
  """
293
350
  raise NotImplementedError( f"{self.__class__.__name__} needs to implement get_cutout" )
294
351
 
@@ -594,27 +651,10 @@ class FITSImage( Numpy2DImage ):
594
651
  else:
595
652
  raise RuntimeError("get_data called with which='flags', but flags are not set.")
596
653
 
597
- def get_cutout(self, x, y, xsize, ysize=None):
598
- """Creates a new snappl image object that is a cutout of the original image, at a location in pixel-space.
599
-
600
- This implementation (in FITSImage) assumes that the image WCS is an AstropyWCS.
601
-
602
- Parameters
603
- ----------
604
- x : int
605
- x pixel coordinate of the center of the cutout.
606
- y : int
607
- y pixel coordinate of the center of the cutout.
608
- xsize : int
609
- Width of the cutout in pixels.
610
- ysize : int
611
- Height of the cutout in pixels. If None, set to xsize.
612
-
613
- Returns
614
- -------
615
- cutout : snappl.image.Image
616
- A new snappl image object that is a cutout of the original image.
654
+ def get_cutout(self, x, y, xsize, ysize=None, mode='strict', fill_value=np.nan):
655
+ """See Image.get_cutout
617
656
 
657
+ The mode and fill_value parameters are passed directly to astropy.nddata.Cutout2D for FITSImage.
618
658
  """
619
659
  if not all( [ isinstance( x, (int, np.integer) ),
620
660
  isinstance( y, (int, np.integer) ),
@@ -638,9 +678,13 @@ class FITSImage( Numpy2DImage ):
638
678
  apwcs = None if wcs is None else wcs._wcs
639
679
 
640
680
  # Remember that numpy arrays are indexed [y, x] (at least if they're read with astropy.io.fits)
641
- astropy_cutout = Cutout2D(data, (x, y), size=(ysize, xsize), mode='strict', wcs=apwcs)
642
- astropy_noise = Cutout2D(noise, (x, y), size=(ysize, xsize), mode='strict', wcs=apwcs)
643
- astropy_flags = Cutout2D(flags, (x, y), size=(ysize, xsize), mode='strict', wcs=apwcs)
681
+
682
+ astropy_cutout = Cutout2D(data, (x, y), size=(ysize, xsize), wcs=apwcs, mode=mode, fill_value=fill_value)
683
+ astropy_noise = Cutout2D(noise, (x, y), size=(ysize, xsize), wcs=apwcs, mode=mode, fill_value=fill_value)
684
+ # Because flags are integer, we can't use the same fill_value as the default.
685
+ # Per the slack channel, it seemed 1 will be used for bad pixels.
686
+ # https://github.com/spacetelescope/roman_datamodels/blob/main/src/roman_datamodels/dqflags.py
687
+ astropy_flags = Cutout2D(flags, (x, y), size=(ysize, xsize), wcs=apwcs, mode=mode, fill_value=1)
644
688
 
645
689
  snappl_cutout = self.__class__(self.path)
646
690
  snappl_cutout._data = astropy_cutout.data
@@ -651,31 +695,17 @@ class FITSImage( Numpy2DImage ):
651
695
 
652
696
  return snappl_cutout
653
697
 
654
- def get_ra_dec_cutout(self, ra, dec, xsize, ysize=None):
655
- """Creates a new snappl image object that is a cutout of the original image, at a location in pixel-space.
698
+ def get_ra_dec_cutout(self, ra, dec, xsize, ysize=None, mode='strict', fill_value=np.nan):
699
+ """See Image.get_ra_dec_cutout
656
700
 
657
- Parameters
658
- ----------
659
- ra : float
660
- RA coordinate of the center of the cutout, in degrees.
661
- dec : float
662
- DEC coordinate of the center of the cutout, in degrees.
663
- xsize : int
664
- Width of the cutout in pixels.
665
- ysize : int
666
- Height of the cutout in pixels. If None, set to xsize.
667
-
668
- Returns
669
- -------
670
- cutout : snappl.image.Image
671
- A new snappl image object that is a cutout of the original image.
701
+ The mode and fill_value parameters are passed directly to astropy.nddata.Cutout2D for FITSImage.
672
702
  """
673
703
 
674
704
  wcs = self.get_wcs()
675
705
  x, y = wcs.world_to_pixel( ra, dec )
676
706
  x = int( np.floor( x + 0.5 ) )
677
707
  y = int( np.floor( y + 0.5 ) )
678
- return self.get_cutout( x, y, xsize, ysize )
708
+ return self.get_cutout( x, y, xsize, ysize, mode=mode, fill_value=fill_value )
679
709
 
680
710
 
681
711
  # ======================================================================
@@ -686,7 +716,7 @@ class FITSImage( Numpy2DImage ):
686
716
 
687
717
  class ManualFITSImage(FITSImage):
688
718
  def __init__(self, header, data=None, noise=None, flags=None,
689
- path = None, exposure = None, sca = None, *args, **kwargs):
719
+ path=None, exposure=None, sca=None, *args, **kwargs):
690
720
 
691
721
  self._data = data
692
722
  self._noise = noise
@@ -919,8 +949,18 @@ class OpenUniverse2024FITSImage( FITSImageOnDisk ):
919
949
  TODO : is this start-time, mid-time, or end-time?
920
950
 
921
951
  """
922
- header = self.get_fits_header()
923
- return float( header['MJD-OBS'] )
952
+ if self._mjd is None:
953
+ header = self.get_fits_header()
954
+ self.mjd = float( header['MJD-OBS'] )
955
+ return self._mjd
956
+
957
+ @mjd.setter
958
+ def mjd( self, val ):
959
+ # We need an MJD setter so that ImageCollection can set the MJD when fetching the images, much faster than
960
+ # reading the header each time!
961
+ self._mjd = val
962
+
963
+
924
964
 
925
965
  @property
926
966
  def exptime( self ):
@@ -240,12 +240,15 @@ class ImageCollectionOU2024:
240
240
  if exptime_max is not None:
241
241
  params['exptime_max'] = float(exptime_max)
242
242
 
243
- res = retry_post( "https://roman-desc-simdex.lbl.gov/findromanimages", json=params )
243
+ res = retry_post( "https://roman-desc-simdex.lbl.gov/findromanimages", json=params ).json()
244
244
 
245
245
  images = []
246
246
  for i in range( len(res['pointing']) ):
247
247
  path = self.get_image_path( res['pointing'][i], res['filter'][i], res['sca'][i] )
248
- images.append( OpenUniverse2024FITSImage( path, None, res['sca'][i] ) )
248
+ image = OpenUniverse2024FITSImage(path, None, res["sca"][i])
249
+ image.mjd = res['mjd'][i]
250
+ images.append( image )
251
+
249
252
 
250
253
  return images
251
254