FilterMags 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- filtermags-0.0.1/FilterMags/__init__.py +0 -0
- filtermags-0.0.1/FilterMags/filtermag.py +90 -0
- filtermags-0.0.1/FilterMags.egg-info/PKG-INFO +19 -0
- filtermags-0.0.1/FilterMags.egg-info/SOURCES.txt +10 -0
- filtermags-0.0.1/FilterMags.egg-info/dependency_links.txt +1 -0
- filtermags-0.0.1/FilterMags.egg-info/requires.txt +4 -0
- filtermags-0.0.1/FilterMags.egg-info/top_level.txt +1 -0
- filtermags-0.0.1/LICENSE +19 -0
- filtermags-0.0.1/PKG-INFO +19 -0
- filtermags-0.0.1/README.md +3 -0
- filtermags-0.0.1/pyproject.toml +26 -0
- filtermags-0.0.1/setup.cfg +4 -0
|
File without changes
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# outside packages
|
|
2
|
+
import os
|
|
3
|
+
from astropy.io import ascii
|
|
4
|
+
from astropy.io import fits
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
# dictionary containing keywords for all filter transmission files
|
|
8
|
+
current_dir = os.getcwd()
|
|
9
|
+
filter_dict = {
|
|
10
|
+
"sdss_u": os.path.join(current_dir, 'TransmissionCurves/SLOAN_SDSS.u.dat'),
|
|
11
|
+
"sdss_g": os.path.join(current_dir, 'TransmissionCurves/SLOAN_SDSS.g.dat'),
|
|
12
|
+
"sdss_r": os.path.join(current_dir, 'TransmissionCurves/SLOAN_SDSS.r.dat'),
|
|
13
|
+
"sdss_i": os.path.join(current_dir, 'TransmissionCurves/SLOAN_SDSS.i.dat'),
|
|
14
|
+
"sdss_z": os.path.join(current_dir, 'TransmissionCurves/SLOAN_SDSS.z.dat'),
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# read the transmission curve
|
|
18
|
+
class TransmissionCurve:
|
|
19
|
+
"""
|
|
20
|
+
Class that defines transmission curve objects. Each transmission curve has a filter name and arrays of
|
|
21
|
+
wavelengths and transmission (%) based on the transmission curve files in the repo. The dictionary
|
|
22
|
+
``filter_dict`` contains the file names for each filter.
|
|
23
|
+
"""
|
|
24
|
+
def __init__(self, filtername):
|
|
25
|
+
"""Constructor method
|
|
26
|
+
"""
|
|
27
|
+
filename = filter_dict[filtername]
|
|
28
|
+
transmission_data = ascii.read(filename)
|
|
29
|
+
self.wavelength = transmission_data['col1'].data
|
|
30
|
+
self.transmission = transmission_data['col2'].data
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
# read SDSS spectrum from a FITS file
|
|
34
|
+
def read_spectrum(filename):
|
|
35
|
+
"""Read SDSS spectrum from FITS
|
|
36
|
+
|
|
37
|
+
Function to read an SDSS spectrum from a FITS file.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
filename (string): name of the FITS spectrum file
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
wave_spectra (array): wavelength of the spectrum in Angstroms
|
|
44
|
+
flux (array): flux of the spectrum in erg s-1 cm-2 A-1
|
|
45
|
+
"""
|
|
46
|
+
spectrum_file = fits.open(filename)
|
|
47
|
+
spectrum_data = spectrum_file[1].data
|
|
48
|
+
|
|
49
|
+
wave_spectra = 10**spectrum_data['loglam']
|
|
50
|
+
flux = spectrum_data['flux'] * 1e-17
|
|
51
|
+
|
|
52
|
+
spectrum_file.close()
|
|
53
|
+
|
|
54
|
+
return wave_spectra, flux
|
|
55
|
+
|
|
56
|
+
# calculate filter magnitude
|
|
57
|
+
def filter_mag(wave_spectra, flux, filter):
|
|
58
|
+
"""Filter magnitude calculator
|
|
59
|
+
|
|
60
|
+
Calculate the filter magnitude for a spectrum provided by the user in a given filter.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
wave_spectra (array): the wavelengths of the spectrum (in Angstroms)
|
|
64
|
+
flux (array): the associated fluxes for the wavelengths (in erg s-1 cm-2 A-1)
|
|
65
|
+
filter (string): the filter that magnitude will be calculated in, identified using a key in ``filter_dict``
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
float: filter magnitude for the spectrum
|
|
69
|
+
"""
|
|
70
|
+
# read in the transmission curve for the given filter
|
|
71
|
+
trans_curve = TransmissionCurve(filter)
|
|
72
|
+
wave_trans = trans_curve.wavelength
|
|
73
|
+
t = trans_curve.transmission
|
|
74
|
+
|
|
75
|
+
if max(wave_spectra) < max(wave_trans) or min(wave_spectra) > min(wave_trans):
|
|
76
|
+
raise ValueError('At least part of filter out of range of spectrum')
|
|
77
|
+
|
|
78
|
+
# three integrals that are needed for calculation
|
|
79
|
+
int_1 = np.trapezoid(t / wave_trans, wave_trans)
|
|
80
|
+
int_2 = np.trapezoid(t * wave_trans, wave_trans)
|
|
81
|
+
t_spectra = np.interp(wave_spectra, wave_trans, t, left=0, right=0) #interpolation for third integral
|
|
82
|
+
int_3 = np.trapezoid((flux*t_spectra)/wave_spectra, wave_spectra)
|
|
83
|
+
|
|
84
|
+
# magnitude calculation
|
|
85
|
+
flam = int_3 / int_1 #f_lambda
|
|
86
|
+
pivot = int_2 / int_1 #pivot wavelength squared
|
|
87
|
+
c = 3e18 #angstrom/s
|
|
88
|
+
mag = -2.5 * np.log10(flam) - 2.5 * np.log10(pivot / c) - 48.6
|
|
89
|
+
|
|
90
|
+
return mag
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: FilterMags
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A package to calculate AB magnitude of a filter given a spectrum.
|
|
5
|
+
Author-email: Simarpreet Girn <girn.simarpreet@gmail.com>, Katherine Panebianco <kpanebianco@me.com>, Yogita Patel <ypatel@das.uchile.cl>
|
|
6
|
+
Project-URL: Homepage, https://github.com/SimGirn/FilterMags
|
|
7
|
+
Project-URL: Issues, https://github.com/SimGirn/FilterMags/issues
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: os
|
|
12
|
+
Requires-Dist: astropy
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Requires-Dist: speclite
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# FilterMags
|
|
18
|
+
Calculate the AB magnitude in various filters for spectra from SDSS.
|
|
19
|
+
Code Astro project
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
FilterMags/__init__.py
|
|
5
|
+
FilterMags/filtermag.py
|
|
6
|
+
FilterMags.egg-info/PKG-INFO
|
|
7
|
+
FilterMags.egg-info/SOURCES.txt
|
|
8
|
+
FilterMags.egg-info/dependency_links.txt
|
|
9
|
+
FilterMags.egg-info/requires.txt
|
|
10
|
+
FilterMags.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
FilterMags
|
filtermags-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2018 The Python Packaging Authority
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: FilterMags
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A package to calculate AB magnitude of a filter given a spectrum.
|
|
5
|
+
Author-email: Simarpreet Girn <girn.simarpreet@gmail.com>, Katherine Panebianco <kpanebianco@me.com>, Yogita Patel <ypatel@das.uchile.cl>
|
|
6
|
+
Project-URL: Homepage, https://github.com/SimGirn/FilterMags
|
|
7
|
+
Project-URL: Issues, https://github.com/SimGirn/FilterMags/issues
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: os
|
|
12
|
+
Requires-Dist: astropy
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Requires-Dist: speclite
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# FilterMags
|
|
18
|
+
Calculate the AB magnitude in various filters for spectra from SDSS.
|
|
19
|
+
Code Astro project
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools >= 61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "FilterMags"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Simarpreet Girn", email = "girn.simarpreet@gmail.com"},
|
|
10
|
+
{ name='Katherine Panebianco', email='kpanebianco@me.com'},
|
|
11
|
+
{ name = 'Yogita Patel', email='ypatel@das.uchile.cl'},
|
|
12
|
+
]
|
|
13
|
+
description = "A package to calculate AB magnitude of a filter given a spectrum."
|
|
14
|
+
readme = "README.md"
|
|
15
|
+
requires-python = ">=3.10"
|
|
16
|
+
|
|
17
|
+
dependencies = [
|
|
18
|
+
"os",
|
|
19
|
+
"astropy",
|
|
20
|
+
"numpy",
|
|
21
|
+
"speclite"
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://github.com/SimGirn/FilterMags"
|
|
26
|
+
Issues = "https://github.com/SimGirn/FilterMags/issues"
|