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

1from builtins import object 

2import numpy 

3 

4__all__ = ["PhotometricParameters"] 

5 

6class DefaultPhotometricParameters(object): 

7 """ 

8 This class will just contain a bunch of dict which store 

9 the default PhotometricParameters for LSST Bandpasses 

10 

11 Users should not access this class (which is why it is 

12 not included in the __all__ declaration for this file). 

13 

14 It is only used to initialize PhotometricParameters off of 

15 a bandpass name. 

16 """ 

17 

18 # Obviously, some of these parameters (effarea, gain, platescale, 

19 # darkcurrent, and readnoise) will not change as a function of bandpass; 

20 # we are just making them dicts here to be consistent with 

21 # everything else (and to make it possible for 

22 # PhotometricParameters to access them using the bandpass name 

23 # passed to its constructor) 

24 # 

25 # Note: all dicts contain an 'any' key which will be the default 

26 # value if an unknown bandpass is asked for 

27 # 

28 # 'any' values should be kept consistent with r band 

29 

30 bandpassNames = ['u', 'g', 'r', 'i', 'z', 'y', 'any'] 

31 

32 def makeDict(value, 

33 bandpassNames = ('u', 'g', 'r', 'i', 'z', 'y', 'any')): 

34 newdict = {} 

35 for f in bandpassNames: 

36 newdict[f] = value 

37 return newdict 

38 

39 # exposure time in seconds 

40 exptimeSec = 15.0 

41 exptime = makeDict(exptimeSec) 

42 

43 # number of exposures 

44 nexpN = 2 

45 nexp = makeDict(nexpN) 

46 

47 # effective area in cm^2 

48 effareaCm2 = numpy.pi * (6.423/2.*100)**2 

49 effarea = makeDict(effareaCm2) 

50 

51 # electrons per ADU 

52 gainADU = 2.3 

53 gain = makeDict(gainADU) 

54 

55 # electrons per pixel per exposure 

56 readnoiseE = 8.8 

57 readnoise = makeDict(readnoiseE) 

58 

59 # electrons per pixel per second 

60 darkcurrentE = 0.2 

61 darkcurrent = makeDict(darkcurrentE) 

62 

63 # electrons per pixel per exposure 

64 othernoiseE = 0.0 

65 othernoise = makeDict(othernoiseE) 

66 

67 # arcseconds per pixel 

68 platescaleAS = 0.2 

69 platescale = makeDict(platescaleAS) 

70 

71 # systematic squared error in magnitudes 

72 # see Table 14 of the SRD document 

73 # https://docushare.lsstcorp.org/docushare/dsweb/Get/LPM-17 

74 sigmaSys = {'u':0.0075, 'g':0.005, 'r':0.005, 'i':0.005, 'z':0.0075, 'y':0.0075, 

75 'any':0.005} 

76 

77 

78class PhotometricParameters(object): 

79 

80 def __init__(self, exptime=None, 

81 nexp=None, 

82 effarea=None, 

83 gain=None, 

84 readnoise=None, 

85 darkcurrent=None, 

86 othernoise=None, 

87 platescale=None, 

88 sigmaSys=None, 

89 bandpass=None): 

90 

91 """ 

92 @param [in] exptime exposure time in seconds (defaults to LSST value) 

93 

94 @param [in] nexp number of exposures (defaults to LSST value) 

95 

96 @param [in] effarea effective area in cm^2 (defaults to LSST value) 

97 

98 @param [in] gain electrons per ADU (defaults to LSST value) 

99 

100 @param [in] readnoise electrons per pixel per exposure (defaults to LSST value) 

101 

102 @param [in] darkcurrent electons per pixel per second (defaults to LSST value) 

103 

104 @param [in] othernoise electrons per pixel per exposure (defaults to LSST value) 

105 

106 @param [in] platescale arcseconds per pixel (defaults to LSST value) 

107 

108 @param [in] sigmaSys systematic error in magnitudes 

109 (defaults to LSST value) 

110 

111 @param [in] bandpass is the name of the bandpass to which these parameters 

112 correspond. If set to an LSST bandpass, the constructor will initialize 

113 PhotometricParameters to LSST default values for that bandpass, excepting 

114 any parameters that have been set by hand, i.e 

115 

116 myPhotParams = PhotometricParameters(nexp=3, bandpass='u') 

117 

118 will initialize a PhotometricParameters object to u bandpass defaults, except 

119 with 3 exposures instead of 2. 

120 

121 If bandpass is left as None, other parameters will default to LSST r band 

122 values (except for those values set by hand). The bandpass member variable 

123 of PhotometricParameters will, however, remain None. 

124 """ 

