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.1.1.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.1.1-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: galsynthspec-0.1.1.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.1.1.tar.gz
Algorithm Hash digest
SHA256 17a275189d1e8278ddc57adfce354d7e2e46f0493c3a655d2a2ff86c13cef338
MD5 09925a06e14adc60d232f001bef7d9a8
BLAKE2b-256 52ddc9c067d274e7031602558494a9895faedb945bd4e3722c2749d8ff774bb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for galsynthspec-0.1.1.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.1.1-py3-none-any.whl.

File metadata

  • Download URL: galsynthspec-0.1.1-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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae84f7a273c2705bd123cc8330bfa9dd56927b001f0c7a05c4afe47bae9cfc85
MD5 a9b788f6ee646ed5a9206cd1d2e21e8d
BLAKE2b-256 c07a041b0aac40a5a87459d3059aa684b42af19dce16b0e72c38eebac7170a39

See more details on using hashes here.

Provenance

The following attestation bundles were made for galsynthspec-0.1.1-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