Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-22260

Metadata is not persisted when persisting an ExposureCatalog to fits

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: afw
    • Labels:
      None

      Description

      When writing an ExposureCatalog to FITS, the metadata property list is not persisted. When writing a test case for this I ran into the problem that the case of the property list values is not always round-trippable ( https://community.lsst.org/t/fits-and-lowercase-header-keys/1184/3 ) but by looking at the header of the persisted file I see that this is unrelated to the current issue. That is, the metadata is not persisted to the FITS file for an ExposureCatalog with any case.

      import lsst.afw.table as afwTable
      import lsst.daf.base as dafBase
      import lsst.geom
       
      name = 'TEST'
       
      schema = afwTable.ExposureTable.makeMinimalSchema()
      cat = afwTable.ExposureCatalog(schema)
      cat.reserve(1)
      rec = cat.addNew()
       
      plist = dafBase.PropertyList()
      plist.addDouble(name, 1.0)
       
      cat.setMetadata(plist)
       
      print(cat.getMetadata()[name])
       
      cat.writeFits('%s_expcatalog_metadata.fits' % (name))
       
      cat2 = afwTable.ExposureCatalog.readFits('%s_expcatalog_metadata.fits' % (name))
       
      print(cat2.getMetadata()[name])
      
      

      This results in a KeyError: 'TEST not found'.

        Attachments

          Issue Links

            Activity

            Hide
            tjenness Tim Jenness added a comment -

            We know that metadata is written for BaseCatalog so what's special about ExposureCatalog? Do we have no tests of ExposureCatalog that use setMetadata?

            Show
            tjenness Tim Jenness added a comment - We know that metadata is written for BaseCatalog so what's special about ExposureCatalog? Do we have no tests of ExposureCatalog that use setMetadata?
            Hide
            erykoff Eli Rykoff added a comment -

            I guess not. I just wrote a quick one in test_exposureTable.py on my machine and it fails.

            Show
            erykoff Eli Rykoff added a comment - I guess not. I just wrote a quick one in test_exposureTable.py on my machine and it fails.
            Hide
            erykoff Eli Rykoff added a comment -

            The problem appears to be here: https://github.com/lsst/afw/blob/d8786685a889d9c94e279327d68a2888e50e6bfb/src/table/Exposure.cc#L230 in that a new table is being generated from the old table prior to persistence, and it doesn't also set the metadata.

            Show
            erykoff Eli Rykoff added a comment - The problem appears to be here: https://github.com/lsst/afw/blob/d8786685a889d9c94e279327d68a2888e50e6bfb/src/table/Exposure.cc#L230 in that a new table is being generated from the old table prior to persistence, and it doesn't also set the metadata.
            Show
            erykoff Eli Rykoff added a comment - PR here https://github.com/lsst/afw/pull/502 Jenkins here https://ci.lsst.codes/blue/organizations/jenkins/stack-os-matrix/detail/stack-os-matrix/30797/pipeline

              People

              Assignee:
              erykoff Eli Rykoff
              Reporter:
              erykoff Eli Rykoff
              Reviewers:
              Jim Bosch
              Watchers:
              Eli Rykoff, Jim Bosch, Tim Jenness
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: