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

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

""" Site Class 

 

Class defines the attributes of the site unless overridden 

ajc@astro 2/23/2010 

 

Restoring this so that the astrometry mixin in Astrometry.py 

can inherit the site information 

danielsf 1/27/2014 

 

""" 

from builtins import object 

 

import numpy as np 

import warnings 

 

__all__ = ["Site"] 

 

 

class LSST_site_parameters(object): 

""" 

This is a struct containing the LSST site parameters as defined in 

 

https://docushare.lsstcorp.org/docushare/dsweb/ImageStoreViewer/LSE-30 

 

(accessed on 4 January 2016) 

 

This class only exists for initializing Site with LSST parameter values. 

Users should not be accessing this class directly. 

""" 

 

def __init__(self): 

self.longitude = -70.7494 # in degrees 

self.latitude = -30.2444 # in degrees 

self.height = 2650.0 # in meters 

self.temperature = 11.5 # in centigrade 

self.pressure = 750.0 # in millibars 

self.humidity = 0.4 # scale 0-1 

self.lapseRate = 0.0065 # in Kelvin per meter 

# the lapse rate was not specified by LSE-30; 

# 0.0065 K/m appears to be the "standard" value 

# see, for example http://mnras.oxfordjournals.org/content/365/4/1235.full 

 

 

class Site (object): 

""" 

This class will store site information for use in Catalog objects. 

 

Defaults values are LSST site values taken from the Observatory System Specification 

document 

 

https://docushare.lsstcorp.org/docushare/dsweb/ImageStoreViewer/LSE-30 

 

on 4 January 2016 

 

Attributes 

---------- 

longitude: in degrees 

 

longitude_rad: longitude in radians 

 

latitude: in degrees 

 

latitude_rad: latitude in radians 

 

height: in meters 

 

temperature: mean temperature in Centigrade 

 

temperature_kelvin: mean temperature in Kelvin 

 

pressure: in millibars 

 

humidity: relative humidity (range 0-1) 

 

lapseRate: change in temperature in Kelvins per meter 

 

name: name of the observatory. If set to 'LSST' any unspecified 

values will default to LSST values as defined in 

 

https://docushare.lsstcorp.org/docushare/dsweb/ImageStoreViewer/LSE-30 

 

i.e. 

longitude=-70.7494 degrees 

latitude=-30.2444 degrees 

height=2650.0 meters 

temperature=11.5 centigrade 

pressure=750.0 millibars 

humidity=0.4 

lapseRate=0.0065in Kelvin per meter 

""" 

def __init__(self, 

name=None, 

longitude=None, 

latitude=None, 

height=None, 

temperature=None, 

pressure=None, 

humidity=None, 

lapseRate=None): 

""" 

Parameters 

---------- 

name: a string denoting the name of the observator. Set to 'LSST' 

for other parameters to default to LSST values. 

 

i.e. 

longitude=-70.7494 degrees 

latitude=-30.2444 degrees 

height=2650.0 meters 

temperature=11.5 centigrade 

pressure=750.0 millibars 

humidity=0.4 

lapseRate=0.0065 in Kelvin per meter 

 

longitude: in degrees 

 

latitude: in degrees 

 

height: in meters 

 

temperature: in Centigrade 

 

pressure: in millibars 

 

humidity: relative (range 0-1) 

 

lapseRate: in Kelvin per meter 

""" 

 

default_params = None 

self._name = name 

132 ↛ 135line 132 didn't jump to line 135, because the condition on line 132 was never false if self._name is 'LSST': 

default_params = LSST_site_parameters() 

 

135 ↛ 157line 135 didn't jump to line 157, because the condition on line 135 was never false if default_params is not None: 

136 ↛ 139line 136 didn't jump to line 139, because the condition on line 136 was never false if longitude is None: 

longitude = default_params.longitude 

 

139 ↛ 142line 139 didn't jump to line 142, because the condition on line 139 was never false if latitude is None: 

latitude = default_params.latitude 

 

142 ↛ 145line 142 didn't jump to line 145, because the condition on line 142 was never false if height is None: 

height = default_params.height 

 

145 ↛ 148line 145 didn't jump to line 148, because the condition on line 145 was never false if temperature is None: 

temperature = default_params.temperature 

 

148 ↛ 151line 148 didn't jump to line 151, because the condition on line 148 was never false if pressure is None: 

pressure = default_params.pressure 

 

151 ↛ 154line 151 didn't jump to line 154, because the condition on line 151 was never false if humidity is None: 

humidity = default_params.humidity 

 

154 ↛ 157line 154 didn't jump to line 157, because the condition on line 154 was never false if lapseRate is None: 

lapseRate = default_params.lapseRate 

 

157 ↛ 160line 157 didn't jump to line 160, because the condition on line 157 was never false if longitude is not None: 

