Crates.io | mavdac |
lib.rs | mavdac |
version | 0.1.1 |
source | src |
created_at | 2024-10-04 07:08:07.416116 |
updated_at | 2024-10-04 07:09:53.762488 |
description | MAVIS Differential Astrometric Calibrator |
homepage | |
repository | https://github.com/jcranney/mavdac |
max_upload_size | |
id | 1396237 |
size | 33,919 |
MAVIS Differential Astrometric Calibration. This image processing pipeline is designed to ingest images acquired during astrometric calibration of (e.g.) MAVIS, and output the estimated distortion field derived from these images. The bulk of the pipeline is written in Rust, but the most useful functions and the CLI tool are wrapped in Python.
Eventually this will be pip installable, but for now, the easiest way to get going
is through maturin
(which is pip install
able). Clone this repo then build it:
git clone https://github.com/jcranney/mavdac
cd mavdac
maturin develop --release
If successful, you should now be able to run mavdac
as per Usage
The simplest usage of this software is by calling
mavdac "./some/pattern*.fits"
which tries to parse all images on disk matching the glob pattern argument, and prints the distortion basis-function coefficients to stdout. These are not very useful on their own, so a user can also provide a set of coordinates to evaluate the distortion functions:
mavdac "./some/pattern*.fits" ./coordinates.txt
In this case, mavdac
prints the sampled distortion function values to stdout, which the user can (e.g.) cat to some output file:
mavdac "./some/pattern*.fits" ./coordinates.txt > output.txt
There are a few ways to use mavdac
, e.g.,:
Here, I assume you are a standard user, hoping to perform astrometric calibration of an optical system using the MAVIS Differential Astrometric Calibration technique. In that case, the workflow is as follows:
./some/dir/img_0*.fits
,./some/dir/coords
:0,0,
0,8,
0,16,
0,32,
...
4096,4088,
4096,4096,
grid.yaml
file, specifying the geometry of the pinhole mask/calibration source.mavdac
pipeline, specifying image filename pattern and coordinates filename path, piping stdout
to some ./results
file.Below we provide the requirements for each of the above tasks.
{u8, f32, f64, i32, u32}
type. Note that internally, all images are converted to f64
upon loading.XSHIFT
: shift in pixels along x-axis of the calibration mask for that exposure (from some nominal "home" position),YSHIFT
: shift in pixels along y-axis of the calibration mask for that exposure (from some nominal "home" position),mavdac "./some/dir/imgs_*.fits"
then the software will print some status updates to stderr, and eventually the coefficients of the fitted basis functions to stdout. This is mostly unusable, unless you write your own software to parse these coefficients. The intended usage is to provide a set of coordinates in pixel space, in which case you will get the distortions at those coordinates printed to stdout. E.g., with a coordinates file, ./some/coords
:
0,0,
0,2000,
2000,0,
2000,2000,
you can run:
mavdac "./some/dir/imgs_*.fits" ./some/coords
which will output:
0,0,0.0966850540113886,0.3300609989212976,
0,2000,0.07252484678180265,0.007773570343281411,
2000,0,0.004342546567941594,0.26372826456406706,
2000,2000,-0.0018909241959087534,-0.0036487693998900166,
to stdout. The expected usage is something like:
mavdac "./imgs_*.fits" ./coords > ./out
which cats only the stdout to a file, ./out
. I've spent a bit of time thinking about the simplest user interface with this software, and that is the best I can come up with, but if you have a better idea (perhaps inspired by experience using similar pipelines), please contact me or raise an issue in this repo.
grid.yaml
fileThe coordinates of the pinhole grid are specified by a grid.yaml
file, which currently only supports the "Hex" geometry. Here is an example:
!Hex
pitch: 133.33333333333334
rotation: 0.0
offset:
x: 0.0
y: 0.0
All of these parameters are required, they are described below:
pitch
: distance between adjacent pinholes (in pixel units),rotation
: orientation of hexagonal pinhole geometry (in radians),offset
: shift of overall grid in pixel units, in x
and y
dimensions. Note that for x=0
and y=0
, there is a point in the grid at the exact middle of the image.mavdac
Finally, once you have:
./some/dir
,grid.yaml
file,./coords
text file,you can run mavdac from the command line by:
mavdac "./some/dir/*.fits" ./coords > ./out
For a reminder, you can check mavdac --help
:
mavis_acm/lab/inputs
$ python -m mavdac --help
usage: process mavis differential astrometric calibrations [-h] pattern [coordinates]
positional arguments:
pattern glob pattern for matching fits files to use for calibration
coordinates file containing coordinates to map through distortions
options:
-h, --help show this help message and exit
All versions of mavdac < 1.0.0 are subject to breaking changes between any two releases. The tests and validations are being developed side-by-side with the software, so will become populated as the pipeline matures. It is envisioned that there will be 3 levels of validation for the software that should be re-satisfied for any release:
Unit tests for the rust package will be found within each rust module, e.g., within ./rust/src/lib.rs
, under mod tests {...}
.
System tests for the rust + python package (e.g., the CLI), can be found in ./src/tests
. These will include tests that generate images with known distortions that are piped through mavdac, and the measured distortion field can be checked for quality.
The final validation of this software package is through it's use on data acquired in a real optical system with introduced distortions. To demonstrate the challenges associated with this kind of validation - try to construct an experiment which can verify that the software works as intended. The following are the most direct: