binlite-2 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.
Files changed (41) hide show
  1. binlite_2-0.0.1/LICENSE.md +21 -0
  2. binlite_2-0.0.1/PKG-INFO +24 -0
  3. binlite_2-0.0.1/README.md +3 -0
  4. binlite_2-0.0.1/binlite/__init__.py +5 -0
  5. binlite_2-0.0.1/binlite/accretion.py +222 -0
  6. binlite_2-0.0.1/binlite/data/q0p01_primary_20F.dat +1000 -0
  7. binlite_2-0.0.1/binlite/data/q0p01_secondary_20F.dat +1000 -0
  8. binlite_2-0.0.1/binlite/data/q0p01_total_20F.dat +1000 -0
  9. binlite_2-0.0.1/binlite/data/q0p05_primary_20F.dat +1001 -0
  10. binlite_2-0.0.1/binlite/data/q0p05_secondary_20F.dat +1001 -0
  11. binlite_2-0.0.1/binlite/data/q0p05_total_20F.dat +1001 -0
  12. binlite_2-0.0.1/binlite/data/q0p15_primary_20F.dat +1000 -0
  13. binlite_2-0.0.1/binlite/data/q0p15_secondary_20F.dat +1000 -0
  14. binlite_2-0.0.1/binlite/data/q0p15_total_20F.dat +1000 -0
  15. binlite_2-0.0.1/binlite/data/q0p1_primary_20F.dat +957 -0
  16. binlite_2-0.0.1/binlite/data/q0p1_secondary_20F.dat +957 -0
  17. binlite_2-0.0.1/binlite/data/q0p1_total_20F.dat +957 -0
  18. binlite_2-0.0.1/binlite/data/q0p25_primary_20F.dat +1000 -0
  19. binlite_2-0.0.1/binlite/data/q0p25_secondary_20F.dat +1000 -0
  20. binlite_2-0.0.1/binlite/data/q0p25_total_20F.dat +1000 -0
  21. binlite_2-0.0.1/binlite/data/q0p3_primary_20F.dat +1000 -0
  22. binlite_2-0.0.1/binlite/data/q0p3_secondary_20F.dat +1000 -0
  23. binlite_2-0.0.1/binlite/data/q0p3_total_20F.dat +1000 -0
  24. binlite_2-0.0.1/binlite/data/q0p45_primary_20F.dat +1000 -0
  25. binlite_2-0.0.1/binlite/data/q0p45_secondary_20F.dat +1000 -0
  26. binlite_2-0.0.1/binlite/data/q0p45_total_20F.dat +1000 -0
  27. binlite_2-0.0.1/binlite/data/q0p6_primary_20F.dat +1000 -0
  28. binlite_2-0.0.1/binlite/data/q0p6_secondary_20F.dat +1000 -0
  29. binlite_2-0.0.1/binlite/data/q0p6_total_20F.dat +1000 -0
  30. binlite_2-0.0.1/binlite/data/q1_primary_20F.dat +1000 -0
  31. binlite_2-0.0.1/binlite/data/q1_primary_20F_new.dat +1000 -0
  32. binlite_2-0.0.1/binlite/data/q1_secondary_20F.dat +1000 -0
  33. binlite_2-0.0.1/binlite/data/q1_secondary_20F_new.dat +1000 -0
  34. binlite_2-0.0.1/binlite/data/q1_total_20F.dat +1000 -0
  35. binlite_2-0.0.1/binlite_2.egg-info/PKG-INFO +24 -0
  36. binlite_2-0.0.1/binlite_2.egg-info/SOURCES.txt +39 -0
  37. binlite_2-0.0.1/binlite_2.egg-info/dependency_links.txt +1 -0
  38. binlite_2-0.0.1/binlite_2.egg-info/top_level.txt +1 -0
  39. binlite_2-0.0.1/pyproject.toml +19 -0
  40. binlite_2-0.0.1/setup.cfg +4 -0
  41. binlite_2-0.0.1/setup.py +31 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thomas Slamecka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: binlite_2
