RTModel 2.1.0__tar.gz → 2.2__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.
- {rtmodel-2.1.0 → rtmodel-2.2}/CMakeLists.txt +1 -1
- {rtmodel-2.1.0 → rtmodel-2.2}/PKG-INFO +5 -3
- {rtmodel-2.1.0 → rtmodel-2.2}/README.md +3 -1
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/RTModel.py +78 -27
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/__init__.py +1 -1
- rtmodel-2.2/RTModel/include/LevMarFit.h +91 -0
- rtmodel-2.2/RTModel/include/VBMicrolensingLibrary.h +483 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/lib/Finalizer.cpp +37 -14
- rtmodel-2.2/RTModel/lib/InitCond.cpp +1737 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/lib/LevMarFit.cpp +418 -140
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/lib/ModelSelector.cpp +284 -135
- rtmodel-2.2/RTModel/lib/VBMicrolensingLibrary.cpp +8007 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/plotmodel/__init__.py +1 -1
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/plotmodel/plotmodel.py +36 -27
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/templates/__init__.py +2 -2
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/templates/templates.py +7 -7
- rtmodel-2.2/changelog.md +6 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/Animation.md +2 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/Archive.md +9 -0
- rtmodel-2.2/docs/Constraints.md +69 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/DataPreprocessing.md +10 -3
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/FinalAssessment.md +2 -2
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/Fitting.md +15 -6
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/InitCond.md +15 -7
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/LimbDarkening.md +1 -1
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/ModelCategories.md +42 -7
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/ModelSelection.md +12 -3
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/ModelingRun.md +13 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/PlotModel.md +1 -1
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/README.md +3 -1
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/Satellite.md +11 -3
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/TemplateLibraries.md +4 -2
- {rtmodel-2.1.0 → rtmodel-2.2}/pyproject.toml +2 -2
- rtmodel-2.1.0/RTModel/include/LevMarFit.h +0 -81
- rtmodel-2.1.0/RTModel/include/VBBinaryLensingLibrary.h +0 -312
- rtmodel-2.1.0/RTModel/lib/InitCond.cpp +0 -1427
- rtmodel-2.1.0/RTModel/lib/VBBinaryLensingLibrary.cpp +0 -4986
- rtmodel-2.1.0/changelog.md +0 -4
- {rtmodel-2.1.0 → rtmodel-2.2}/.github/workflows/run_tests.yml +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/.gitignore +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/LICENSE +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/MANIFEST.in +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/data/ESPL.tbl +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/data/TemplateLibrary.txt +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/include/bumper.h +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/lib/LevMar.cpp +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/lib/Reader.cpp +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/RTModel/lib/bumper.cpp +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/DataPreparation.md +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/Template.png +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/ani.gif +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/plotchain.png +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/plotmodel_fig1.png +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/docs/plotmodel_fig2.png +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/events/OB190033.zip +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/events/event001.zip +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/events/event001done.zip +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/events/event002.zip +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/events/readme.md +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/events/satellite1.txt +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/jupyter/Model_event001.ipynb +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/tests/build_tests/test_built_executables_exist.py +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/tests/end_to_end_tests/test_ps_run.py +0 -0
- {rtmodel-2.1.0 → rtmodel-2.2}/tests/end_to_end_tests/test_ps_run_resources/example_event.zip +0 -0
|
@@ -21,7 +21,7 @@ add_executable(InitCond RTModel/lib/InitCond.cpp)
|
|
|
21
21
|
target_include_directories(InitCond PRIVATE RTModel/include)
|
|
22
22
|
|
|
23
23
|
add_executable(LevMar RTModel/lib/bumper.cpp RTModel/lib/LevMar.cpp RTModel/lib/LevMarFit.cpp
|
|
24
|
-
RTModel/lib/
|
|
24
|
+
RTModel/lib/VBMicrolensingLibrary.cpp)
|
|
25
25
|
target_include_directories(LevMar PRIVATE RTModel/include)
|
|
26
26
|
|
|
27
27
|
add_executable(ModelSelector RTModel/lib/bumper.cpp RTModel/lib/ModelSelector.cpp)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: RTModel
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2
|
|
4
4
|
Summary: RTModel is a tool for microlensing event interpretation.
|
|
5
5
|
Keywords: Microlensing analysis and fitting
|
|
6
6
|
Author-Email: Valerio Bozza <valboz@sa.infn.it>
|
|
@@ -15,7 +15,7 @@ Requires-Dist: numpy
|
|
|
15
15
|
Requires-Dist: pytest
|
|
16
16
|
Requires-Dist: matplotlib
|
|
17
17
|
Requires-Dist: tqdm
|
|
18
|
-
Requires-Dist:
|
|
18
|
+
Requires-Dist: VBMicrolensing>=4.1.0
|
|
19
19
|
Description-Content-Type: text/markdown
|
|
20
20
|
|
|
21
21
|
# RTModel
|
|
@@ -32,6 +32,8 @@ The library is in the form of a standard Python package that launches specific s
|
|
|
32
32
|
|
|
33
33
|
`RTModel` also includes a subpackage **`RTModel.plotmodel`** that allows an immediate visualization of models and the possibility to review each individual fitting process as an animated gif.
|
|
34
34
|
|
|
35
|
+
A second subpackage **`RTModel.templates`** helps the user in the visualization and customization of the template library.
|
|
36
|
+
|
|
35
37
|
## Attribution
|
|
36
38
|
|
|
37
39
|
`RTModel` has been created by Valerio Bozza (University of Salerno) as a product of many years of direct experience on microlensing modeling (see [RTModel webpage](http://www.fisica.unisa.it/GravitationAstrophysics/RTModel.htm)).
|
|
@@ -60,7 +62,7 @@ pip install RTModel
|
|
|
60
62
|
|
|
61
63
|
Currently, `RTModel` works on Linux, Windows and MacOS, requiring Python >= 3.6.
|
|
62
64
|
A C++ compiler compatible with C++17 standard is needed for installation.
|
|
63
|
-
`RTModel` also incorporates version
|
|
65
|
+
`RTModel` also incorporates version 4.1 of [`VBMicrolensing`](https://github.com/valboz/VBMicrolensing). You are encouraged to cite the relevant papers listed in that repository as well.
|
|
64
66
|
|
|
65
67
|
## Documentation
|
|
66
68
|
Full [documentation for the use of RTModel](docs/README.md) is available.
|
|
@@ -12,6 +12,8 @@ The library is in the form of a standard Python package that launches specific s
|
|
|
12
12
|
|
|
13
13
|
`RTModel` also includes a subpackage **`RTModel.plotmodel`** that allows an immediate visualization of models and the possibility to review each individual fitting process as an animated gif.
|
|
14
14
|
|
|
15
|
+
A second subpackage **`RTModel.templates`** helps the user in the visualization and customization of the template library.
|
|
16
|
+
|
|
15
17
|
## Attribution
|
|
16
18
|
|
|
17
19
|
`RTModel` has been created by Valerio Bozza (University of Salerno) as a product of many years of direct experience on microlensing modeling (see [RTModel webpage](http://www.fisica.unisa.it/GravitationAstrophysics/RTModel.htm)).
|
|
@@ -40,7 +42,7 @@ pip install RTModel
|
|
|
40
42
|
|
|
41
43
|
Currently, `RTModel` works on Linux, Windows and MacOS, requiring Python >= 3.6.
|
|
42
44
|
A C++ compiler compatible with C++17 standard is needed for installation.
|
|
43
|
-
`RTModel` also incorporates version
|
|
45
|
+
`RTModel` also incorporates version 4.1 of [`VBMicrolensing`](https://github.com/valboz/VBMicrolensing). You are encouraged to cite the relevant papers listed in that repository as well.
|
|
44
46
|
|
|
45
47
|
## Documentation
|
|
46
48
|
Full [documentation for the use of RTModel](docs/README.md) is available.
|
|
@@ -34,7 +34,7 @@ class RTModel:
|
|
|
34
34
|
self.eventname = os.path.realpath(event)
|
|
35
35
|
print("Event name: " + self.eventname)
|
|
36
36
|
self.inidir = "ini"
|
|
37
|
-
self.modelcodes = ['PS', 'PX', 'BS', 'BO', 'LS', 'LX', 'LO']
|
|
37
|
+
self.modelcodes = ['PS', 'PX', 'BS', 'BO', 'LS', 'LX', 'LO', 'LK', 'TS', 'TX']
|
|
38
38
|
self.endphase = len(self.modelcodes)*2+3
|
|
39
39
|
self.eventinifile = 'event.ini'
|
|
40
40
|
self.nprocessors = os.cpu_count()
|
|
@@ -54,6 +54,14 @@ class RTModel:
|
|
|
54
54
|
def set_satellite_dir(self, satellitedir):
|
|
55
55
|
self.satellitedir = satellitedir
|
|
56
56
|
|
|
57
|
+
def set_constraints(self, constraints = None):
|
|
58
|
+
self.constraints = constraints
|
|
59
|
+
if(not os.path.exists(self.eventname + '/' + self.inidir)):
|
|
60
|
+
os.makedirs(self.eventname + '/' + self.inidir)
|
|
61
|
+
with open(self.eventname + '/' + self.inidir + '/Constraints.ini','w') as f:
|
|
62
|
+
for cons in constraints:
|
|
63
|
+
f.write(cons[0] + ' = '+ str(cons[1]) + ' '+ str(cons[2]) + ' '+ str(cons[3]) + ' ' + '\n')
|
|
64
|
+
|
|
57
65
|
def config_Reader(self, tau = 0.1, binning = 4000, otherseasons = 1, renormalize = 1, thresholdoutliers = 10):
|
|
58
66
|
self.Reader_tau= tau # conventional correlation time for consecutive points
|
|
59
67
|
self.Reader_binning = binning # maximum number of points left after re-binning
|
|
@@ -80,15 +88,17 @@ class RTModel:
|
|
|
80
88
|
print(' OK')
|
|
81
89
|
|
|
82
90
|
def config_InitCond(self, npeaks = 2, peakthreshold = 10.0, oldmodels = 4, override = None, nostatic = False, onlyorbital = False, usesatellite = 0
|
|
83
|
-
,
|
|
91
|
+
, templatelibrary = None, modelcategories = ['PS','PX','BS','BO','LS','LX','LO'], onlyupdate =False):
|
|
84
92
|
self.InitCond_npeaks = npeaks # Number of peaks in the observed light curve to be considered for setting initial conditions.
|
|
85
93
|
self.InitCond_peakthreshold = peakthreshold # Number of sigmas necessary for a deviation to be identified as a maximum or a minimum.
|
|
86
94
|
self.InitCond_oldmodels = oldmodels # Maximum number of old models to include in new run as initial conditions
|
|
87
95
|
self.InitCond_override = override # Override peak identification and manually set peak times
|
|
88
96
|
self.InitCond_nostatic = nostatic or onlyorbital # No static models will be calculated.
|
|
89
|
-
self.InitCond_onlyorbital = onlyorbital
|
|
90
|
-
self.InitCond_usesatellite = usesatellite
|
|
91
|
-
self.
|
|
97
|
+
self.InitCond_onlyorbital = onlyorbital # Only orbital motion models will be calculated.
|
|
98
|
+
self.InitCond_usesatellite = usesatellite # Satellite to be used for initial conditions. Ground telescopes by default.
|
|
99
|
+
self.InitCond_templatelibrary = templatelibrary # Template library to be used in place of the default one.
|
|
100
|
+
self.InitCond_modelcategories = modelcategories # Model categories to be fit
|
|
101
|
+
self.InitCond_onlyupdate = onlyupdate # No search but only update of previously found best models
|
|
92
102
|
|
|
93
103
|
def InitCond(self):
|
|
94
104
|
''' Establishes initial conditions for fitting by executing the InitCond external module.
|
|
@@ -106,8 +116,12 @@ class RTModel:
|
|
|
106
116
|
f.write('onlyorbital = 1\n')
|
|
107
117
|
if(self.InitCond_override != None):
|
|
108
118
|
f.write('override = ' + str(self.InitCond_override[0])+ ' ' + str(self.InitCond_override[1]) + '\n')
|
|
109
|
-
if(self.
|
|
110
|
-
f.write('templatelibrary = ' + self.
|
|
119
|
+
if(self.InitCond_templatelibrary != None):
|
|
120
|
+
f.write('templatelibrary = ' + self.InitCond_templatelibrary + '\n')
|
|
121
|
+
if(self.InitCond_modelcategories != None):
|
|
122
|
+
f.write('modelcategories = '+ ''.join(self.InitCond_modelcategories) + '\n')
|
|
123
|
+
if(self.InitCond_onlyupdate):
|
|
124
|
+
f.write('onlyupdate = 1\n')
|
|
111
125
|
print('- Launching: InitCond')
|
|
112
126
|
print(' Setting initial conditions...')
|
|
113
127
|
completedprocess = subprocess.run([self.bindir+self.initcondexe,self.eventname], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
|
|
@@ -115,16 +129,17 @@ class RTModel:
|
|
|
115
129
|
print('! Error in setting initial conditions!')
|
|
116
130
|
self.done = True
|
|
117
131
|
else:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
132
|
+
peaksearch = True
|
|
133
|
+
i=0
|
|
134
|
+
while(peaksearch):
|
|
135
|
+
initfils=glob.glob(self.eventname + '/InitCond/InitCond'+ self.modelcodes[i] + '*')
|
|
136
|
+
if(len(initfils)!=0):
|
|
137
|
+
peaksearch = False
|
|
138
|
+
with open(initfils[0], 'r') as f:
|
|
139
|
+
npeaks = int(f.readline().split()[0])
|
|
140
|
+
print('Peaks: ',end ='')
|
|
141
|
+
for i in range(0,npeaks):
|
|
142
|
+
print(f'{float(f.readline().split()[0]):.4f}',end = ' ')
|
|
128
143
|
print('\n OK')
|
|
129
144
|
|
|
130
145
|
def config_LevMar(self, nfits = 5, timelimit = 600.0, maxsteps = 50, bumperpower = 2.0):
|
|
@@ -173,7 +188,10 @@ class RTModel:
|
|
|
173
188
|
'BO' : '- Single-lens-Binary-source fits with xallarap',
|
|
174
189
|
'LS' : '- Binary-lens-Single-source fits',
|
|
175
190
|
'LX' : '- Binary-lens-Single-source fits with parallax',
|
|
176
|
-
'LO' : '- Binary-lens-Single-source fits with orbital motion'
|
|
191
|
+
'LO' : '- Binary-lens-Single-source fits with orbital motion',
|
|
192
|
+
'LK' : '- Binary-lens-Single-source fits with eccentric orbital motion',
|
|
193
|
+
'TS' : '- Triple-lens-Single-source fits',
|
|
194
|
+
'TX' : '- Triple-lens-Single-source fits with parallax'}
|
|
177
195
|
print(stringfits[modelcode])
|
|
178
196
|
initcondfile = self.eventname + '/InitCond/' + 'InitCond'+ modelcode + '.txt'
|
|
179
197
|
if(os.path.exists(initcondfile)):
|
|
@@ -220,7 +238,7 @@ class RTModel:
|
|
|
220
238
|
time.sleep(0.1)
|
|
221
239
|
pbar.close()
|
|
222
240
|
else:
|
|
223
|
-
print('- No initial conditions for this
|
|
241
|
+
print('- No initial conditions for this category')
|
|
224
242
|
|
|
225
243
|
def config_ModelSelector(self, sigmasoverlap = 3.0, sigmachisquare = 1.0, maxmodels = 10):
|
|
226
244
|
self.ModelSelector_sigmasoverlap = sigmasoverlap # factor multiplying the inverse covariance in search for superpositions (models are incompatible if farther than sigmasoverlap*sigma)
|
|
@@ -240,7 +258,10 @@ class RTModel:
|
|
|
240
258
|
'BO' : '- Selecting models for Single-lens-Binary-source fits with xallarap',
|
|
241
259
|
'LS' : '- Selecting models for Binary-lens-Single-source fits',
|
|
242
260
|
'LX' : '- Selecting models for Binary-lens-Single-source fits with parallax',
|
|
243
|
-
'LO' : '- Selecting models for Binary-lens-Single-source fits with orbital motion'
|
|
261
|
+
'LO' : '- Selecting models for Binary-lens-Single-source fits with orbital motion',
|
|
262
|
+
'LK' : '- Selecting models for Binary-lens-Single-source fits with eccentric orbital motion',
|
|
263
|
+
'TS' : '- Selecting models for Triple-lens-Single-source fits',
|
|
264
|
+
'TX' : '- Selecting models for Triple-lens-Single-source fits with parallax'}
|
|
244
265
|
print(stringmodels[modelcode])
|
|
245
266
|
completedprocess = subprocess.run([self.bindir+self.modelselectorexe,self.eventname, modelcode], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
|
|
246
267
|
if(completedprocess.returncode != 0):
|
|
@@ -262,13 +283,13 @@ class RTModel:
|
|
|
262
283
|
print(" " + line,end='')
|
|
263
284
|
print(" OK")
|
|
264
285
|
|
|
265
|
-
def run(self, event = None):
|
|
286
|
+
def run(self, event = None, cleanup = False):
|
|
266
287
|
phase =0
|
|
267
288
|
if(event!= None):
|
|
268
289
|
self.eventname = os.path.realpath(event)
|
|
269
290
|
self.done = False
|
|
291
|
+
print("o " + time.asctime())
|
|
270
292
|
while not(self.done):
|
|
271
|
-
print("o " + time.asctime())
|
|
272
293
|
# Check that event directory exists
|
|
273
294
|
if phase == 0:
|
|
274
295
|
if(os.path.exists(self.eventname + '/Data')):
|
|
@@ -280,28 +301,44 @@ class RTModel:
|
|
|
280
301
|
# Launch Reader
|
|
281
302
|
elif phase == 1:
|
|
282
303
|
self.Reader()
|
|
304
|
+
print("o " + time.asctime())
|
|
283
305
|
phase = 2
|
|
284
306
|
# Launch InitCond
|
|
285
307
|
elif phase == 2:
|
|
286
308
|
self.InitCond()
|
|
309
|
+
print("o " + time.asctime())
|
|
287
310
|
phase = 3
|
|
288
311
|
# Launch Finalizer
|
|
289
312
|
elif phase == self.endphase:
|
|
290
313
|
self.Finalizer()
|
|
314
|
+
print("o " + time.asctime())
|
|
291
315
|
phase += 1
|
|
292
316
|
# Conclude analysis
|
|
293
317
|
elif phase > self.endphase:
|
|
318
|
+
if(cleanup):
|
|
319
|
+
print('- Cleaning up preliminary models')
|
|
320
|
+
cleanup_preliminary_models()
|
|
294
321
|
print("- Analysis of " + self.eventname + " successfully completed!")
|
|
322
|
+
print("o " + time.asctime())
|
|
295
323
|
self.done = True
|
|
296
324
|
# Launch LevMar for next class
|
|
297
325
|
elif phase%2 == 1:
|
|
298
|
-
self.
|
|
326
|
+
if(self.InitCond_modelcategories == None or self.modelcodes[phase//2-1] in self.InitCond_modelcategories):
|
|
327
|
+
self.launch_fits(self.modelcodes[phase//2-1])
|
|
328
|
+
print("o " + time.asctime())
|
|
299
329
|
phase += 1
|
|
300
330
|
# Launch ModelSelector for this class
|
|
301
331
|
else:
|
|
302
|
-
self.
|
|
303
|
-
|
|
304
|
-
|
|
332
|
+
if(self.InitCond_modelcategories == None or self.modelcodes[phase//2-2] in self.InitCond_modelcategories):
|
|
333
|
+
self.ModelSelector(self.modelcodes[phase//2-2])
|
|
334
|
+
print("o " + time.asctime())
|
|
335
|
+
phase += 1
|
|
336
|
+
|
|
337
|
+
def cleanup_preliminary_models(self):
|
|
338
|
+
os.chdir(self.eventname)
|
|
339
|
+
if(os.path.exists('PreModels')):
|
|
340
|
+
shutil.rmtree('PreModels')
|
|
341
|
+
|
|
305
342
|
def archive_run(self, destination = None):
|
|
306
343
|
olddir = os.getcwd()
|
|
307
344
|
os.chdir(self.eventname)
|
|
@@ -335,6 +372,15 @@ class RTModel:
|
|
|
335
372
|
if(not(os.path.exists(pathname))):
|
|
336
373
|
print("Invalid path!")
|
|
337
374
|
return
|
|
375
|
+
if(os.path.exists(pathname + '/' + self.inidir + '/Constraints.ini')):
|
|
376
|
+
with open(pathname + '/' + self.inidir + '/Constraints.ini','r') as f:
|
|
377
|
+
lines = f.read().splitlines()
|
|
378
|
+
print('Constraints --- ',lines)
|
|
379
|
+
self.constraints =[]
|
|
380
|
+
for line in lines:
|
|
381
|
+
chunks =line.split()
|
|
382
|
+
self.constraints.append([chunks[0], float(chunks[2]), float(chunks[3]), float(chunks[4])])
|
|
383
|
+
self.set_constraints(self.constraints)
|
|
338
384
|
if(os.path.exists(pathname + '/' + self.inidir + '/Reader.ini')):
|
|
339
385
|
with open(pathname + '/' + self.inidir + '/Reader.ini','r') as f:
|
|
340
386
|
lines = f.read().splitlines()
|
|
@@ -358,6 +404,7 @@ class RTModel:
|
|
|
358
404
|
self.InitCond_nostatic = False
|
|
359
405
|
self.InitCond_onlyorbital = False
|
|
360
406
|
self.InitCond_override = None
|
|
407
|
+
self.InitCond_onlyupdate = False
|
|
361
408
|
for line in lines:
|
|
362
409
|
chunks = line.split()
|
|
363
410
|
if(chunks[0]=='npeaks'):
|
|
@@ -372,10 +419,14 @@ class RTModel:
|
|
|
372
419
|
self.InitCond_nostatic = (int(chunks[2])!=0)
|
|
373
420
|
elif(chunks[0]=='onlyorbital'):
|
|
374
421
|
self.InitCond_onlyorbital = (int(chunks[2])!=0)
|
|
422
|
+
elif(chunks[0]=='onlyupdate'):
|
|
423
|
+
self.InitCond_onlyupdate = (int(chunks[2])!=0)
|
|
375
424
|
elif(chunks[0]=='override'):
|
|
376
425
|
self.InitCond_override = (float(chunks[2]),float(chunks[3]))
|
|
377
426
|
elif(chunks[0]=='templatelibrary'):
|
|
378
|
-
self.
|
|
427
|
+
self.InitCond_templatelibrary = chunks[2]
|
|
428
|
+
elif(chunks[0]=='modelcategories'):
|
|
429
|
+
self.InitCond_modelcategories = [chunks[2][i:i+2] for i in range(0, len(chunks[2]), 2)]
|
|
379
430
|
if(os.path.exists(pathname + '/' + self.inidir + '/LevMar.ini')):
|
|
380
431
|
with open(pathname + '/' + self.inidir + '/LevMar.ini','r') as f:
|
|
381
432
|
lines = f.read().splitlines()
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// LevMarFit.h
|
|
2
|
+
// Definition of the LevMar and bumper classes for Levenberg-Marquardt fitting
|
|
3
|
+
|
|
4
|
+
#include <cstdio>
|
|
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 <VBMicrolensingLibrary.h>
|
|
17
|
+
|
|
18
|
+
class LevMar {
|
|
19
|
+
|
|
20
|
+
VBMicrolensing* VBM;
|
|
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 (VBMicrolensing::* 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
|
+
int consnumber, *consindex;
|
|
39
|
+
double* constraints, * consleft, * consright, *consvars;
|
|
40
|
+
int modnumber;
|
|
41
|
+
|
|
42
|
+
double Tol;
|
|
43
|
+
|
|
44
|
+
void (LevMar::* PrintOut)(double*);
|
|
45
|
+
void (LevMar::* PrintFile)(FILE*, double, bool);
|
|
46
|
+
|
|
47
|
+
bumper* stepchain, * bumperlist, * laststep;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
LevMar(int, char**);
|
|
52
|
+
~LevMar();
|
|
53
|
+
|
|
54
|
+
void ReadFiles(int, char**);
|
|
55
|
+
int InitCond(double* presigmapr, double* preleftlim, double* prerightlim);
|
|
56
|
+
void ReadCurve();
|
|
57
|
+
void ReadOptions();
|
|
58
|
+
void Run();
|
|
59
|
+
double ChiSquared(double*);
|
|
60
|
+
void Grad();
|
|
61
|
+
void Covariance();
|
|
62
|
+
double ComputeConstraint(double *pr, int i);
|
|
63
|
+
|
|
64
|
+
void PrintOutPS(double*);
|
|
65
|
+
void PrintOutPX(double*);
|
|
66
|
+
void PrintOutBS(double*);
|
|
67
|
+
void PrintOutBO(double*);
|
|
68
|
+
void PrintOutLS(double*);
|
|
69
|
+
void PrintOutLX(double*);
|
|
70
|
+
void PrintOutLO(double*);
|
|
71
|
+
void PrintOutLK(double*);
|
|
72
|
+
void PrintOutTS(double*);
|
|
73
|
+
void PrintOutTX(double*);
|
|
74
|
+
|
|
75
|
+
void PrintFilePS(FILE*, double, bool);
|
|
76
|
+
void PrintFilePX(FILE*, double, bool);
|
|
77
|
+
void PrintFileBS(FILE*, double, bool);
|
|
78
|
+
void PrintFileBO(FILE*, double, bool);
|
|
79
|
+
void PrintFileLS(FILE*, double, bool);
|
|
80
|
+
void PrintFileLX(FILE*, double, bool);
|
|
81
|
+
void PrintFileLO(FILE*, double, bool);
|
|
82
|
+
void PrintFileLK(FILE*, double, bool);
|
|
83
|
+
void PrintFileTS(FILE*, double, bool);
|
|
84
|
+
void PrintFileTX(FILE*, double, bool);
|
|
85
|
+
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
double Determinant(double*, int);
|
|
89
|
+
void Inverse(double*, double*, int);
|
|
90
|
+
|
|
91
|
+
#endif
|