Raw FITS parser
Project description
fitsm
fitsm is a command-line interface and Python package for indexing FITS files into an SQL database. It extracts metadata from FITS headers and organizes it for easy querying.
Installation
fitsm is available on PyPI. It is recommended to install it in a fresh Python virtual environment. You can use uv for fast and reproducible environment management, or use venv/pip as you prefer.
Using PyPI (recommended)
uv venv
source .venv/bin/activate
uv pip install fitsm
From source
git clone https://github.com/lgrcia/fitsm.git
cd fitsm
uv venv
source .venv/bin/activate
uv sync
uv pip install -e .
This will install the fitsm CLI and all dependencies.
Instrument YAML Configuration
The instrument configuration YAML file defines how FITS header keywords are mapped to database fields and how instrument names are recognized. This file is required for the index command and is specified using the -i or --instruments option in the CLI. The CLI uses this configuration to correctly interpret FITS headers for different instruments and to standardize the metadata stored in the database.
Example Structure
default:
instrument_names:
default: ["default",]
definition:
keyword_instrument: "TELESCOP"
keyword_object: "OBJECT"
keyword_image_type: "IMAGETYP"
keyword_light_images: "light"
keyword_dark_images: "dark"
keyword_flat_images: "flat"
keyword_bias_images: "bias"
keyword_observation_date: "DATE-OBS"
keyword_exposure_time: "EXPTIME"
keyword_filter: "FILTER"
keyword_ra: "RA"
keyword_dec: "DEC"
keyword_jd: "JD"
unit_ra : "deg"
unit_dec : "deg"
scale_jd : "utc"
speculoos:
instrument_names:
# these are all the possible names under the 'keyword_image_type' that
# correspond to the Callisto instrument
Callisto: ["speculoos-Callisto", "callisto"]
Europa: ["speculoos-Europa",]
Io: ["speculoos-Io",]
Ganymede: ["speculoos-Ganymede",]
Artemis: ["speculoos-Artemis", "artemis", "sno"]
definition:
keyword_light_images: "Light Frame"
Other:
instrument_names:
Trius-SX694: ["Trius-SX694",]
definition:
keyword_instrument: "INSTRUME"
keyword_light_images: "Light_Frame"
Sections
- instrument_names: Maps instrument aliases to canonical names.
- definition: Maps FITS header keywords to logical fields used by the parser.
You can add more sections for different instruments as needed. The default section is used as a fallback.
CLI Usage
Index FITS Files
To index FITS files into a database, use:
fitsm index <folder> -i instruments.yaml [-o output.sqlite]
Arguments:
<folder>: Path to the folder containing FITS files.-i,--instruments: (Optional) Path to theinstruments.yamlfile defining instrument configurations.-o,--output: (Optional) Path to the output database file. Defaults todb.sqlitein the<folder>.
Show Observations
Show observations from the database (supports regex, case-insensitive):
fitsm observations db.sqlite [-i INSTRUMENT] [-d DATE] [-f FILTER] [-o OBJECT]
Show Files
Show files from the database (supports regex, case-insensitive):
fitsm files db.sqlite [-i INSTRUMENT] [-d DATE] [-f FILTER] [-o OBJECT]
Filtering Options (for show commands):
-i,--instrument: (Optional, regex) Filter by instrument name.-d,--date: (Optional, regex) Filter by date (format: YYYY-MM-DD).-f,--filter: (Optional, regex) Filter by filter name.-o,--object: (Optional, regex) Filter by object name.
Custom SQL Query
Run a custom SQL query on the database:
fitsm query db.sqlite "SELECT * FROM observations WHERE instrument REGEXP 'europa|io'"
Example:
fitsm index /path/to/fits/files -i /path/to/instruments.yaml -o mydata.sqlite
fitsm observations mydata.sqlite -i Europa -d 2024-01-01
fitsm files mydata.sqlite -f R
fitsm observations mydata.sqlite -i 'europa|io' # regex, case-insensitive
fitsm query mydata.sqlite "SELECT * FROM files WHERE object REGEXP 'mars|jupiter'"
All regex filters are case-insensitive.
Development
Requirements
- Python 3.11+
- Dependencies listed in
pyproject.toml.
License
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fitsm-0.0.4.tar.gz.
File metadata
- Download URL: fitsm-0.0.4.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af975f7f2751978887f77d3cd2b0867b5d4a3af1251528b73848d66e0b19b5af
|
|
| MD5 |
d995e2f57d649d31f1c7ad7f15e4d720
|
|
| BLAKE2b-256 |
69d69965ebffb7b34942c495d3e5fb9062649796630eeded6fc5930edce5544a
|
File details
Details for the file fitsm-0.0.4-py3-none-any.whl.
File metadata
- Download URL: fitsm-0.0.4-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06b4e8f0a862f8244a61dac10903a12d7e0529ed7b5a290e6064e0ce7ca6db65
|
|
| MD5 |
4a2b6092a8d5d80814144489c050287e
|
|
| BLAKE2b-256 |
d3cdc3a81bd9aec4e42213b5a731a30cb30e1fdc8c9eb43bbd613d01ba73973b
|