| 1 |
Writing tests to compare array results from synphot and pysynphot was |
| 2 |
difficult. The problem had two elements: |
| 3 |
|
| 4 |
- produce arrays to be compared on the same waveset |
| 5 |
- devise a comparison that was reasonably insensitive to numerical noise |
| 6 |
|
| 7 |
Producing arrays on the same waveset |
| 8 |
------------------------------------- |
| 9 |
|
| 10 |
Because pysynphot was deliberately designed to correct some of synphot's |
| 11 |
deficiencies in waveset handling, it is clear that the spectral arrays |
| 12 |
produced by the two software packages will be different, unless |
| 13 |
special steps are taken to force them onto the same waveset. |
| 14 |
|
| 15 |
testcrspec: |
| 16 |
This test uses the synphot.countrate task, with a box(15000,30000) |
| 17 |
to simulate the obsmode to produce the source spectrum unconvolved with the |
| 18 |
instrumental obsmode. The task uses a wavecat file to select the |
| 19 |
wavelength table used based on the obsmode. For this test, a special |
| 20 |
purpose wavecat was produced for each run, so that the wavelength |
| 21 |
table in the pysynphot-computed spectrum would be used. |
| 22 |
|
| 23 |
testthru: |
| 24 |
This test samples the pysynphot-computed throughput array on the |
| 25 |
wavelength table used for the synphot-computed throughput. |
| 26 |
|
| 27 |
testcrphotlam: |
| 28 |
For this test, the synphot.countrate task selects its wavelength |
| 29 |
table from the wavecat based on the obsmode, and the pysynphot |
| 30 |
Observation selects its binned wavelength set from the same wavecat |
| 31 |
based on the obsmode. Thus the synphot spectrum can be compared |
| 32 |
directly to the binned tables associated with the pysynphot |
| 33 |
Observation. |
| 34 |
|
| 35 |
testcrcounts: |
| 36 |
For this test, the wavelength table from the synphot-computed |
| 37 |
spectrum is used as the binned wavelength set when constructing |
| 38 |
the pysynphot Observation. |
| 39 |
|
| 40 |
|
| 41 |
Performing the array comparisons |
| 42 |
-------------------------------- |
| 43 |
|
| 44 |
Constructing a meaningful comparison of array numerical data that will |
| 45 |
be sensitive to significant differences, but insensitive to |
| 46 |
insignificant differences, is a difficult task. This was the most |
| 47 |
volatile element of the commissioning test software, as we |
| 48 |
experimented with various approaches; details can be seen in the |
| 49 |
revision log. This document describes the final approach used. |
| 50 |
|
| 51 |
- After confirming that the arrays are the same size, exclude the two |
| 52 |
endpoints on either end of the array from the comparison. This step |
| 53 |
was introduced when it was observed that the endpoints were often |
| 54 |
significantly discrepant due to a difference in waveset handling. |
| 55 |
|
| 56 |
- For each array, identify its significant elements by selecting |
| 57 |
elements that were greater than SIGTHRESH*the array maximum. The |
| 58 |
value of SIGTHRESH was tunable for test runs but is typically on |
| 59 |
the order of 0.01. If the two arrays have different sets of |
| 60 |
significant elements, the test fails. |
| 61 |
|
| 62 |
- From the set of significant elements, further select the set of |
| 63 |
elements for which the synphot array is nonzero. Then, using this |
| 64 |
subset of elements, construct the discrepancy array (test-ref)/ref. |
| 65 |
|
| 66 |
- If any elements in the discrepancy array exceed the threshold |
| 67 |
THRESH (also tunable, typically set to 0.01), the test fails. |
| 68 |
|
| 69 |
- If more than SUPERTHRESH (typically 20%) of the elements in the |
| 70 |
discrepancy array exceed the threshold, the test is considered an |
| 71 |
"extreme failure". |
| 72 |
|
| 73 |
- The min, max, mean, and std of the discrepancy array were also |
| 74 |
reported, as were the number of 5-sigma outliers. |