3
+ Version: 0.0.1
4
+ Summary: Rapidly generates accretion templates of eccentric binaries.
5
+ Home-page: https://github.com/tslamecka/binlite_2
6
+ Author: Thomas Slamecka
7
+ Author-email: Thomas Slamecka <thomasslamecka@gmail.com>
8
+ License-Expression: MIT
9
+ Project-URL: Homepage, https://github.com/tslamecka/binlite_2
10
+ Project-URL: Issues, https://github.com/tslamecka/binlite_2/issues
11
+ Platform: Any
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.9
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE.md
17
+ Dynamic: author
18
+ Dynamic: home-page
19
+ Dynamic: license-file
20
+ Dynamic: platform
21
+
22
+ Binlite rapidly generates accretion templates of eccentric binaries.
23
+
24
+ README to be updated in the soon future.
@@ -0,0 +1,3 @@
1
+ Binlite rapidly generates accretion templates of eccentric binaries.
2
+
3
+ README to be updated in the soon future.
@@ -0,0 +1,5 @@
1
+ """Rapidly generates accretion templates of eccentric binaries."""
2
+
3
+ import sys
4
+ if not '-m' in sys.argv:
5
+ from .accretion import AccretionSeries
@@ -0,0 +1,222 @@
1
+ import numpy as np
2
+ import os
3
+
4
+ #=================================================================================================================================
5
+ # Define files
6
+
7
+ def get_base_dir():
8
+ return os.path.join(os.path.dirname(__file__), 'data\\')
9
+
10
+ dfp_1p0 = np.genfromtxt(open(get_base_dir() + 'q1_primary_20F_new.dat'))
11
+ dfs_1p0 = np.genfromtxt(open(get_base_dir() + 'q1_secondary_20F_new.dat'))
12
+ dfT_1p0 = np.genfromtxt(open(get_base_dir() + 'q1_total_20F.dat'))
13
+
14
+ dfp_0p6 = np.genfromtxt(open(get_base_dir() + 'q0p6_primary_20F.dat'))
15
+ dfs_0p6 = np.genfromtxt(open(get_base_dir() + 'q0p6_secondary_20F.dat'))
16
+ dfT_0p6 = np.genfromtxt(open(get_base_dir() + 'q0p6_total_20F.dat'))
17
+
18
+ dfp_0p45 = np.genfromtxt(open(get_base_dir() + 'q0p45_primary_20F.dat'))
19
+ dfs_0p45 = np.genfromtxt(open(get_base_dir() + 'q0p45_secondary_20F.dat'))
20
+ dfT_0p45 = np.genfromtxt(open(get_base_dir() + 'q0p45_total_20F.dat'))
21
+
22
+ dfp_0p3 = np.genfromtxt(open(get_base_dir() + 'q0p3_primary_20F.dat'))
23
+ dfs_0p3 = np.genfromtxt(open(get_base_dir() + 'q0p3_secondary_20F.dat'))
24
+ dfT_0p3 = np.genfromtxt(open(get_base_dir() + 'q0p3_total_20F.dat'))
25
+
26
+ dfp_0p25 = np.genfromtxt(open(get_base_dir() + 'q0p25_primary_20F.dat'))
27
+ dfs_0p25 = np.genfromtxt(open(get_base_dir() + 'q0p25_secondary_20F.dat'))
28
+ dfT_0p25 = np.genfromtxt(open(get_base_dir() + 'q0p25_total_20F.dat'))
29
+
30
+ dfp_0p15 = np.genfromtxt(open(get_base_dir() + 'q0p15_primary_20F.dat'))
31
+ dfs_0p15 = np.genfromtxt(open(get_base_dir() + 'q0p15_secondary_20F.dat'))
32
+ dfT_0p15 = np.genfromtxt(open(get_base_dir() + 'q0p15_total_20F.dat'))
33
+
34
+ dfp_0p1 = np.genfromtxt(open(get_base_dir() + 'q0p1_primary_20F.dat'))
35
+ dfs_0p1 = np.genfromtxt(open(get_base_dir() + 'q0p1_secondary_20F.dat'))
36
+ dfT_0p1 = np.genfromtxt(open(get_base_dir() + 'q0p1_total_20F.dat'))
37
+
38
+ dfp_0p05 = np.genfromtxt(open(get_base_dir() + 'q0p05_primary_20F.dat'))
39
+ dfs_0p05 = np.genfromtxt(open(get_base_dir() + 'q0p05_secondary_20F.dat'))
40
+ dfT_0p05 = np.genfromtxt(open(get_base_dir() + 'q0p05_total_20F.dat'))
41
+
42
+ dfp_0p01 = np.genfromtxt(open(get_base_dir() + 'q0p01_primary_20F.dat'))
43
+ dfs_0p01 = np.genfromtxt(open(get_base_dir() + 'q0p01_secondary_20F.dat'))
44
+ dfT_0p01 = np.genfromtxt(open(get_base_dir() + 'q0p01_total_20F.dat'))
45
+
46
+ dfp = [dfp_0p01, dfp_0p05, dfp_0p1, dfp_0p15, dfp_0p25, dfp_0p3, dfp_0p45, dfp_0p6, dfp_1p0]
47
+ dfs = [dfs_0p01, dfs_0p05, dfs_0p1, dfs_0p15, dfs_0p25, dfs_0p3, dfs_0p45, dfs_0p6, dfs_1p0]
48
+ dfT = [dfT_0p01, dfT_0p05, dfT_0p1, dfT_0p15, dfT_0p25, dfT_0p3, dfT_0p45, dfT_0p6, dfT_1p0]
49
+
50
+ #=================================================================================================================================
51
+ # MAGIC
52
+
53
+ class AccretionSeries:
54
+ """For generating mock timseries of accretion rates onto equal mass binaries of a desired eccentricity
55
+ - prograde binaries with e < 0.1 will recover additional 5-orbit features if n_orbs > 5
56
+ - retrograde binaries with e > 0.55 will recover additional 2-orbit features if n_orbs > 2
57
+
58
+ Parameters
59
+ ----------
60
+ eccentricity:
61
+ desired binary eccentricity for accretion series (0<e<0.8)
62
+ mass_ratio:
63
+ desired binary mass ratio for accretion series (max 1)
64
+ n_modes (optional, default=20):
65
+ number of modes to be used in constructing the series (max 20)
66
+ n_orbits (optional, default=10):
67
+ number of periods to generate
68
+ retrograde (optional, default=False):
69
+ whether the binary should be regarded as retrograde to the CBD (otherwise prograde assumed)
70
+
71
+ Public attributes
72
+ -----------------
73
+ time : values of the time associated with generated accretion series (in orbits)
74
+ primary : periodic accretion series for the primary component (in units of viscous feeding rate)
75
+ secondary : periodic accretion series for the secondary component (in units of viscous feeding rate)
76
+ total : total accretion rate series onto the binary (in units of viscous feeding rate)
77
+ """
78
+ def __init__(self, eccentricity: float, mass_ratio: float, n_modes: int = 10, n_orbits: int = 10):
79
+ self.ecc = eccentricity
80
+ self.q = mass_ratio
81
+ self.modes = n_modes
82
+ self.orbits = n_orbits
83
+
84
+ if n_modes > 20:
85
+ print("error : exceeded maximum number of prograde Fourier modes (20)")
86
+ quit()
87
+ if eccentricity > 0.8 or eccentricity == 0.0:
88
+ print("error : outside of eccentricity range: 0.0 < e < 0.8")
89
+ quit()
90
+
91
+ mode = 1
92
+ self.mode = mode
93
+
94
+ self.q_smpls = np.array([0.01,0.05,0.1,0.15,0.25,0.3,0.45,0.6,1.0])
95
+
96
+ if self.q != 1.0:
97
+ i1 = np.where(self.q >= self.q_smpls)[0][-1]
98
+ i2 = i1 + 1
99
+ else:
100
+ i1 = len(self.q_smpls) - 1
101
+ i2 = len(self.q_smpls) - 1
102
+
103
+ self.q1 = self.q_smpls[i1]
104
+ self.q2 = self.q_smpls[i2]
105
+
106
+ self.dataP1 = dfp[i1]
107
+ self.dataS1 = dfs[i1]
108
+ self.dataT1 = dfT[i1]
109
+
110
+ self.dataP2 = dfp[i2]
111
+ self.dataS2 = dfs[i2]
112
+ self.dataT2 = dfT[i2]
113
+
114
+ self.repeats = int(self.orbits) # Number of orbits
115
+ self.remainder = self.orbits % 1 # Remainder for non-integer orbits
116
+ self.e_smpls = np.transpose(self.dataT1)[:][2]
117
+ self.nx = len(self.dataP1) # Number of data points
118
+ self.x = np.linspace(0.0, 2. * np.pi, self.nx) # Space made for plotting
119
+
120
+ i = np.where(self.ecc >= self.e_smpls)[0][-1]
121
+ a01, a02 = self.dataT1[i][3], self.dataT2[i][3]
122
+ if self.q != 1.0:
123
+ self.a0 = ((self.q - self.q2) * a01 + (self.q1 - self.q) * a02) / (self.q1 - self.q2)
124
+ else:
125
+ self.a0 = a01
126
+
127
+
128
+ # Public attributes
129
+ # -------------------------------------------------------------------------
130
+ @property
131
+ def time(self):
132
+ xlong = [] # Initial array for time
133
+ for n in range(self.repeats):
134
+ xlong.append(self.x / 2. / np.pi + n) # Appends orbit number to array
135
+ xlong = np.concatenate(xlong)
136
+ idx = int(len(self.x) * self.remainder) # Finds fraction of an orbit
137
+ xtra = self.x[:idx] / 2. / np.pi + self.repeats # Appends fraction of an orbit
138
+ xlong = np.concatenate([xlong, xtra])
139
+ return xlong
140
+
141
+ @property
142
+ def primary(self):
143
+ """
144
+ Gives approximate accretion rate timeseries on primary (in units of the viscous feeding rate).
145
+
146
+ : return : (ndarray) periodic accretion rate timeseries
147
+ """
148
+ dm = self.__compute_signal_mode(self.dataP1, self.dataP2, self.mode)
149
+ dm = dm / self.a0
150
+ idx = int(len(dm) * self.remainder)
151
+ base = np.tile(dm, self.repeats)
152
+ return np.concatenate([base, dm[:idx]])
153
+
154
+ @property
155
+ def secondary(self):
156
+ """
157
+ Gives approximate accretion rate timeseries on secondary (in units of the viscous feeding rate).
158
+
159
+ : return : (ndarray) periodic accretion rate timeseries
160
+ """
161
+ dm = self.__compute_signal_mode(self.dataS1, self.dataS2, self.mode)
162
+ dm = dm / self.a0
163
+ idx = int(len(dm) * self.remainder)
164
+ base = np.tile(dm, self.repeats)
165
+ return np.concatenate([base, dm[:idx]])
166
+
167
+ @property
168
+ def total(self):
169
+ """
170
+ Gives approximate total accretion rate timeseries onto the binary (in units of the viscous feeding rate).
171
+
172
+ : return : (ndarray) periodic accretion rate timeseries
173
+ """
174
+ dm = self.__compute_signal_mode(self.dataT1, self.dataT2, self.mode)
175
+ dm = dm / self.a0
176
+ idx = int(len(dm) * self.remainder)
177
+ base = np.tile(dm, self.repeats)
178
+ return np.concatenate([base, dm[:idx]])
179
+
180
+ # Internal methods
181
+ # -------------------------------------------------------------------------
182
+ def __compute_signal_mode(self, data1, data2, m):
183
+ fs = []
184
+ i1 = np.where(self.ecc >= self.e_smpls)[0][-1]
185
+ i0 = i1 + 1
186
+ n = self.modes
187
+ e1 = self.e_smpls[i1]
188
+ e0 = self.e_smpls[i0]
189
+ a01 = data1[i1][3]
190
+ f11 = data1[i1][5:5+2*n]
191
+ f01 = data1[i0][5:5+2*n]
192
+ a02 = data2[i1][3]
193
+ f12 = data2[i1][5:5+2*n]
194
+ f02 = data2[i0][5:5+2*n]
195
+ fe1 = ((self.ecc - e0) * f11 + (e1 - self.ecc) * f01) / (e1 - e0) # interpolated coefficients
196
+ fe2 = ((self.ecc - e0) * f12 + (e1 - self.ecc) * f02) / (e1 - e0)
197
+ if self.q != 1.0:
198
+ fq = ((self.q - self.q2) * fe1 + (self.q1 - self.q) * fe2) / (self.q1 - self.q2)
199
+ a0 = ((self.q - self.q2) * a01 + (self.q1 - self.q) * a02) / (self.q1 - self.q2)
200
+ else:
201
+ fq = fe1
202
+ a0 = a01
203
+ for i in range(self.nx):
204
+ f = a0
205
+ for jj in range(n):
206
+ f += fq[2*jj] * np.cos((jj+1) * self.x[i] / m) + fq[2*jj+1] * np.sin((jj+1) * self.x[i] / m)
207
+ fs.append(f)
208
+ return np.array(fs)
209
+
210
+ # Direct user callable functions
211
+ # =============================================================================
212
+ def orbits(eccentricity: float, n_modes: int = 20, n_orbits: int = 10, retrograde: bool = False):
213
+ return AccretionSeries(eccentricity, n_modes=n_modes, n_orbits=n_orbits).time
214
+
215
+ def primary(eccentricity: float, n_modes: int = 20, n_orbits: int = 10, retrograde: bool = False):
216
+ return AccretionSeries(eccentricity, n_modes=n_modes, n_orbits=n_orbits).primary
217
+
218
+ def secondary(eccentricity: float, n_modes: int = 20, n_orbits: int = 10, retrograde: bool = False):
219
+ return AccretionSeries(eccentricity, n_modes=n_modes, n_orbits=n_orbits).secondary
220
+
221
+ def total(eccentricity: float, n_modes: int = 20, n_orbits: int = 10, retrograde: bool = False):
222
+ return AccretionSeries(eccentricity, n_modes=n_modes, n_orbits=n_orbits).total