Inspired by the error I just found in multi-tan, let's add a test here
that processes the wcs512 sample file with the multi-wcs framework and
checks the barycenters. It works!
We add a test for tile-study of a FITS file here, even though there's a tile_study.py,
since this has the reference data for what the proper tiling looks like.
If we're tiling into FITS format, we have to emulate the funkiness in
the multi-WCS and multi-TAN processors: the data buffers for the
individual tiles need to be flipped vertically. So, copy-paste the code
to do that.
It's helpful to split the study tiling operation into two steps,
preparation and execution, because (1) you can only correctly apply WCS
information after preparation and (2) it's nice to check that the WCS is
all set up correctly before spending the time on the execution step. Here
we add some new APIs to Builder and use them in tile-study
We also improve tile-study to ensure that its image has negative
(JPEG-like) parity, which is required for WWT studies.
In an ideal world, we'd just automatically detect AVM and Do The Right
Thing, but not a lot of people are necessarily going to have pyavm
installed and we don't necessarily want to require it.
Part of this is making the decision to just unilaterally invert the
parity of the WCS that pyavm hands us based on the AVM data. From the
files that I've seen in the wild, this looks to be the correct thing to
do.
The reproject package is pretty memory-hungry, and for large images I
find that it can get killed for memory overuse pretty easily. Here we
mitigate that by reprojecting large images in horizontal bands, AKA
"chunks". This can reduce the memory consumption significantly, and for
small images the behavior is equivalent to what we had before.
Some FITS files have additional axes of size 1. We can work with them just fine, but we need
to strip out the non-celestial axes to make the rest of our machinery happy.
Haven't touched this code in a while, but WWT can now display tiled FITS
so we're about to use it a lot more! The new code has to be careful
about the parities of FITS vs. tilings but I believe that we're doing
that all correctly now. We now also emit WTML using the standard
framework and otherwise modernize this code.
No parallel implementation yet, just trying to tidy up the serial
approach first.
To render tiled FITS, things are a bit awkward because the individual
FITS files are rendered by WWT assuming a bottoms-up (positive parity)
data layout, but the overall tiling coordinate system is still top-down.
If you work through the geometry, the cascade process can be nearly
identical for both this case and the case where the tiles are also
top-down: all you need to change is to reorder the vertical stacking in
the cascade process. So, do that. In order for this to work, we need to
add some infrastructure to "know" the expected vertical data layout of
the pyramid tiles.