Skip to main content

cabaret

cabaret is a Python package to simulate astronomical images using the Gaia catalog of stars.

Documentation can be found at cabaret.readthedocs.io.

Installation

You can install cabaret in a Python (>=3.11) environment with

pip install cabaret

or from a local clone

git clone https://github.com/ppp-one/cabaret
pip install -e cabaret

You can test the package has been properly installed with

python -c "import cabaret"

Quick Start

Basic image

To generate an image from RA/DEC coordinates, run:

import cabaret

image = cabaret.Observatory().generate_image(
    ra=12.33230,  # right ascension in degrees
    dec=30.4343,  # declination in degrees
    exp_time=10,  # exposure time in seconds
)

To display the image:

from cabaret.plot import plot_image

plot_image(image, contrast=0.25)

Custom Observatory Configuration

Create a fully customized observatory by defining each component:

from datetime import UTC, datetime
import cabaret

# Define observatory components
site = cabaret.Site(
    sky_background=150,  # e-/m^2/arcsec^2/s
    seeing=1.5,  # arcseconds
    elevation=2500,  # meters
)

telescope = cabaret.Telescope(
    focal_length=8,  # meters
    diameter=1.0,  # meters
)

camera = cabaret.Camera(
    name="Example Camera",
    width=2048,  # pixels
    height=2048,  # pixels
    pitch=10,  # microns
    gain=1,  # electrons per ADU
    read_noise=6.2,  # electrons
)

# Create the observatory
observatory = cabaret.Observatory(
    name="My Observatory",
    site=site,
    telescope=telescope,
    camera=camera,
)

# Generate a FITS image with metadata
hdu = observatory.generate_fits_image(
    ra=323.362583,
    dec=-0.82325,
    exp_time=0.5,
    dateobs=datetime.now(UTC),
    filter_band=cabaret.Filters.G,
    seed=42,
)

# Save as FITS file
hdu.writeto("simulated_image.fits", overwrite=True)

Custom Source Lists

You can manipulate the source catalog before generating images:

from astropy.coordinates import SkyCoord
import numpy as np

# Query Gaia catalog
center = SkyCoord(ra=323.362583, dec=-0.82325, unit="deg")
table = cabaret.GaiaQuery.query(
    center=center,
    radius=camera.get_fov_radius() * 1.5,
    filter_bands=cabaret.Filters.G,
)

# Filter out bright sources
fluxes = table[cabaret.Filters.G.value].value.data
mask = fluxes < 1e4
filtered_table = table[mask]

# Create custom source list
sources = cabaret.Sources.from_arrays(
    ra=filtered_table["ra"].value.data,
    dec=filtered_table["dec"].value.data,
    fluxes=filtered_table[cabaret.Filters.G.value].value.data,
)

# Generate image with custom sources
image = observatory.generate_image(
    ra=center.ra.deg,
    dec=center.dec.deg,
    exp_time=0.5,
    sources=sources,
)

Offline SQLite Catalogs

You can query a local SQLite catalog instead of a remote TAP endpoint.

The local table is expected to contain at least ra and dec, and optionally pmra, pmdec, plus Gaia/2MASS magnitude columns like phot_g_mean_mag, phot_bp_mean_mag, phot_rp_mean_mag, j_m, h_m, ks_m.

import cabaret
from astropy.coordinates import SkyCoord

sqlite_source = cabaret.GaiaSQLiteSource(
    database="/data/catalogs/gaia_subset.sqlite",
)

table = cabaret.GaiaQuery.query(
    center=SkyCoord(ra=323.362583, dec=-0.82325, unit="deg"),
    radius=0.1,
    filter_bands=[cabaret.Filters.G],
    tap_source=sqlite_source,
    limit=5000,
)

Explore the full documentation, API reference, and advanced usage examples at cabaret.readthedocs.io.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cabaret-0.5.5.tar.gz (658.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cabaret-0.5.5-py3-none-any.whl (41.6 kB view details)

Uploaded Python 3

File details

Details for the file cabaret-0.5.5.tar.gz.

File metadata

  • Download URL: cabaret-0.5.5.tar.gz
  • Upload date:
  • Size: 658.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cabaret-0.5.5.tar.gz
Algorithm Hash digest
SHA256 84d880cea92c8f6c6d8d0b504db31030d7b8d3e36c2fadef276c8ac1d18e523e
MD5 1affe901fae550a87ecc830f3178159a
BLAKE2b-256 148aef8f3ae8dfc0a98db1c45f9d530402af19d67959366f584ae8c6caf94076

See more details on using hashes here.

Provenance

The following attestation bundles were made for cabaret-0.5.5.tar.gz:

Publisher: publish.yml on ppp-one/cabaret

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cabaret-0.5.5-py3-none-any.whl.

File metadata

  • Download URL: cabaret-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 41.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cabaret-0.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a9fe43165bc6dba54cb503dff3df17ff0cb022de1c2db16f4cb730470cba08d4
MD5 b55845c998590ccc64390e1f0d25ed20
BLAKE2b-256 7d7568a5bbcaef70a12e0e4c4740c7f183ca5420041a91538bda51c555cb04cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for cabaret-0.5.5-py3-none-any.whl:

Publisher: publish.yml on ppp-one/cabaret

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.5.5 This release

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.4.7

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.6

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page