125 

126 # readnoise, darkcurrent and othernoise are measured in electrons. 

127 # This is taken from the specifications document LSE-30 on Docushare 

128 # Section 3.4.2.3 states that the total noise per pixel shall be 12.7 electrons per visit 

129 # which the defaults sum to (remember to multply darkcurrent by the number 

130 # of seconds in an exposure=15). [9 e- per 15 second exposure] 

131 

132 self._exptime = None 

133 self._nexp = None 

134 self._effarea = None 

135 self._gain = None 

136 self._platescale = None 

137 self._sigmaSys = None 

138 self._readnoise = None 

139 self._darkcurrent = None 

140 self._othernoise = None 

141 

142 

143 self._bandpass = bandpass 

144 defaults = DefaultPhotometricParameters() 

145 

146 if bandpass is None: 

147 bandpassKey = 'any' 

148 # This is so we do not set the self._bandpass member variable 

149 # without the user's explicit consent, but we can still access 

150 # default values from the PhotometricParameterDefaults 

151 else: 

152 bandpassKey = bandpass 

153 

154 if bandpassKey in defaults.bandpassNames: 

155 self._exptime = defaults.exptime[bandpassKey] 

156 self._nexp = defaults.nexp[bandpassKey] 

157 self._effarea = defaults.effarea[bandpassKey] 

158 self._gain = defaults.gain[bandpassKey] 

159 self._platescale = defaults.platescale[bandpassKey] 

160 self._sigmaSys = defaults.sigmaSys[bandpassKey] 

161 self._readnoise = defaults.readnoise[bandpassKey] 

162 self._darkcurrent = defaults.darkcurrent[bandpassKey] 

163 self._othernoise = defaults.othernoise[bandpassKey] 

164 

165 if exptime is not None: 

166 self._exptime = exptime 

167 

168 if nexp is not None: 

169 self._nexp = nexp 

170 

171 if effarea is not None: 

172 self._effarea = effarea 

173 

174 if gain is not None: 

175 self._gain = gain 

176 

177 if platescale is not None: 

178 self._platescale = platescale 

179 

180 if sigmaSys is not None: 

181 self._sigmaSys = sigmaSys 

182 

183 if readnoise is not None: 

184 self._readnoise = readnoise 

185 

186 if darkcurrent is not None: 

187 self._darkcurrent = darkcurrent 

188 

189 if othernoise is not None: 

190 self._othernoise = othernoise 

191 

192 failureMessage = '' 

193 failureCt = 0 

194 

195 if self._exptime is None: 

196 failureMessage += 'did not set exptime\n' 

197 failureCt += 1 

198 

199 if self._nexp is None: 

200 failureMessage += 'did not set nexp\n' 

201 failureCt += 1 

202 

203 if self._effarea is None: 

204 failureMessage += 'did not set effarea\n' 

205 failureCt += 1 

206 

207 if self._gain is None: 

208 failureMessage += 'did not set gain\n' 

209 failureCt += 1 

210 

211 if self._platescale is None: 

212 failureMessage += 'did not set platescale\n' 

213 failureCt +=1 

214 

215 if self._sigmaSys is None: 

216 failureMessage += 'did not set sigmaSys\n' 

217 failureCt += 1 

218 

219 if self._readnoise is None: 

220 failureMessage += 'did not set readnoise\n' 

221 failureCt += 1 

