{"action":"created","issue":{"url":"https://api.github.com/repos/spacetelescope/mosviz/issues/11","repository_url":"https://api.github.com/repos/spacetelescope/mosviz","labels_url":"https://api.github.com/repos/spacetelescope/mosviz/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/spacetelescope/mosviz/issues/11/comments","events_url":"https://api.github.com/repos/spacetelescope/mosviz/issues/11/events","html_url":"https://github.com/spacetelescope/mosviz/issues/11","id":162974840,"number":11,"title":"Support rotation for cutouts","user":{"login":"astrofrog","id":314716,"avatar_url":"https://avatars.githubusercontent.com/u/314716?v=3","gravatar_id":"","url":"https://api.github.com/users/astrofrog","html_url":"https://github.com/astrofrog","followers_url":"https://api.github.com/users/astrofrog/followers","following_url":"https://api.github.com/users/astrofrog/following{/other_user}","gists_url":"https://api.github.com/users/astrofrog/gists{/gist_id}","starred_url":"https://api.github.com/users/astrofrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astrofrog/subscriptions","organizations_url":"https://api.github.com/users/astrofrog/orgs","repos_url":"https://api.github.com/users/astrofrog/repos","events_url":"https://api.github.com/users/astrofrog/events{/privacy}","received_events_url":"https://api.github.com/users/astrofrog/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2016-06-29T16:50:44Z","updated_at":"2016-06-30T08:50:08Z","closed_at":null,"body":"### Background\r\n\r\nAs discussed on the tag-up, it would be nice to support specifying a position angle when creating cutouts. I had a look at the existing code:\r\n\r\nhttps://github.com/spacetelescope/mosviz/blob/master/mosviz/utils/cutout_tools.py#L22\r\n\r\nand I think it would be easy to integrate.\r\n\r\n@pllim - I decided to just write this up for now - would you like to implement what I am suggesting below, or would you like me to do it? (either way is fine, though I don't have much example data to try it on). If you decide to implement it, just let me know if you run into any issues!\r\n\r\n### Specifying the angle\r\n\r\nThere are different possibilities for specifying the position angle for the cutouts. I think that if the user doesn't specify anything, it should default to what it does right now, which is to line up the cutout with the pixels.\r\n\r\nIf the user wants to make sure the cutouts are lined up with some position angle, then we could consider either allowing them to specify a column in the catalog, or as an extra keyword argument to ``make_cutouts``. If the latter, then we should think whether we want to just allow a scalar, or also an array of values (one value per source). I think either way we should use Astropy Quantities to make sure there is no ambiguity in terms of units.\r\n\r\nWe should make sure there is a difference between ``angle=None`` (line up with the pixels) and ``angle=0`` (line up with celestial north).\r\n\r\n### Making the cutout\r\n\r\nIf the user doesn't specify a PA, then we should just keep the code exactly as-is for now, because we don't want to do any reprojection.\r\n\r\nLet's now assume a PA is specified. The easiest thing to do is then to take the following information:\r\n\r\n        * ``'id'`` - ID string; no unit necessary.\r\n        * ``'ra'`` - RA (e.g., in degrees).\r\n        * ``'dec'`` - DEC (e.g., in degrees).\r\n        * ``'cutout_x_size'`` - Cutout width (e.g., in arcsec).\r\n        * ``'cutout_y_size'`` - Cutout height (e.g., in arcsec).\r\n        * ``'spatial_pixel_scale'`` - Pixel scale (e.g., in arcsec/pix).\r\n\r\nand create a header from this which does **not** include any rotation (so we specify ``CDELT1`` and ``CDELT2`` manually), and then if the user specified a non-zero angle, we add ``CROTA2``. For ``CTYPE`` I think we could just use ``RA---TAN`` and ``DEC--TAN`` for simplicity (the projection probably doesn't matter for cutouts)\r\n\r\nOnce we have the header, then calling reproject is easy:\r\n \r\n```python\r\nfrom reproject import reproject_interp\r\narray, footprint = reproject_interp(imagename, cutout_header)\r\n```\r\n\r\nand array is your new cutout array! :tada:\r\n\r\n### Advanced options\r\n\r\nThere are several things one can do to then allow the quality of the cutout\r\nto be adjusted. By default it will use bilinear interpolation, but the\r\ninterpolation order can be adjusted using the ``order=`` keyword argument. We\r\ncould consider adding a similar option to ``make_cutouts`` to give this kind\r\nof flexibility to the user. We could also allow the user to specify that they\r\nwant to use flux-conserving reprojection and then use this reproject function:\r\n\r\nhttp://reproject.readthedocs.io/en/stable/api/reproject.reproject_exact.html#reproject.reproject_exact\r\n\r\n### Future\r\n\r\nFuture work could include implementing something like this into Astropy core or the reproject package. In addition, we could make it possible for people to specify **which** north to use (equatorial, galactic, etc.)"},"comment":{"url":"https://api.github.com/repos/spacetelescope/mosviz/issues/comments/229600254","html_url":"https://github.com/spacetelescope/mosviz/issues/11#issuecomment-229600254","issue_url":"https://api.github.com/repos/spacetelescope/mosviz/issues/11","id":229600254,"user":{"login":"astrofrog","id":314716,"avatar_url":"https://avatars.githubusercontent.com/u/314716?v=3","gravatar_id":"","url":"https://api.github.com/users/astrofrog","html_url":"https://github.com/astrofrog","followers_url":"https://api.github.com/users/astrofrog/followers","following_url":"https://api.github.com/users/astrofrog/following{/other_user}","gists_url":"https://api.github.com/users/astrofrog/gists{/gist_id}","starred_url":"https://api.github.com/users/astrofrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astrofrog/subscriptions","organizations_url":"https://api.github.com/users/astrofrog/orgs","repos_url":"https://api.github.com/users/astrofrog/repos","events_url":"https://api.github.com/users/astrofrog/events{/privacy}","received_events_url":"https://api.github.com/users/astrofrog/received_events","type":"User","site_admin":false},"created_at":"2016-06-30T08:50:08Z","updated_at":"2016-06-30T08:50:08Z","body":"@pllim - by the way, you may want to try and hard-code ``order=2`` or ``order=3`` when doing the reprojection, since that may provide a better 'default' quality."}}
{"actor":{"display_login":"astrofrog"}}