How to save custom aperture masks?
See original GitHub issueImagine you painstakingly create a custom aperture mask for aperture photometry. Perhaps you’ve done so with our slick new .interact()
method. Or maybe you’ve done so programmatically by some other means that may be difficult to reproduce. What are your options for saving your work?
Chiefly, the options come down to:
- Do nothing— leave it up to the user to save masks with their desired format (status quo)
- Save just the mask (in some format-to-be-named-later)
- Save the lightcurve with e.g. the
.to_fits()
method with an HDU extension for the mask - Save a new target pixel file with a new HDU extension for the mask
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (10 by maintainers)
Top Results From Across the Web
Creating your own light curves using custom aperture ...
We'll use Lightkurve for downloading and handling Kepler data throughout this tutorial. We'll also use NumPy to handle arrays for aperture masks. [1]:....
Read more >Why and how to make a sub-aperture mask for a refractor
To make a more permanent mask, I needed plastic, heavier cardboard, or foam-core board. So I unscrewed the dewshield from the scope and...
Read more >Aperture Photometry (photutils.aperture) — photutils 1.6.0
To perform aperture photometry with sky-based apertures, one will need to specify a WCS transformation. Users can also create their own custom apertures...
Read more >Create an Aperture ring using Photoshop - YouTube
... you how you can create an aperture ring from scratch using Photoshop that ... and I show you how to save as...
Read more >Under what situations can an aperture mask improve the ...
So using an aperture mask can remove the spikes due to the spider vanes. ... The telescope is not performance-limited by the aperture...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gully, @nksaunders and I have had a chat about this.
We’ve weighed up the options from @gully’s first post:
Some take aways from our discussion is below.
Note: @barentsen and I are adding a 4th option, which I’m describing below.
GenericLightCurveFile
class. The aperture information would be accessible viaGenericLightCurveFile.hdu[-1].data
.Option 1. Save just the mask
Masks would be fits files with keywords describing the way they were generated and the file they apply to.
Pros:
Cons:
tpf.to_lightcurve(aperture_mask=parse_mask('mask.fits'))
)Option 2. Save a fits file with a light curve and an aperture extension
Pros:
Cons:
aperture_mask
in allLightCurve
, which is populated or produces a descriptive warning in all subclasses. This is a fairly large change to a major class in lightkurve.aperture_mask
attribute must be writeable in theLightCurve.to_fits()
tpf.interact
will not behave like Light Curve Files. They must still be readable by lightkurve, intoKeplerLightCurve
objects (orTESSLightCurve
objects). This is new behavior which needs to be written and unit tested.Watch out for:
Need to ensure that the fits file generated by
tpf.interact()
has no information loss compared with the equivalentlcf.SAP_FLUX()
object.Have to ensure that the fits file generated by the
tpf.interact()
button can be read back into lightkurve. (i.e.lk.open('custom_lc_file.fits')
must produce the same object with the same attributes as the equivalentlcf.SAP_FLUX()
object.) Gully refers to this as round tripping above. This is necessary for this button to really be useful. If we include this button in lightkurve v1.0, this issue must be addressed.lk.open('custom_lc_file.fits')
must return aKeplerLightCurve
orTESSLightCurve
class, not a genericLightCurve
class. (Otherwise information has been lost.)This option will require that the KeplerLightCurve returned by
lk.open('custom_lc_file.fits')
will have a new attributeaperture_mask
. This requires changing the base classLightCurve
to have a blankaperture_mask
attribute that will be able to be set. When the attribute is accessed from different objects it should always provide a reasonable result, see below. All of these scenarios must be unit testedOption 3. Save a new target pixel file with a new HDU extension for the mask
Pros:
Cons:
Option 4 Save a fits file that would be opened by a
GenericLightCurveFile
class.@barentsen and I have been chatting and like a fourth option. Here we would create a new
GenericLightCurveFile
class which would attempt to read in any fits file. This would be able to have any extensions we liked. Some behaviors would include:If the fits file has the keyword
MISSION = KEPLER
,lc.SAP_FLUX
would return aKeplerLightCurve
. If the fits file has the keywordMISSION = TESS
,lc.SAP_FLUX
would return aTESSLightCurve
. If the fits file has an unrecognized or noMISSION
keyword then it would return aLightCurve
.All my concerns about ensuring no information is lost from option 2 still apply. The output from
tpf.interact() #SAVE\ lc = open('custom_file.fits').SAP_FLUX
must be exactly equivalent totpf.to_lightcurve()
Pros:
Cons:
LightCurveFile
open()
to have a new file type to open.Some decisions
@gully has made lots of headway on option 2 in PR #329. I’m writing my concerns about option two in detail here. I find option 1 to probably on balance be the most palatable, although I don’t love the idea of lots of dangling mask files that I’m easily going to lose.
If all my concerns under option 2 can be addressed then it is the best solution. However, it looks like quite a bit of work, especially before we release v1.0.
Below I copy/paste the exact specification from the Kepler archive manual and the TESS documentation. They are different but they both give the same meaning to bits 1 and 2, so I think we may want to stick to those!