-
Notifications
You must be signed in to change notification settings - Fork 14
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-3766: Add Butler access to calibration data in obs_decam #5
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b12417d
Add Decam customized config and parse for the new task ingestCalibs
3da3ff3
DecamMapper: Add calibration dataset types bias/flat/fringe
c800fc5
tests/getRaw.py: Use print_function
3396300
Remove unused imports in tests/getRaw.py and decamMapper.py
bd7636c
Ensure line length to be less than or equal to 110 char
99726a8
ingest.py: Pass dryrun argument to register.openRegistry
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from lsst.obs.decam.ingestCalibs import DecamCalibsParseTask | ||
config.parse.retarget(DecamCalibsParseTask) | ||
config.parse.hdu = 1 | ||
# N30 is not included becasue it is not functional. | ||
config.parse.extnames = ['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'S10', 'S11', 'S12', 'S13', | ||
'S14', 'S15', 'S16', 'S17', 'S18', 'S19', 'S20', 'S21', 'S22', 'S23', 'S24', 'S25', | ||
'S26', 'S27', 'S28', 'S29', 'S30', 'S31', 'N1', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', | ||
'N8', 'N9', 'N10', 'N11', 'N12', 'N13', 'N14', 'N15', 'N16', 'N17', 'N18', 'N19', | ||
'N20', 'N21', 'N22', 'N23', 'N24', 'N25', 'N26', 'N27', 'N28', 'N29', 'N31', | ||
] | ||
config.parse.translators = {'filter': 'translate_filter', | ||
'ccdnum': 'translate_ccdnum', | ||
'calibDate': 'translate_date', | ||
'validStart': 'translate_date', | ||
'validEnd': 'translate_date', | ||
} | ||
config.register.columns = {'filter': 'text', | ||
'ccdnum': 'int', | ||
'path': 'text', | ||
'calibDate': 'text', | ||
'validStart': 'text', | ||
'validEnd': 'text', | ||
} | ||
config.register.unique = ['filter', 'ccdnum', 'calibDate'] | ||
config.register.tables = ['bias', 'flat', 'fringe'] | ||
config.register.visit = ['calibDate'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import collections | ||
import re | ||
from lsst.pipe.tasks.ingestCalibs import CalibsParseTask | ||
|
||
class DecamCalibsParseTask(CalibsParseTask): | ||
def getInfo(self, filename): | ||
"""Get information about the image from the filename and/or its contents | ||
|
||
@param filename: Name of file to inspect | ||
@return File properties; list of file properties for each extension | ||
""" | ||
phuInfo, infoList = CalibsParseTask.getInfo(self, filename) | ||
# Single-extension fits without EXTNAME can be a valid CP calibration product | ||
# Use info of primary header unit | ||
if not infoList: | ||
infoList.append(phuInfo) | ||
return phuInfo, infoList | ||
|
||
def translate_ccdnum(self, md): | ||
"""Return CCDNUM as a integer | ||
|
||
@param md (PropertySet) FITS header metadata | ||
""" | ||
if md.exists("CCDNUM"): | ||
ccdnum = md.get("CCDNUM") | ||
else: | ||
self.log.warn("Unable to find value for CCDNUM") | ||
ccdnum = None | ||
# Some MasterCal from NOAO Archive has 2 CCDNUM keys in each HDU | ||
# Make sure only one integer is returned. | ||
if isinstance(ccdnum, collections.Sequence): | ||
try: | ||
ccdnum = ccdnum[0] | ||
except IndexError: | ||
ccdnum = None | ||
return ccdnum | ||
|
||
def translate_date(self, md): | ||
"""Extract the date as a strong in format YYYY-MM-DD from the FITS header DATE-OBS. | ||
Return "unknown" if the value cannot be found or converted. | ||
|
||
@param md (PropertySet) FITS header metadata | ||
""" | ||
if md.exists("DATE-OBS"): | ||
date = md.get("DATE-OBS") | ||
found = re.search('(\d\d\d\d-\d\d-\d\d)', date) | ||
if found: | ||
date = found.group(1) | ||
else: | ||
self.log.warn("DATE-OBS does not match format YYYY-MM-DD") | ||
date = "unknown" | ||
else: | ||
self.log.warn("Unable to find value for DATE-OBS") | ||
date = "unknown" | ||
return date | ||
|
||
@staticmethod | ||
def getExtensionName(md): | ||
""" Get the name of the extension | ||
|
||
@param md (PropertySet) FITS header metadata | ||
""" | ||
return md.get('EXTNAME') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if the DATE-OBS header does not contain a "T" for some reason this function just returns whatever was present in the header? If there is no T the header is not compliant so I'd rather the routine got upset. If you are trying to support pre-Y2K standard DATE-OBS headers then there will be inconsistencies because those used "/" rather than "-".
I think it would be much safer if this code used a pattern match of something like `^\d\d\d\d-\d\d-\d\dT' so it could be sure what is actually being returned.