self._longitude_rad = np.radians(longitude) 

else: 

self._longitude_rad = None 

 

162 ↛ 165line 162 didn't jump to line 165, because the condition on line 162 was never false if latitude is not None: 

self._latitude_rad = np.radians(latitude) 

else: 

self._latitude_rad = None 

 

self._longitude_deg = longitude 

self._latitude_deg = latitude 

self._height = height 

self._pressure = pressure 

 

172 ↛ 175line 172 didn't jump to line 175, because the condition on line 172 was never false if temperature is not None: 

self._temperature_kelvin = temperature + 273.15 # in Kelvin 

else: 

self._temperature_kelvin = None 

 

self._temperature_centigrade = temperature 

self._humidity = humidity 

self._lapseRate = lapseRate 

 

# Go through all the attributes of this Site. 

# Raise a warning if any are None so that the user 

# is not surprised when some use of this Site fails 

# because something that should have beena a float 

# is NoneType 

list_of_nones = [] 

187 ↛ 188line 187 didn't jump to line 188, because the condition on line 187 was never true if self.longitude is None or self.longitude_rad is None: 

if self.longitude_rad is not None: 

raise RuntimeError("in Site: longitude is None but longitude_rad is not") 

if self.longitude is not None: 

raise RuntimeError("in Site: longitude_rad is None but longitude is not") 

list_of_nones.append('longitude') 

 

194 ↛ 195line 194 didn't jump to line 195, because the condition on line 194 was never true if self.latitude is None or self.latitude_rad is None: 

if self.latitude_rad is not None: 

raise RuntimeError("in Site: latitude is None but latitude_rad is not") 

if self.latitude is not None: 

raise RuntimeError("in Site: latitude_rad is None but latitude is not") 

list_of_nones.append('latitude') 

 

201 ↛ 202line 201 didn't jump to line 202, because the condition on line 201 was never true if self.temperature is None or self.temperature_kelvin is None: 

if self.temperature is not None: 

raise RuntimeError("in Site: temperature_kelvin is None but temperature is not") 

if self.temperature_kelvin is not None: 

raise RuntimeError("in Site: temperature is None but temperature_kelvin is not") 

list_of_nones.append('temperature') 

 

208 ↛ 209line 208 didn't jump to line 209, because the condition on line 208 was never true if self.height is None: 

list_of_nones.append('height') 

 

211 ↛ 212line 211 didn't jump to line 212, because the condition on line 211 was never true if self.pressure is None: 

list_of_nones.append('pressure') 

 

214 ↛ 215line 214 didn't jump to line 215, because the condition on line 214 was never true if self.humidity is None: 

list_of_nones.append('humidity') 

 

217 ↛ 218line 217 didn't jump to line 218, because the condition on line 217 was never true if self.lapseRate is None: 

list_of_nones.append('lapseRate') 

 

220 ↛ 221line 220 didn't jump to line 221, because the condition on line 220 was never true if len(list_of_nones) != 0: 

msg = "The following attributes of your Site were None:\n" 

for name in list_of_nones: 

msg += "%s\n" % name 

msg += "If you want these to just default to LSST values,\n" 

msg += "instantiate your Site with name='LSST'" 

warnings.warn(msg) 

 

def __eq__(self, other): 

 

for param in self.__dict__: 

if param not in other.__dict__: 

return False 

if self.__dict__[param] != other.__dict__[param]: 

return False 

 

for param in other.__dict__: 

if param not in self.__dict__: 

return False 

 

return True 

 

def __ne__(self, other): 

return not self.__eq__(other) 

 

@property 

def name(self): 

""" 

observatory name 

""" 

return self._name 

 

@property 

def longitude_rad(self): 

""" 

observatory longitude in radians 

""" 

return self._longitude_rad 

 

@property 

def longitude(self): 

""" 

observatory longitude in degrees 

""" 

return self._longitude_deg 

 

@property 

def latitude_rad(self): 

""" 

observatory latitude in radians 

""" 

return self._latitude_rad 

 

@property 

def latitude(self): 

""" 

observatory latitude in degrees 

""" 

return self._latitude_deg 

 

@property 

def temperature(self): 

""" 

mean temperature in centigrade 

""" 

return self._temperature_centigrade 

 

@property 

def temperature_kelvin(self): 

""" 

mean temperature in Kelvin 

""" 

return self._temperature_kelvin 

 

@property 

def height(self): 

""" 

height in meters 

""" 

return self._height 

 

@property 

def pressure(self): 

""" 

mean pressure in millibars 

""" 

return self._pressure 

 

@property 

def humidity(self): 

""" 

mean humidity in the range 0-1 

""" 

return self._humidity 

 

@property 

def lapseRate(self): 

""" 

temperature lapse rate (in Kelvin per meter) 

""" 

return self._lapseRate