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

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

# 

# LSST Data Management System 

# Copyright 2016 LSST Corporation. 

# 

# 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 <http://www.lsstcorp.org/LegalNotices/>. 

# 

import warnings 

import numpy 

import lsst.afw.cameraGeom as cameraGeom 

import lsst.geom as geom 

import lsst.afw.geom as afwGeom 

from lsst.afw.table import AmpInfoCatalog, AmpInfoTable, LL 

 

 

class Monocam(cameraGeom.Camera): 

"""The monocam Camera 

 

There is one ccd with name "0" 

It has sixteen amplifiers with names like "00".."07" and "10".."17" 

 

Standard keys are: 

amp: amplifier name: one of 00, 01, 02, 03, 04, 05, 06, 07, 10, 11, 12, 

13, 14, 15, 16, 17 

ccd: ccd name: always 0 

visit: exposure number; this will be provided by the DAQ 

""" 

# Taken from fit4_20160413-154303.pdf 

gain = {(0, 0): 3.707220, 

(1, 0): 3.724264, 

(2, 0): 3.758828, 

(3, 0): 3.794040, 

(4, 0): 3.724264, 

(5, 0): 3.776352, 

(6, 0): 3.758828, 

(7, 0): 3.776352, 

(0, 1): 3.724264, 

(1, 1): 3.657009, 

(2, 1): 3.640573, 

(3, 1): 3.624284, 

(4, 1): 3.640573, 

(5, 1): 3.707220, 

(6, 1): 3.673594, 

(7, 1): 3.640573} 

 

readNoise = {(0, 0): 7.105902, 

(1, 0): 6.860052, 

(2, 0): 7.387405, 

(3, 0): 7.222204, 

(4, 0): 7.250763, 

(5, 0): 7.315250, 

(6, 0): 7.104838, 

(7, 0): 7.272336, 

(0, 1): 8.485139, 

(1, 1): 8.022778, 

(2, 1): 8.157399, 

(3, 1): 8.021112, 

(4, 1): 8.015486, 

(5, 1): 7.928829, 

(6, 1): 16.031720, 

(7, 1): 7.938155} 

 

def __init__(self): 

"""Construct a TestCamera 

""" 

plateScale = geom.Angle(13.55, geom.arcseconds) # plate scale, in angle on sky/mm 

radialDistortion = 0. # radial distortion in mm/rad^2 

radialCoeff = numpy.array((0.0, 1.0, 0.0, radialDistortion)) / plateScale.asRadians() 

focalPlaneToFieldAngle = afwGeom.makeRadialTransform(radialCoeff) 

fieldAngleToFocalPlane = focalPlaneToFieldAngle.inverted() 

cameraTransformMap = cameraGeom.TransformMap(cameraGeom.FOCAL_PLANE, 

{cameraGeom.FIELD_ANGLE: fieldAngleToFocalPlane}) 

detectorList = self._makeDetectorList(fieldAngleToFocalPlane, plateScale) 

cameraGeom.Camera.__init__(self, "monocam", detectorList, cameraTransformMap) 

 

def _makeDetectorList(self, focalPlaneToFieldAngle, plateScale): 

"""!Make a list of detectors 

 

@param[in] focalPlaneToFieldAngle 

lsst.afw.geom.TransformPoint2ToPoint2 

from FOCAL_PLANE to FIELD_ANGLE coordinates 

@param[in] plateScale plate scale, in angle on sky/mm 

@return a list of detectors (lsst.afw.cameraGeom.Detector) 

""" 

warnings.warn("plateScale no longer an argument to cameraGeom.makeDetector. Tread carefully.") 

detectorList = [] 

detectorConfigList = self._makeDetectorConfigList() 

for detectorConfig in detectorConfigList: 

ampInfoCatalog = self._makeAmpInfoCatalog() 

detector = cameraGeom.makeDetector(detectorConfig, ampInfoCatalog, focalPlaneToFieldAngle) 

detectorList.append(detector) 

return detectorList 

 

def _makeDetectorConfigList(self): 

"""!Make a list of detector configs 

 

@return a list of detector configs (lsst.afw.cameraGeom.DetectorConfig) 

""" 

# There is only a single detector assumed perfectly centered and 

# aligned. 

detector0Config = cameraGeom.DetectorConfig() 

detector0Config.name = '0' 

detector0Config.id = 0 

detector0Config.serial = 'abcd1234' 

detector0Config.detectorType = 0 

# This is the orientation we need to put the serial direciton along 

