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.
- RTModel/RTModel.py +293 -0
- RTModel/__init__.py +5 -0
- RTModel/bin/Finalizer.exe +0 -0
- RTModel/bin/InitCond.exe +0 -0
- RTModel/bin/LevMar.exe +0 -0
- RTModel/bin/ModelSelector.exe +0 -0
- RTModel/bin/Reader.exe +0 -0
- RTModel/data/ESPL.tbl +0 -0
- RTModel/data/TemplateLibrary.txt +114 -0
- RTModel/include/LevMarFit.h +81 -0
- RTModel/include/VBBinaryLensingLibrary.h +312 -0
- RTModel/include/bumper.h +32 -0
- RTModel/lib/Finalizer.cpp +412 -0
- RTModel/lib/InitCond.cpp +1398 -0
- RTModel/lib/LevMar.cpp +12 -0
- RTModel/lib/LevMarFit.cpp +1277 -0
- RTModel/lib/ModelSelector.cpp +913 -0
- RTModel/lib/Reader.cpp +670 -0
- RTModel/lib/VBBinaryLensingLibrary.cpp +4986 -0
- RTModel/lib/bumper.cpp +168 -0
- RTModel/plotmodel/__init__.py +5 -0
- RTModel/plotmodel/plotmodel.py +452 -0
- RTModel-2.0.dist-info/LICENSE +165 -0
- RTModel-2.0.dist-info/METADATA +61 -0
- RTModel-2.0.dist-info/RECORD +27 -0
- RTModel-2.0.dist-info/WHEEL +5 -0
- RTModel-2.0.dist-info/top_level.txt +1 -0
RTModel/RTModel.py
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
|
|
2
|
+
import subprocess
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import glob
|
|
6
|
+
import time
|
|
7
|
+
import inspect
|
|
8
|
+
from tqdm import tqdm
|
|
9
|
+
import shutil
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class RTModel:
|
|
13
|
+
def __init__(self, event = None):
|
|
14
|
+
# Directory preliminaries
|
|
15
|
+
print('*********************')
|
|
16
|
+
print('**** RTModel ****')
|
|
17
|
+
print('*********************')
|
|
18
|
+
self.pathtoRTM = inspect.getfile(RTModel)
|
|
19
|
+
self.bindir = os.path.dirname(self.pathtoRTM) + '/bin/'
|
|
20
|
+
if os.name =='nt':
|
|
21
|
+
self.readerexe = 'Reader.exe'
|
|
22
|
+
self.initcondexe = 'InitCond.exe'
|
|
23
|
+
self.levmarexe = 'LevMar.exe'
|
|
24
|
+
self.modelselectorexe = 'ModelSelector.exe'
|
|
25
|
+
self.finalizerexe = 'Finalizer.exe'
|
|
26
|
+
else:
|
|
27
|
+
self.readerexe = 'Reader'
|
|
28
|
+
self.initcondexe = 'InitCond'
|
|
29
|
+
self.levmarexe = 'LevMar'
|
|
30
|
+
self.modelselectorexe = 'ModelSelector'
|
|
31
|
+
self.finalizerexe = 'Finalizer'
|
|
32
|
+
if(event == None):
|
|
33
|
+
self.eventname = os.getcwd()
|
|
34
|
+
else:
|
|
35
|
+
self.eventname = os.path.realpath(event)
|
|
36
|
+
print("Event name: " + self.eventname)
|
|
37
|
+
self.inidir = "ini"
|
|
38
|
+
self.modelcodes = ['PS', 'PX', 'BS', 'BO', 'LS', 'LX', 'LO']
|
|
39
|
+
self.endphase = len(self.modelcodes)*2+3
|
|
40
|
+
self.eventinifile = 'event.ini'
|
|
41
|
+
self.nprocessors = os.cpu_count()
|
|
42
|
+
print('Number of processors: {}'.format(self.nprocessors))
|
|
43
|
+
self.config_Reader()
|
|
44
|
+
self.config_InitCond()
|
|
45
|
+
self.config_LevMar()
|
|
46
|
+
self.config_ModelSelector()
|
|
47
|
+
self.satellitedir = '.'
|
|
48
|
+
|
|
49
|
+
def set_processors(self, nprocessors):
|
|
50
|
+
self.nprocessors = nprocessors
|
|
51
|
+
|
|
52
|
+
def set_event(self, event):
|
|
53
|
+
self.eventname = os.path.realpath(event)
|
|
54
|
+
|
|
55
|
+
def set_satellite_dir(self, satellitedir):
|
|
56
|
+
self.satellitedir = satellitedir
|
|
57
|
+
|
|
58
|
+
def config_Reader(self, tau = 0.1, binning = 4000, otherseasons = 1, renormalize = 1, thresholdoutliers = 10):
|
|
59
|
+
self.Reader_tau= tau # conventional correlation time for consecutive points
|
|
60
|
+
self.Reader_binning = binning # maximum number of points left after re-binning
|
|
61
|
+
self.Reader_otherseasons = otherseasons # How to use other seasons (0 = Yes, 1 = decrease significance, 2 = remove)
|
|
62
|
+
self.Reader_renormalize = renormalize # Re-normalize error bars if non-zero
|
|
63
|
+
self.Reader_thresholdoutliers = thresholdoutliers # Threshold in sigmas for removing outliers
|
|
64
|
+
|
|
65
|
+
def Reader(self):
|
|
66
|
+
if(not os.path.exists(self.eventname + '/' + self.inidir)):
|
|
67
|
+
os.makedirs(self.eventname + '/' + self.inidir)
|
|
68
|
+
with open(self.eventname + '/' + self.inidir + '/Reader.ini','w') as f:
|
|
69
|
+
f.write('tau = ' + str(self.Reader_tau) + '\n')
|
|
70
|
+
f.write('binning = ' + str(self.Reader_binning) + '\n')
|
|
71
|
+
f.write('otherseasons = ' + str(self.Reader_otherseasons) + '\n')
|
|
72
|
+
f.write('renormalize = ' + str(self.Reader_renormalize) + '\n')
|
|
73
|
+
f.write('thresholdoutliers = ' + str(self.Reader_thresholdoutliers) + '\n')
|
|
74
|
+
print('- Launching: Reader')
|
|
75
|
+
print(' Pre-processing data...')
|
|
76
|
+
completedprocess = subprocess.run([self.bindir+self.readerexe,self.eventname], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
|
|
77
|
+
if(completedprocess.returncode != 0):
|
|
78
|
+
print('! Error in pre-processing. Please check your data!')
|
|
79
|
+
self.done = True
|
|
80
|
+
else:
|
|
81
|
+
print(' OK')
|
|
82
|
+
|
|
83
|
+
def config_InitCond(self, npeaks = 2, peakthreshold = 10.0, oldmodels = 4, override = None, nostatic = False, onlyorbital = False, usesatellite = 0):
|
|
84
|
+
self.InitCond_npeaks = npeaks # Number of peaks in the observed light curve to be considered for setting initial conditions.
|
|
85
|
+
self.InitCond_peakthreshold = peakthreshold # Number of sigmas necessary for a deviation to be identified as a maximum or a minimum.
|
|
86
|
+
self.InitCond_oldmodels = oldmodels # Maximum number of old models to include in new run as initial conditions
|
|
87
|
+
self.InitCond_override = override # Override peak identification and manually set peak times
|
|
88
|
+
self.InitCond_nostatic = nostatic or onlyorbital # No static models will be calculated.
|
|
89
|
+
self.InitCond_noparallax = onlyorbital; # Only orbital motion models will be calculated.
|
|
90
|
+
self.InitCond_usesatellite = usesatellite; # Satellite to be used for initial conditions. Ground telescopes by default.
|
|
91
|
+
|
|
92
|
+
def InitCond(self):
|
|
93
|
+
if(not os.path.exists(self.eventname + '/' + self.inidir)):
|
|
94
|
+
os.makedirs(self.eventname + '/' + self.inidir)
|
|
95
|
+
with open(self.eventname + '/' + self.inidir + '/InitCond.ini','w') as f:
|
|
96
|
+
f.write('npeaks = ' + str(self.InitCond_npeaks) + '\n')
|
|
97
|
+
f.write('peakthreshold = ' + str(self.InitCond_peakthreshold) + '\n')
|
|
98
|
+
f.write('oldmodels = ' + str(self.InitCond_oldmodels) + '\n')
|
|
99
|
+
f.write('usesatellite = ' + str(self.InitCond_usesatellite) + '\n')
|
|
100
|
+
if(self.InitCond_nostatic):
|
|
101
|
+
f.write('nostatic = 1\n')
|
|
102
|
+
if(self.InitCond_noparallax):
|
|
103
|
+
f.write('noparallax = 1\n')
|
|
104
|
+
if(self.InitCond_override != None):
|
|
105
|
+
f.write('override = ' + str(self.InitCond_override[0])+ ' ' + str(self.InitCond_override[1]) + '\n')
|
|
106
|
+
print('- Launching: InitCond')
|
|
107
|
+
print(' Setting initial conditions...')
|
|
108
|
+
completedprocess = subprocess.run([self.bindir+self.initcondexe,self.eventname], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
|
|
109
|
+
if(completedprocess.returncode != 0):
|
|
110
|
+
print('! Error in setting initial conditions!')
|
|
111
|
+
self.done = True
|
|
112
|
+
else:
|
|
113
|
+
print(' OK')
|
|
114
|
+
|
|
115
|
+
def config_LevMar(self, nfits = 5, timelimit = 600.0, maxsteps = 50, bumperpower = 2.0):
|
|
116
|
+
self.LevMar_nfits = nfits # Number of models to be calculated from the same initial condition using the bumper method
|
|
117
|
+
self.LevMar_maxsteps = maxsteps # Maximum number of steps in each fit
|
|
118
|
+
self.LevMar_timelimit = timelimit # Maximum time in seconds for total execution
|
|
119
|
+
self.LevMar_bumperpower = bumperpower # Repulsion factor of bumpers
|
|
120
|
+
|
|
121
|
+
def LevMar(self,strmodel):
|
|
122
|
+
if(not os.path.exists(self.eventname + '/' + self.inidir)):
|
|
123
|
+
os.makedirs(self.eventname + '/' + self.inidir)
|
|
124
|
+
with open(self.eventname + '/' + self.inidir + '/LevMar.ini','w') as f:
|
|
125
|
+
f.write('nfits = ' + str(self.LevMar_nfits) + '\n')
|
|
126
|
+
f.write('maxsteps = ' + str(self.LevMar_maxsteps) + '\n')
|
|
127
|
+
f.write('timelimit = ' + str(self.LevMar_timelimit) + '\n')
|
|
128
|
+
f.write('bumperpower = ' + str(self.LevMar_bumperpower) + '\n')
|
|
129
|
+
print('- Launching: LevMar')
|
|
130
|
+
print(' Fitting ' + strmodel + ' ...')
|
|
131
|
+
completedprocess = subprocess.run([self.bindir+self.levmarexe,self.eventname, strmodel,self.satellitedir], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
|
|
132
|
+
if(completedprocess.returncode != 0):
|
|
133
|
+
print('! Error in fit!')
|
|
134
|
+
self.done = True
|
|
135
|
+
else:
|
|
136
|
+
print(' OK')
|
|
137
|
+
|
|
138
|
+
def launch_fits(self,modelcode):
|
|
139
|
+
if(not os.path.exists(self.eventname + '/' + self.inidir)):
|
|
140
|
+
os.makedirs(self.eventname + '/' + self.inidir)
|
|
141
|
+
with open(self.eventname + '/' + self.inidir + '/LevMar.ini','w') as f:
|
|
142
|
+
f.write('nfits = ' + str(self.LevMar_nfits) + '\n')
|
|
143
|
+
f.write('maxsteps = ' + str(self.LevMar_maxsteps) + '\n')
|
|
144
|
+
f.write('timelimit = ' + str(self.LevMar_timelimit) + '\n')
|
|
145
|
+
f.write('bumperpower = ' + str(self.LevMar_bumperpower) + '\n')
|
|
146
|
+
stringfits = {'PS' : '- Single-lens-Single-source fits',
|
|
147
|
+
'PX' : '- Single-lens-Single-source fits with parallax',
|
|
148
|
+
'BS' : '- Single-lens-Binary-source fits',
|
|
149
|
+
'BO' : '- Single-lens-Binary-source fits with xallarap',
|
|
150
|
+
'LS' : '- Binary-lens-Single-source fits',
|
|
151
|
+
'LX' : '- Binary-lens-Single-source fits with parallax',
|
|
152
|
+
'LO' : '- Binary-lens-Single-source fits with orbital motion'}
|
|
153
|
+
print(stringfits[modelcode])
|
|
154
|
+
initcondfile = self.eventname + '/InitCond/' + 'InitCond'+ modelcode + '.txt'
|
|
155
|
+
if(os.path.exists(initcondfile)):
|
|
156
|
+
with open(self.eventname + '/InitCond/' + 'InitCond'+ modelcode + '.txt') as f:
|
|
157
|
+
line = f.readline().split()
|
|
158
|
+
npeaks = int(line[0])
|
|
159
|
+
ninitconds = int(line[1])
|
|
160
|
+
processes = []
|
|
161
|
+
procnumbers = []
|
|
162
|
+
iinitcond = 0
|
|
163
|
+
finitcond = 0
|
|
164
|
+
finitcondold = -1
|
|
165
|
+
pbar = tqdm(total = ninitconds,desc = 'Fits completed',file=sys.stdout, colour='GREEN', smoothing = 0)
|
|
166
|
+
while(finitcond < ninitconds):
|
|
167
|
+
i=0
|
|
168
|
+
while i < len(processes):
|
|
169
|
+
if(processes[i].poll() != None):
|
|
170
|
+
processes.pop(i)
|
|
171
|
+
procnumbers.pop(i)
|
|
172
|
+
finitcond += 1
|
|
173
|
+
else:
|
|
174
|
+
i += 1
|
|
175
|
+
while(iinitcond < ninitconds and len(processes) < self.nprocessors):
|
|
176
|
+
strmodel = modelcode + '{:0>4}'.format(str(iinitcond))
|
|
177
|
+
if(glob.glob(self.eventname +'/PreModels/' + strmodel + '/t' + strmodel + '.dat')==[]):
|
|
178
|
+
processes.append(subprocess.Popen([self.bindir+self.levmarexe,self.eventname, strmodel,self.satellitedir], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL))
|
|
179
|
+
procnumbers.append(iinitcond)
|
|
180
|
+
else:
|
|
181
|
+
finitcond += 1
|
|
182
|
+
iinitcond += 1
|
|
183
|
+
if(finitcond != finitcondold):
|
|
184
|
+
#print(' Fits launched: {}; completed: {}/{}'.format(iinitcond, finitcond, ninitconds))
|
|
185
|
+
pbar.update(finitcond - max(finitcondold,0))
|
|
186
|
+
finitcondold =finitcond
|
|
187
|
+
time.sleep(0.1)
|
|
188
|
+
pbar.close()
|
|
189
|
+
else:
|
|
190
|
+
print('- No initial conditions for this class')
|
|
191
|
+
|
|
192
|
+
def config_ModelSelector(self, sigmasoverlap = 3.0, sigmachisquare = 1.0, maxmodels = 10):
|
|
193
|
+
self.ModelSelector_sigmasoverlap = sigmasoverlap # factor multiplying the inverse covariance in search for superpositions (models are incompatible if farther than sigmasoverlap*sigma)
|
|
194
|
+
self.ModelSelector_sigmachisquare = sigmachisquare # number of sigmas in the chi square distribution for accepting alternative models after the best one
|
|
195
|
+
self.ModelSelector_maxmodels = maxmodels # maximum number of models returned
|
|
196
|
+
|
|
197
|
+
def ModelSelector(self, modelcode):
|
|
198
|
+
if(not os.path.exists(self.eventname + '/' + self.inidir)):
|
|
199
|
+
os.makedirs(self.eventname + '/' + self.inidir)
|
|
200
|
+
with open(self.eventname + '/' + self.inidir + '/ModelSelector.ini','w') as f:
|
|
201
|
+
f.write('sigmasoverlap = ' + str(self.ModelSelector_sigmasoverlap) + '\n')
|
|
202
|
+
f.write('sigmachisquare = ' + str(self.ModelSelector_sigmachisquare) + '\n')
|
|
203
|
+
f.write('maxmodels = ' + str(self.ModelSelector_maxmodels) + '\n')
|
|
204
|
+
stringmodels = {'PS' : '- Selecting models for Single-lens-Single-source fits',
|
|
205
|
+
'PX' : '- Selecting models for Single-lens-Single-source fits with parallax',
|
|
206
|
+
'BS' : '- Selecting models for Single-lens-Binary-source fits',
|
|
207
|
+
'BO' : '- Selecting models for Single-lens-Binary-source fits with xallarap',
|
|
208
|
+
'LS' : '- Selecting models for Binary-lens-Single-source fits',
|
|
209
|
+
'LX' : '- Selecting models for Binary-lens-Single-source fits with parallax',
|
|
210
|
+
'LO' : '- Selecting models for Binary-lens-Single-source fits with orbital motion'}
|
|
211
|
+
print(stringmodels[modelcode])
|
|
212
|
+
completedprocess = subprocess.run([self.bindir+self.modelselectorexe,self.eventname, modelcode], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
|
|
213
|
+
if(completedprocess.returncode != 0):
|
|
214
|
+
print('! Error in model selection!')
|
|
215
|
+
self.done = True
|
|
216
|
+
else:
|
|
217
|
+
print(' OK')
|
|
218
|
+
|
|
219
|
+
def Finalizer(self):
|
|
220
|
+
print('- Launching: Finalizer')
|
|
221
|
+
print(' Making final assessment for this event')
|
|
222
|
+
completedprocess = subprocess.run([self.bindir+self.finalizerexe,self.eventname], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
|
|
223
|
+
if(completedprocess.returncode != 0):
|
|
224
|
+
print('! Error in finalization. Maybe there are problems with models')
|
|
225
|
+
self.done = True
|
|
226
|
+
else:
|
|
227
|
+
with open(self.eventname + '/Nature.txt') as f:
|
|
228
|
+
for line in f.readlines():
|
|
229
|
+
print(" " + line,end='')
|
|
230
|
+
print(" OK")
|
|
231
|
+
|
|
232
|
+
def run(self, event = None):
|
|
233
|
+
phase =0
|
|
234
|
+
if(event!= None):
|
|
235
|
+
self.eventname = os.path.realpath(event)
|
|
236
|
+
self.done = False
|
|
237
|
+
while not(self.done):
|
|
238
|
+
print("o " + time.asctime())
|
|
239
|
+
# Check that event directory exists
|
|
240
|
+
if phase == 0:
|
|
241
|
+
if(os.path.exists(self.eventname + '/Data')):
|
|
242
|
+
print('- Analyzing event: ',self.eventname)
|
|
243
|
+
phase = 1
|
|
244
|
+
else:
|
|
245
|
+
print('! Event data for ' + self.eventname + ' not found !')
|
|
246
|
+
self.done = True
|
|
247
|
+
# Launch Reader
|
|
248
|
+
elif phase == 1:
|
|
249
|
+
self.Reader()
|
|
250
|
+
phase = 2
|
|
251
|
+
# Launch InitCond
|
|
252
|
+
elif phase == 2:
|
|
253
|
+
self.InitCond()
|
|
254
|
+
phase = 3
|
|
255
|
+
# Launch Finalizer
|
|
256
|
+
elif phase == self.endphase:
|
|
257
|
+
self.Finalizer()
|
|
258
|
+
phase += 1
|
|
259
|
+
# Conclude analysis
|
|
260
|
+
elif phase > self.endphase:
|
|
261
|
+
print("- Analysis of " + self.eventname + " successfully completed!")
|
|
262
|
+
self.done = True
|
|
263
|
+
# Launch LevMar for next class
|
|
264
|
+
elif phase%2 == 1:
|
|
265
|
+
self.launch_fits(self.modelcodes[phase//2-1])
|
|
266
|
+
phase += 1
|
|
267
|
+
# Launch ModelSelector for this class
|
|
268
|
+
else:
|
|
269
|
+
self.ModelSelector(self.modelcodes[phase//2-2])
|
|
270
|
+
phase += 1
|
|
271
|
+
|
|
272
|
+
def archive_run(self, destination = None):
|
|
273
|
+
olddir = os.getcwd()
|
|
274
|
+
os.chdir(self.eventname)
|
|
275
|
+
if(os.path.exists('LCToFit.txt')):
|
|
276
|
+
previousrunslist = glob.glob('run-*')
|
|
277
|
+
previousrunslist.sort()
|
|
278
|
+
if(destination == None):
|
|
279
|
+
if(len(previousrunslist)>0):
|
|
280
|
+
lastrun = int(previousrunslist[-1].split('-')[-1])
|
|
281
|
+
else:
|
|
282
|
+
lastrun = 0
|
|
283
|
+
rundir = 'run-' + str(lastrun+1). zfill(4)
|
|
284
|
+
else:
|
|
285
|
+
rundir = destination
|
|
286
|
+
alllist = glob.glob('*')
|
|
287
|
+
alllist.remove('Data')
|
|
288
|
+
filelist = list(set(alllist) - set(previousrunslist))
|
|
289
|
+
os.mkdir(rundir)
|
|
290
|
+
shutil.copytree('Data',rundir+'/Data')
|
|
291
|
+
for nam in filelist:
|
|
292
|
+
shutil.move(nam,rundir)
|
|
293
|
+
os.chdir(olddir)
|
RTModel/__init__.py
ADDED
|
Binary file
|
RTModel/bin/InitCond.exe
ADDED
|
Binary file
|
RTModel/bin/LevMar.exe
ADDED
|
Binary file
|
|
Binary file
|
RTModel/bin/Reader.exe
ADDED
|
Binary file
|
RTModel/data/ESPL.tbl
ADDED
|
Binary file
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
113
|
|
2
|
+
0.7 0.5 0.15 3.5 0.01 -0.183 0.016
|
|
3
|
+
0.7 0.5 0.15 3.5 0.01 -0.183 0.086
|
|
4
|
+
0.7 0.5 0.15 3.5 0.01 0.016 0.086
|
|
5
|
+
0.7 0.1 0. 5.38 0.01 -0.066 0.025
|
|
6
|
+
0.7 0.1 0. 5.38 0.01 -0.066 0.305
|
|
7
|
+
0.7 0.1 0. 5.38 0.01 0.025 0.305
|
|
8
|
+
0.7 0.5 0. 2. 0.01 -1.202 -0.113
|
|
9
|
+
0.7 0.5 0. 2. 0.01 -1.202 0.138
|
|
10
|
+
0.7 0.5 0. 2. 0.01 -0.113 0.138
|
|
11
|
+
0.7 0.5 -0.1 1.57 0.01 -0.508 -0.013
|
|
12
|
+
0.7 0.5 -0.1 1.57 0.01 -0.508 0.013
|
|
13
|
+
0.7 0.5 -0.1 1.57 0.01 -0.013 0.013
|
|
14
|
+
0.7 0.5 0.1 1.35 0.01 -0.082 0.075
|
|
15
|
+
0.7 0.5 0.1 1.35 0.01 -0.082 1.121
|
|
16
|
+
0.7 0.5 0.1 1.35 0.01 0.075 1.121
|
|
17
|
+
0.65 0.1 0.52 5. 0.01 -0.291 0.871
|
|
18
|
+
0.65 0.1 0.52 5. 0.01 -0.291 0.879
|
|
19
|
+
0.65 0.1 0.52 5. 0.01 0.871 0.879
|
|
20
|
+
0.7 0.5 -0.35 1.5 0.01 -1.017 -0.975
|
|
21
|
+
0.7 0.5 -0.35 1.5 0.01 -1.017 0.015
|
|
22
|
+
0.7 0.5 -0.35 1.5 0.01 -0.975 0.015
|
|
23
|
+
0.7 0.5 0.8 4. 0.01 0.045 0.552
|
|
24
|
+
0.7 0.5 0.8 4. 0.01 0.045 0.605
|
|
25
|
+
0.7 0.5 0.8 4. 0.01 0.552 0.605
|
|
26
|
+
0.7 0.1 0.1 4.6 0.01 -0.208 -0.007
|
|
27
|
+
0.7 0.1 0.1 4.6 0.01 -0.208 0.149
|
|
28
|
+
0.7 0.1 0.1 4.6 0.01 -0.007 0.149
|
|
29
|
+
0.7 0.5 -0.2 1.4 0.01 -0.516 0.031
|
|
30
|
+
0.7 0.5 -0.2 1.4 0.01 -0.516 1.129
|
|
31
|
+
0.7 0.5 -0.2 1.4 0.01 0.031 1.129
|
|
32
|
+
0.7 0.5 0.3 1.93 0.01 -1.119 0.106
|
|
33
|
+
0.7 0.1 0.25 5.3 0.01 -0.102 0.914
|
|
34
|
+
0.7 0.5 1.12 3.2 0.01 -0.326 -0.095
|
|
35
|
+
0.7 0.1 0.75 4.6 0.01 -0.743 0.032
|
|
36
|
+
0.7 0.1 0.75 4.6 0.01 -0.743 0.54
|
|
37
|
+
0.7 0.1 0.75 4.6 0.01 0.032 0.54
|
|
38
|
+
0.9 0.03 -0.15 2. 0.01 -0.277 0.066
|
|
39
|
+
0.9 0.03 -0.15 2. 0.01 -0.277 0.09
|
|
40
|
+
0.9 0.03 -0.15 2. 0.01 0.066 0.09
|
|
41
|
+
0.9 0.03 -0.1 1.6 0.01 -0.151 -0.122
|
|
42
|
+
0.9 0.03 -0.1 1.6 0.01 -0.151 0.112
|
|
43
|
+
0.9 0.03 -0.1 1.6 0.01 -0.122 0.112
|
|
44
|
+
0.9 0.03 -0.2 2.3 0.01 -0.472 0.01
|
|
45
|
+
0.9 0.03 -0.2 2.3 0.01 -0.472 0.04
|
|
46
|
+
0.9 0.03 -0.2 2.3 0.01 0.01 0.04
|
|
47
|
+
1.5 0.5 0.1 3.2 0.01 -0.459 -0.325
|
|
48
|
+
1.5 0.5 0.1 3.2 0.01 -0.459 0.632
|
|
49
|
+
1.5 0.5 0.1 3.2 0.01 -0.325 0.632
|
|
50
|
+
1.5 0.5 0. 3. 0.01 -0.446 -0.348
|
|
51
|
+
1.5 0.5 0. 3. 0.01 -0.446 0.656
|
|
52
|
+
1.5 0.5 0. 3. 0.01 -0.348 0.656
|
|
53
|
+
0.9 0.03 -0.26 1.65 0.01 -0.222 0.167
|
|
54
|
+
0.9 0.03 -0.26 1.65 0.01 -0.222 0.194
|
|
55
|
+
0.9 0.03 -0.26 1.65 0.01 0.167 0.194
|
|
56
|
+
1.5 0.5 0.3 2.8 0.01 0.314 0.782
|
|
57
|
+
1.5 0.5 0.3 2.8 0.01 0.588 0.782
|
|
58
|
+
0.9 0.03 -0.3 1.8 0.01 -0.285 0.129
|
|
59
|
+
0.9 0.03 -0.3 1.8 0.01 -0.285 0.142
|
|
60
|
+
0.9 0.03 -0.3 1.8 0.01 0.129 0.142
|
|
61
|
+
1.5 0.5 0.3 2.9 0.01 -0.491 0.392
|
|
62
|
+
1.5 0.5 0.3 2.9 0.01 -0.491 0.562
|
|
63
|
+
1.5 0.5 0.3 2.9 0.01 0.392 0.562
|
|
64
|
+
1.5 0.5 0.25 2.75 0.01 0.208 0.738
|
|
65
|
+
1.5 0.5 0.25 2.75 0.01 0.668 0.738
|
|
66
|
+
1.5 0.5 0.35 2.2 0.01 0.06 0.646
|
|
67
|
+
1.5 0.5 0.35 2.2 0.01 0.538 0.646
|
|
68
|
+
1.5 0.5 0.25 2.5 0.01 -0.458 0.096
|
|
69
|
+
1.5 0.5 0.25 2.5 0.01 -0.458 0.587
|
|
70
|
+
1.5 0.5 0.25 2.5 0.01 0.096 0.587
|
|
71
|
+
1.5 0.5 0.25 2. 0.01 -0.041 0.296
|
|
72
|
+
1.5 0.5 0.25 2. 0.01 -0.041 0.472
|
|
73
|
+
1.5 0.5 0.25 2. 0.01 0.296 0.472
|
|
74
|
+
1.5 0.5 0.7 1.5 0.01 -0.08 -0.016
|
|
75
|
+
1.5 0.5 0.7 1.5 0.01 -0.08 0.346
|
|
76
|
+
1.5 0.5 0.7 1.5 0.01 -0.016 0.346
|
|
77
|
+
1.5 0.5 0.45 4.6 0.01 -0.409 -0.049
|
|
78
|
+
1.5 0.5 0.45 4.6 0.01 -0.409 0.277
|
|
79
|
+
1.5 0.5 0.45 4.6 0.01 -0.049 0.277
|
|
80
|
+
1.5 0.5 0.33 3.2 0.01 -0.367 0.652
|
|
81
|
+
0.9 0.1 -0.45 1.65 0.01 -0.466 -0.001
|
|
82
|
+
0.9 0.1 -0.45 1.65 0.01 -0.466 0.372
|
|
83
|
+
0.9 0.1 -0.45 1.65 0.01 -0.001 0.372
|
|
84
|
+
2.2 0.5 0.1 3. 0.01 0.746 1.069
|
|
85
|
+
2.2 0.5 0.1 3. 0.01 0.746 1.189
|
|
86
|
+
2.2 0.5 0.1 3. 0.01 1.069 1.189
|
|
87
|
+
2.2 0.5 0.35 2.9 0.01 1.073 1.142
|
|
88
|
+
2.2 0.5 0.35 2.9 0.01 1.073 1.287
|
|
89
|
+
2.2 0.5 0.35 2.9 0.01 1.142 1.287
|
|
90
|
+
2.2 0.5 0.4 2.8 0.01 0.985 1.169
|
|
91
|
+
2.2 0.5 0.4 2.8 0.01 0.985 1.215
|
|
92
|
+
2.2 0.5 0.4 2.8 0.01 1.169 1.215
|
|
93
|
+
2.2 0.5 1.05 2. 0.01 0.394 0.563
|
|
94
|
+
2.2 0.5 1.05 2. 0.01 0.394 0.657
|
|
95
|
+
2.2 0.5 1.05 2. 0.01 0.563 0.657
|
|
96
|
+
2.2 0.5 0.45 2.7 0.01 -0.675 0.896
|
|
97
|
+
2.2 0.5 0.45 2.7 0.01 -0.675 1.107
|
|
98
|
+
2.2 0.5 0.45 2.7 0.01 0.896 1.107
|
|
99
|
+
2.2 0.5 1. 1.9 0.01 0.3 0.398
|
|
100
|
+
2.2 0.5 1. 1.9 0.01 0.3 0.526
|
|
101
|
+
2.2 0.5 1. 1.9 0.01 0.398 0.526
|
|
102
|
+
2.2 0.5 1.23 1.6 0.01 -0.17 0.018
|
|
103
|
+
2.2 0.5 1.23 1.6 0.01 -0.17 0.053
|
|
104
|
+
2.2 0.5 1.23 1.6 0.01 0.018 0.053
|
|
105
|
+
2.2 0.5 0.35 2.7 0.01 -0.667 0.745
|
|
106
|
+
2.2 0.5 0.35 2.7 0.01 -0.667 1.146
|
|
107
|
+
2.2 0.5 0.35 2.7 0.01 0.745 1.146
|
|
108
|
+
2.2 0.5 0.05 2.95 0.01 -0.645 0.231
|
|
109
|
+
2.2 0.5 0.05 2.95 0.01 -0.645 1.201
|
|
110
|
+
2.2 0.5 0.05 2.95 0.01 0.231 1.201
|
|
111
|
+
2.2 0.5 0.35 3. 0.01 -0.69 1.154
|
|
112
|
+
1.8 0.03 1. 2.3 0.01 -0.084 0.72
|
|
113
|
+
1.8 0.03 1. 2.3 0.01 -0.084 0.889
|
|
114
|
+
1.8 0.03 1. 2.3 0.01 0.72 0.889
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// LevMarFit.h
|
|
2
|
+
// Definition of the LevMar and bumper classes for Levenberg-Marquardt fitting
|
|
3
|
+
|
|
4
|
+
#include <stdio.h>
|
|
5
|
+
#include "bumper.h"
|
|
6
|
+
#include <regex>
|
|
7
|
+
#include <filesystem>
|
|
8
|
+
|
|
9
|
+
using namespace std;
|
|
10
|
+
using namespace std::filesystem;
|
|
11
|
+
|
|
12
|
+
#ifndef _LevMarFit
|
|
13
|
+
#define _LevMarFit
|
|
14
|
+
#define __unmanaged
|
|
15
|
+
|
|
16
|
+
#include <VBBinaryLensingLibrary.h>
|
|
17
|
+
|
|
18
|
+
class LevMar{
|
|
19
|
+
|
|
20
|
+
VBBinaryLensing *VBBL;
|
|
21
|
+
|
|
22
|
+
char eventname[512],filename[30],filnum[10],outdir[30],satellitedir[256];
|
|
23
|
+
char modelcode[16];
|
|
24
|
+
int error;
|
|
25
|
+
int flagblending;
|
|
26
|
+
path exedir;
|
|
27
|
+
|
|
28
|
+
double tim0,tm;
|
|
29
|
+
|
|
30
|
+
double (VBBinaryLensing::*model)(double *,double);
|
|
31
|
+
int nps;
|
|
32
|
+
double *sigmapr,*leftlim,*rightlim;
|
|
33
|
+
|
|
34
|
+
int *filter,*satel,nfil,np,OGLE;
|
|
35
|
+
double *t,*y,*w,*delta,*maxdelta,*Curv,*A,*B,*B0,*Cov,*fb,**Gr,*dFdp,*errs;
|
|
36
|
+
double *pr,*prn,*sumy, *sumy2, *sumsigma,*sumfy,*sumf,*sumf2,*limbdarks;
|
|
37
|
+
|
|
38
|
+
double Tol;
|
|
39
|
+
|
|
40
|
+
void (LevMar::*PrintOut)(double *);
|
|
41
|
+
void (LevMar::*PrintFile)(FILE *,double, bool);
|
|
42
|
+
|
|
43
|
+
bumper *stepchain,*bumperlist,*laststep;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
LevMar(int,char **);
|
|
48
|
+
~LevMar();
|
|
49
|
+
|
|
50
|
+
void ReadFiles(int,char **);
|
|
51
|
+
int InitCond(double *presigmapr, double *preleftlim,double *prerightlim);
|
|
52
|
+
void ReadCurve();
|
|
53
|
+
void Run();
|
|
54
|
+
double ChiSquared(double *);
|
|
55
|
+
void Grad();
|
|
56
|
+
void Covariance();
|
|
57
|
+
|
|
58
|
+
void PrintOutPS(double *);
|
|
59
|
+
void PrintOutPX(double *);
|
|
60
|
+
void PrintOutBS(double *);
|
|
61
|
+
void PrintOutBO(double *);
|
|
62
|
+
void PrintOutLS(double *);
|
|
63
|
+
void PrintOutLX(double *);
|
|
64
|
+
void PrintOutLO(double *);
|
|
65
|
+
void PrintOutLK(double*);
|
|
66
|
+
|
|
67
|
+
void PrintFilePS(FILE *,double, bool);
|
|
68
|
+
void PrintFilePX(FILE *,double, bool);
|
|
69
|
+
void PrintFileBS(FILE *,double, bool);
|
|
70
|
+
void PrintFileBO(FILE *,double, bool);
|
|
71
|
+
void PrintFileLS(FILE *,double, bool);
|
|
72
|
+
void PrintFileLX(FILE *,double, bool);
|
|
73
|
+
void PrintFileLO(FILE *,double, bool);
|
|
74
|
+
void PrintFileLK(FILE*, double, bool);
|
|
75
|
+
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
double Determinant(double *,int);
|
|
79
|
+
void Inverse(double*, double*, int);
|
|
80
|
+
|
|
81
|
+
#endif
|