Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

# 

# LSST Data Management System 

# Copyright 2008-2015 AURA/LSST. 

# 

# This product includes software developed by the 

# LSST Project (http://www.lsst.org/). 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 3 of the License, or 

# (at your option) any later version. 

# 

# This program is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

# GNU General Public License for more details. 

# 

# You should have received a copy of the LSST License Statement and 

# the GNU General Public License along with this program. If not, 

# see <https://www.lsstcorp.org/LegalNotices/>. 

# 

import sys 

import traceback 

 

import lsst.afw.geom as afwGeom 

import lsst.pex.config as pexConfig 

import lsst.pipe.base as pipeBase 

from lsst.skymap import skyMapRegistry 

 

 

class MakeSkyMapConfig(pexConfig.Config): 

"""Config for MakeSkyMapTask 

""" 

coaddName = pexConfig.Field( 

doc="coadd name, e.g. deep, goodSeeing, chiSquared", 

dtype=str, 

default="deep", 

) 

skyMap = skyMapRegistry.makeField( 

doc="type of skyMap", 

default="dodeca", 

) 

doWrite = pexConfig.Field( 

doc="persist the skyMap? If False then run generates the sky map and returns it, " 

"but does not save it to the data repository", 

dtype=bool, 

default=True, 

) 

 

 

class MakeSkyMapRunner(pipeBase.TaskRunner): 

"""Only need a single butler instance to run on.""" 

@staticmethod 

def getTargetList(parsedCmd): 

return [parsedCmd.butler] 

 

def __call__(self, butler): 

task = self.TaskClass(config=self.config, log=self.log) 

results = None # in case the task fails 

exitStatus = 0 # exit status for shell 

if self.doRaise: 

results = task.runDataRef(butler) 

else: 

try: 

results = task.runDataRef(butler) 

except Exception as e: 

task.log.fatal("Failed: %s" % e) 

exitStatus = 1 

if not isinstance(e, pipeBase.TaskError): 

traceback.print_exc(file=sys.stderr) 

task.writeMetadata(butler) 

if self.doReturnResults: 

return pipeBase.Struct( 

exitStatus=exitStatus, 

result=results, 

) 

else: 

return pipeBase.Struct( 

exitStatus=exitStatus, 

) 

 

 

class MakeSkyMapTask(pipeBase.CmdLineTask): 

"""!Make a sky map in a repository 

 

Making a sky map in a repository is a prerequisite for making a coadd, 

since the sky map is used as the pixelization for the coadd. 

""" 

ConfigClass = MakeSkyMapConfig 

_DefaultName = "makeSkyMap" 

RunnerClass = MakeSkyMapRunner 

 

def __init__(self, **kwargs): 

pipeBase.CmdLineTask.__init__(self, **kwargs) 

 

@pipeBase.timeMethod 

def runDataRef(self, butler): 

"""!Make a skymap, persist it (optionally) and log some information about it 

 

@param[in] butler data butler 

@return a pipeBase Struct containing: 

- skyMap: the constructed SkyMap 

""" 

skyMap = self.config.skyMap.apply() 

self.logSkyMapInfo(skyMap) 

106 ↛ 108line 106 didn't jump to line 108, because the condition on line 106 was never false if self.config.doWrite: 

butler.put(skyMap, self.config.coaddName + "Coadd_skyMap") 

return pipeBase.Struct( 

skyMap=skyMap 

) 

 

def logSkyMapInfo(self, skyMap): 

"""!Log information about a sky map 

 

@param[in] skyMap sky map (an lsst.skyMap.SkyMap) 

""" 

self.log.info("sky map has %s tracts" % (len(skyMap),)) 

for tractInfo in skyMap: 

wcs = tractInfo.getWcs() 

posBox = afwGeom.Box2D(tractInfo.getBBox()) 

pixelPosList = ( 

posBox.getMin(), 

afwGeom.Point2D(posBox.getMaxX(), posBox.getMinY()), 

posBox.getMax(), 

afwGeom.Point2D(posBox.getMinX(), posBox.getMaxY()), 

) 

skyPosList = [wcs.pixelToSky(pos).getPosition(afwGeom.degrees) for pos in pixelPosList] 

posStrList = ["(%0.3f, %0.3f)" % tuple(skyPos) for skyPos in skyPosList] 

self.log.info("tract %s has corners %s (RA, Dec deg) and %s x %s patches" % 

(tractInfo.getId(), ", ".join(posStrList), 

tractInfo.getNumPatches()[0], tractInfo.getNumPatches()[1])) 

 

@classmethod 

def _makeArgumentParser(cls): 

"""Create an argument parser 

 

No identifiers are added because none are used. 

""" 

return pipeBase.ArgumentParser(name=cls._DefaultName) 

 

def _getConfigName(self): 

"""Disable persistence of config 

 

There's only one SkyMap per rerun anyway, so the config is redundant, 

and checking it means we can't overwrite or append to one once we've 

written it. 

""" 

return None 

 

def _getMetadataName(self): 

"""Disable persistence of metadata 

 

There's nothing worth persisting. 

""" 

return None