TARDIS-Spectrum-Filtering 1.0.0__py2.py3-none-any.whl → 1.0.3__py2.py3-none-any.whl
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.
- {tardis_spectrum_filtering-1.0.0.dist-info → tardis_spectrum_filtering-1.0.3.dist-info}/METADATA +7 -4
- tardis_spectrum_filtering-1.0.3.dist-info/RECORD +6 -0
- tardis_spectrum_filtering-1.0.3.dist-info/top_level.txt +1 -0
- TARDIS_Spectrum_Filtering/TARDIS_Spectrum_Filtering.py +0 -134
- TARDIS_Spectrum_Filtering/__init__.py +0 -5
- TARDIS_Spectrum_Filtering/common.py +0 -7
- tardis_spectrum_filtering-1.0.0.dist-info/RECORD +0 -9
- tardis_spectrum_filtering-1.0.0.dist-info/top_level.txt +0 -1
- {tardis_spectrum_filtering-1.0.0.dist-info → tardis_spectrum_filtering-1.0.3.dist-info}/WHEEL +0 -0
- {tardis_spectrum_filtering-1.0.0.dist-info → tardis_spectrum_filtering-1.0.3.dist-info}/entry_points.txt +0 -0
- {tardis_spectrum_filtering-1.0.0.dist-info → tardis_spectrum_filtering-1.0.3.dist-info}/licenses/LICENSE +0 -0
{tardis_spectrum_filtering-1.0.0.dist-info → tardis_spectrum_filtering-1.0.3.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: TARDIS_Spectrum_Filtering
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Package used to apply telescope filters to spectra from Stars or Supernovae
|
|
5
5
|
Author-email: Clyde Watson <clyde.n.watson@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -17,9 +17,13 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
17
17
|
Requires-Python: >=3.8
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
|
+
Requires-Dist: matplotlib
|
|
20
21
|
Requires-Dist: numpy
|
|
22
|
+
Requires-Dist: astropy
|
|
23
|
+
Requires-Dist: requests
|
|
24
|
+
Requires-Dist: pyyaml
|
|
21
25
|
Provides-Extra: all
|
|
22
|
-
Requires-Dist:
|
|
26
|
+
Requires-Dist: TARDIS_Spectrum_Filtering[extra]; extra == "all"
|
|
23
27
|
Provides-Extra: extra
|
|
24
28
|
Requires-Dist: pandas; extra == "extra"
|
|
25
29
|
Dynamic: license-file
|
|
@@ -27,8 +31,7 @@ Dynamic: license-file
|
|
|
27
31
|
# spectra-filtering
|
|
28
32
|
|
|
29
33
|
|
|
30
|
-
[](https://anaconda.org/conda-forge/spectra-filtering)
|
|
34
|
+
[](https://pypi.python.org/pypi/TARDIS_Spectrum_Filtering)
|
|
32
35
|
|
|
33
36
|
|
|
34
37
|
**Package used to apply telescope filters to spectra from Stars or Supernovae**
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
tardis_spectrum_filtering-1.0.3.dist-info/licenses/LICENSE,sha256=J8qEL369U2AjyyxQeLNe50xQVZj1CVfxpcR-KZDYSqk,1071
|
|
2
|
+
tardis_spectrum_filtering-1.0.3.dist-info/METADATA,sha256=Bhdx3XFrxgt8qZX6I_odejVG3j3g7VTUKilZiQkETWI,1364
|
|
3
|
+
tardis_spectrum_filtering-1.0.3.dist-info/WHEEL,sha256=Mk1ST5gDzEO5il5kYREiBnzzM469m5sI8ESPl7TRhJY,110
|
|
4
|
+
tardis_spectrum_filtering-1.0.3.dist-info/entry_points.txt,sha256=VxSb86QTkEoasQ0E8LoEnYMdvYEQ0Ji1sXpvx6CH6II,81
|
|
5
|
+
tardis_spectrum_filtering-1.0.3.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
6
|
+
tardis_spectrum_filtering-1.0.3.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"""Main module."""
|
|
2
|
-
import os
|
|
3
|
-
import xml.etree.ElementTree as et
|
|
4
|
-
import matplotlib.pyplot as plt
|
|
5
|
-
import numpy as np
|
|
6
|
-
import requests
|
|
7
|
-
import yaml
|
|
8
|
-
from astropy import units as u
|
|
9
|
-
|
|
10
|
-
# Function to get Filter URL from TARDIS config file
|
|
11
|
-
def get_url_from_config(config_file_path):
|
|
12
|
-
|
|
13
|
-
with open(config_file_path, 'r') as f:
|
|
14
|
-
config = yaml.safe_load(f)
|
|
15
|
-
telescope = config['filter']['Telescope_Name']
|
|
16
|
-
instrument = config['filter']['Instrument']
|
|
17
|
-
filter_id = config['filter']['Filter_ID']
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
name = f"{telescope}/{instrument}.{filter_id}"
|
|
21
|
-
safe_name = name.replace('/', '.')
|
|
22
|
-
url = f"https://svo2.cab.inta-csic.es/theory/fps/fps.php?ID={name}"
|
|
23
|
-
|
|
24
|
-
return url, safe_name
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# Function to check if the filter file is valid
|
|
28
|
-
def check_filter(filter_name):
|
|
29
|
-
|
|
30
|
-
root = et.parse(f"Filters/{filter_name}.xml")
|
|
31
|
-
|
|
32
|
-
info = root.find('INFO')
|
|
33
|
-
|
|
34
|
-
check = info.get('value')
|
|
35
|
-
|
|
36
|
-
if check == 'ERROR':
|
|
37
|
-
return False
|
|
38
|
-
elif info is None:
|
|
39
|
-
return False
|
|
40
|
-
else:
|
|
41
|
-
return True
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
# Function to download the filter file
|
|
45
|
-
def download_filter(url, filename):
|
|
46
|
-
req = requests.get(url, timeout = 10)
|
|
47
|
-
|
|
48
|
-
with open((f'Filters/{filename}.xml'), 'wb') as f:
|
|
49
|
-
|
|
50
|
-
# Chunking to avoid large memory consumption
|
|
51
|
-
for chunk in req.iter_content(chunk_size=8192):
|
|
52
|
-
if chunk:
|
|
53
|
-
f.write(chunk)
|
|
54
|
-
|
|
55
|
-
if check_filter(filename) == True:
|
|
56
|
-
print("Filter URL is valid.")
|
|
57
|
-
return filename
|
|
58
|
-
elif check_filter(filename) == False:
|
|
59
|
-
print("Filter URL is not valid. Removing invalid filter file.")
|
|
60
|
-
os.remove(f'Filters/{filename}.xml')
|
|
61
|
-
raise ValueError("Invalid Filter URL. The filter file has been removed.")
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
# Function to get wavelength and transmission values from filter file
|
|
65
|
-
def get_filter(filter_name):
|
|
66
|
-
|
|
67
|
-
# Parse XML File from Filters Directory
|
|
68
|
-
root = et.parse(f"Filters/{filter_name}.xml")
|
|
69
|
-
|
|
70
|
-
# Get wavelength and transmission values in one array (Will be in aleternating order)
|
|
71
|
-
all_vals = np.array([float(x.text) for x in root.findall('.//TD')])
|
|
72
|
-
|
|
73
|
-
# Separate wavelength and transmission values
|
|
74
|
-
wl = all_vals[0::2] * u.AA
|
|
75
|
-
tr = all_vals[1::2]
|
|
76
|
-
return wl, tr
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
# Function to interpolate filter to match TARDIS Spectrum
|
|
80
|
-
def interp_filter(spectrum_to_filter, filter_name):
|
|
81
|
-
#Interpolate filter transmission values to match TARDIS Spectrum
|
|
82
|
-
wl, tr = get_filter(filter_name)
|
|
83
|
-
return np.interp(spectrum_to_filter, wl, tr)
|
|
84
|
-
|
|
85
|
-
# Function to apply filter to TARDIS Spectrum
|
|
86
|
-
def apply_filter(spectrum, spectrum_virtual, spectrum_integrated, chosen_filter):
|
|
87
|
-
|
|
88
|
-
# Interpolate filter transmission values to match TARDIS Spectrum
|
|
89
|
-
prepared_filter = interp_filter(spectrum.wavelength, chosen_filter)
|
|
90
|
-
|
|
91
|
-
# Apply filter to TARDIS Spectrum
|
|
92
|
-
filtered_spectrum = spectrum.luminosity_density_lambda * prepared_filter
|
|
93
|
-
filtered_spectrum_virt = spectrum_virtual.luminosity_density_lambda * prepared_filter
|
|
94
|
-
filtered_spec_integ = spectrum_integrated.luminosity_density_lambda * prepared_filter
|
|
95
|
-
return filtered_spectrum, filtered_spectrum_virt, filtered_spec_integ
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
# Function to plot original TARDIS Spectrum
|
|
99
|
-
def plot_original_spectrum(spectrum, spectrum_virtual, spectrum_integrated):
|
|
100
|
-
# Plot TARDIS Spectrum before filtering
|
|
101
|
-
plt.figure()
|
|
102
|
-
plt.plot(spectrum.wavelength, spectrum.luminosity_density_lambda)
|
|
103
|
-
plt.plot(spectrum.wavelength, spectrum_virtual.luminosity_density_lambda)
|
|
104
|
-
plt.plot(spectrum.wavelength, spectrum_integrated.luminosity_density_lambda)
|
|
105
|
-
plt.xlabel("Wavelength (Angstrom)")
|
|
106
|
-
plt.ylabel("Luminosity Density (erg/s/Angstrom)")
|
|
107
|
-
plt.title("Unfiltered TARDIS Spectrum")
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
# Function to plot filter transmission curve
|
|
111
|
-
def plot_filter(spectrum, chosen_filter):
|
|
112
|
-
|
|
113
|
-
# Interpolate filter transmission values to match TARDIS Spectrum
|
|
114
|
-
prepared_filter = interp_filter(spectrum.wavelength, chosen_filter)
|
|
115
|
-
|
|
116
|
-
# Plot the filter transmission curve
|
|
117
|
-
plt.figure()
|
|
118
|
-
plt.plot(spectrum.wavelength, prepared_filter)
|
|
119
|
-
plt.title("Filter Transmission Curve")
|
|
120
|
-
plt.xlabel("Wavelength (Angstrom)")
|
|
121
|
-
plt.ylabel("Transmission")
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
# Function to plot the filtered spectrum
|
|
125
|
-
def plot_filtered_spectrum(spectrum, spectrum_virtual, spectrum_integrated, chosen_filter):
|
|
126
|
-
|
|
127
|
-
plt.figure()
|
|
128
|
-
plt.plot(spectrum.wavelength, apply_filter(spectrum, spectrum_virtual, spectrum_integrated, chosen_filter)[0])
|
|
129
|
-
plt.plot(spectrum.wavelength, apply_filter(spectrum, spectrum_virtual, spectrum_integrated, chosen_filter)[1])
|
|
130
|
-
plt.plot(spectrum.wavelength, apply_filter(spectrum, spectrum_virtual, spectrum_integrated, chosen_filter)[2])
|
|
131
|
-
plt.xlabel("Wavelength (Angstrom)")
|
|
132
|
-
plt.ylabel("Luminosity Density (erg/s/Angstrom)")
|
|
133
|
-
plt.title("Filtered TARDIS Example Model Spectrum")
|
|
134
|
-
plt.show()
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
TARDIS_Spectrum_Filtering/TARDIS_Spectrum_Filtering.py,sha256=9m6ajMDodJ9E99B-6pFLUsc05Q7J-7IkSNqQCPFEC0U,4807
|
|
2
|
-
TARDIS_Spectrum_Filtering/__init__.py,sha256=y_joxtHrPuHZgVWumIkTeL6xQSMtGSZMl37BKLOKiwM,149
|
|
3
|
-
TARDIS_Spectrum_Filtering/common.py,sha256=UkxoF8RazqaFu7o-ZH3HUoPu7oVGAAB3Ja02Zm6IW9I,189
|
|
4
|
-
tardis_spectrum_filtering-1.0.0.dist-info/licenses/LICENSE,sha256=J8qEL369U2AjyyxQeLNe50xQVZj1CVfxpcR-KZDYSqk,1071
|
|
5
|
-
tardis_spectrum_filtering-1.0.0.dist-info/METADATA,sha256=tNAEtN-Z4VXsKN-Wz2zqwLh-qVpkUi1CkdP3iChVpeg,1375
|
|
6
|
-
tardis_spectrum_filtering-1.0.0.dist-info/WHEEL,sha256=Mk1ST5gDzEO5il5kYREiBnzzM469m5sI8ESPl7TRhJY,110
|
|
7
|
-
tardis_spectrum_filtering-1.0.0.dist-info/entry_points.txt,sha256=VxSb86QTkEoasQ0E8LoEnYMdvYEQ0Ji1sXpvx6CH6II,81
|
|
8
|
-
tardis_spectrum_filtering-1.0.0.dist-info/top_level.txt,sha256=JAeZtUL5WUopZQbw6RgjDU0dO7I7Fytpfil1lz4lLjM,26
|
|
9
|
-
tardis_spectrum_filtering-1.0.0.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
TARDIS_Spectrum_Filtering
|
{tardis_spectrum_filtering-1.0.0.dist-info → tardis_spectrum_filtering-1.0.3.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|