222 

223 if self._darkcurrent is None: 

224 failureMessage += 'did not set darkcurrent\n' 

225 failureCt +=1 

226 

227 if self._othernoise is None: 

228 failureMessage += 'did not set othernoise\n' 

229 failureCt += 1 

230 

231 if failureCt>0: 

232 raise RuntimeError('In PhotometricParameters:\n%s' % failureMessage) 

233 

234 

235 

236 @property 

237 def bandpass(self): 

238 """ 

239 The name of the bandpass associated with these parameters (can be None) 

240 """ 

241 return self._bandpass 

242 

243 @bandpass.setter 

244 def bandpass(self, value): 

245 raise RuntimeError("You should not be setting bandpass on the fly; " + 

246 "Just instantiate a new case of PhotometricParameters") 

247 

248 @property 

249 def exptime(self): 

250 """ 

251 exposure time in seconds 

252 """ 

253 return self._exptime 

254 

255 @exptime.setter 

256 def exptime(self, value): 

257 raise RuntimeError("You should not be setting exptime on the fly; " + 

258 "Just instantiate a new case of PhotometricParameters") 

259 

260 

261 @property 

262 def nexp(self): 

263 """ 

264 number of exposures 

265 """ 

266 return self._nexp 

267 

268 @nexp.setter 

269 def nexp(self, value): 

270 raise RuntimeError("You should not be setting nexp on the fly; " + 

271 "Just instantiate a new case of PhotometricParameters") 

272 

273 

274 @property 

275 def effarea(self): 

276 """ 

277 effective area in cm^2 

278 """ 

279 return self._effarea 

280 

281 @effarea.setter 

282 def effarea(self, value): 

283 raise RuntimeError("You should not be setting effarea on the fly; " + 

284 "Just instantiate a new case of PhotometricParameters") 

285 

286 

287 @property 

288 def gain(self): 

289 """ 

290 electrons per ADU 

291 """ 

292 return self._gain 

293 

294 @gain.setter 

295 def gain(self, value): 

296 raise RuntimeError("You should not be setting gain on the fly; " + 

297 "Just instantiate a new case of PhotometricParameters") 

298 

299 

300 @property 

301 def platescale(self): 

302 """ 

303 arcseconds per pixel 

304 """ 

305 return self._platescale 

306 

307 @platescale.setter 

308 def platescale(self, value): 

309 raise RuntimeError("You should not be setting platescale on the fly; " + 

310 "Just instantiate a new case of PhotometricParameters") 

311 

312 

313 @property 

314 def readnoise(self): 

315 """ 

316 electrons per pixel per exposure 

317 """ 

318 return self._readnoise 

319 

320 @readnoise.setter 

321 def readnoise(self, value): 

322 raise RuntimeError("You should not be setting readnoise on the fly; " + 

323 "Just instantiate a new case of PhotometricParameters") 

324 

325 

326 @property 

327 def darkcurrent(self): 

328 """ 

329 electrons per pixel per second 

330 """ 

331 return self._darkcurrent 

332 

333 @darkcurrent.setter 

334 def darkcurrent(self, value): 

335 raise RuntimeError("You should not be setting darkcurrent on the fly; " + 

336 "Just instantiate a new case of PhotometricParameters") 

337 

338 

339 @property 

340 def othernoise(self): 

341 """ 

342 electrons per pixel per exposure 

343 """ 

344 return self._othernoise 

345 

346 @othernoise.setter 

347 def othernoise(self,value): 

348 raise RuntimeError("You should not be setting othernoise on the fly; " + 

349 "Just instantiate a new case of PhotometricParameters") 

350 

351 

352 @property 

353 def sigmaSys(self): 

354 """ 

355 systematic error in magnitudes 

356 """ 

357 return self._sigmaSys 

358 

359 

360 @sigmaSys.setter 

361 def sigmaSys(self, value): 

362 raise RuntimeError("You should not be setting sigmaSys on the fly; " + 

363 "Just instantiate a new case of PhotometricParameters")