EranOfek / AstroPack

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

Aperture photometry sometimes returns complex errors #493

Closed RuslanKonno closed 2 weeks ago

RuslanKonno commented 2 months ago

When running aperture photometry with imUtil.sources.aperPhotCube, the error on the flux is derived in line 174

Result.AperPhotErr = sqrt(Result.AnnulusBack.*Result.AperArea + Result.AperPhot);

For large negative flux, this will lead to a complex flux error. Then because matlab sometimes requires uniform data format, some catalogs can become complex (see https://github.com/EranOfek/AstroPack/issues/492#issue-2442972383) when the error is saved to the catalog.

Can we just change the line to

Result.AperPhotErr = sqrt(abs(Result.AnnulusBack.*Result.AperArea + Result.AperPhot));

as a simple solution?

RuslanKonno commented 2 weeks ago

I implemented the suggested solution of taking the absolute value in imUtil.sources.aperPhotCube.