| 1 |
Pysynphot Commissioning Report |
| 2 |
========================== |
| 3 |
|
| 4 |
Goals and methodology |
| 5 |
------------------------------- |
| 6 |
|
| 7 |
The purpose of this commissioning process was to demonstrate to the |
| 8 |
Instruments branch, and by extension other potential pysynphot users, |
| 9 |
that the answers produced by pysynphot are at least as accurate as |
| 10 |
those produced by synphot. |
| 11 |
|
| 12 |
Because synphot has known deficiencies, and pysynphot was developed in |
| 13 |
part to address those deficiencies, we began by comparing synphot and |
| 14 |
pysynphot results, but examined cases that failed this comparison to |
| 15 |
determine whether the differences could be explained by known |
| 16 |
differences in the two packages. If so, the outcome was deemed |
| 17 |
acceptable; if not, further investigation was undertaken to determine |
| 18 |
which package was less correct, producing either a bug report and |
| 19 |
corresponding corrective action for pysynphot, or a bug report and no |
| 20 |
further action for synphot. |
| 21 |
|
| 22 |
|
| 23 |
Test software |
| 24 |
------------- |
| 25 |
|
| 26 |
Software was developed to execute the synphot and pysynphot commands |
| 27 |
and perform the comparisons. This software evolved over time as our |
| 28 |
comparisons were refined, and as failed tests were traced to bugs in |
| 29 |
the test software. The details of this effort are not included in this |
| 30 |
report, but are recorded in the change log for the test software, |
| 31 |
located in the subversion repository with the pysynphot code under |
| 32 |
test/commissioning. The test sets are also stored in this repository. |
| 33 |
|
| 34 |
Test sets |
| 35 |
------------- |
| 36 |
|
| 37 |
The largest test set was derived from the existing set of ETC |
| 38 |
regression tests for ACS, NICMOS, STIS, and WFC3, as part of the |
| 39 |
preparation for moving these ETCs to use pysynphot. (No similar set |
| 40 |
was derived for COS because its ETC was already using pysynphot and |
| 41 |
its regression tests had already passed.) Each ETC test case resulted |
| 42 |
in multiple (py)synphot calls; after removing obvious duplicates in |
| 43 |
function/obsmode/spectrum space, these became the ETC-based test set. |
| 44 |
|
| 45 |
However, this test set was overwhelmingly large, and a smaller set was |
| 46 |
eventually produced by selecting a representative subset for |
| 47 |
review. |
| 48 |
|
| 49 |
Additional smaller test sets were defined: |
| 50 |
- from first principles |
| 51 |
- from cases with reported problems identified by INS |
| 52 |
- for functionality that is not exercised by the ETC, including |
| 53 |
more general renormalization and calcphot.effstim functionality |
| 54 |
- from the existing synphot regression test suite (TBD) and |
| 55 |
cookbook examples in the synphot manual (TBD) |
| 56 |
|
| 57 |
|
| 58 |
Table of tests run as a function of testcase type: |
| 59 |
|
| 60 |
|calcphot|calcspec|countrate|specsourcerate|thermback| |
| 61 |
Array tests: | | | | | | |
| 62 |
--------------|--------|--------|---------|--------------|---------| |
| 63 |
testthru | X | | X | X | | |
| 64 |
--------------|--------|--------|---------|--------------|---------| |
| 65 |
testcrspec | X | X | X | X | X | |
| 66 |
--------------|--------|--------|---------|--------------|---------| |
| 67 |
testcrphotlam | | | X | X | | |
| 68 |
--------------|--------|--------|---------|--------------|---------| |
| 69 |
testcrcounts | | | X | X | | |
| 70 |
--------------|--------|--------|---------|--------------|---------| |
| 71 |
| | | | | | |
| 72 |
Scalar tests: | | | | | | |
| 73 |
--------------|--------|--------|---------|--------------|---------| |
| 74 |
testcountrate | | | X | X | | |
| 75 |
--------------|--------|--------|---------|--------------|---------| |
| 76 |
testefflam | X | | X | X | | |
| 77 |
--------------|--------|--------|---------|--------------|---------| |
| 78 |
testthermback | | | | | X | |
| 79 |
--------------|--------|--------|---------|--------------|---------| |
| 80 |
|
| 81 |
The final test set included 15701 tests. Of these, 1456 constituted |
| 82 |
the subset that received more careful scrutiny, as did all |
| 83 |
testcountrate and testthru tests. Additionally, any 'extreme" failures |
| 84 |
in a given run were reviewed. |
| 85 |
|
| 86 |
Table of test breakdown: |
| 87 |
|
| 88 |
Total tests 15701 |
| 89 |
Repr. subset 1456 |
| 90 |
testcountrate 1769 |
| 91 |
testthru 3218 |
| 92 |
|
| 93 |
|
| 94 |
Comparing quantities |
| 95 |
---------------------------- |
| 96 |
|
| 97 |
For each test case (synphot function/obsmode/spectrum), several |
| 98 |
quantities were compared, depending on the synphot functionality being |
| 99 |
tested. Initial or intermediate quantities were compared as well as |
| 100 |
final quantities; for example, a test case involving the countrate |
| 101 |
functionality generated tests that compared not only the final scalar |
| 102 |
count rate, but the throughput for the specified obsmode, the spectrum |
| 103 |
alone, and the spectrum-throughput combination, both in counts and in |
| 104 |
photlam (the flux unit used internally by both synphot and |
| 105 |
pysynphot). This procedure ensured that any problems could be quickly |
| 106 |
localized and more easily investigated. |
| 107 |
|
| 108 |
After the initial testing period, the review procedure was modified to |
| 109 |
investigate only cases for which the throughput or count rate |
| 110 |
comparisons failed, and review the other quantities only as part of an |
| 111 |
ongoing investigation. This was necessary in order to reduce the |
| 112 |
amount of work to better match available resources. (In progress.) |
| 113 |
|
| 114 |
While comparing scalar quantities, such as the count rate and |
| 115 |
effective wavelength, was relatively straightforward, writing tests to |
| 116 |
compare array results from synphot and pysynphot was difficult. The |
| 117 |
problem had two elements: |
| 118 |
|
| 119 |
- produce arrays to be compared on the same waveset |
| 120 |
- devise a comparison that was reasonably insensitive to numerical noise |
| 121 |
|
| 122 |
Producing arrays on the same waveset |
| 123 |
----------------------------------------------------- |
| 124 |
|
| 125 |
Because pysynphot was deliberately designed to correct some of synphot's |
| 126 |
deficiencies in waveset handling, it is clear that the spectral arrays |
| 127 |
produced by the two software packages will be different, unless |
| 128 |
special steps are taken to force them onto the same waveset. |
| 129 |
|
| 130 |
testcrspec: |
| 131 |
This test uses the synphot.countrate task, with a box(R/2,R) where R |
| 132 |
is the full wavelength range over which the source spectrum is defined, |
| 133 |
to simulate the obsmode to produce the source spectrum unconvolved with the |
| 134 |
instrumental obsmode. The task uses a wavecat file to select the |
| 135 |
wavelength table used based on the obsmode. For this test, a special |
| 136 |
purpose wavecat was produced for each run, so that the wavelength |
| 137 |
table in the pysynphot-computed spectrum would be used. |
| 138 |
|
| 139 |
testthru: |
| 140 |
This test samples the pysynphot-computed throughput array on the |
| 141 |
wavelength table used for the synphot-computed throughput. |
| 142 |
|
| 143 |
testcrcounts, testcrphotlam: |
| 144 |
For these tests, the wavelength table from the synphot-computed |
| 145 |
spectrum is used as the binned wavelength set when constructing |
| 146 |
the pysynphot Observation. |
| 147 |
|
| 148 |
|
| 149 |
Performing the array comparisons |
| 150 |
---------------------------------------------- |
| 151 |
|
| 152 |
Constructing a meaningful comparison of array numerical data that will |
| 153 |
be sensitive to significant differences, but insensitive to |
| 154 |
insignificant differences, is a difficult task. This was the most |
| 155 |
volatile element of the commissioning test software, as we |
| 156 |
experimented with various approaches; details can be seen in the |
| 157 |
revision log. This document describes the final approach used. |
| 158 |
|
| 159 |
- After confirming that the arrays are the same size, exclude the two |
| 160 |
endpoints on either end of the array from the comparison. This step |
| 161 |
was introduced when it was observed that the endpoints were often |
| 162 |
significantly discrepant due to a difference in waveset handling. |
| 163 |
|
| 164 |
- For each array, identify its significant elements by selecting |
| 165 |
elements that were greater than SIGTHRESH*the array maximum. The |
| 166 |
value of SIGTHRESH was tunable for test runs but is typically on |
| 167 |
the order of 0.01. If the two arrays have different sets of |
| 168 |
significant elements, a flag is set, and the test continues using |
| 169 |
the set of elements that were significant in the SYNPHOT array. |
| 170 |
|
| 171 |
- From the set of significant elements, further select the set of |
| 172 |
elements for which the synphot array is nonzero. Then, using this |
| 173 |
subset of elements, construct the discrepancy array (test-ref)/ref. |
| 174 |
|
| 175 |
- If any elements in the discrepancy array exceed the threshold |
| 176 |
THRESH (also tunable, typically set to 0.01), the test fails. |
| 177 |
|
| 178 |
- If more than SUPERTHRESH (typically 20%) of the elements in the |
| 179 |
discrepancy array exceed the threshold, the test is considered an |
| 180 |
"extreme failure". |
| 181 |
|
| 182 |
- The min, max, mean, and std of the discrepancy array were also |
| 183 |
reported, as were the number of 5-sigma outliers. |
| 184 |
|
| 185 |
|
| 186 |
Identified synphot errors |
| 187 |
-------------------------------- |
| 188 |
|
| 189 |
The following problems with synphot were either previously known, or |
| 190 |
were identified during this commissioning process. Tests exhibiting |
| 191 |
these problems were either deemed acceptable, or reworked to avoid the |
| 192 |
failure so that a meaningful comparison could be performed: |
| 193 |
|
| 194 |
- Poor performance around very narrow lines or very steep gradients |
| 195 |
(acceptable discrepancy) |
| 196 |
- Spectrum differences shortward of 900A due to intersection with Vega |
| 197 |
waveset (acceptable discrepancy --> modify test to avoid failing) |
| 198 |
- Spectrum differences because synphot drops any wavelength bins |
| 199 |
outside the range defined by the renormalization bandpass (as above:TBD) |
| 200 |
- Poor performance in renormalization around suddenly sparse |
| 201 |
wavelength tables (rework tests) |
| 202 |
- Bug in calcspec not present in countrate (reworked tests) |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
Identified and repaired pysynphot errors |
| 207 |
----------------------------------------------------- |
| 208 |
|
| 209 |
The following problems with pysynphot were identified and fixed during |
| 210 |
this commissioning process: |
| 211 |
|
| 212 |
- Incorrect calculation of interpolated spectral elements (#134) |
| 213 |
- Incorrect tapering behavior (#149) |
| 214 |
- FITS files written to single precision by default (#146) |
| 215 |
- Incorrect parsing of obsmode keywords that look like numbers (#125) |
| 216 |
- Incorrect parsing of band() arguments (#126) |
| 217 |
- Implement gal3 extinction law (#127/123) |
| 218 |
- Improve behavior in case of partial overlap (#157) |
| 219 |
- Handle partial overlap cases in the etc.py interface (#158) |
| 220 |
- Performance issues when simulating an Observation (TBD #130) |