Closed mcara closed 5 years ago
Now I believe I understand the intention of the code better and most likely the single issue with the code is that it uses wrong array order indexing as confirmed by the "quick fix" presented above. An alternative algorithm entirely in Python/numpy
was implemented in https://github.com/spacetelescope/drizzlepac/pull/227 thus making this package unnecessary: drizzlepac
was the only package that was using stsci.imagemanip
.
I started working on finding an appropriate replacement function/algorithm for this package as discussed in https://github.com/spacetelescope/stsci.imagemanip/issues/9 IMO this package is so incorrect, that
drizzlepac
would have been better off settingLFLTFILE
to all 1 instead of usingstsci.imagemanip
. However, I am not an expert in STIS flat field files and so I am invoking higher powers here: @philhodge @ibusko - the experts in STIS flat fields, based on references found online.From the STIS book:
stsci.imagemanip
is used by thedrizzlepac
to perform this "expansion" ofLFLTFILE
.I believe the major issue with
stsci.imagemanip
code is that it seem that the code uses indices incorrectly fornumpy
arrays in the sense that it incorrectly "flattens" 2D array. The code may work correctly if arrays were using Fortran order (maybe, but my experiments failed to fix it by playing with array ordering). I am also not too sure the interpolation is truly "bi"-linear in the sense that it may not work well in the presence of cross-terms.The test module for this package is useless and it does not help at all in understanding how STIS
LFLTFILE
files should be expanded (i.e., what is the intention) nor does it actually test that package works as intended.Small synthetic test
Results are:
Possibly the only instance when this code works is when input arrays are square and maybe this is good enough for STIS flats, ... don't know.
A Quick Fix:
The issue of incorrect indices could be fixed in the caller like this:
I can't believe this was the intended way of calling this function.