RTModel 2.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.
@@ -0,0 +1,312 @@
1
+ // VBBinaryLensing v3.7 (2024)
2
+ //
3
+ // This code has been developed by Valerio Bozza (University of Salerno) and collaborators.
4
+ // Any use of this code for scientific publications should be acknowledged by a citation to:
5
+ // V. Bozza, E. Bachelet, F. Bartolic, T.M. Heintz, A.R. Hoag, M. Hundertmark, MNRAS 479 (2018) 5157
6
+ // If you use astrometry, user-defined limb darkening or Keplerian orbital motion, please cite
7
+ // V. Bozza, E. Khalouei and E. Bachelet (arXiv:2011.04780)
8
+ // The original methods present in v1.0 are described in
9
+ // V. Bozza, MNRAS 408 (2010) 2188
10
+ // Check the repository at http://www.fisica.unisa.it/GravitationAstrophysics/VBBinaryLensing.htm
11
+ // for the newest version.
12
+ //
13
+ // The code relies on the root solving algorithm by Jan Skworon and Andy Gould
14
+ // described in Skowron & Gould arXiv:1203.1034.
15
+ // Please also cite this paper if specifically relevant in your scientific publication.
16
+ // The original Fortran code available on http://www.astrouw.edu.pl/~jskowron/cmplx_roots_sg/
17
+ // has been translated to C++ by Tyler M. Heintz and Ava R. Hoag (2017)
18
+ //
19
+ // GNU Lesser General Public License applies to all parts of this code.
20
+ // Please read the separate LICENSE.txt file for more details.
21
+
22
+
23
+ #ifndef __binlens
24
+ #define __binlens
25
+ #define __unmanaged
26
+
27
+ #define _L1 x1-((x1+a/2.0)/((x1+a/2.0)*(x1+a/2.0)+x2*x2)+q*(x1-a/2.0)/((x1-a/2.0)*(x1-a/2.0)+x2*x2))/(1.0+q) // Used in PlotCrits
28
+ #define _L2 x2-(x2/((x1+a/2.0)*(x1+a/2.0)+x2*x2)+q*x2/((x1-a/2.0)*(x1-a/2.0)+x2*x2))/(1.0+q)
29
+ #define _LL (y-z)+coefs[21]/(zc-coefs[20])+coefs[22]/zc //Lens equation test
30
+ #define _J1c coefs[21]/((zc-coefs[20])*(zc-coefs[20]))+coefs[22]/(zc*zc) //#define _J1 m1/((zc-0.5*a)*(zc-0.5*a))+m2/((zc+0.5*a)*(zc+0.5*a))
31
+ #define _J2 -2.0*(coefs[21]/((z-coefs[20])*(z-coefs[20])*(z-coefs[20]))+coefs[22]/(z*z*z))
32
+ #define _J3 6.0*(coefs[21]/((z-coefs[20])*(z-coefs[20])*(z-coefs[20])*(z-coefs[20]))+coefs[22]/(z*z*z*z))
33
+ #define _skew(p1,p2,q1,q2) p1*q2-p2*q1
34
+ #define _NP 200.0
35
+ #define __rsize 151
36
+ #define __zsize 101
37
+
38
+ #define _sign(x) ((x>0)? +1 : -1)
39
+
40
+ #include<stdio.h>
41
+
42
+ class _curve;
43
+ class _sols;
44
+ class _theta;
45
+ class complex;
46
+ struct annulus;
47
+
48
+ #ifndef __unmanaged
49
+ namespace VBBinaryLensingLibrary {
50
+
51
+ public ref class VBBinaryLensing
52
+ #else
53
+ class VBBinaryLensing
54
+ #endif
55
+ {
56
+ protected:
57
+ int *ndatasat;
58
+ double **tsat,***possat;
59
+ double Mag0, corrquad, corrquad2, safedist;
60
+ int nim0;
61
+ double e,phi,phip,phi0,Om,inc,t0,d3,v3,GM,flagits;
62
+ double Obj[3],rad[3],tang[3],t0old;
63
+ double Eq2000[3],Quad2000[3],North2000[3];
64
+ double ESPLout[__rsize][__zsize], ESPLin[__rsize][__zsize],ESPLoutastro[__rsize][__zsize], ESPLinastro[__rsize][__zsize];
65
+ double *LDtab,*rCLDtab,*CLDtab;
66
+ double scr2, sscr2;
67
+ int npLD;
68
+ bool ESPLoff, multidark;
69
+ annulus *annlist;
70
+
71
+ void ComputeParallax(double, double, double *);
72
+ double LDprofile(double r);
73
+ double rCLDprofile(double tc,annulus *,annulus *);
74
+ double BinaryMagSafe(double s, double q, double y1, double y2, double rho, _sols **images);
75
+ _curve *NewImages(complex,complex *,_theta *);
76
+ void OrderImages(_sols *,_curve *);
77
+ void cmplx_laguerre(complex *, int, complex *, int &, bool &);
78
+ void cmplx_newton_spec(complex *, int, complex *, int &, bool &);
79
+ void cmplx_laguerre2newton(complex *, int, complex *, int &, bool &, int);
80
+ void solve_quadratic_eq(complex &, complex &, complex *);
81
+ void solve_cubic_eq(complex &, complex &, complex &, complex *);
82
+
83
+ public:
84
+
85
+ double Tol, RelTol, a1,a2, t0_par;
86
+ double mass_radius_exponent, mass_luminosity_exponent;
87
+ bool astrometry;
88
+ int satellite,parallaxsystem,t0_par_fixed,nsat;
89
+ int minannuli,nannuli,NPS,NPcrit;
90
+ double y_1,y_2,av, therr,astrox1,astrox2;
91
+
92
+
93
+ // Critical curves and caustic calculation
94
+ _sols *PlotCrit(double a,double q);
95
+ void PrintCau(double a,double q,double y1, double y2, double rho);
96
+
97
+ // Initialization for calculations including parallax
98
+ void SetObjectCoordinates(char *Coordinates_file, char *Directory_for_satellite_tables);
99
+ void SetObjectCoordinates(char *CoordinateString);
100
+
101
+ // Magnification calculation functions.
102
+
103
+ double BinaryMag0(double s,double q,double y1,double y2, _sols **Images);
104
+ double BinaryMag0(double s, double q, double y1, double y2);
105
+ double BinaryMag(double s,double q,double y1,double y2,double rho,double accuracy, _sols **Images);
106
+ double BinaryMag(double s,double q ,double y1,double y2,double rho,double accuracy);
107
+ double BinaryMag2(double s, double q, double y1, double y2, double rho);
108
+ double BinaryMagDark(double s, double q, double y1, double y2, double rho,double accuracy);
109
+ void BinaryMagMultiDark(double s, double q, double y1, double y2, double rho, double *a1_list, int n_filters, double *mag_list, double accuracy);
110
+
111
+ // Limb Darkening control
112
+ enum LDprofiles { LDlinear, LDquadratic, LDsquareroot, LDlog, LDuser};
113
+ void SetLDprofile(double(*UserLDprofile)(double), int tablesampling);
114
+ void SetLDprofile(LDprofiles);
115
+
116
+ // ESPL functions
117
+ void LoadESPLTable(char *tablefilename);
118
+ double ESPLMag(double u, double rho);
119
+ double ESPLMag2(double u, double rho);
120
+ double ESPLMagDark(double u, double rho);
121
+ double PSPLMag(double u);
122
+
123
+
124
+ // New (v2) light curve functions, operating on arrays
125
+
126
+ void PSPLLightCurve(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, int np);
127
+ void PSPLLightCurveParallax(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, int np);
128
+ void ESPLLightCurve(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, int np);
129
+ void ESPLLightCurveParallax(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, int np);
130
+
131
+ void BinaryLightCurve(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, int np);
132
+ void BinaryLightCurveW(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, int np);
133
+ void BinaryLightCurveParallax(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, int np);
134
+ void BinaryLightCurveOrbital(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, double *sep_array, int np);
135
+ void BinaryLightCurveKepler(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, double *sep_array, int np);
136
+
137
+ void BinSourceLightCurve(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, int np);
138
+ void BinSourceLightCurveParallax(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, int np);
139
+ void BinSourceLightCurveXallarap(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, double *sep_array, int np);
140
+ void BinSourceExtLightCurve(double* parameters, double* t_array, double* mag_array, double* y1_array, double* y2_array, int np);
141
+ void BinSourceSingleLensXallarap(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, double *y1_array2, double *y2_array2, int np);
142
+ void BinSourceBinLensXallarap(double *parameters, double *t_array, double *mag_array, double *y1_array, double *y2_array, int np);
143
+
144
+ // Old (v1) light curve functions, for a single calculation
145
+ double PSPLLightCurve(double *parameters, double t);
146
+ double PSPLLightCurveParallax(double *parameters, double t);
147
+ double ESPLLightCurve(double *parameters, double t);
148
+ double ESPLLightCurveParallax(double *parameters, double t);
149
+
150
+ double BinaryLightCurve(double *parameters,double t);
151
+ double BinaryLightCurveW(double *parameters, double t);
152
+ double BinaryLightCurveParallax(double *parameters, double t);
153
+ double BinaryLightCurveOrbital(double *parameters, double t);
154
+ double BinaryLightCurveKepler(double *parameters, double t);
155
+
156
+ double BinSourceLightCurve(double *parameters, double t);
157
+ double BinSourceLightCurveParallax(double *parameters, double t);
158
+ double BinSourceLightCurveXallarap(double *parameters, double t);
159
+ double BinSourceExtLightCurve(double* parameters, double t);
160
+ double BinSourceBinLensXallarap(double *parameters, double t);
161
+ double BinSourceSingleLensXallarap(double *parameters, double t);
162
+ double BinSourceBinLensPOX(double* parameters, double t);
163
+
164
+ // Skowron & Gould root calculator
165
+ void cmplx_roots_gen(complex *, complex *, int, bool, bool);
166
+
167
+ // Constructor and destructor
168
+
169
+ VBBinaryLensing();
170
+ ~VBBinaryLensing();
171
+
172
+ private:
173
+ LDprofiles curLDprofile;
174
+ };
175
+
176
+ struct annulus{
177
+ double bin;
178
+ double cum;
179
+ double Mag;
180
+ double err;
181
+ double f;
182
+ int nim;
183
+ double LDastrox1,LDastrox2;
184
+ annulus *prev,*next;
185
+ };
186
+
187
+
188
+ #ifndef __unmanaged
189
+ }
190
+ #endif
191
+
192
+
193
+ class _theta{
194
+ public:
195
+ double th,maxerr,Mag,errworst,astrox1,astrox2;
196
+ _theta *prev,*next;
197
+
198
+ _theta(double);
199
+
200
+ };
201
+
202
+ class _thetas{
203
+ public:
204
+ _theta *first,*last;
205
+ int length;
206
+
207
+ _thetas(void);
208
+ ~_thetas(void);
209
+ _theta *insert(double);
210
+ void remove(_theta*);
211
+
212
+
213
+ };
214
+
215
+ class complex{
216
+ public:
217
+ double re;
218
+ double im;
219
+ complex(double,double);
220
+ complex(double);
221
+ complex(void);
222
+ };
223
+
224
+ class _point{
225
+ public:
226
+ double x1;
227
+ double x2;
228
+ double parab,ds,dJ,parabastrox1,parabastrox2;
229
+ complex d,J2;
230
+ _theta *theta;
231
+ _point(double ,double,_theta *);
232
+ _point *next,*prev;
233
+ double operator-(_point);
234
+ };
235
+
236
+ class _curve{
237
+ public:
238
+ int length;
239
+ _point *first,*last;
240
+ _curve *next,*prev;
241
+ _curve *partneratstart,*partneratend;
242
+ double parabstart,parabastrox1,parabastrox2;
243
+
244
+ _curve(_point *);
245
+ _curve(void);
246
+ ~_curve(void);
247
+
248
+ _curve *divide(_point *);
249
+ void drop(_point *);
250
+ void append(double,double);
251
+ void append(_point *);
252
+ void prepend(double,double);
253
+ // void prepend(_point *);
254
+ _curve *join(_curve *);
255
+ _curve *joinbefore(_curve *);
256
+ _curve *reverse(void);
257
+ double closest(_point *,_point **);
258
+ double closest2(_point *,_point **);
259
+ void complement(_point **,int,_point **,int);
260
+ };
261
+
262
+ class _sols{
263
+ public:
264
+ int length;
265
+ _curve *first,*last;
266
+
267
+ _sols(void);
268
+ ~_sols(void);
269
+ void drop(_curve *);
270
+ void append(_curve *);
271
+ void prepend(_curve *);
272
+ void join(_sols *);
273
+ };
274
+
275
+
276
+ #define MR 8
277
+ #define MT 10
278
+ #define MAXIT (MT*MR)
279
+ #define MAXM 30
280
+
281
+ #endif
282
+
283
+ double abs(complex);
284
+ complex conj(complex);
285
+ complex sqrt(complex);
286
+ double real(complex);
287
+ double imag(complex);
288
+ complex expcmplx(complex);
289
+ complex cbrt(complex);
290
+ complex operator+(complex, complex);
291
+ complex operator-(complex, complex);
292
+ complex operator*(complex, complex);
293
+ complex operator/(complex, complex);
294
+ complex operator+(complex, double);
295
+ complex operator-(complex, double);
296
+ complex operator*(complex, double);
297
+ complex operator/(complex, double);
298
+ complex operator+(double, complex);
299
+ complex operator-(double, complex);
300
+ complex operator*(double, complex);
301
+ complex operator/(double, complex);
302
+ complex operator+(int, complex);
303
+ complex operator-(int, complex);
304
+ complex operator*(int, complex);
305
+ complex operator/(int, complex);
306
+ complex operator+(complex, int);
307
+ complex operator-(complex, int);
308
+ complex operator*(complex, int);
309
+ complex operator/(complex, int);
310
+ complex operator-(complex);
311
+ bool operator==(complex, complex);
312
+ bool operator!=(complex, complex);
@@ -0,0 +1,32 @@
1
+ // bumper.h
2
+ // Definition of the bumper class containing information on a single model
3
+
4
+ #ifndef _bumper
5
+ #define _bumper
6
+
7
+ // Bumper class is the penalty function to be used to fill minima in chi square
8
+ class bumper{
9
+ public:
10
+ double *p0;
11
+ double *dp;
12
+ double *curv, *cov;
13
+ double Amp;
14
+ int nps;
15
+ char modelcode[16];
16
+ int il;
17
+ bumper(double *,int);
18
+ ~bumper();
19
+ void SetCurvature(double *,double);
20
+ void SetCovariance(double*, double);
21
+ void UpdateCurvature(double);
22
+ void signCovariance(int);
23
+ void flipCovariance(int, int);
24
+ double distance(double *);
25
+ bumper *next;
26
+ };
27
+
28
+ double Determinant(double *,int);
29
+ void Inverse(double*, double*, int);
30
+ void CombineCovariances(bumper*, bumper*, double *Cov, double * Curv, int);
31
+
32
+ #endif