# the x-axis 

detector0Config.bbox_x0 = 0 

detector0Config.bbox_x1 = 4095 

detector0Config.bbox_y0 = 0 

detector0Config.bbox_y1 = 4003 

detector0Config.pixelSize_x = 0.01 # in mm 

detector0Config.pixelSize_y = 0.01 # in mm 

detector0Config.transformDict.nativeSys = 'Pixels' 

detector0Config.transformDict.transforms = None 

detector0Config.refpos_x = 2001.5 

detector0Config.refpos_y = 2047.5 

detector0Config.offset_x = 0.0 

detector0Config.offset_y = 0.0 

detector0Config.transposeDetector = False 

detector0Config.pitchDeg = 0.0 

detector0Config.yawDeg = 0.0 # this is where chip rotation goes in. 

detector0Config.rollDeg = 0.0 

return [detector0Config] 

 

def _makeAmpInfoCatalog(self): 

"""Construct an amplifier info catalog 

""" 

# Much of this will need to be filled in when we know it. 

xDataExtent = 512 # trimmed 

yDataExtent = 2002 

 

extended = 10 # extended register 

h_overscan = 22 # number of overscan in x 

v_overscan = 46 # number of overscan in y 

 

xRawExtent = extended + h_overscan + xDataExtent 

yRawExtent = v_overscan + yDataExtent # no prescan in vertical 

 

saturation = 65535 

# Linearity correction is still under discussion, so this is a 

# placeholder. 

linearityType = "PROPORTIONAL" 

linearityThreshold = 0 

linearityMax = saturation 

linearityCoeffs = [linearityThreshold, linearityMax] 

 

schema = AmpInfoTable.makeMinimalSchema() 

 

linThreshKey = schema.addField('linearityThreshold', type=float) 

linMaxKey = schema.addField('linearityMaximum', type=float) 

linUnitsKey = schema.addField('linearityUnits', type=str, size=9) 

# end placeholder 

self.ampInfoDict = {} 

ampCatalog = AmpInfoCatalog(schema) 

for ampY in (0, 1): 

for ampX in range(8): 

record = ampCatalog.addNew() 

record.setName("%d%d" % (ampX, ampY)) 

 

if bool(ampY): 

record.setBBox(geom.Box2I( 

geom.Point2I(ampX*xDataExtent, ampY*yDataExtent), 

geom.Extent2I(xDataExtent, yDataExtent), 

)) 

else: 

record.setBBox(geom.Box2I( 

geom.Point2I((7 - ampX)*xDataExtent, ampY*yDataExtent), 

geom.Extent2I(xDataExtent, yDataExtent), 

)) 

 

readCorner = LL # in raw frames; always LL because raws are in amp coords 

# bias region 

x0Bias = extended + xDataExtent 

y0Data = 0 

x0Data = extended 

 

record.setRawBBox(geom.Box2I( 

geom.Point2I(0, 0), 

geom.Extent2I(xRawExtent, yRawExtent), 

)) 

record.setRawDataBBox(geom.Box2I( 

geom.Point2I(x0Data, y0Data), 

geom.Extent2I(xDataExtent, yDataExtent), 

)) 

record.setRawHorizontalOverscanBBox(geom.Box2I( 

geom.Point2I(x0Bias, y0Data), 

geom.Extent2I(h_overscan, yDataExtent), 

)) 

record.setRawVerticalOverscanBBox(geom.Box2I( 

geom.Point2I(x0Data, y0Data+yDataExtent), 

geom.Extent2I(xDataExtent, v_overscan), 

)) 

record.setRawXYOffset(geom.Extent2I(ampX*xRawExtent, ampY*yRawExtent)) 

record.setReadoutCorner(readCorner) 

record.setGain(self.gain[(ampX, ampY)]) 

record.setReadNoise(self.readNoise[(ampX, ampY)]) 

record.setSaturation(saturation) 

record.setHasRawInfo(True) 

record.setRawFlipX(bool(ampY)) 

# flip data when assembling if in top of chip 

record.setRawFlipY(bool(ampY)) 

record.setRawPrescanBBox(geom.Box2I()) 

# linearity placeholder stuff 

record.setLinearityCoeffs([float(val) for val in linearityCoeffs]) 

record.setLinearityType(linearityType) 

record.set(linThreshKey, float(linearityThreshold)) 

record.set(linMaxKey, float(linearityMax)) 

record.set(linUnitsKey, "DN") 

return ampCatalog