Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle WCS with galsim instead of Astropy #99

Open
aguinot opened this issue Feb 24, 2021 · 1 comment
Open

Handle WCS with galsim instead of Astropy #99

aguinot opened this issue Feb 24, 2021 · 1 comment
Labels
help wanted Extra attention is needed refactor code refactoring
Milestone

Comments

@aguinot
Copy link

aguinot commented Feb 24, 2021

We discussed about using Galsim WCS instead of Astropy, here is a simple function I have (from this code) to create CelestialWCS with Galsim (no optical distortion here):

def get_wcs(world_position= (0,0), pixel_scale=0.187, img_shape=(51,51)):
    """ Get WCS

    Give basic WCS as galsim object.

    Parameters
    ----------
    world_position: tuple
        World position at the center of the postage stamp (ra, dec) in degrees.
    pixel_scale: float
        Pixel scale of the image in arcsec/pixel.
    img_shape: tuple
        Final size of the postage stamp (nx, ny).

    Returns
    -------
    wcs: galsim.fitswcs.GSFitsWCS
        WCS for the postage stamp.
    """
    tot_origin = galsim.PositionD(img_shape[0]/2, img_shape[1]/2)
    tot_world_origin = galsim.CelestialCoord(world_position[0]*galsim.degrees, 
                                             world_position[1]*galsim.degrees)
    affine = galsim.AffineTransform(pixel_scale, 0, 0, pixel_scale, origin=tot_origin)
    wcs = galsim.TanWCS(affine, world_origin=tot_world_origin)

    return wcs

The reason why it is done this way and not using PixelScale or ShearWCS is to have a celestial projection which might preferable in some cases.. This should give you the equivalent of what you get with astropy.

@aguinot aguinot changed the title Handle WCS wit galsim instead of Astropy Handle WCS with galsim instead of Astropy Feb 24, 2021
@thuiop
Copy link
Collaborator

thuiop commented Feb 24, 2021

I think the point of implementing WCS feature in BTK was to be able to manage the celestial projection if needed ; using a simple pixel scale is not much work anyway and do not really require a WCS. I do not use the feature myself so I do not know how important it is though ; I suppose it would be important if one where to draw blends from real blends in the catalog for instance.

I notice that you use TanWCS which corresponds to the TAN projection ; the astropy WCS supports a bunch of other projections https://docs.astropy.org/en/stable/wcs/supported_projections.html (which the user should be able to specify but I am not sure if this is the case right now) ; are those useful to anyone ?

Otherwise using the galsim feature seems fair to me ; anyway we definitely need to take a look at the feature to check if it is working correctly with all the updates BTK had in the meantime.

@ismael-mendoza ismael-mendoza added refactor code refactoring help wanted Extra attention is needed labels Mar 11, 2021
@ismael-mendoza ismael-mendoza added this to the 1.1.0 milestone Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed refactor code refactoring
Projects
None yet
Development

No branches or pull requests

3 participants