EranOfek / AstroPack

Astronomy & Astrophysics Software Pacakge
Other
19 stars 4 forks source link

`imProc.image.image2subimages` and `AstroImage.crop` should attempt to update WCS #182

Closed EastEriq closed 1 year ago

EastEriq commented 1 year ago

even approximately, taking into account at least the center offset and not the rotation/distorsions, which may be small. Currently they don't, and therefore functions like imProc.astrometry.astrometryRefine on image subsets fail

EastEriq commented 1 year ago

And perhaps also augment the header with CROPID, see issue #210

EastEriq commented 1 year ago

Example of what I'm forced to do, and should be automatic and foolproofed:

    % split in subimages
    AI=imProc.image.image2subimages(AI,2048);
    % correct CPIX for the second image (temporary workaround for
    %  https://github.com/EranOfek/AstroPack/issues/182 )
    AI(2).WCS.CRPIX(2)=AI(2).WCS.CRPIX(2)-2037;
    AI(2).HeaderData.setVal('CRPIX2',AI(2).WCS.CRPIX(2));
    AI(1).HeaderData.setVal('CROPID',1);
    AI(2).HeaderData.setVal('CROPID',2);
EranOfek commented 1 year ago

AstroImage.crop & imProc.image.image2subimages - feature added (exact) Need to test!

EranOfek commented 1 year ago

crop tested

EastEriq commented 1 year ago

apparently commit https://github.com/EranOfek/AstroPack/commit/f0a4ec1b1c7e064f5a24bd7611fea55ae37621f2 created a regression. Reopening and reporting my investigations here

EastEriq commented 1 year ago

As a baseline, this call is ok:

AI=AstroImage('/raid/enrico/PTF/2ndTake/images/level1/proc/2012/01/07/f11/c0/p5/v1/PTF_201201075069_i_p_scie_t120955_u011063047_f11_p015199_c00.fits');
AI=imProc.image.image2subimages(AI,2048);
for k=1:2
    ds9(AI(k),k,'zoom','to fit')
end

In the sense that looking in ds9, the coordinates of the upper two corners of the first frame match those of the lower two corners of the second. (I don't know if there wouldn't be a function to check it instead of hovering the mouse) In a more complex script of mine, not. Going to figure out why.

EastEriq commented 1 year ago

ok, "not your fault". The problem funnily pops up when reading the original image mask (3rd line of the following):

ff='/raid/enrico/PTF/2ndTake/images/level1/proc/2012/01/07/f11/c0/p5/v1/PTF_201201075069_i_p_scie_t120955_u011063047_f11_p015199_c00.fits';
AI=AstroImage(ff);
AI.MaskData.Data=mapPTF2oursMask(MaskImage(strrep(ff,'scie','mask')));
AI=imProc.image.image2subimages(AI,2048);
for k=1:2
    ds9(AI(k),k,'zoom','to fit')
end

Weirdly even if the mask refers to the full image, only the coordinates of the second subimage come out wrong.

Reclosing this issue and opening a dedicated one.

EastEriq commented 1 year ago

crop tested

Not tested well enough, apparently.