You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 15, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 15, 2020. It is now read-only.
Well I can see different ways to specify the region to cutout. For starters, one might want to accept a SkyCoord and a radius. Or give a range of pixels in x and y. I guess there's not too many options. What API are you using in gammapy?
My idea in Gammapy was to have the crop_image function only accept a BoundingBox object which simply represents a slice in pixel coordinates and then there could be various ways to create a BoundingBox.
I think a BoundingBox class would be a useful addition to imageutils (and then also be used in photutils or gammapy), because it's needed as input or internally for many methods.
But I'm not 100% sure it's a good idea ... @astrofrog what do you think?
PS: the Gammapy imageutils functions and classes are mostly crap and unfinished / untested, so don't look at them too closely ... the idea is to find a good API and then implement it well here in astropy.image and remove the versions from Gammapy.
This doesn't have the WCS slicing and worries about FITS header format, which I am not sure if it is needed here, but it depends on how general the task should be.
@larrybradley@astrofrog What do you think about introducing a ImageBoundingBox or ImageSlice or ImageCutout class in astropy.image and then using it in photutils, gammapy, ccdproc, ...
At the moment slices are mostly used internally and not part of the API and something definitely needs to be done about #40 ... we can't leave these slice helper functions as is.
@cdeil This could be useful if we can find a good API. Perhaps a simple ImageCutout class that takes data and x0, x1, y0, y1 as input and have a slice tuple, bounding box, and center pixel, etc. as object properties?
@larrybradley – As I said ... I don't know what a good solution is here even after discussing this for an hour with @adonath ... I'd have to write down simple examples with the various use cases first to see what works best.
The smallest useful thing would be to have an NDSlice class that has a Python list of slice objects as a data member and provides convenience functions (e.g. create it from a center position) and attributes.
For other use cases it would be better if the class has a reference to the image and sometimes also a reference to a kernel ... probably these could be optional and one could have a single class that is useful to implement a lot of image processing stuff e.g. in modeling and photutils and gammapy where one operates on image cutouts for speed.
So +10 if you can make a concrete proposal ... I'm very interested and will try it out for my use cases.
Activity
astrofrog commentedon Oct 2, 2014
Well I can see different ways to specify the region to cutout. For starters, one might want to accept a SkyCoord and a radius. Or give a range of pixels in x and y. I guess there's not too many options. What API are you using in gammapy?
cdeil commentedon Oct 2, 2014
My idea in Gammapy was to have the crop_image function only accept a BoundingBox object which simply represents a slice in pixel coordinates and then there could be various ways to create a
BoundingBox.I think a
BoundingBoxclass would be a useful addition toimageutils(and then also be used inphotutilsorgammapy), because it's needed as input or internally for many methods.But I'm not 100% sure it's a good idea ... @astrofrog what do you think?
cdeil commentedon Oct 2, 2014
PS: the Gammapy imageutils functions and classes are mostly crap and unfinished / untested, so don't look at them too closely ... the idea is to find a good API and then implement it well here in
astropy.imageand remove the versions from Gammapy.crawfordsm commentedon Oct 3, 2014
As another example, there's also the trim_image function in ccdproc: https://github.com/astropy/ccdproc/blob/master/ccdproc/core.py#L230
This doesn't have the WCS slicing and worries about FITS header format, which I am not sure if it is needed here, but it depends on how general the task should be.
Merge pull request astropy#4 from crawfordsm/add_openmp_check
cdeil commentedon Dec 2, 2014
@larrybradley @astrofrog What do you think about introducing a
ImageBoundingBoxorImageSliceorImageCutoutclass inastropy.imageand then using it inphotutils,gammapy,ccdproc, ...At the moment slices are mostly used internally and not part of the API and something definitely needs to be done about #40 ... we can't leave these slice helper functions as is.
larrybradley commentedon Dec 17, 2014
@cdeil This could be useful if we can find a good API. Perhaps a simple
ImageCutoutclass that takesdataandx0, x1, y0, y1as input and have aslicetuple, bounding box, and center pixel, etc. as object properties?cdeil commentedon Dec 17, 2014
@larrybradley – As I said ... I don't know what a good solution is here even after discussing this for an hour with @adonath ... I'd have to write down simple examples with the various use cases first to see what works best.
The smallest useful thing would be to have an
NDSliceclass that has a Python list of slice objects as a data member and provides convenience functions (e.g. create it from a center position) and attributes.For other use cases it would be better if the class has a reference to the image and sometimes also a reference to a kernel ... probably these could be optional and one could have a single class that is useful to implement a lot of image processing stuff e.g. in modeling and photutils and gammapy where one operates on image cutouts for speed.
So +10 if you can make a concrete proposal ... I'm very interested and will try it out for my use cases.
keflavich commentedon Jun 30, 2015
Over the past few days, I've had a need for this functionality on 3 separate occasions. So, big 👍.
cdeil commentedon Jun 30, 2015
@larrybradley has implemented this in astropy/astropy#3823 .
Closing this issue so that discussion can continue there ...