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

# 

# LSST Data Management System 

# 

# Copyright 2018 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 unittest 

import numpy as np 

 

import lsst.utils.tests 

from lsst.afw.geom import Point2D 

from lsst.obs.hsc import makeTransmissionCurves 

 

 

class MakeTransmissionCurvesTest(lsst.utils.tests.TestCase): 

 

def testOptics(self): 

wavelengths = np.linspace(4000, 10000, 100) 

point = Point2D(1000, -500) 

for curve in makeTransmissionCurves.getOpticsTransmission().values(): 

if curve is None: 

continue 

throughputs = curve.sampleAt(point, wavelengths) 

self.assertTrue((throughputs > 0.70).all()) 

 

def testAtmosphere(self): 

wavelengths = np.linspace(4000, 12000, 100) 

point = Point2D(1000, -500) 

for curve in makeTransmissionCurves.getAtmosphereTransmission().values(): 

46 ↛ 47line 46 didn't jump to line 47, because the condition on line 46 was never true if curve is None: 

continue 

throughputs = curve.sampleAt(point, wavelengths) 

ohAbsorption = np.logical_and(wavelengths > 11315, wavelengths < 11397) 

midR = np.logical_and(wavelengths > 6000, wavelengths < 6300) 

self.assertTrue((throughputs[ohAbsorption] < throughputs[midR]).all()) 

 

def testSensors(self): 

wavelengths = np.linspace(4000, 12000, 100) 

point = Point2D(200, 10) 

for sensors in makeTransmissionCurves.getSensorTransmission().values(): 

for i in range(112): 

curve = sensors[i] 

throughputs = curve.sampleAt(point, wavelengths) 

siliconTransparent = wavelengths > 11000 

self.assertTrue((throughputs[siliconTransparent] < 0.01).all()) 

midR = np.logical_and(wavelengths > 6000, wavelengths < 6300) 

self.assertTrue((throughputs[midR] > 0.9).all()) 

 

def testFilters(self): 

wavelengths = np.linspace(3000, 12000, 1000) 

point = Point2D(1000, -500) 

 

def check(curve, central, w1, w2): 

# check that throughput within w1 of central is strictly greater 

# than throughput outside w2 of central 

throughput = curve.sampleAt(point, wavelengths) 

mid = np.logical_and(wavelengths > central - w1, wavelengths < central + w1) 

outer = np.logical_or(wavelengths < central - w2, wavelengths > central + w2) 

self.assertGreater(throughput[mid].min(), throughput[outer].max()) 

 

for curves in makeTransmissionCurves.getFilterTransmission().values(): 

check(curves["NB0387"], 3870, 50, 100) 

check(curves["NB0816"], 8160, 50, 100) 

check(curves["NB0921"], 9210, 50, 100) 

check(curves["HSC-G"], 4730, 500, 1500) 

check(curves["HSC-R"], 6230, 500, 1500) 

check(curves["HSC-R2"], 6230, 500, 1500) 

check(curves["HSC-I"], 7750, 500, 1500) 

check(curves["HSC-I2"], 7750, 500, 1500) 

check(curves["HSC-Z"], 8923, 500, 1500) 

check(curves["HSC-Y"], 10030, 500, 1500) 

 

def testRadialDependence(self): 

wavelengths = np.linspace(5000, 9000, 500) 

radii = np.linspace(0, 20000, 50) 

 

def computeMeanWavelengths(curve): 

w = [] 

for radius in radii: 

throughput = curve.sampleAt(Point2D(radius, 0), wavelengths) 

w.append(np.dot(throughput, wavelengths)/throughput.sum()) 

return np.array(w) 

 

for curves in makeTransmissionCurves.getFilterTransmission().values(): 

r = computeMeanWavelengths(curves['HSC-R']) 

r2 = computeMeanWavelengths(curves['HSC-R2']) 

i = computeMeanWavelengths(curves['HSC-I']) 

i2 = computeMeanWavelengths(curves['HSC-I2']) 

# i2 and r2 should have lower variance as a function of radius 

self.assertLess(r2.std(), r.std()) 

self.assertLess(i2.std(), i.std()) 

# the mean wavelengths of the two r and two i filters should 

# neverthess be close (within 100 angstroms) 

self.assertLess(np.abs(r2.mean() - r.mean()), 100) 

self.assertLess(np.abs(i2.mean() - i.mean()), 100) 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

118 ↛ 119line 118 didn't jump to line 119, because the condition on line 118 was never trueif __name__ == "__main__": 

lsst.utils.tests.init() 

unittest.main()