rainbowkit 0.0.2__tar.gz → 0.0.3__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.
- rainbowkit-0.0.3/PKG-INFO +147 -0
- rainbowkit-0.0.3/README.md +132 -0
- {rainbowkit-0.0.2 → rainbowkit-0.0.3}/pyproject.toml +8 -1
- rainbowkit-0.0.3/rainbowkit/__init__.py +2 -0
- {rainbowkit-0.0.2 → rainbowkit-0.0.3}/rainbowkit/rainbowkit.py +15 -6
- rainbowkit-0.0.3/rainbowkit/spec_PKS0405-12.dat +59602 -0
- rainbowkit-0.0.3/rainbowkit.egg-info/PKG-INFO +147 -0
- {rainbowkit-0.0.2 → rainbowkit-0.0.3}/rainbowkit.egg-info/SOURCES.txt +2 -0
- rainbowkit-0.0.3/rainbowkit.egg-info/requires.txt +2 -0
- rainbowkit-0.0.2/PKG-INFO +0 -30
- rainbowkit-0.0.2/README.md +0 -18
- rainbowkit-0.0.2/rainbowkit/__init__.py +0 -0
- rainbowkit-0.0.2/rainbowkit.egg-info/PKG-INFO +0 -30
- {rainbowkit-0.0.2 → rainbowkit-0.0.3}/LICENSE +0 -0
- {rainbowkit-0.0.2 → rainbowkit-0.0.3}/rainbowkit/linelist.py +0 -0
- {rainbowkit-0.0.2 → rainbowkit-0.0.3}/rainbowkit.egg-info/dependency_links.txt +0 -0
- {rainbowkit-0.0.2 → rainbowkit-0.0.3}/rainbowkit.egg-info/top_level.txt +0 -0
- {rainbowkit-0.0.2 → rainbowkit-0.0.3}/setup.cfg +0 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rainbowkit
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: Tools to work with spectra
|
|
5
|
+
Author-email: Sourav Das <souravdas.sd20@gmail.com>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: numpy
|
|
13
|
+
Requires-Dist: matplotlib
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# RainbowKit
|
|
17
|
+
|
|
18
|
+
RainbowKit is a Python toolkit for spectral analysis. It allows you to create spectrum objects and perform various tasks, such as plotting spectra, marking spectral lines, and estimating redshifts from observed spectral transitions.
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- Create and manipulate spectrum objects
|
|
23
|
+
- Plot flux versus wavelength
|
|
24
|
+
- Plot normalized flux
|
|
25
|
+
- Mark important spectral lines for analysis
|
|
26
|
+
- Estimate redshift from spectral transitions
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
You can install RainbowKit using pip:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install rainbowkit
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
RainbowKit requires Python 3.8 or later.
|
|
37
|
+
|
|
38
|
+
## Quick start
|
|
39
|
+
|
|
40
|
+
Import RainbowKit:
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import rainbowkit
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
RainbowKit includes an example spectrum, which can be loaded directly:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
spec = rainbowkit.Spectrum()
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
or your own spectrum file:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
spec = rainbowkit.Spectrum("my_spectrum.dat")
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
You can then plot the spectrum:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
spec.fplot()
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
or plot the normalized spectrum:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
spec.nfplot()
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The input file should contain four columns:
|
|
71
|
+
|
|
72
|
+
1. Wavelength
|
|
73
|
+
2. Flux
|
|
74
|
+
3. Error
|
|
75
|
+
4. Continuum
|
|
76
|
+
|
|
77
|
+
Important spectral transitions can be marked on the spectrum:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
spec.marklines()
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The lines can also be shifted according to a redshift:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
spec.marklines(z=3.0)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
RainbowKit can estimate the redshift of a spectral transition interactively.
|
|
90
|
+
|
|
91
|
+
For example:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
spec.getz("CIV_1548")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
After calling this method, click on the observed transition in the plotted spectrum.
|
|
98
|
+
RainbowKit will calculate and print the corresponding redshift.
|
|
99
|
+
|
|
100
|
+
## Example workflow
|
|
101
|
+
|
|
102
|
+
A minimal working example:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
import rainbowkit
|
|
106
|
+
|
|
107
|
+
spec = rainbowkit.Spectrum() # default example spectrum
|
|
108
|
+
# For user-provided spectrum
|
|
109
|
+
# spec = rainbowkit.Spectrum('my_spectrum.dat')
|
|
110
|
+
|
|
111
|
+
spec.nfplot()
|
|
112
|
+
spec.marklines()
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Input Spectrum Format
|
|
116
|
+
|
|
117
|
+
RainbowKit expects a plain-text spectrum containing four columns:
|
|
118
|
+
|
|
119
|
+
| Column | Description |
|
|
120
|
+
|---|---|
|
|
121
|
+
| 1 | Wavelength |
|
|
122
|
+
| 2 | Flux |
|
|
123
|
+
| 3 | Error |
|
|
124
|
+
| 4 | Continuum |
|
|
125
|
+
|
|
126
|
+
The columns should be separated by whitespace.
|
|
127
|
+
|
|
128
|
+
## Requirements
|
|
129
|
+
|
|
130
|
+
- Python >= 3.8
|
|
131
|
+
- NumPy
|
|
132
|
+
- Matplotlib
|
|
133
|
+
|
|
134
|
+
## Acknowledgements
|
|
135
|
+
|
|
136
|
+
I would like to thank Prof. Sowgat Muzahid at the Inter-University Centre for Astronomy and Astrophysics (IUCAA), who was my MSc supervisor, for his guidance and support during the development of this work.
|
|
137
|
+
|
|
138
|
+
I am particularly grateful to him for providing the spectral line lists and the example spectrum included with RainbowKit.
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
RainbowKit is released under the MIT License. See the `LICENSE` file for details.
|
|
143
|
+
|
|
144
|
+
## Author
|
|
145
|
+
|
|
146
|
+
[Sourav Das](https://github.com/PhysicistSouravDas "PhysicistSouravDas GitHub page")
|
|
147
|
+
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# RainbowKit
|
|
2
|
+
|
|
3
|
+
RainbowKit is a Python toolkit for spectral analysis. It allows you to create spectrum objects and perform various tasks, such as plotting spectra, marking spectral lines, and estimating redshifts from observed spectral transitions.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Create and manipulate spectrum objects
|
|
8
|
+
- Plot flux versus wavelength
|
|
9
|
+
- Plot normalized flux
|
|
10
|
+
- Mark important spectral lines for analysis
|
|
11
|
+
- Estimate redshift from spectral transitions
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
You can install RainbowKit using pip:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install rainbowkit
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
RainbowKit requires Python 3.8 or later.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
Import RainbowKit:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import rainbowkit
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
RainbowKit includes an example spectrum, which can be loaded directly:
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
spec = rainbowkit.Spectrum()
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
or your own spectrum file:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
spec = rainbowkit.Spectrum("my_spectrum.dat")
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
You can then plot the spectrum:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
spec.fplot()
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
or plot the normalized spectrum:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
spec.nfplot()
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The input file should contain four columns:
|
|
56
|
+
|
|
57
|
+
1. Wavelength
|
|
58
|
+
2. Flux
|
|
59
|
+
3. Error
|
|
60
|
+
4. Continuum
|
|
61
|
+
|
|
62
|
+
Important spectral transitions can be marked on the spectrum:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
spec.marklines()
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The lines can also be shifted according to a redshift:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
spec.marklines(z=3.0)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
RainbowKit can estimate the redshift of a spectral transition interactively.
|
|
75
|
+
|
|
76
|
+
For example:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
spec.getz("CIV_1548")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
After calling this method, click on the observed transition in the plotted spectrum.
|
|
83
|
+
RainbowKit will calculate and print the corresponding redshift.
|
|
84
|
+
|
|
85
|
+
## Example workflow
|
|
86
|
+
|
|
87
|
+
A minimal working example:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
import rainbowkit
|
|
91
|
+
|
|
92
|
+
spec = rainbowkit.Spectrum() # default example spectrum
|
|
93
|
+
# For user-provided spectrum
|
|
94
|
+
# spec = rainbowkit.Spectrum('my_spectrum.dat')
|
|
95
|
+
|
|
96
|
+
spec.nfplot()
|
|
97
|
+
spec.marklines()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Input Spectrum Format
|
|
101
|
+
|
|
102
|
+
RainbowKit expects a plain-text spectrum containing four columns:
|
|
103
|
+
|
|
104
|
+
| Column | Description |
|
|
105
|
+
|---|---|
|
|
106
|
+
| 1 | Wavelength |
|
|
107
|
+
| 2 | Flux |
|
|
108
|
+
| 3 | Error |
|
|
109
|
+
| 4 | Continuum |
|
|
110
|
+
|
|
111
|
+
The columns should be separated by whitespace.
|
|
112
|
+
|
|
113
|
+
## Requirements
|
|
114
|
+
|
|
115
|
+
- Python >= 3.8
|
|
116
|
+
- NumPy
|
|
117
|
+
- Matplotlib
|
|
118
|
+
|
|
119
|
+
## Acknowledgements
|
|
120
|
+
|
|
121
|
+
I would like to thank Prof. Sowgat Muzahid at the Inter-University Centre for Astronomy and Astrophysics (IUCAA), who was my MSc supervisor, for his guidance and support during the development of this work.
|
|
122
|
+
|
|
123
|
+
I am particularly grateful to him for providing the spectral line lists and the example spectrum included with RainbowKit.
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
RainbowKit is released under the MIT License. See the `LICENSE` file for details.
|
|
128
|
+
|
|
129
|
+
## Author
|
|
130
|
+
|
|
131
|
+
[Sourav Das](https://github.com/PhysicistSouravDas "PhysicistSouravDas GitHub page")
|
|
132
|
+
|
|
@@ -4,16 +4,23 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rainbowkit"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.3"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Sourav Das", email="souravdas.sd20@gmail.com" },
|
|
10
10
|
]
|
|
11
11
|
description = "Tools to work with spectra"
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
requires-python = ">=3.8"
|
|
14
|
+
dependencies=[
|
|
15
|
+
"numpy",
|
|
16
|
+
"matplotlib",
|
|
17
|
+
]
|
|
14
18
|
classifiers = [
|
|
15
19
|
"Programming Language :: Python :: 3",
|
|
16
20
|
"License :: OSI Approved :: MIT License",
|
|
17
21
|
"Operating System :: OS Independent",
|
|
18
22
|
]
|
|
19
23
|
|
|
24
|
+
[tool.setuptools.package-data]
|
|
25
|
+
rainbowkit = ["*.dat"]
|
|
26
|
+
|
|
@@ -2,6 +2,8 @@ import numpy as np
|
|
|
2
2
|
import matplotlib.pyplot as plt
|
|
3
3
|
import matplotlib.offsetbox as offsetbox
|
|
4
4
|
|
|
5
|
+
from importlib.resources import files
|
|
6
|
+
|
|
5
7
|
from . import linelist as ll
|
|
6
8
|
|
|
7
9
|
class Spectrum():
|
|
@@ -33,9 +35,16 @@ class Spectrum():
|
|
|
33
35
|
'SiIII_1206', 'SiIV_1402', 'SiIV_1393',
|
|
34
36
|
)
|
|
35
37
|
|
|
36
|
-
def __init__(self, filename
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
def __init__(self, filename=None):
|
|
39
|
+
|
|
40
|
+
if filename is None:
|
|
41
|
+
# default spectrum
|
|
42
|
+
f = files("rainbowkit").joinpath("spec_PKS0405-12.dat").open("r")
|
|
43
|
+
self.filename = "spec_PKS0405-12.dat"
|
|
44
|
+
else:
|
|
45
|
+
f = open(filename)
|
|
46
|
+
self.filename = filename
|
|
47
|
+
|
|
39
48
|
wvlength = []
|
|
40
49
|
flux = []
|
|
41
50
|
cont = [] # continuum
|
|
@@ -45,7 +54,7 @@ class Spectrum():
|
|
|
45
54
|
wvlength.append(float(line[0].lstrip().rstrip()))
|
|
46
55
|
flux.append(float(line[1].lstrip().rstrip()))
|
|
47
56
|
cont.append(float(line[3].lstrip().rstrip()))
|
|
48
|
-
|
|
57
|
+
|
|
49
58
|
f.close()
|
|
50
59
|
|
|
51
60
|
self.wvlength = np.asarray(wvlength)
|
|
@@ -57,14 +66,14 @@ class Spectrum():
|
|
|
57
66
|
# Keep track of added lines and annotations
|
|
58
67
|
self.added_lines = []
|
|
59
68
|
self.added_annotations = []
|
|
60
|
-
|
|
69
|
+
|
|
61
70
|
# Store the clicked coordinates
|
|
62
71
|
self.clicked_coords = None
|
|
63
72
|
self.cid = None
|
|
64
73
|
|
|
65
74
|
# Storing the transition value of getz
|
|
66
75
|
self.transition = None
|
|
67
|
-
|
|
76
|
+
|
|
68
77
|
def fplot(self):
|
|
69
78
|
"""
|
|
70
79
|
Method to plot flux vs wavelength
|