jasonfrowe / neossat

Source Code related to CSA's NEOSSat Mission to extract Photometry.
GNU General Public License v3.0
3 stars 1 forks source link

Photometry will crash if no objects are present. #24

Open jasonfrowe opened 3 years ago

jasonfrowe commented 3 years ago

Error is:

""" Traceback (most recent call last): File "/usr/lib64/python3.7/multiprocessing/pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "/home/rowe/Documents/python/NEOSSat/New_worksheets/neossat/photprocess.py", line 24, in photprocess positions = np.column_stack([sources['xcentroid'], sources['ycentroid']]) TypeError: 'NoneType' object is not subscriptable """

Since this is a pooled compute job all other results are lost when this error occurs.

jasonfrowe commented 3 years ago

Fix is to add exception to photprocess routine in photprocess.py


def photprocess(filename, date, photap, bpix):

    scidata = utils.read_fitsdata(filename)

    mean, median, std = sigma_clipped_stats(scidata, sigma=3.0, maxiters=5)
    daofind = DAOStarFinder(fwhm=2.0, threshold=5.*std)
    sources = daofind(scidata - median)

    try:
        positions = np.column_stack([sources['xcentroid'], sources['ycentroid']])
        apertures = CircularAperture(positions, r=photap)
        phot_table = aperture_photometry(scidata - median, apertures)
    except:
        phot_table=[]

    return [phot_table, date, mean, median, std, filename]