Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-23983: Cannot apply crosstalk in Gen 3 DECam processing #140

Merged
merged 10 commits into from
Jun 11, 2020
2 changes: 1 addition & 1 deletion python/lsst/ip/isr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from .version import *
from .isrFunctions import *
from .assembleCcdTask import *
from .calibType import *
from .isrTask import *
from .linearize import *
from .crosstalk import *
Expand All @@ -36,4 +37,3 @@
from .measureCrosstalk import *
from .isrQa import *
from .isrMock import *
from .calibType import *
17 changes: 9 additions & 8 deletions python/lsst/ip/isr/calibType.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import warnings
import yaml
from astropy.table import Table
from astropy.io import fits

from lsst.log import Log
from lsst.daf.base import PropertyList
Expand Down Expand Up @@ -141,7 +142,7 @@ def updateMetadata(self, setDate=False, **kwargs):
----------
setDate : `bool`, optional
Ensure the metadata CALIBDATE fields are set to the current datetime.
kwargs :
kwargs : `dict` or `collections.abc.Mapping`, optional
Set of key=value pairs to assign to the metadata.
"""
mdOriginal = self.getMetadata()
Expand Down Expand Up @@ -262,8 +263,8 @@ def readFits(cls, filename):
try:
with warnings.catch_warnings("error"):
newTable = Table.read(filename, hdu=extNum)
tableList.append(newTable)
extNum += 1
tableList.append(newTable)
extNum += 1
Comment on lines +266 to +267
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually change any behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The with warnings.catch_warnings("error") is needed because astropy will read the "first available" table if the requested table does not exist, throwing a warning instead of an exception. This promotes the warning to an exception, and ensures that the list represents what's in the FITS table.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that is subtle. Sounds good!

except Exception:
pass

Expand All @@ -284,13 +285,13 @@ def writeFits(self, filename):

"""
tableList = self.toTable()

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=Warning, module="astropy.io")
tableList[0].write(filename)
for table in tableList[1:]:
table.write(filename, append=True)
astropyList = [fits.table_to_hdu(table) for table in tableList]
astropyList.insert(0, fits.PrimaryHDU())

writer = fits.HDUList(astropyList)
writer.writeto(filename, overwrite=True)
return filename

def fromDetector(self, detector):
Expand Down Expand Up @@ -473,7 +474,7 @@ def updateMetadata(self, setDate=False, **kwargs):
setDate : `bool, optional
Update the CALIBDATE fields in the metadata to the current
time. Defaults to False.
kwargs :
kwargs : `dict` or `collections.abc.Mapping`, optional
Other keyword parameters to set in the metadata.
"""
kwargs["DETECTOR"] = self._detectorName
Expand Down