sedlib 1.0.0__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.
- sedlib/__init__.py +47 -0
- sedlib/bol2rad.py +552 -0
- sedlib/catalog.py +1141 -0
- sedlib/core.py +6059 -0
- sedlib/data/__init__.py +2 -0
- sedlib/data/temp_to_bc_coefficients.yaml +62 -0
- sedlib/filter/__init__.py +5 -0
- sedlib/filter/core.py +1064 -0
- sedlib/filter/data/__init__.py +2 -0
- sedlib/filter/data/svo_all_filter_database.pickle +0 -0
- sedlib/filter/data/svo_filter_catalog.pickle +0 -0
- sedlib/filter/data/svo_meta_data.xml +1282 -0
- sedlib/filter/utils.py +71 -0
- sedlib/helper.py +361 -0
- sedlib/utils.py +789 -0
- sedlib/version.py +12 -0
- sedlib-1.0.0.dist-info/METADATA +611 -0
- sedlib-1.0.0.dist-info/RECORD +21 -0
- sedlib-1.0.0.dist-info/WHEEL +5 -0
- sedlib-1.0.0.dist-info/licenses/LICENSE +201 -0
- sedlib-1.0.0.dist-info/top_level.txt +1 -0
sedlib/version.py
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
|
3
|
+
"""Version information for sedlib."""
|
4
|
+
|
5
|
+
__version__ = "1.0.0"
|
6
|
+
__author__ = "Oğuzhan Okuyan"
|
7
|
+
__author_email__ = "ookuyan@gmail.com, oguzhan.okuyan@tubitak.gov.tr"
|
8
|
+
__license__ = "Apache License 2.0"
|
9
|
+
__description__ = "A Python library for Spectral Energy Distribution (SED) analysis"
|
10
|
+
__url__ = "https://github.com/ookuyan/sedlib"
|
11
|
+
|
12
|
+
VERSION = tuple(map(int, __version__.split(".")))
|
@@ -0,0 +1,611 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: sedlib
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: A Python library for Spectral Energy Distribution (SED) analysis
|
5
|
+
Author-email: Oğuzhan OKUYAN <ookuyan@gmail.com>
|
6
|
+
Maintainer-email: Oğuzhan OKUYAN <ookuyan@gmail.com>
|
7
|
+
License: Apache-2.0
|
8
|
+
Project-URL: Homepage, https://github.com/ookuyan/sedlib
|
9
|
+
Project-URL: Repository, https://github.com/ookuyan/sedlib
|
10
|
+
Project-URL: Bug Tracker, https://github.com/ookuyan/sedlib/issues
|
11
|
+
Project-URL: Documentation, https://github.com/ookuyan/sedlib
|
12
|
+
Keywords: astrophysics,astronomy,spectral-energy-distribution,stellar-physics,photometry,bolometric-correction,extinction,sed-analysis
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
16
|
+
Classifier: Operating System :: OS Independent
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
25
|
+
Requires-Python: >=3.8
|
26
|
+
Description-Content-Type: text/markdown
|
27
|
+
License-File: LICENSE
|
28
|
+
Requires-Dist: numpy>=1.20.0
|
29
|
+
Requires-Dist: scipy>=1.6.0
|
30
|
+
Requires-Dist: astroquery>=0.4.1
|
31
|
+
Requires-Dist: astropy>=4.0
|
32
|
+
Requires-Dist: dust-extinction>=1.0
|
33
|
+
Requires-Dist: beautifulsoup4>=4.9.3
|
34
|
+
Requires-Dist: lxml
|
35
|
+
Requires-Dist: pandas>=1.2.0
|
36
|
+
Requires-Dist: pyyaml>=5.4.0
|
37
|
+
Requires-Dist: requests>=2.25.0
|
38
|
+
Requires-Dist: bokeh>=2.3.0
|
39
|
+
Requires-Dist: corner>=2.2.1
|
40
|
+
Requires-Dist: ipywidgets>=7.6.0
|
41
|
+
Requires-Dist: matplotlib>=3.3.0
|
42
|
+
Requires-Dist: dill>=0.3.4
|
43
|
+
Requires-Dist: joblib>=1.0.0
|
44
|
+
Requires-Dist: psutil>=5.8.0
|
45
|
+
Requires-Dist: tqdm
|
46
|
+
Provides-Extra: dev
|
47
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
48
|
+
Requires-Dist: pytest-cov>=3.0; extra == "dev"
|
49
|
+
Requires-Dist: black>=22.0; extra == "dev"
|
50
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
51
|
+
Requires-Dist: mypy>=0.990; extra == "dev"
|
52
|
+
Requires-Dist: pre-commit>=2.20; extra == "dev"
|
53
|
+
Provides-Extra: notebook
|
54
|
+
Requires-Dist: ipython>=7.20.0; extra == "notebook"
|
55
|
+
Requires-Dist: jupyterlab; extra == "notebook"
|
56
|
+
Provides-Extra: all
|
57
|
+
Requires-Dist: sedlib[dev,notebook]; extra == "all"
|
58
|
+
Dynamic: license-file
|
59
|
+
|
60
|
+
# sedlib
|
61
|
+
|
62
|
+
A Python library for Spectral Energy Distribution (SED) analysis of single stars.
|
63
|
+
|
64
|
+
[](https://doi.org/10.5281/zenodo.17332608)
|
65
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
66
|
+
[](https://www.python.org/downloads/)
|
67
|
+
[](https://www.astropy.org/)
|
68
|
+
|
69
|
+
## Table of Contents
|
70
|
+
|
71
|
+
- [1. Overview](#1-overview)
|
72
|
+
- [2. Installation](#2-installation)
|
73
|
+
- [2.1. Prerequisites](#21-prerequisites)
|
74
|
+
- [2.2. Install from PyPI (when available)](#22-install-from-pypi-when-available)
|
75
|
+
- [2.3. Install from source](#23-install-from-source)
|
76
|
+
- [2.4. Dependencies](#24-dependencies)
|
77
|
+
- [3. Quick Start](#3-quick-start)
|
78
|
+
- [3.1. Basic Usage](#31-basic-usage)
|
79
|
+
- [4. API Reference](#4-api-reference)
|
80
|
+
- [4.1. SED Class](#41-sed-class)
|
81
|
+
- [4.1.1. Parameters](#411-parameters)
|
82
|
+
- [4.1.2. Key Methods](#412-key-methods)
|
83
|
+
- [4.1.3. Attributes](#413-attributes)
|
84
|
+
- [4.2. Catalog Class](#42-catalog-class)
|
85
|
+
- [4.2.1. Key Methods](#421-key-methods)
|
86
|
+
- [4.3. Filter Class](#43-filter-class)
|
87
|
+
- [4.3.1. Parameters](#431-parameters)
|
88
|
+
- [4.3.2. Key Methods](#432-key-methods)
|
89
|
+
- [4.4. BolometricCorrection Class](#44-bolometriccorrection-class)
|
90
|
+
- [4.4.1. Parameters](#441-parameters)
|
91
|
+
- [4.4.2. Key Methods](#442-key-methods)
|
92
|
+
- [4.4.3. Attributes](#443-attributes)
|
93
|
+
- [4.5. Project Management](#45-project-management)
|
94
|
+
- [4.6. Interactive Plotting](#46-interactive-plotting)
|
95
|
+
- [4.7. Custom Analysis Pipeline](#47-custom-analysis-pipeline)
|
96
|
+
- [5. Examples](#5-examples)
|
97
|
+
- [5.1. Complete Analysis Pipeline](#51-complete-analysis-pipeline)
|
98
|
+
- [6. Contributing](#6-contributing)
|
99
|
+
- [6.1. Development Setup](#61-development-setup)
|
100
|
+
- [6.2. Code Style](#62-code-style)
|
101
|
+
- [7. About](#7-about)
|
102
|
+
- [7.1. License](#71-license)
|
103
|
+
- [7.2. Citation](#72-citation)
|
104
|
+
- [7.3. Acknowledgments](#73-acknowledgments)
|
105
|
+
- [8. Changelog](#8-changelog)
|
106
|
+
- [8.1. Version 1.0.0](#81-version-100)
|
107
|
+
|
108
|
+
## 1. Overview
|
109
|
+
|
110
|
+
sedlib provides comprehensive tools for analyzing stellar spectral energy distributions, including:
|
111
|
+
|
112
|
+
- **Photometric data management** with the `Catalog` class
|
113
|
+
- **Filter handling** with the `Filter` class
|
114
|
+
- **SED analysis** with the `SED` class
|
115
|
+
- **Bolometric corrections** for accurate stellar radius determination
|
116
|
+
- **Advanced optimization** for interstellar extinction correction
|
117
|
+
- **Integration** with astronomical libraries like astropy and dust_extinction
|
118
|
+
|
119
|
+
## 2. Installation
|
120
|
+
|
121
|
+
### 2.1. Prerequisites
|
122
|
+
|
123
|
+
- Python 3.8 or higher
|
124
|
+
- pip package manager
|
125
|
+
|
126
|
+
### 2.2. Install from PyPI (when available)
|
127
|
+
|
128
|
+
```bash
|
129
|
+
pip install sedlib
|
130
|
+
```
|
131
|
+
|
132
|
+
### 2.3. Install from source
|
133
|
+
|
134
|
+
```bash
|
135
|
+
git clone https://github.com/ookuyan/sedlib.git
|
136
|
+
cd sedlib
|
137
|
+
pip install -e .
|
138
|
+
```
|
139
|
+
|
140
|
+
### 2.4. Dependencies
|
141
|
+
|
142
|
+
The library requires several scientific Python packages:
|
143
|
+
|
144
|
+
- `astropy` - Astronomical utilities
|
145
|
+
- `numpy` - Numerical computing
|
146
|
+
- `scipy` - Scientific computing
|
147
|
+
- `matplotlib` - Plotting
|
148
|
+
- `pandas` - Data manipulation
|
149
|
+
- `dust_extinction` - Extinction models
|
150
|
+
- `astroquery` - Astronomical data queries
|
151
|
+
- `bokeh` - Interactive plotting
|
152
|
+
- `corner` - Corner plots for MCMC results
|
153
|
+
- `joblib` - Parallel processing
|
154
|
+
- `dill` - Serialization
|
155
|
+
- `tqdm` - Progress bars
|
156
|
+
- `beautifulsoup4` - HTML parsing
|
157
|
+
- `requests` - HTTP requests
|
158
|
+
|
159
|
+
## 3. Quick Start
|
160
|
+
|
161
|
+
### 3.1. Basic Usage
|
162
|
+
|
163
|
+
```python
|
164
|
+
from sedlib import SED
|
165
|
+
|
166
|
+
# initialize the SED object
|
167
|
+
sed = SED(name='Gaia DR3 145538372736262912')
|
168
|
+
|
169
|
+
# run the complete analysis pipeline
|
170
|
+
sed.run()
|
171
|
+
```
|
172
|
+
|
173
|
+
```
|
174
|
+
================================================================================
|
175
|
+
SED ANALYSIS PIPELINE FOR: UCAC4 559-009409
|
176
|
+
================================================================================
|
177
|
+
🚀 Pipeline stages to be executed:
|
178
|
+
1. 🧹 Data Cleaning
|
179
|
+
2. 📊 Flux Combination
|
180
|
+
3. 🔍 Outlier Filtering
|
181
|
+
4. ⭕ Radius Estimation
|
182
|
+
5. 🌫️ Extinction Estimation
|
183
|
+
6. ✨ Bolometric Correction
|
184
|
+
7. 💾 Save Project
|
185
|
+
--------------------------------------------------------------------------------
|
186
|
+
Initial parameters:
|
187
|
+
🔥 Temperature: 6588.9638671875 K
|
188
|
+
± Temperature error: 16.833251953125 K
|
189
|
+
⭕ Radius: 1.5003000497817993 solRad
|
190
|
+
± Radius error: 0.02544999122619629 solRad
|
191
|
+
📏 Distance: 464.364907135142 pc
|
192
|
+
± Distance error: 3.0629455414607314 pc
|
193
|
+
📊 Number of photometric measurements: 165
|
194
|
+
--------------------------------------------------------------------------------
|
195
|
+
|
196
|
+
|
197
|
+
🔄 STAGE 1/7: 🧹 Data Cleaning
|
198
|
+
Starting data cleaning...
|
199
|
+
Removed 3 rows with missing data in 'filter' column(s)
|
200
|
+
Remaining data points: 162
|
201
|
+
✅ COMPLETED: Stage 1/7 - Data Cleaning in 0.00s
|
202
|
+
|
203
|
+
🔄 STAGE 2/7: 📊 Flux Combination
|
204
|
+
Starting flux combination...
|
205
|
+
Combined flux measurements using 'median' method
|
206
|
+
Combined 123 measurements
|
207
|
+
Unique filters after combination: 39
|
208
|
+
✅ COMPLETED: Stage 2/7 - Flux Combination in 0.04s
|
209
|
+
|
210
|
+
🔄 STAGE 3/7: 🔍 Outlier Filtering
|
211
|
+
Starting outlier filtering...
|
212
|
+
Identified 1 outliers with sigma > 3.0
|
213
|
+
Remaining valid measurements: 38
|
214
|
+
Outliers are marked but not removed from the dataset
|
215
|
+
✅ COMPLETED: Stage 3/7 - Outlier Filtering in 0.01s
|
216
|
+
|
217
|
+
🔄 STAGE 4/7: ⭕ Radius Estimation
|
218
|
+
Starting radius estimation...
|
219
|
+
Using mc method for radius estimation
|
220
|
+
Running with 1000 Monte Carlo samples
|
221
|
+
MC Sampling: 100%|██████████████████████████████████| 1000/1000 [00:11<00:00, 89.61it/s]
|
222
|
+
--------- RADIUS ESTIMATION RESULTS ---------
|
223
|
+
Radius: 1.3805923531705158 solRad
|
224
|
+
Uncertainty: 0.009412372349938383 solRad
|
225
|
+
Method: mc
|
226
|
+
Valid samples: 1000
|
227
|
+
--------------------------------------------
|
228
|
+
✅ COMPLETED: Stage 4/7 - Radius Estimation in 11.54s
|
229
|
+
|
230
|
+
🔄 STAGE 5/7: 🌫️ Extinction Estimation
|
231
|
+
Starting extinction estimation...
|
232
|
+
Using mc method for extinction estimation
|
233
|
+
Extinction model: G23
|
234
|
+
Running with 1000 Monte Carlo samples
|
235
|
+
Batch 1/10: 100%|█████████████████████████████████████| 100/100 [00:03<00:00, 32.19it/s]
|
236
|
+
Batch 2/10: 100%|█████████████████████████████████████| 100/100 [00:03<00:00, 32.12it/s]
|
237
|
+
Batch 3/10: 100%|█████████████████████████████████████| 100/100 [00:03<00:00, 32.13it/s]
|
238
|
+
Batch 4/10: 100%|█████████████████████████████████████| 100/100 [00:03<00:00, 31.97it/s]
|
239
|
+
Batch 5/10: 100%|█████████████████████████████████████| 100/100 [00:03<00:00, 31.22it/s]
|
240
|
+
Batch 6/10: 100%|█████████████████████████████████████| 100/100 [00:03<00:00, 32.16it/s]
|
241
|
+
Batch 7/10: 100%|█████████████████████████████████████| 100/100 [00:03<00:00, 32.25it/s]
|
242
|
+
Batch 8/10: 100%|█████████████████████████████████████| 100/100 [00:03<00:00, 32.58it/s]
|
243
|
+
Batch 9/10: 100%|█████████████████████████████████████| 100/100 [00:03<00:00, 31.30it/s]
|
244
|
+
Batch 10/10: 100%|████████████████████████████████████| 100/100 [00:03<00:00, 31.98it/s]
|
245
|
+
-------- EXTINCTION ESTIMATION RESULTS --------
|
246
|
+
E(B-V): 0.3760
|
247
|
+
Uncertainty: 0.0087
|
248
|
+
Method: mc
|
249
|
+
Valid samples: 1000
|
250
|
+
-----------------------------------------------
|
251
|
+
✅ COMPLETED: Stage 5/7 - Extinction Estimation in 32.36s
|
252
|
+
|
253
|
+
🔄 STAGE 6/7: ✨ Bolometric Correction
|
254
|
+
Starting bolometric correction...
|
255
|
+
Computing extinction (A_λ) for each filter
|
256
|
+
Computing absolute magnitudes
|
257
|
+
Running bolometric correction
|
258
|
+
Accept radius correction: True
|
259
|
+
-------- BOLOMETRIC CORRECTION RESULTS --------
|
260
|
+
Bolometric radius: 1.3815522981780102 solRad
|
261
|
+
Bolometric radius error: 0.03654157830727994 solRad
|
262
|
+
-----------------------------------------------
|
263
|
+
✅ COMPLETED: Stage 6/7 - Bolometric Correction in 0.81s
|
264
|
+
|
265
|
+
🔄 STAGE 7/7: 💾 Save Project
|
266
|
+
Starting save project...
|
267
|
+
Saving SED project to 'sedlib/tmp/20251007222842-Gaia_DR3_145538372736262912.sed.zip'
|
268
|
+
✅ COMPLETED: Stage 7/7 - Save Project in 0.82s
|
269
|
+
|
270
|
+
================================================================================
|
271
|
+
PIPELINE SUMMARY
|
272
|
+
================================================================================
|
273
|
+
Stages completed: 7/7
|
274
|
+
Total execution time: 45.59 seconds
|
275
|
+
|
276
|
+
Stage Status:
|
277
|
+
✅ Data Cleaning: SUCCESS
|
278
|
+
✅ Flux Combination: SUCCESS
|
279
|
+
✅ Outlier Filtering: SUCCESS
|
280
|
+
✅ Radius Estimation: SUCCESS
|
281
|
+
✅ Extinction Estimation: SUCCESS
|
282
|
+
✅ Bolometric Correction: SUCCESS
|
283
|
+
✅ Save Project: SUCCESS
|
284
|
+
|
285
|
+
Final Results:
|
286
|
+
Radius: 1.3815522981780102 solRad ± 0.03654157830727994 solRad
|
287
|
+
E(B-V): 0.3760 ± 0.0087
|
288
|
+
|
289
|
+
SED project saved to: sedlib/tmp/20251007222842-Gaia_DR3_145538372736262912.sed.zip
|
290
|
+
================================================================================
|
291
|
+
```
|
292
|
+
|
293
|
+
```python
|
294
|
+
sed.plot(with_blackbody=True, with_extinction=True, with_outliers=True, show=True)
|
295
|
+
```
|
296
|
+
|
297
|
+

|
298
|
+
|
299
|
+
|
300
|
+
## 4. API Reference
|
301
|
+
|
302
|
+
### 4.1. SED Class
|
303
|
+
|
304
|
+
The main class for Spectral Energy Distribution analysis.
|
305
|
+
|
306
|
+
#### 4.1.1. Parameters
|
307
|
+
|
308
|
+
- `name` (str, optional): Name of the astronomical object
|
309
|
+
- `ra` (str or float, optional): Right ascension
|
310
|
+
- `dec` (str or float, optional): Declination
|
311
|
+
- `search_radius` (Quantity, optional): Search radius for queries (default: 1 arcsec)
|
312
|
+
- `coord` (SkyCoord, optional): Object coordinates
|
313
|
+
- `frame` (str, optional): Reference frame (default: 'icrs')
|
314
|
+
- `auto_search` (bool, optional): Auto-search on initialization (default: True)
|
315
|
+
- `cache` (bool, optional): Enable caching (default: True)
|
316
|
+
- `timeout` (int, optional): Query timeout in seconds (default: 10)
|
317
|
+
- `find_basic_parameters` (bool, optional): Find basic parameters from catalogs (default: True)
|
318
|
+
- `info` (bool, optional): Print summary info (default: True)
|
319
|
+
|
320
|
+
#### 4.1.2. Key Methods
|
321
|
+
|
322
|
+
- `add_photometry(filter_name, mag, mag_error=None)`: Add photometric data
|
323
|
+
- `filter_outliers(sigma_threshold=3.0)`: Filter outliers using sigma clipping
|
324
|
+
- `estimate_radius(accept=False)`: Estimate stellar radius
|
325
|
+
- `estimate_ebv()`: Estimate interstellar extinction
|
326
|
+
- `compute_A_lambda()`: Compute extinction at each wavelength
|
327
|
+
- `compute_absolute_magnitudes()`: Convert to absolute magnitudes
|
328
|
+
- `plot(with_blackbody=False, with_extinction=False, interactive=False)`: Plot SED
|
329
|
+
- `save(path, compression=True)`: Save SED project
|
330
|
+
- `load(path)`: Load saved SED project (class method)
|
331
|
+
- `run()`: Run complete analysis pipeline
|
332
|
+
|
333
|
+
#### 4.1.3. Attributes
|
334
|
+
|
335
|
+
- `name`: Object name
|
336
|
+
- `ra`, `dec`: Coordinates
|
337
|
+
- `coord`: SkyCoord object
|
338
|
+
- `parallax`, `parallax_error`: Parallax measurements
|
339
|
+
- `distance`, `distance_error`: Distance measurements
|
340
|
+
- `radius`, `radius_error`: Stellar radius
|
341
|
+
- `teff`, `teff_error`: Effective temperature
|
342
|
+
- `ebv`, `ebv_error`: Interstellar extinction
|
343
|
+
- `ext_model`: Extinction model
|
344
|
+
- `catalog`: Photometric catalog
|
345
|
+
|
346
|
+
### 4.2. Catalog Class
|
347
|
+
|
348
|
+
Manages photometric data in an Astropy Table format.
|
349
|
+
|
350
|
+
#### 4.2.1. Key Methods
|
351
|
+
|
352
|
+
- `delete_missing_data_rows(columns)`: Remove rows with missing data
|
353
|
+
- `delete_rows(conditions)`: Remove rows matching conditions
|
354
|
+
- `combine_fluxes(method='mean', overwrite=False)`: Combine duplicate filter measurements
|
355
|
+
- `filter_outliers(sigma_threshold=3.0)`: Apply sigma clipping
|
356
|
+
- `sql_query(query)`: Execute SQL queries on the catalog
|
357
|
+
|
358
|
+
### 4.3. Filter Class
|
359
|
+
|
360
|
+
Handles astronomical filter transmission curves from the SVO Filter Profile Service.
|
361
|
+
|
362
|
+
> **📖 For comprehensive Filter class documentation, examples, and advanced usage, visit: [https://github.com/ookuyan/filter](https://github.com/ookuyan/filter)**
|
363
|
+
|
364
|
+
#### 4.3.1. Parameters
|
365
|
+
|
366
|
+
- `name` (str, optional): Filter identifier (SVO format)
|
367
|
+
- `method` (str): Interpolation method ('linear' or 'nearest')
|
368
|
+
- `bounds_error` (bool): Raise errors for out-of-bounds values
|
369
|
+
- `fill_value` (float or None): Value for out-of-bounds interpolation
|
370
|
+
- `cache` (bool): Enable caching
|
371
|
+
- `timeout` (int): Request timeout
|
372
|
+
|
373
|
+
#### 4.3.2. Key Methods
|
374
|
+
|
375
|
+
- `from_svo(name)`: Load filter from SVO service
|
376
|
+
- `from_data(name, wavelength, transmission)`: Create filter from custom data
|
377
|
+
- `search(name, case=False)`: Search filter catalog
|
378
|
+
- `apply(wavelength, flux, error)`: Apply filter to spectrum
|
379
|
+
- `plot()`: Plot transmission curve
|
380
|
+
|
381
|
+
### 4.4. BolometricCorrection Class
|
382
|
+
|
383
|
+
Computes bolometric corrections and stellar radii based on effective temperature. The class implements the methodology from [Eker & Bakış (2023, MNRAS)](https://arxiv.org/abs/2305.12538), using fourth-degree polynomial fits for various photometric filters (Johnson B, V; GAIA G, GBP, GRP; TESS). Bolometric magnitudes are computed by applying filter-specific corrections to absolute magnitudes and combining them via inverse-variance weighting to derive stellar radii.
|
384
|
+
|
385
|
+
#### 4.4.1. Parameters
|
386
|
+
|
387
|
+
- `sed` (SED object): SED object with absolute magnitudes and effective temperature
|
388
|
+
- `coeff_file` (str, optional): Path to coefficient file
|
389
|
+
- `accept_radius` (bool): Store computed radius in sed object (default: False)
|
390
|
+
|
391
|
+
#### 4.4.2. Key Methods
|
392
|
+
|
393
|
+
- `run(verbose=False)`: Execute complete bolometric correction pipeline
|
394
|
+
- `compute_bolometric_corrections()`: Compute BCs for available filters
|
395
|
+
- `compute_weighted_abs_bol_mag()`: Compute weighted bolometric magnitude
|
396
|
+
- `compute_normalized_radius()`: Compute stellar radius in solar units
|
397
|
+
|
398
|
+
#### 4.4.3. Attributes
|
399
|
+
|
400
|
+
- `abs_bol_mag`, `abs_bol_mag_err`: Weighted bolometric magnitude and uncertainty
|
401
|
+
- `radius`, `radius_error`: Stellar radius in solar units and uncertainty
|
402
|
+
|
403
|
+
### 4.5. Project Management
|
404
|
+
|
405
|
+
The `save()` and `load()` methods provide a convenient way to preserve your entire SED analysis in a single file. When you save an SED project, the library uses dill serialization to bundle everything together—all stellar parameters, photometric data, analysis results, extinction estimates, and even the processing history. This means you can stop your work at any point and pick up exactly where you left off later, without needing to rerun time-consuming calculations like Monte Carlo simulations. This feature makes it easy to share your analysis with collaborators or archive results for future reference, ensuring reproducibility since the entire state of your analysis is preserved in one portable file. Optional zip compression is available for situations where file size matters, such as when sending analysis results as email attachments.
|
406
|
+
|
407
|
+
```python
|
408
|
+
# Save complete analysis
|
409
|
+
sed.save('sed_analysis.sedlib')
|
410
|
+
|
411
|
+
# Load saved project
|
412
|
+
loaded_sed = SED.load('sed_analysis.sedlib')
|
413
|
+
|
414
|
+
# Access results
|
415
|
+
print(f"Radius: {loaded_sed.radius:.2f} ± {loaded_sed.radius_error:.2f}")
|
416
|
+
print(f"E(B-V): {loaded_sed.ebv:.3f} ± {loaded_sed.ebv_error:.3f}")
|
417
|
+
```
|
418
|
+
|
419
|
+
```
|
420
|
+
Radius: 1.29 solRad ± 0.04 solRad
|
421
|
+
E(B-V): 0.425 ± 0.009
|
422
|
+
```
|
423
|
+
|
424
|
+
### 4.6. Interactive Plotting
|
425
|
+
|
426
|
+
Create interactive plots with Bokeh:
|
427
|
+
|
428
|
+
```python
|
429
|
+
# Interactive SED plot
|
430
|
+
sed.plot(
|
431
|
+
with_blackbody=True,
|
432
|
+
with_extinction=True,
|
433
|
+
with_outliers=True,
|
434
|
+
interactive=True
|
435
|
+
)
|
436
|
+
```
|
437
|
+
|
438
|
+
### 4.7. Custom Analysis Pipeline
|
439
|
+
|
440
|
+
```python
|
441
|
+
# Define custom pipeline configuration
|
442
|
+
config = {
|
443
|
+
'data_cleaning': {
|
444
|
+
'delete_missing_data_columns': ['filter', 'eflux'],
|
445
|
+
'combine_fluxes': True,
|
446
|
+
'filter_outliers': True,
|
447
|
+
'sigma_threshold': 3.0
|
448
|
+
},
|
449
|
+
'radius_estimation': {
|
450
|
+
'enabled': True,
|
451
|
+
'method': 'monte_carlo',
|
452
|
+
'n_samples': 1000
|
453
|
+
},
|
454
|
+
'extinction_estimation': {
|
455
|
+
'enabled': True,
|
456
|
+
'method': 'monte_carlo',
|
457
|
+
'n_samples': 1000
|
458
|
+
}
|
459
|
+
}
|
460
|
+
|
461
|
+
# Run custom pipeline
|
462
|
+
sed.run(custom_config=config)
|
463
|
+
```
|
464
|
+
|
465
|
+
|
466
|
+
## 5. Examples
|
467
|
+
|
468
|
+
### 5.1. Complete Analysis Pipeline
|
469
|
+
|
470
|
+
```python
|
471
|
+
from sedlib import SED, BolometricCorrection
|
472
|
+
from astropy import units as u
|
473
|
+
|
474
|
+
# Initialize SED object
|
475
|
+
sed = SED(name='Gaia DR3 164561603226850304')
|
476
|
+
|
477
|
+
# Set stellar parameters (from gaia)
|
478
|
+
sed.teff = 5850.74 * u.K
|
479
|
+
sed.teff_error = 29.62 * u.K
|
480
|
+
|
481
|
+
sed.radius = 1.4948 * u.solRad
|
482
|
+
sed.radius_error = 0.00840002 * u.solRad
|
483
|
+
|
484
|
+
sed.distance = 248.791 * u.pc
|
485
|
+
sed.distance_error = 0.772802 * u.pc
|
486
|
+
|
487
|
+
# Data cleaning
|
488
|
+
sed.catalog.filter_outliers(sigma_threshold=3.0, over_write=True)
|
489
|
+
sed.catalog.delete_missing_data_rows(['filter', 'eflux'])
|
490
|
+
sed.catalog.combine_fluxes(method='mean', overwrite=True)
|
491
|
+
|
492
|
+
# Radius estimation with Monte Carlo sampling
|
493
|
+
sed.estimate_radius(method='mc', n_samples=10000, accept=True)
|
494
|
+
```
|
495
|
+
|
496
|
+
```python
|
497
|
+
{'method': 'mc',
|
498
|
+
'n_samples': 10000,
|
499
|
+
'elapsed_time': 64.39362096786499,
|
500
|
+
'radius_mean': <Quantity 1.28601477 solRad>,
|
501
|
+
'radius_median': <Quantity 1.28599561 solRad>,
|
502
|
+
'radius_std': <Quantity 0.00709151 solRad>,
|
503
|
+
'success': True}
|
504
|
+
```
|
505
|
+
|
506
|
+
```python
|
507
|
+
# Extinction estimation with Monte Carlo sampling
|
508
|
+
sed.estimate_ebv(method='mc', n_samples=10000, accept=True)
|
509
|
+
```
|
510
|
+
|
511
|
+
```python
|
512
|
+
{'ebv_mean': np.float64(0.4253809724895975),
|
513
|
+
'ebv_std': np.float64(0.008834504561834948),
|
514
|
+
'ebv_median': np.float64(0.4255177019864373),
|
515
|
+
'method': 'mc',
|
516
|
+
'num_samples': 10000,
|
517
|
+
'num_valid_samples': 10000,
|
518
|
+
'elapsed_time': 167.62379121780396,
|
519
|
+
'success': True}
|
520
|
+
```
|
521
|
+
|
522
|
+
```python
|
523
|
+
# Plot E(B-V) Monte Carlo results
|
524
|
+
sed.plot_results(ebv_mc=True)
|
525
|
+
```
|
526
|
+
|
527
|
+

|
528
|
+
|
529
|
+
```python
|
530
|
+
# Compute extinction and absolute magnitudes
|
531
|
+
sed.compute_A_lambda()
|
532
|
+
sed.compute_absolute_magnitudes()
|
533
|
+
|
534
|
+
# Bolometric correction
|
535
|
+
bc = BolometricCorrection(sed, accept_radius=True)
|
536
|
+
bc.run()
|
537
|
+
|
538
|
+
# Visualization
|
539
|
+
sed.plot(with_blackbody=True, with_extinction=True, with_outliers=True, show=True)
|
540
|
+
```
|
541
|
+
|
542
|
+

|
543
|
+
|
544
|
+
## 6. Contributing
|
545
|
+
|
546
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
547
|
+
|
548
|
+
### 6.1. Development Setup
|
549
|
+
|
550
|
+
1. Fork the repository
|
551
|
+
2. Clone your fork: `git clone https://github.com/yourusername/sedlib.git`
|
552
|
+
3. Install in development mode: `pip install -e .`
|
553
|
+
4. Install development dependencies: `pip install -r requirements.txt`
|
554
|
+
|
555
|
+
### 6.2. Code Style
|
556
|
+
|
557
|
+
The project follows PEP 8 style guidelines. Please ensure your code is properly formatted.
|
558
|
+
|
559
|
+
## 7. About
|
560
|
+
|
561
|
+
### 7.1. License
|
562
|
+
|
563
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
564
|
+
|
565
|
+
### 7.2. Citation
|
566
|
+
|
567
|
+
If you use sedlib in your research, please cite:
|
568
|
+
|
569
|
+
[](https://doi.org/10.5281/zenodo.17332608)
|
570
|
+
|
571
|
+
```bibtex
|
572
|
+
@software{sedlib_zenodo,
|
573
|
+
author = {Oğuzhan OKUYAN},
|
574
|
+
title = {sedlib: A Python library for Spectral Energy Distribution analysis},
|
575
|
+
year = {2024},
|
576
|
+
publisher = {Zenodo},
|
577
|
+
version = {[VERSION]},
|
578
|
+
doi = {10.5281/zenodo.17332608},
|
579
|
+
url = {https://doi.org/10.5281/zenodo.17332608}
|
580
|
+
}
|
581
|
+
```
|
582
|
+
|
583
|
+
Or cite the GitHub repository:
|
584
|
+
|
585
|
+
```bibtex
|
586
|
+
@software{sedlib2024,
|
587
|
+
author = {Oğuzhan OKUYAN},
|
588
|
+
title = {sedlib: A Python library for Spectral Energy Distribution analysis},
|
589
|
+
year = {2024},
|
590
|
+
url = {https://github.com/ookuyan/sedlib},
|
591
|
+
version = {1.0.0}
|
592
|
+
}
|
593
|
+
```
|
594
|
+
|
595
|
+
### 7.3. Acknowledgments
|
596
|
+
|
597
|
+
- The SVO Filter Profile Service for providing filter transmission curves
|
598
|
+
- The Astropy community for excellent astronomical tools
|
599
|
+
- The dust_extinction package for extinction models
|
600
|
+
- The VizieR service for photometric data access
|
601
|
+
|
602
|
+
## 8. Changelog
|
603
|
+
|
604
|
+
### 8.1. Version 1.0.0
|
605
|
+
- Initial release
|
606
|
+
- Complete SED analysis pipeline
|
607
|
+
- Filter management via SVO service
|
608
|
+
- Bolometric correction calculations
|
609
|
+
- Monte Carlo uncertainty estimation
|
610
|
+
- Interactive plotting capabilities
|
611
|
+
- Project save/load functionality
|
@@ -0,0 +1,21 @@
|
|
1
|
+
sedlib/__init__.py,sha256=KYpZpuhP5aKD1XGS5C8QckVZT3i70a79jz3GyNZh3mo,1314
|
2
|
+
sedlib/bol2rad.py,sha256=K9tFM-jCq_zkuRe4ETI0qwMMD9-ZET2_-4WMvXMv9kw,18738
|
3
|
+
sedlib/catalog.py,sha256=PGZ8iZ-Agh4ZkqJ2kMaccU19Y94cEd-0fRcfvwIms4I,40592
|
4
|
+
sedlib/core.py,sha256=JFKSwenwx66D0n0VTOQGXsbzCBEG3PTNMtnWexGTvSc,234419
|
5
|
+
sedlib/helper.py,sha256=UpprfqxwMdv15JfQu2kN5F3LOdB2aON0WhUbEyvjw6I,11174
|
6
|
+
sedlib/utils.py,sha256=QdjzdZc0sNSkhQmRIZweyLaFPaDN-W59zIYum8ZotSI,27448
|
7
|
+
sedlib/version.py,sha256=b3efICdNaHYVJ7AXT7Amxff8JxkD6xwL26Uyk0gdzZQ,402
|
8
|
+
sedlib/data/__init__.py,sha256=mkL84nioLVyThe5S_YYMfmKdoQxY5TkTEMxiP9eQVY4,26
|
9
|
+
sedlib/data/temp_to_bc_coefficients.yaml,sha256=IMbPlCuelvbEMfyZPBb69rnVReD4iSA2taQefbhA69Q,1653
|
10
|
+
sedlib/filter/__init__.py,sha256=DTS22vvwoPuHl77l1LuSSNGDp6TeAWYvWpVQqrvPsmg,102
|
11
|
+
sedlib/filter/core.py,sha256=GnaXvsyU0SaYZ53dAiMGAy8psDICO1TGASnpIrM5McQ,35128
|
12
|
+
sedlib/filter/utils.py,sha256=Wjl6vVH6RtXO7yV49mvafm_HS40a1U-jdUPL2kdrJI8,2281
|
13
|
+
sedlib/filter/data/__init__.py,sha256=qLVi-gY0xlzsfFvnZAWpq1sC-dCYDyKBV_6hk4FTqtA,44
|
14
|
+
sedlib/filter/data/svo_all_filter_database.pickle,sha256=2EXZSjPliYXp_9dsVR6pnpSQiya-_cAcjBvSs2A3cZY,5405126
|
15
|
+
sedlib/filter/data/svo_filter_catalog.pickle,sha256=kzYximKCuDanfHvuRts3VjRIQuZuqQ2m-MSfDWZgFXc,244679
|
16
|
+
sedlib/filter/data/svo_meta_data.xml,sha256=O9TErngO1kGCkDhMck5zF3m5QgdAMbOR8xkGOr-yo10,47579
|
17
|
+
sedlib-1.0.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
18
|
+
sedlib-1.0.0.dist-info/METADATA,sha256=iv90dSJob36a1T98A0UXvOdNrNXzsH4dyDYq7VXHndU,22262
|
19
|
+
sedlib-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
20
|
+
sedlib-1.0.0.dist-info/top_level.txt,sha256=s7RDBIlba9H1hXN2m5p3-zYwvy3HXzQqkiUefaE0SQ0,7
|
21
|
+
sedlib-1.0.0.dist-info/RECORD,,
|