GalSim-developers / GalSim

The modular galaxy image simulation toolkit. Documentation:
http://galsim-developers.github.io/GalSim/
Other
227 stars 107 forks source link

Add ability to shear image positions #1090

Closed esheldon closed 4 years ago

esheldon commented 4 years ago

@rmjarvis has suggested an API like the following

pos = galsim.PositionD(x, y)

shear = galsim.Shear(g1=g1, g2=g2)
sheared_pos = pos.shear(shear)

And could be used to shear an entire scene without first doing Add to a set of objects

image = ImageF(nx,ny, wcs=complex_wcs)
shear = Shear(g1=g1,g2=g2)
for obj, world_pos in zip(obj_list, world_pos_list):
    image_pos = (image.wcs.toImage(world_pos) - image.true_center).shear(shear) + image.true_center
    stamp = obj.shear(shear).drawImage(wcs=image.wcs, center=image_pos)
    b = stamp.bounds & image.bounds
    image[b] += stamp[b]

Implied here is that the shear is in reference to some origin.

rmjarvis commented 4 years ago

One thing that occurs to me on re-reading through my proposed snippet is that shear is usually defined with respect to north, not the image grid. So we probably also want the ability to toWorld and toImage a shear as well as profiles and positions:

shear_world = Shear(g1=g1, g2=g2)
shear_image = wcs.toImage(shear_world, world_pos=world_pos)

The latter I think would then be the one to use in image coordinates.

rmjarvis commented 4 years ago

Done #1097