pyDANDIA / pyDANDIA

A difference imaging pipeline in Python
9 stars 2 forks source link

Aperture photometry failing in stage 6 #101

Closed rachel3834 closed 4 years ago

rachel3834 commented 4 years ago

Seems to apply only to branch gaia_phot_calib.

Stage 6 photometry output in function run_psf_photometry_on_difference_image appears to be producing zero measured flux for all stars at line 591.
Preliminary investigation suggest that the sky background, difference image etc parameters are all fine.

The version of photutils in use is 0.6, the same as is being run for the operational pipeline right now. The only recent version change was the downgrade to scikit-image to (apparently) resolve an issue in stage 4.

rachel3834 commented 4 years ago

I've implemented a new commandline option for stage6 to be run with '-per-star-logging'. This provides additional (but very verbose) logging output which helps to diagnose problems like this, but is left off by default.

This revealed that the aperture photometry on the difference image stamps was returning zero fluxes for all stars, because the aperture radius was being set to zero.

Stage 6 reads this aperture from the psf_dimensions table in the metadata, and the correct aperture is set by stage3, which had run normally.

The problem only arose when the pipeline was re-run to add data to an existing dataset, for which the reference image had already been analyzed. The psf_dimensions table was being re-initialized by stage0 on the expectation that it would be filled in by stage3. But stage3 should not need to be re-run for datasets with an existing reference image. So this table remained set to zero.

I've modified stage0 so that this table is only now initialized if it does not already exist in the metadata, which resolves this issue.