Skip to content

Astropy bug when downloading Pan-STARRS finder images #10

Description

@genghisken

The following bug occurs when downloading Pan-STARRS finders. This was using astropy version 5.3.3 or similar.

Processing Request: qub_ps_request_20250408_221304
Downloading image...
Number of stars = 200
No ref stars of mag 15.0 within specified radius 120.0 arcsec. Attempting another search with fainter mag threshold of 16.0.
No ref stars of mag 16.0 within specified radius 120.0 arcsec. Attempting another search with fainter mag threshold of 17.0.
No ref stars of mag 17.0 within specified radius 120.0 arcsec. Attempting another search with fainter mag threshold of 18.0.
Loading r image...
Traceback (most recent call last):
  File "/usr/local/ps1code/gitrelease/psat-server/psat-server/scripts/stamps/python/./downloadPSFinders.py", line 271, in <module>
    main()
  File "/usr/local/ps1code/gitrelease/psat-server/psat-server/scripts/stamps/python/./downloadPSFinders.py", line 263, in main
    downloadPostageStampResults(conn, options, psRequests, PSSImageRootLocation, offsetStarFilter = 'r', downloadURL = downloadURL, nsigma = float(options.nsigma), connSherlock = connSherlock)
  File "/usr/local/ps1code/gitrelease/psat-server/psat-server/scripts/stamps/python/./downloadPSFinders.py", line 186, in downloadPostageStampResults
    if downloadAllFinderImages(conn, options, requestName, PSSImageRootLocation, offsetStarFilter = offsetStarFilter, downloadURL = downloadURL, nsigma = nsigma, connSherlock = connSherlock) == 0:
  File "/usr/local/ps1code/gitrelease/psat-server/psat-server/scripts/stamps/python/./downloadPSFinders.py", line 141, in downloadAllFinderImages
    downloadStatus = downloadFinderImage2(conn, requestName, fitsRow, dataStoreFileInfo, PSSImageRootLocation, offsetStarFilter = offsetStarFilter, dataStoreURL = downloadURL, nsigma = nsigma, connSherlock = connSherlock)
  File "/usr/local/ps1code/gitrelease/psat-server/psat-server/scripts/stamps/python/pstamp_utils.py", line 1502, in downloadFinderImage2
    imageDetails = createFinderImage(connSherlock, absoluteLocalImageName, objectInfo, xhColor = xhColor, flip = flip, offsetStarSearchRadius = offsetStarSearchRadius, offsetStarMagThreshold = offsetStarMagThreshold, pixelScale = pixelScale, offsetStarFilter = offsetStarFilter, nsigma = nsigma)
  File "/usr/local/ps1code/gitrelease/psat-server/psat-server/scripts/stamps/python/pstamp_utils.py", line 1354, in createFinderImage
    (maskedPixelRatio, maskedPixelRatioAtCore) = imu.convertFitsToJpegWithCrosshairs2(absoluteLocalImageName, imu.fitsToJpegExtension(absoluteLocalImageName), flip = flip, xhColor = xhColor, negate = True, nsigma = nsigma, objectInfo = objectInfo, standardStars = convertedRefStars, pixelScale = pixelScale)
  File "/usr/local/ps1code/gitrelease/psat-server/psat-server/scripts/stamps/python/image_utils.py", line 639, in convertFitsToJpegWithCrosshairs2
    (maskedPixelRatio, maskedPixelRatioAtCore) = fitsToImage(fitsFilename, g=fitsFilename, b=fitsFilename, outputFilename=jpegFilename, nsigma = nsigma, magicNumber = magicNumber)
  File "/usr/local/ps1code/gitrelease/psat-server/psat-server/scripts/stamps/python/image_utils.py", line 555, in fitsToImage
    r_img = pf.getdata(r)
  File "/usr/local/swtools/python/pstc/anaconda3/envs/panstarrs39/lib/python3.9/site-packages/astropy/io/fits/convenience.py", line 232, in getdata
    data = hdu.data
  File "/usr/local/swtools/python/pstc/anaconda3/envs/panstarrs39/lib/python3.9/site-packages/astropy/utils/decorators.py", line 837, in __get__
    val = self.fget(obj)
  File "/usr/local/swtools/python/pstc/anaconda3/envs/panstarrs39/lib/python3.9/site-packages/astropy/io/fits/hdu/compressed.py", line 1558, in data
    data = self.section[...]
  File "/usr/local/swtools/python/pstc/anaconda3/envs/panstarrs39/lib/python3.9/site-packages/astropy/io/fits/hdu/compressed.py", line 2189, in __getitem__
    data = decompress_hdu_section(self.hdu, first_tile_index, last_tile_index)
  File "/usr/local/swtools/python/pstc/anaconda3/envs/panstarrs39/lib/python3.9/site-packages/astropy/io/fits/_tiled_compression/tiled_compression.py", line 442, in decompress_hdu_section
    tile_data[blank_mask] = np.nan
ValueError: cannot convert float NaN to integer

Downgrading to 5.0.8 (with python 3.9) works OK. Recommend that we upgrade to python 3.11 and use the latest version of astropy which also seems to work OK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions