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

from __future__ import division 

from builtins import object 

import os 

import warnings 

import numpy as np 

try: 

from lsst.sims.photUtils import Bandpass 

no_photUtils = False 

except ImportError: 

no_photUtils = True 

DEFAULT_WAVELENGTH_VERSION = '1.3' 

DEFAULT_FILTER_LIST = ('u', 'g', 'r', 'i', 'z', 'y') 

DEFAULT_WAVELENGTHS = np.array([367.06988658, 482.68517118, 

622.32403587, 754.59752265, 

869.09018708, 971.02780848]) 

 

__all__ = ["SeeingModel"] 

 

 

class SeeingModel(object): 

"""LSST FWHM calculations for FWHM_effective and FWHM_geometric. 

Calculations of the delivered values are based on equations in Document-20160 

("Atmospheric and Delivered Image Quality in OpSim" by Bo Xin, George Angeli, Zeljko Ivezic) 

 

Parameters 

---------- 

telescope_seeing : float, opt 

The contribution to the FWHM at zenith from the telescope, in arcseconds. 

Default 0.25" 

optical_design_seeing : float, opt 

The contribution to the FWHM at zenith from the optical design, in arcseconds. 

Default 0.08" 

camera_seeing : float, opt 

The contribution to the FWHM at zenith from the camera components, in arcseconds. 

Default 0.30" 

raw_seeing_wavelength : float, opt 

The wavelength (in nm) of the provided value of the atmospheric fwhm at zenith. 

Default 500nm. 

filter_effwavelen : numpy.ndarray or None, opt 

An array containing the effective wavelengths per filter in filter_list, in nm. 

If this is None (default), sims_photUtils will be used to calculate the values for ugrizy 

based on the setup throughputs repository. 

""" 

def __init__(self, telescope_seeing=0.25, 

optical_design_seeing=0.08, camera_seeing=0.30, 

raw_seeing_wavelength=500, 

filter_effwavelens=None): 

self.set_fwhm_zenith_system(telescope_seeing, 

optical_design_seeing, 

camera_seeing) 

self.raw_seeing_wavelength = raw_seeing_wavelength 

if filter_effwavelens is None: 

self._get_effwavelens() 

else: 

self.filter_effwavelens = filter_effwavelens 

 

def _get_effwavelens(self): 

"""Calculate the effective wavelengths. 

 

This method will attempt to calculate the effective wavelengths using 

the throughputs curves in the throughput directory and sims_photUtils. 

 

If sims_photUtils or throughputs is unavailable, it will just use default values. 

These default values correspond to throughputs v 1.3 (4/2018). 

""" 

self.filter_list = ('u', 'g', 'r', 'i', 'z', 'y') 

fdir = os.getenv('LSST_THROUGHPUTS_DEFAULT') 

if no_photUtils or (fdir is None): 

warnings.warn('Cannot calculate effective wavelengths; either sims_photUtils is ' 

'unavailable (setup sims_photUtils) or $LSST_THROUGHPUTS_DEFAULT ' 

'is undefined (setup throughputs package). ' 

'Without these, simply using default effective wavelengths from version %s.' 

% (DEFAULT_WAVELENGTH_VERSION), Warning) 

self.filter_list = DEFAULT_FILTER_LIST 

self.filter_effwavelens = DEFAULT_WAVELENGTHS 

else: 

# Read the throughputs curves from the throughputs package. 

# Note that if sims_photUtils is setup, the throughputs package is as well. 

lsst = {} 

for f in self.filter_list: 

lsst[f] = Bandpass() 

lsst[f].readThroughput(os.path.join(fdir, 'total_' + f + '.dat')) 

eff_wavelens = np.zeros(len(self.filter_list), float) 

for i, f in enumerate(self.filter_list): 

eff_wavelens[i] = lsst[f].calcEffWavelen()[1] 

self.filter_effwavelens = eff_wavelens 

 

def set_fwhm_zenith_system(self, telescope_seeing, optical_design_seeing, camera_seeing): 

"""Calculate the system contribution to FWHM at zenith. 

 

This is simply the individual telescope, optics, and camera contributions 

combined in quadrature. 

""" 

self.fwhm_system_zenith = np.sqrt(telescope_seeing**2 + 

optical_design_seeing**2 + 

camera_seeing**2) 

 

def seeing_at_airmass(self, fwhm_500, airmass=1.0): 

"""Calculate the FWHM_eff and FWHM_geom as a function of wavelength, at a range of airmasses, 

given FWHM_500 (seeing at 500nm / raw_seeing_wavelength at zenith). 

 

FWHM_geom represents the geometric size of the PSF; FWHM_eff represents the FWHM of a 

single gaussian which encloses the same number of pixels as N_eff (the number of pixels 

enclosed in the actual PSF -- this is the value to use when calculating SNR). 

 

FWHM_geom(") = 0.822 * FWHM_eff(") + 0.052" 

 

The FWHM_eff includes a contribution from the system and from the atmosphere. 

Both of these are expected to scale with airmass^0.6 and with (500(nm)/wavelength(nm))^0.3. 

FWHM_eff = 1.16 * sqrt(FWHM_sys**2 + 1.04*FWHM_atm**2) 

 

Parameters 

---------- 

fwhm_500 : float 

The FWHM_500 (FWHM at 500nm at zenith). Fiducial values is 0.6". 

eff_wavelen : numpy.ndarray 

The effective wavelengths of the system bandpasses. 

Can be calculated using get_effwavelens. 

airmass : float or numpy.ndarray 

The airmass at which to calculate the FWHMeff and FWHMgeom values. 

Default 1.0. 

Can be a single value or a numpy array. 

 

Returns 

------- 

numpy.ndarray, numpy.ndarray 

FWHMeff, FWHMgeom: both are the same shape numpy.ndarray. 

If airmass is a single value, FWHMeff & FWHMgeom are 1-d arrays, 

with the same order as eff_wavelen (i.e. eff_wavelen[0] = u, then FWHMeff[0] = u). 

If airmass is a numpy array, FWHMeff and FWHMgeom are 2-d arrays, 

in the order of <filter><airmass> (i.e. eff_wavelen[0] = u, 1-d array over airmass range). 

""" 

airmass_correction = np.power(airmass, 0.6) 

wavelen_correction = np.power(self.raw_seeing_wavelength / self.filter_effwavelens, 0.3) 

if isinstance(airmass, np.ndarray): 

fwhm_system = self.fwhm_system_zenith * np.outer(np.ones(len(wavelen_correction)), 

airmass_correction) 

fwhm_atmo = fwhm_500 * np.outer(wavelen_correction, airmass_correction) 

else: 

fwhm_system = self.fwhm_system_zenith * airmass_correction 

fwhm_atmo = fwhm_500 * wavelen_correction * airmass_correction 

# Calculate combined FWHMeff. 

fwhm_eff = 1.16 * np.sqrt(fwhm_system ** 2 + 1.04 * fwhm_atmo ** 2) 

# Translate to FWHMgeom. 

fwhm_geom = self.fwhmEff_to_fwhmGeom(fwhm_eff) 

return fwhm_eff, fwhm_geom 

 

@staticmethod 

def fwhmEff_to_fwhmGeom(fwhm_eff): 

"""Calculate FWHM_geom from FWHM_eff. 

 

Parameters 

---------- 

fwhm_eff : float or np.ndarray 

 

Returns 

------- 

float or np.ndarray 

""" 

return (0.822 * fwhm_eff + 0.052) 

 

@staticmethod 

def fwhmGeom_to_fwhmEff(fwhm_geom): 

"""Calculate FWHM_eff from FWHM_geom. 

 

Parameters 

---------- 

fwhm_geom : float or np.ndarray 

 

Returns 

------- 

float or np.ndarray 

""" 

return (fwhm_geom - 0.052)/0.822