Skip to main content

Synthesize galaxy spectra from photometry

Project description

galsynthspec

Galaxy Synthetic Spectrum fitting

PyPI version License: MIT CI Coverage Status

Galsynthspec is a Python package for fitting synthetic galaxy spectra to observed data. It is designed to work with the sfdmap package for spectral fitting and provides tools for analyzing and visualizing the results.

It combines three key features:

  1. Coordinate-based photometry retrieval using the astroquery package, allowing users to fetch photometric data from various surveys.
  2. Galaxy fitting using prospector.
  3. Analysis and visualization tools for the fitted spectra.

If you are working with transient data, galsynthspec can also use TNS to resolve transient names to their respective coordinates, and identify a likely host using PS1.

galsynthspec is a wrapper, which combines the functionality of several other packages in one easy-to-install place. If you use the package, please credit those packages as well, in particular:

Installation

Easy way (Docker):

Use Docker to run the package without needing to install it locally. This is the recommended way to use galsynthspec, as it ensures that all dependencies are correctly set up.

docker pull robertdstein/galsynthspec:latest

Hard way (local installation):

Python Package

You can try the hard way:

git clone git@github.com:robertdstein/galsynthspec.git
cd galsynthspec
pip install -e ".[dev]"
pre-commit install

SFDMap and FSPS

galsynthspec also uses the sfdmap package for extinction corrections. While the package will be installed when using pip, it requires additional data files to function properly. Find a directory to store the SFDMAP data files, and then run:

wget https://github.com/kbarbary/sfddata/archive/master.tar.gz
tar xzf master.tar.gz

You also need to install https://github.com/cconroy20/fsps

Usage

Using Docker

If you want to use galsynthspec without installing it locally, you can run it in a Docker container. After you've pulled the Docker image, you need the prefix:

docker run -v /my/local/dir:/mydata robertdstein/galsynthspec

This command mounts a local directory (/my/local/dir) to a directory inside the Docker container (/mydata), allowing you to access your data files from within the container.

Using a local installation

If you prefer to install galsynthspec locally, you can do so by cloning the repository and installing the package in editable mode. You should copy the .env.example file to .env and set the SFD_DATA_DIR variable to the directory where you want to store the data files. You should also set the FSPS_DIR variable to the directory where you have installed fsps. Finally, be sure to set the GALSYNTHSPEC_DATA_DIR variable to the directory where you want to store the galsynthspec data files.

Running galsynthspec

You can use the package to fetch photometric data for a galaxy by its transient name or coordinates, fit a synthetic spectrum to the data, and analyze the results.

For example, to fetch photometric data for a galaxy by its transient name, you can use the following command:

docker run -v /my/local/dir:/mydata robertdstein/galsynthspec by-name AT2019fdr

for Docker, or

galsynthspec by-name AT2019fdr

for local installation.

This will run the by-name command with the transient name AT2019fdr, which will resolve the name to its coordinates and fetch the photometric data. It will then use the prospector package to perform population synthesis. Finally, it will analyze the results and generate plots. It will generate an 'average' spectrum for the galaxy, with uncertainty. It will also generate tabulated predictions for photometry in various bands, which can be used for further analysis. Finally, it will generate diagnostic plots to visualize the results of the fitting process. All this can be viewed in the data directory, under AT2019fdr/.

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

galsynthspec-0.2.0.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

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

galsynthspec-0.2.0-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

Details for the file galsynthspec-0.2.0.tar.gz.

File metadata

  • Download URL: galsynthspec-0.2.0.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for galsynthspec-0.2.0.tar.gz
Algorithm Hash digest
SHA256 796e790b944203e66cd46bc27d6ee9357b758ad9a8475a5fe44299d2cdd70ab5
MD5 e4fd8a4f2a360694d1a3a9590b129351
BLAKE2b-256 e5ab7dfc8f6ceb46d228ea9d9f95bbdbd510a62f64f2933c34dcd4e718c605d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for galsynthspec-0.2.0.tar.gz:

Publisher: continuous_integration.yml on robertdstein/galsynthspec

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

File details

Details for the file galsynthspec-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: galsynthspec-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for galsynthspec-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12db97123576865531e7653945a45bc600b829833721f445857ab491daef9c56
MD5 73779e13742de4ea5cba1aef790462fd
BLAKE2b-256 55f24464ce3aec097340e914953c7708f3ab32debe7dbc9560e68343b1e41fd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for galsynthspec-0.2.0-py3-none-any.whl:

Publisher: continuous_integration.yml on robertdstein/galsynthspec

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page