Some useful scripts to compute integrated line fluxes and equivalent widths from galaxy spectra using 3 different methods:
- numerical (trapezoidal) integration
- Gaussian fit using a "standard" Levenberg-Marquardt algorithm
- Gaussian fit using an MCMC algorithm
## Installing the package
To install ``PySpecLines`` you can use ``pip``, which will take care of installing the required dependencies as well
```
pip install pyspeclines
```
To upgrade to the latest available version you can run
```
pip install pyspeclines --upgrade
```
## Data format
### FITS binary table
``PySpecLines`` works with FITS tables. Each spectrum should be contained in a separate FITS file, which **must** contain the following columns:
- ``wl``, wavelength array in ``ang``
- ``flux``, flux array in ``erg s^-1 cm^-2 ang^-1``
- ``err``, error array in ``erg s^-1 cm^-2 ang^-1``
### FITS header
``PySpecLines`` also uses the following (**optional**) FITS header keywords:
- ``REDSHIFT``, used to de-redshift a spectrum from the observed-frame to the rest-frame
- ``RA``, right ascension of the object in ``deg``, in the ``ICRS`` frame, used to correct for Galactic absorption
- ``DEC``, declination of the object in ``deg``, in the ``ICRS`` frame, used to correct for Galactic absorption
When both keywords ``RA`` and ``DEC`` are present, ``PySpecLines`` can de-redden the spectrum (passing the option ``-deredden``) using the Galactic dust map of Schlegel, Finkbeiner & Davis (1998) recalibrated by Schlafly & Finkbeiner (2011), and the ``R_V=3.1`` extinction curve of Fitzpatrick (1999).
### JSON configuration file
A JSON file allows you to select and configure the emission lines to be measured. Some example JSON files are provided in the [PySpecLines/files](https://github.com/jacopo-chevallard/PySpecLines/tree/master/PySpecLines/files) folder. The JSON file contains a dictionary of ``key : values`` where ``key`` labels the line (or group of lines) and ``values`` contains multiple entries.
Below we report some simple examples:
- single line:
```json
{
"HeII4686" : {
"wl_central": [4686.0],
"wl_range":[4680.0, 4681.0],
"continuum_left":[4672.0, 4679.0],
"continuum_right":[4692.0, 4700.0]
}
}
```
- ``wl_central`` is used as starting point for the line center in the Gaussian fitting
- ``wl_range`` is the range of numerical integration of the line
- ``continuum_left`` is the range of numerical integration of the left-continuum
- ``continuum_right`` is the range of numerical integration of the right-continuum
- when using Gaussian fitting, the range over which the continuum is fitted is ``[continuum_left[0], continuum_right[1]]``
- line doublet:
```json
{
"SII6716_SII6731" : {
"wl_central": [6716.0, 6731.0],
"wl_range":[6710.0, 6723.0],
"exclude":[6710.0, 6721.0, 6726.0, 6740.0],
"continuum_left":[6695.0, 6705.0],
"continuum_right":[6740.0, 6750.0]
}
}
```
- wrt to the example above, the ``key`` is composed of two labels separated by an underscore ``_``
- ``exclude`` allows to define regions (``[exclude[0], exclude[1]], [exclude[2], exclude[3]]``) excluded from the continuum fitting
- multiple kinematic components
```json
{
"OIII5007N_OIII5007B" : {
"wl_central": [5007.0, 5007.0],
"width": [100.0, 400.0],
"wl_range":[5000.0, 5014.0],
"exclude":[4995.0, 5020.0],
"continuum_left":[4990.0, 5000.0],
"continuum_right":[5020.0, 5034.0]
}
}
```
- ``width`` allows to define multiple kinematic components, in this case a "narrow" (labelled ``OIII5007N``) and a "broad" (labelled ``OIII5007B``) component, whose starting widths **must** be set to different values.
- multiple lines with multiple kinematic components
```json
{
"NII6548_HalphaN_HalphaB_NII6584" : {
"wl_central": [6548.05, 6563.0, 6563.0, 6584.0],
"width": [100.0, 100.0, 400.0, 100.0],
"exclude":[6542.0, 6580.0],
"wl_range":[6541.0, 6575.0],
"continuum_left":[6515.0,6542.0],
"continuum_right":[6595.0,6610.0]
}
}
```
- in this case we want to use the same width for different lines (``NII6548``, ``HalphaN`` and ``NII6584``) and a different width for ``HalphaB``. We thus use the same ``width`` value for ``NII6548``, ``HalphaN`` and ``NII6584``, as this will "tie" together their widths during the Gaussian fitting, while the ``width`` of ``HalphaB`` will be kept separate.
## Examples
You can see the different available options running
```
pyspeclines --help
```
If the spectrum is provided in the observed frame, then you must provide a ``REDSHIFT`` keyword in the FITS header containing the object redshift.
- Compute the fluxes and EWs using numerical integration
```
pyspeclines --file my_spectrum.fits --json-file emission_lines_EWs_config.json
```
- Compute the fluxes and EWs using Gaussian fit (Levenberg-Marquardt)
```
pyspeclines --file my_spectrum.fits --json-file emission_lines_EWs_config.json --gaussian-fit
```
- Compute the fluxes and EWs using Gaussian fit (MCMC)
```
pyspeclines --file my_spectrum.fits --json-file emission_lines_EWs_config.json --gaussian-fit --use-PyMC --MCMC-samples 5000
```
Metadata
Release files for pyspeclines 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyspeclines-0.2.1.tar.gz | 622.4 kB | Without provenance | Details for pyspeclines-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyspeclines-0.2.1-py2.7.egg | Legacy Egg format | - | - | Details for pyspeclines-0.2.1-py2.7.egg |
Total release size: 1.3 MB
Release files / pyspeclines-0.2.1.tar.gz
| Download URL | pyspeclines-0.2.1.tar.gz |
|---|---|
| Size | 622.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b5a02457e0a849168044caa054e98590111e04b44882ebac7e5d09622087420
|
|
BLAKE2b-256 checksum How to use checksums |
6aa13f2eece2e2c961f924b1217399c261a5ad811857c2c6188a56681c0e8b25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14
|
Release files / pyspeclines-0.2.1-py2.7.egg
| Download URL | pyspeclines-0.2.1-py2.7.egg |
|---|---|
| Size | 651.2 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
c44b2189ac941733b7b2526420262693e5fd54e379b4a020eff0282cd8c821a3
|
|
BLAKE2b-256 checksum How to use checksums |
39e31eb108a5f65db17995dc4d39780ba8ffd58f1fb78d863f9d3f39a3c97feb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14
|
Security for pyspeclines 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.