Debian Codegraph @

commissioning/wfc3_rn_synphot_bug.txt

raw
1 Discovery test set:
2 wfc3_rn_ir1_cases.py (r592)
3
4 Investigation test case:
5 wfc3_rn_ir1_cases/testcrspec/wfc3C26
6
7 Symptom:
8 All cases that use a spectrum are failing because there's a change
9 in shape at lambda=10000 angstroms. Synphot steps down at 10000 but
10 pysynphot doesn't.
11
12 There are also other differences in slope further redward.
13
14 What's magic about 10000A:
15 These spectra, all taken from the Bruzual atlas, change to a very
16 sparse wavelength spacing beginning with 10000A.
17
18 Determination of which package is correct:
19 Compare the shape of the original spectrum to the shape of the
20 renormalized spectrum. Renormalization should be a simple linear
21 transformation: the shape should not change. It was demonstrated that
22 this condition is not met for the synphot renormalization, but is
23 met for the pysynphot renormalization.
24
25 Details:
26 Some complications were necessary to perform this comparison because
27 of the sampling issue. The test case results were on the same
28 sampling as each other, which did not match the wavelength sampling
29 of the original spectrum.
30
31 Pysynphot was used to read in the original spectrum and
32 renormalize it, retaining its native sampling. A ratio of the two
33 was taken, and the finite elements of this ratio were examined and
34 determined to have a constant value.
35
36 This constant value was then used to, effectively,
37 "un-renormalize" the synphot-normalized spectrum in wfc3C26.fits,
38 so that it could be plotted on the same scale as the original
39 spectrum.
40
41 The departure from the original shape is clearly seen on the
42 resulting plot.
43
44 Conclusions:
45 - the SYNPHOT code has a bug, probably related to
46 suddenly-sparse wavelength tables, that causes it to incorrectly
47 modify the shape of the spectrum being renormalized in the vicinity
48 of such points.
49
50 - the bug has been demonstrated to occur in the renormalization
51 code. No effort has been devoted to determine
52 whether this bug also manifests elsewhere in the SYNPHOT codebase.
53
54 - spectra with these characteristics should not be used in the
55 syn-pysyn commissioning tests. This includes the entire Bruzual
56 atlas, which is now in any case obsolescent and the Pickles atlas
57 is recommended for use instead.
58
59 Other potentially affected test cases:
60 The following syn_pysyn test sets make use of a spectrum from the
61 Bruzual atlas:
62 nicmos_etc_cases.py : 25
63 wfc3_ir_imaging_78_cases.py : 144
64 wfc3_ir_spec_61_cases.py : 14
65 wfc3_rn_ir1_cases.py : 24
66 wfc3_uvis1_imaging_61_cases.py : 144
67 wfc3_uvis1_spec_62_cases.py : 14
68 wfc3_uvis2_imaging_18_cases.py : 144
69 wfc3_uvis2_spec_18_cases.py : 14
70
71 NICMOS and WFC3 team members may wish to revisit these cases in order
72 to avoid this SYNPHOT bug.
73
74
75
76
77
78 Script details to reproduce the plots:
79
80 #let's look at C26:wfc3_rn_ir1_cases/testcrspec/wfc3C26::
81 #sp=rn(spec(/grp/hst/cdbs/grid/bz77/bz_48.fits),band(wfc3,ir,f105w),25.0,stmag)
82
83 import pysynphot as S
84 import numpy as N
85 from pylab import *
86
87 sp=S.FileSpectrum('/grp/hst/cdbs/grid/bz77/bz_48.fits')
88 bp=S.ObsBandpass('wfc3,ir,f105w')
89 sprn=sp.renorm(25.0,'stmag',bp)
90 syn=S.FileSpectrum('wfc3C26.fits')
91 sprn.convert('photlam')
92 sp.convert('photlam')
93 plot(syn.wave,syn.flux,'.-')
94 plot(sprn.wave,sprn.flux,'.-')
95 legend(['syn','pysyn'])
96 grid()
97 title('wfc3C26')
98
99 figure(2)
100 rat=sp.flux/sprn.flux
101 realrat=N.isfinite(rat)
102 print rat[realrat].min()
103 #5.7189608156e+15
104 >>> print N.where(rat[realrat]!=rat[realrat].min())
105 #(array([], dtype=int64),)
106 plot(syn.wave,syn.flux*rat[realrat].min(),'.-')
107 plot(sp.wave,sp.flux,'.-')
108 legend(['synphot renormalized then rescaled',sp])
109
110
111
112 Details of investigation case:
113 gaudete> cat wfc3_rn_ir1_cases/testcrspec/wfc3C26.log
114 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: Name=wfc3_rn_ir1_cases/testcrspec/wfc3C26
115 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: Status=F
116 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: Time=Tue Sep 2 11:51:15 2008
117 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tda_SkyLines=False
118 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tda_Obsmode=None
119 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tda_Spectrum=rn(spec(/grp/hst/cdbs/grid/bz77/bz_48.fits),band(wfc3,ir,f105w),25.0,stmag)
120 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tda_Thresh=0.01
121 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tda_SigThresh=0.01
122 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tda_Superthresh=0.2
123 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tra_Discrepmean=-0.000242284646813
124 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tra_Outliers=2
125 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tra_Discrepmax=0.137682874702
126 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tra_Discrepstd=0.0215893046358
127 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tra_Discrepfrac=0.310638297872
128 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tra_Discrepmin=-0.136706452009
129 wfc3_rn_ir1_cases/testcrspec/wfc3C26:: tra_Extreme=True
130 END