EranOfek / AstroPack

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

Performance and PSF Reconstruction in forcedPhot Function #514

Open YarinMS opened 2 weeks ago

YarinMS commented 2 weeks ago

The imProc.sources.forcedPhot function is intended for performing forced photometry on given source coordinates. Generally, the function is invoked as follows:

FP = imProc.sources.forcedPhot(AI, 'Coo', [ra, dec], 'ColNames', ColNames, ...
        'MomentMaxIter', momentMaxIter, 'UseMomCoo', true, 'HeaderZP', true,...
        'ReconstructPSF', false, 'constructPSFArgs', ...
        {'RepopulatePSF', true, 'ThresholdPSF', 20, 'RangeSN', [50,1000], 'RadiusPSF', 6});

Description

Default Behavior (PSF Not Constructed):

When we use the default setting ReconstructPSF = false, the function relies on the PSF provided by the image (or generated by the pipeline), producing results seen in Image1:

noPSFconstruction

With this approach, the scatter of the results is higher, which deviates from our expectation that the forced photometry should at least align closely with catalog data, providing consistent results.

PSF Reconstruction Enabled (Radius = 8; Default):

To improve accuracy, we set ReconstructPSF = true, allowing the function to construct a new PSF directly from the image. This operation is computationally expensive but yields a noticeable improvement in RMS scatter, as seen in Image2:

radius8a However, the PSF radius is initially set to 8, which, while improving results, does not fully align the photometry with catalog values.

Optimized PSF Radius (Radius = 6):

We further refine the PSF by setting RadiusPSF = 6, achieving a closer match between the light curves, seen in Image3:

radius6

This adjustment provides the best results in terms of minimizing RMS differences between the forced photometry and the catalog values.

Additional Notes Figures Scaling: The figures are presented with consistent scaling across all cases to allow easier distinction of changes in results. This intentional scaling makes it simpler to visually assess the impact of each parameter adjustment without overlap of different configurations.

Discussion Points

  1. Should we change the pipeline default setting while constructing a PSF ?

  2. Dynamically adjust PSF parameters based on image quality metrics to optimize performance without manual adjustments?

EranOfek commented 2 weeks ago

did you change also RangeSN and ThresholdSN?

On Sun, Nov 3, 2024 at 11:38 PM YarinMS @.***> wrote:

The imProc.sources.forcedPhot function is intended for performing forced photometry on given source coordinates. Generally, the function is invoked as follows:

FP = imProc.sources.forcedPhot(AI, 'Coo', [ra, dec], 'ColNames', ColNames, ... 'MomentMaxIter', momentMaxIter, 'UseMomCoo', true, 'HeaderZP', true,... 'ReconstructPSF', false, 'constructPSFArgs', ... {'RepopulatePSF', true, 'ThresholdPSF', 20, 'RangeSN', [50,1000], 'RadiusPSF', 6});

Description

Default Behavior (PSF Not Constructed):

When we use the default setting ReconstructPSF = false, the function relies on the PSF provided by the image (or generated by the pipeline), producing results seen in Image1:

noPSFconstruction.png (view on web) https://github.com/user-attachments/assets/ec79e2c1-a25e-4507-abb7-0c6dfebb148b

With this approach, the scatter of the results is higher, which deviates from our expectation that the forced photometry should at least align closely with catalog data, providing consistent results.

PSF Reconstruction Enabled (Radius = 8; Default):

To improve accuracy, we set ReconstructPSF = true, allowing the function to construct a new PSF directly from the image. This operation is computationally expensive but yields a noticeable improvement in RMS scatter, as seen in Image2:

radius8a.png (view on web) https://github.com/user-attachments/assets/36cb9864-86f8-4683-b755-171c14bfdc56 However, the PSF radius is initially set to 8, which, while improving results, does not fully align the photometry with catalog values.

Optimized PSF Radius (Radius = 6):

We further refine the PSF by setting RadiusPSF = 6, achieving a closer match between the light curves, seen in Image3:

radius6.png (view on web) https://github.com/user-attachments/assets/43d5d351-453e-4d94-ba42-17a21471a89a

This adjustment provides the best results in terms of minimizing RMS differences between the forced photometry and the catalog values.

Additional Notes Figures Scaling: The figures are presented with consistent scaling across all cases to allow easier distinction of changes in results. This intentional scaling makes it simpler to visually assess the impact of each parameter adjustment without overlap of different configurations.

Discussion Points

1.

Should we change the pipeline default setting while constructing a PSF ? 2.

Dynamically adjust PSF parameters based on image quality metrics to optimize performance without manual adjustments?

— Reply to this email directly, view it on GitHub https://github.com/EranOfek/AstroPack/issues/514, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJUQ4PSDJTUFJEHTS3BUD3Z62JVJAVCNFSM6AAAAABRDDMQH2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGYZTCNBZGE3DGOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

YarinMS commented 2 weeks ago

The RangeSN and ThresholdPSF values are the default arguments and have not been changed in this example.

EranOfek commented 2 weeks ago

In this case I suggest to change the default to 6 pix. Sasha - please take test it, and modify.

agioffe commented 2 weeks ago

OK, will deal with it as soon as I am back.

agioffe commented 1 week ago

As far as I can see, imProc.sources.forcedPhot by default sets Args.HalfSizePSF = 12; and this value is passed to the 'RadiusPSF' argument of imProc.psf.populatePSF, which replaces the default value of the latter (8 pixels). So it is likely that in the first example of @YarinMS the 12-pixel radius of the PSF is actually employed, and not the 8-pixel radius.

According to my experience, the 99.9% encirclement of a LAST PSF is usually reached with an 11 x 11 pixels stamp, i.e. radius of 5 pixels, which matches the conclusion of @YarinMS. So we could indeed set Args.HalfSizePSF = 5 or 6 by default in imProc.sources.forcedPhot or just in pipeline.last.forcedPhotAll, if we in fact employ this one, but have in mind that this value is instrument-dependent.

EranOfek commented 1 week ago

not clear, so what is the effect of the radius on photometry?

On Sun, Nov 10, 2024 at 1:07 PM Alexander Krassilchtchikov < @.***> wrote:

As far as I can see, imProc.sources.forcedPhot by default sets Args.HalfSizePSF = 12; and this value is passed to the 'RadiusPSF' argument of imProc.psf.populatePSF, which replaces the default value of the latter (8 pixels). So it is likely that in the first example of @YarinMS https://github.com/YarinMS the 12-pixel radius of the PSF is actually employed, and not the 8-pixel radius.

According to my experience, the 99.9% encirclement of a LAST PSF is usually reached with an 11 x 11 pixels stamp, i.e. radius of 5 pixels, which matches the conclusion of @YarinMS https://github.com/YarinMS. So we could indeed set Args.HalfSizePSF = 5 or 6 by default in imProc.sources.forcedPhot or just in pipeline.last.forcedPhotAll, if we in fact employ this one, but have in mind that this value is instrument-dependent.

— Reply to this email directly, view it on GitHub https://github.com/EranOfek/AstroPack/issues/514#issuecomment-2466690193, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJUQ4PTHR33AJLTWE5UHELZ74465AVCNFSM6AAAAABRDDMQH2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRWGY4TAMJZGM . You are receiving this because you were assigned.Message ID: @.***>