RTModel 2.2__tar.gz → 2.4__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 (65) hide show
  1. rtmodel-2.4/.github/workflows/build_wheels.yml +56 -0
  2. {rtmodel-2.2 → rtmodel-2.4}/.github/workflows/run_tests.yml +1 -1
  3. {rtmodel-2.2 → rtmodel-2.4}/CMakeLists.txt +16 -3
  4. {rtmodel-2.2 → rtmodel-2.4}/PKG-INFO +5 -4
  5. {rtmodel-2.2 → rtmodel-2.4}/README.md +1 -1
  6. {rtmodel-2.2 → rtmodel-2.4}/RTModel/RTModel.py +60 -29
  7. {rtmodel-2.2 → rtmodel-2.4}/RTModel/__init__.py +1 -1
  8. {rtmodel-2.2 → rtmodel-2.4}/RTModel/include/bumper.h +2 -1
  9. {rtmodel-2.2 → rtmodel-2.4}/RTModel/lib/Finalizer.cpp +84 -53
  10. {rtmodel-2.2 → rtmodel-2.4}/RTModel/lib/InitCond.cpp +16 -4
  11. {rtmodel-2.2 → rtmodel-2.4}/RTModel/lib/LevMar.cpp +4 -4
  12. {rtmodel-2.2 → rtmodel-2.4}/RTModel/lib/LevMarFit.cpp +99 -74
  13. rtmodel-2.4/RTModel/lib/LevMarFit.h +91 -0
  14. {rtmodel-2.2 → rtmodel-2.4}/RTModel/lib/ModelSelector.cpp +69 -28
  15. {rtmodel-2.2 → rtmodel-2.4}/RTModel/lib/Reader.cpp +3 -2
  16. rtmodel-2.4/RTModel/lib/bumper.cpp +170 -0
  17. {rtmodel-2.2 → rtmodel-2.4}/RTModel/plotmodel/__init__.py +2 -2
  18. {rtmodel-2.2 → rtmodel-2.4}/RTModel/plotmodel/plotmodel.py +149 -29
  19. {rtmodel-2.2 → rtmodel-2.4}/RTModel/templates/__init__.py +1 -1
  20. {rtmodel-2.2 → rtmodel-2.4}/RTModel/templates/templates.py +8 -14
  21. {rtmodel-2.2 → rtmodel-2.4}/changelog.md +2 -0
  22. {rtmodel-2.2 → rtmodel-2.4}/docs/Fitting.md +2 -1
  23. {rtmodel-2.2 → rtmodel-2.4}/docs/ModelCategories.md +6 -2
  24. {rtmodel-2.2 → rtmodel-2.4}/docs/ModelingRun.md +2 -0
  25. {rtmodel-2.2 → rtmodel-2.4}/docs/PlotModel.md +35 -0
  26. {rtmodel-2.2 → rtmodel-2.4}/docs/README.md +7 -7
  27. rtmodel-2.4/docs/Template.png +0 -0
  28. {rtmodel-2.2 → rtmodel-2.4}/docs/TemplateLibraries.md +2 -2
  29. rtmodel-2.4/docs/plotmodel_fig1.png +0 -0
  30. rtmodel-2.4/fVBM.py +16 -0
  31. {rtmodel-2.2 → rtmodel-2.4}/pyproject.toml +11 -4
  32. rtmodel-2.2/RTModel/include/VBMicrolensingLibrary.h +0 -483
  33. rtmodel-2.2/RTModel/lib/VBMicrolensingLibrary.cpp +0 -8007
  34. rtmodel-2.2/RTModel/lib/bumper.cpp +0 -168
  35. rtmodel-2.2/docs/Template.png +0 -0
  36. rtmodel-2.2/docs/plotmodel_fig1.png +0 -0
  37. {rtmodel-2.2 → rtmodel-2.4}/.gitignore +0 -0
  38. {rtmodel-2.2 → rtmodel-2.4}/LICENSE +0 -0
  39. {rtmodel-2.2 → rtmodel-2.4}/MANIFEST.in +0 -0
  40. {rtmodel-2.2 → rtmodel-2.4}/RTModel/data/ESPL.tbl +0 -0
  41. {rtmodel-2.2 → rtmodel-2.4}/RTModel/data/TemplateLibrary.txt +0 -0
  42. {rtmodel-2.2 → rtmodel-2.4}/RTModel/include/LevMarFit.h +0 -0
  43. {rtmodel-2.2 → rtmodel-2.4}/docs/Animation.md +0 -0
  44. {rtmodel-2.2 → rtmodel-2.4}/docs/Archive.md +0 -0
  45. {rtmodel-2.2 → rtmodel-2.4}/docs/Constraints.md +0 -0
  46. {rtmodel-2.2 → rtmodel-2.4}/docs/DataPreparation.md +0 -0
  47. {rtmodel-2.2 → rtmodel-2.4}/docs/DataPreprocessing.md +0 -0
  48. {rtmodel-2.2 → rtmodel-2.4}/docs/FinalAssessment.md +0 -0
  49. {rtmodel-2.2 → rtmodel-2.4}/docs/InitCond.md +0 -0
  50. {rtmodel-2.2 → rtmodel-2.4}/docs/LimbDarkening.md +0 -0
  51. {rtmodel-2.2 → rtmodel-2.4}/docs/ModelSelection.md +0 -0
  52. {rtmodel-2.2 → rtmodel-2.4}/docs/Satellite.md +0 -0
  53. {rtmodel-2.2 → rtmodel-2.4}/docs/ani.gif +0 -0
  54. {rtmodel-2.2 → rtmodel-2.4}/docs/plotchain.png +0 -0
  55. {rtmodel-2.2 → rtmodel-2.4}/docs/plotmodel_fig2.png +0 -0
  56. {rtmodel-2.2 → rtmodel-2.4}/events/OB190033.zip +0 -0
  57. {rtmodel-2.2 → rtmodel-2.4}/events/event001.zip +0 -0
  58. {rtmodel-2.2 → rtmodel-2.4}/events/event001done.zip +0 -0
  59. {rtmodel-2.2 → rtmodel-2.4}/events/event002.zip +0 -0
  60. {rtmodel-2.2 → rtmodel-2.4}/events/readme.md +0 -0
  61. {rtmodel-2.2 → rtmodel-2.4}/events/satellite1.txt +0 -0
  62. {rtmodel-2.2 → rtmodel-2.4}/jupyter/Model_event001.ipynb +0 -0
  63. {rtmodel-2.2 → rtmodel-2.4}/tests/build_tests/test_built_executables_exist.py +0 -0
  64. {rtmodel-2.2 → rtmodel-2.4}/tests/end_to_end_tests/test_ps_run.py +0 -0
  65. {rtmodel-2.2 → rtmodel-2.4}/tests/end_to_end_tests/test_ps_run_resources/example_event.zip +0 -0
@@ -0,0 +1,56 @@
1
+ name: Build
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - '**.cpp'
7
+ - '**.h'
8
+ - '**.py'
9
+ - '**.toml'
10
+ - '**.yml'
11
+
12
+ jobs:
13
+ build_wheels:
14
+ name: Build wheels on ${{ matrix.os }}
15
+ runs-on: ${{ matrix.os }}
16
+ strategy:
17
+ matrix:
18
+ os: [ubuntu-latest, windows-latest, macos-13,macos-14] # was macos-latest
19
+
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - name: Build wheels
24
+ uses: pypa/cibuildwheel@v2.22.0
25
+ env: #
26
+ MACOSX_DEPLOYMENT_TARGET: "10.15" #
27
+ CIBW_SKIP: pp*
28
+ # CIBW_SOME_OPTION: value
29
+ # ...
30
+ #with:
31
+ # package-dir: .
32
+ # output-dir: wheelhouse
33
+ # config-file: "{package}/pyproject.toml
34
+ - uses: actions/upload-artifact@v4
35
+ with:
36
+ name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
37
+ path: ./wheelhouse/*.whl
38
+ build_sdist:
39
+ name: Build source distribution
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+
44
+ - name: Build sdist
45
+ run: pipx run build --sdist
46
+
47
+ - uses: actions/upload-artifact@v4
48
+ with:
49
+ name: cibw-sdist
50
+ path: dist/*.tar.gz
51
+
52
+
53
+ - uses: actions/upload-artifact@v4
54
+ with:
55
+ name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
56
+ path: ./wheelhouse/*.whl
@@ -1,6 +1,6 @@
1
1
  name: run_tests
2
2
 
3
- on: [push, pull_request]
3
+ on: [push]
4
4
 
5
5
  jobs:
6
6
  run_tests:
@@ -11,6 +11,20 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
11
11
  endif()
12
12
  endif()
13
13
 
14
+ # Find directory of VBMicrolensing
15
+
16
+ find_package(Python3 COMPONENTS Interpreter Development)
17
+ set(Python3_EXECUTABLE "./python")
18
+
19
+ execute_process(
20
+ COMMAND ${PYTHON_EXECUTABLE} fVBM.py
21
+ #-c "import sys, os, inspect; sys.path.extend(os.environ['PYTHONPATH'].split(os.pathsep)); mod = __import__('VBMicrolensing'); dir1=os.path.dirname(inspect.getfile(mod)); print(dir1.replace(\"\\\",\"/\"))"
22
+ OUTPUT_VARIABLE VBMICROLENSING_DIR
23
+ OUTPUT_STRIP_TRAILING_WHITESPACE
24
+ )
25
+ message(STATUS "Installation directory of VBMicrolensing: ${VBMICROLENSING_DIR}")
26
+
27
+
14
28
  # Build executables
15
29
  # =================
16
30
 
@@ -20,9 +34,8 @@ target_include_directories(Reader PRIVATE RTModel/include)
20
34
  add_executable(InitCond RTModel/lib/InitCond.cpp)
21
35
  target_include_directories(InitCond PRIVATE RTModel/include)
22
36
 
23
- add_executable(LevMar RTModel/lib/bumper.cpp RTModel/lib/LevMar.cpp RTModel/lib/LevMarFit.cpp
24
- RTModel/lib/VBMicrolensingLibrary.cpp)
25
- target_include_directories(LevMar PRIVATE RTModel/include)
37
+ add_executable(LevMar RTModel/lib/bumper.cpp RTModel/lib/LevMar.cpp RTModel/lib/LevMarFit.cpp ${VBMICROLENSING_DIR}/lib/VBMicrolensingLibrary.cpp)
38
+ target_include_directories(LevMar PRIVATE RTModel/include ${VBMICROLENSING_DIR}/lib)
26
39
 
27
40
  add_executable(ModelSelector RTModel/lib/bumper.cpp RTModel/lib/ModelSelector.cpp)
28
41
  target_include_directories(ModelSelector PRIVATE RTModel/include)
@@ -1,20 +1,21 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: RTModel
3
- Version: 2.2
3
+ Version: 2.4
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>
7
7
  License: GPL-3.0
8
8
  Classifier: Development Status :: 5 - Production/Stable
9
9
  Classifier: Intended Audience :: Science/Research
10
- Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
10
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Project-URL: Homepage, https://github.com/valboz/RTModel
13
- Requires-Python: <4,>=3.6
13
+ Requires-Python: <4,>=3.7
14
14
  Requires-Dist: numpy
15
15
  Requires-Dist: pytest
16
16
  Requires-Dist: matplotlib
17
17
  Requires-Dist: tqdm
18
+ Requires-Dist: tabulate
18
19
  Requires-Dist: VBMicrolensing>=4.1.0
19
20
  Description-Content-Type: text/markdown
20
21
 
@@ -40,7 +41,7 @@ A second subpackage **`RTModel.templates`** helps the user in the visualization
40
41
 
41
42
  Any scientific use of `RTModel` should be acknowledged by citing the paper [V.Bozza, A&A 688 (2024) 83](https://ui.adsabs.harvard.edu/abs/2024A%26A...688A..83B/abstract), describing all the algorithms behind the code.
42
43
 
43
- We are grateful to Greg Olmschenk, who revised the package installation in order to make it as cross-platform as possible.
44
+ We are grateful to Greg Olmschenk, who revised the package installation in order to make it as cross-platform as possible. We also thank all the users who are providing suggestions, reporting bugs or failures: Etienne Bachelet, David Bennett, Jonathan Brashear, Stela Ishitani Silva, Yiannis Tsapras, Keto Zhang.
44
45
 
45
46
  ## Installation
46
47
 
@@ -20,7 +20,7 @@ A second subpackage **`RTModel.templates`** helps the user in the visualization
20
20
 
21
21
  Any scientific use of `RTModel` should be acknowledged by citing the paper [V.Bozza, A&A 688 (2024) 83](https://ui.adsabs.harvard.edu/abs/2024A%26A...688A..83B/abstract), describing all the algorithms behind the code.
22
22
 
23
- We are grateful to Greg Olmschenk, who revised the package installation in order to make it as cross-platform as possible.
23
+ We are grateful to Greg Olmschenk, who revised the package installation in order to make it as cross-platform as possible. We also thank all the users who are providing suggestions, reporting bugs or failures: Etienne Bachelet, David Bennett, Jonathan Brashear, Stela Ishitani Silva, Yiannis Tsapras, Keto Zhang.
24
24
 
25
25
  ## Installation
26
26
 
@@ -80,13 +80,16 @@ class RTModel:
80
80
  f.write('thresholdoutliers = ' + str(self.Reader_thresholdoutliers) + '\n')
81
81
  print('- Launching: Reader')
82
82
  print(' Pre-processing data...')
83
- completedprocess = subprocess.run([self.bindir+self.readerexe,self.eventname], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
84
- if(completedprocess.returncode != 0):
85
- print('! Error in pre-processing. Please check your data!')
86
- self.done = True
87
- else:
83
+ try:
84
+ completedprocess=subprocess.run([self.bindir+self.readerexe,self.eventname], cwd = self.bindir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, text = True)
88
85
  print(' OK')
89
-
86
+ except subprocess.CalledProcessError as e:
87
+ print('\033[30;41m! Error in pre-processing. Please check your data!\033[m')
88
+ print('\033[30;43m'+e.stdout+'\033[m')
89
+ print('\033[30;43m'+e.stderr+'\033[m')
90
+ print('\033[30;41m! Program stopped here!\033[m')
91
+ self.done = True
92
+
90
93
  def config_InitCond(self, npeaks = 2, peakthreshold = 10.0, oldmodels = 4, override = None, nostatic = False, onlyorbital = False, usesatellite = 0
91
94
  , templatelibrary = None, modelcategories = ['PS','PX','BS','BO','LS','LX','LO'], onlyupdate =False):
92
95
  self.InitCond_npeaks = npeaks # Number of peaks in the observed light curve to be considered for setting initial conditions.
@@ -124,11 +127,8 @@ class RTModel:
124
127
  f.write('onlyupdate = 1\n')
125
128
  print('- Launching: InitCond')
126
129
  print(' Setting initial conditions...')
127
- completedprocess = subprocess.run([self.bindir+self.initcondexe,self.eventname], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
128
- if(completedprocess.returncode != 0):
129
- print('! Error in setting initial conditions!')
130
- self.done = True
131
- else:
130
+ try:
131
+ completedprocess=subprocess.run([self.bindir+self.initcondexe,self.eventname], cwd = self.bindir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, text = True)
132
132
  peaksearch = True
133
133
  i=0
134
134
  while(peaksearch):
@@ -141,9 +141,16 @@ class RTModel:
141
141
  for i in range(0,npeaks):
142
142
  print(f'{float(f.readline().split()[0]):.4f}',end = ' ')
143
143
  print('\n OK')
144
+ except subprocess.CalledProcessError as e:
145
+ print('\033[30;41m! Error in setting initial conditions!\033[m')
146
+ print('\033[30;43m'+e.stdout+'\033[m')
147
+ print('\033[30;43m'+e.stderr+'\033[m')
148
+ print('\033[30;41m! Program stopped here!\033[m')
149
+ self.done = True
144
150
 
145
- def config_LevMar(self, nfits = 5, timelimit = 600.0, maxsteps = 50, bumperpower = 2.0):
151
+ def config_LevMar(self, nfits = 6, offsetdegeneracy = 3, timelimit = 600.0, maxsteps = 50, bumperpower = 2.0):
146
152
  self.LevMar_nfits = nfits # Number of models to be calculated from the same initial condition using the bumper method
153
+ self.LevMar_offsetdegeneracy = offsetdegeneracy # Number of models to be fit after applying offset degeneracy to best model found so far
147
154
  self.LevMar_maxsteps = maxsteps # Maximum number of steps in each fit
148
155
  self.LevMar_timelimit = timelimit # Maximum time in seconds for total execution
149
156
  self.LevMar_bumperpower = bumperpower # Repulsion factor of bumpers
@@ -160,6 +167,7 @@ class RTModel:
160
167
  f.write(line)
161
168
  with open(self.eventname + '/' + self.inidir + '/LevMar.ini','w') as f:
162
169
  f.write('nfits = ' + str(self.LevMar_nfits) + '\n')
170
+ f.write('offsetdegeneracy = ' + str(self.LevMar_offsetdegeneracy) + '\n')
163
171
  f.write('maxsteps = ' + str(self.LevMar_maxsteps) + '\n')
164
172
  f.write('timelimit = ' + str(self.LevMar_timelimit) + '\n')
165
173
  f.write('bumperpower = ' + str(self.LevMar_bumperpower) + '\n')
@@ -167,18 +175,22 @@ class RTModel:
167
175
  f.write('parametersfile = ' + parameters_file)
168
176
  print('- Launching: LevMar')
169
177
  print(' Fitting ' + strmodel + ' ...')
170
- completedprocess = subprocess.run([self.bindir+self.levmarexe,self.eventname, strmodel,self.satellitedir], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
171
- if(completedprocess.returncode != 0):
172
- print('! Error in fit!')
173
- self.done = True
174
- else:
178
+ try:
179
+ completedprocess=subprocess.run([self.bindir+self.levmarexe,self.eventname, strmodel,self.satellitedir], cwd = self.bindir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, text = True)
175
180
  print(' OK')
181
+ except subprocess.CalledProcessError as e:
182
+ print('\033[30;41m! Error in fit!\033[m')
183
+ print('\033[30;43m'+e.stdout+'\033[m')
184
+ print('\033[30;43m'+e.stderr+'\033[m')
185
+ print('\033[30;41m! Program stopped here!\033[m')
186
+ self.done = True
176
187
 
177
188
  def launch_fits(self,modelcode):
178
189
  if(not os.path.exists(self.eventname + '/' + self.inidir)):
179
190
  os.makedirs(self.eventname + '/' + self.inidir)
180
191
  with open(self.eventname + '/' + self.inidir + '/LevMar.ini','w') as f:
181
192
  f.write('nfits = ' + str(self.LevMar_nfits) + '\n')
193
+ f.write('offsetdegeneracy = ' + str(self.LevMar_offsetdegeneracy) + '\n')
182
194
  f.write('maxsteps = ' + str(self.LevMar_maxsteps) + '\n')
183
195
  f.write('timelimit = ' + str(self.LevMar_timelimit) + '\n')
184
196
  f.write('bumperpower = ' + str(self.LevMar_bumperpower) + '\n')
@@ -204,18 +216,24 @@ class RTModel:
204
216
  procepochs = []
205
217
  iinitcond = 0
206
218
  finitcond = 0
207
- finitcondold = -1
219
+ finitcondold = -1
220
+ timeouts = 0
221
+ crashes = 0
208
222
  pbar = tqdm(total = ninitconds,desc = 'Fits completed',file=sys.stdout, colour='GREEN', smoothing = 0)
209
223
  while(finitcond < ninitconds):
210
224
  i=0
211
225
  while i < len(processes):
212
226
  if(time.time() - procepochs[i] > self.LevMar_timelimit):
213
227
  processes[i].kill()
228
+ timeouts += 1
229
+ crashes -= 1
214
230
  premodfiles = glob.glob(self.eventname +'/PreModels/*.txt')
215
231
  strmodel = modelcode + '{:0>4}'.format(str(procnumbers[i]))
216
232
  with open(self.eventname +'/PreModels/' + strmodel + '/t' + strmodel + '.dat','w') as f:
217
233
  f.write(f'{len(premodfiles)} {self.LevMar_nfits}')
218
234
  if(processes[i].poll() != None):
235
+ if(processes[i].returncode!=0):
236
+ crashes +=1
219
237
  processes.pop(i)
220
238
  procnumbers.pop(i)
221
239
  procepochs.pop(i)
@@ -237,6 +255,11 @@ class RTModel:
237
255
  finitcondold =finitcond
238
256
  time.sleep(0.1)
239
257
  pbar.close()
258
+ if(crashes>0):
259
+ print('crashed fits: ' + str(crashes))
260
+ if(timeouts>0):
261
+ print('timed out fits: ' + str(timeouts))
262
+ print(' OK')
240
263
  else:
241
264
  print('- No initial conditions for this category')
242
265
 
@@ -263,25 +286,31 @@ class RTModel:
263
286
  'TS' : '- Selecting models for Triple-lens-Single-source fits',
264
287
  'TX' : '- Selecting models for Triple-lens-Single-source fits with parallax'}
265
288
  print(stringmodels[modelcode])
266
- completedprocess = subprocess.run([self.bindir+self.modelselectorexe,self.eventname, modelcode], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
267
- if(completedprocess.returncode != 0):
268
- print('! Error in model selection!')
269
- self.done = True
270
- else:
289
+ try:
290
+ completedprocess=subprocess.run([self.bindir+self.modelselectorexe,self.eventname, modelcode], cwd = self.bindir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, text = True)
271
291
  print(' OK')
292
+ except subprocess.CalledProcessError as e:
293
+ print('\033[30;41m! Error in model selection!\033[m')
294
+ print('\033[30;43m'+e.stdout+'\033[m')
295
+ print('\033[30;43m'+e.stderr+'\033[m')
296
+ print('\033[30;41m! Program stopped here!\033[m')
297
+ self.done = True
272
298
 
273
299
  def Finalizer(self):
274
300
  print('- Launching: Finalizer')
275
301
  print(' Making final assessment for this event')
276
- completedprocess = subprocess.run([self.bindir+self.finalizerexe,self.eventname], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
277
- if(completedprocess.returncode != 0):
278
- print('! Error in finalization. Maybe there are problems with models')
279
- self.done = True
280
- else:
302
+ try:
303
+ completedprocess=subprocess.run([self.bindir+self.finalizerexe,self.eventname], cwd = self.bindir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, text = True)
281
304
  with open(self.eventname + '/Nature.txt') as f:
282
305
  for line in f.readlines():
283
306
  print(" " + line,end='')
284
307
  print(" OK")
308
+ except subprocess.CalledProcessError as e:
309
+ print('\033[30;41m! Error in finalization!\033[m')
310
+ print('\033[30;43m'+e.stdout+'\033[m')
311
+ print('\033[30;43m'+e.stderr+'\033[m')
312
+ print('\033[30;41m! Program stopped here!\033[m')
313
+ self.done = True
285
314
 
286
315
  def run(self, event = None, cleanup = False):
287
316
  phase =0
@@ -317,7 +346,7 @@ class RTModel:
317
346
  elif phase > self.endphase:
318
347
  if(cleanup):
319
348
  print('- Cleaning up preliminary models')
320
- cleanup_preliminary_models()
349
+ self.cleanup_preliminary_models()
321
350
  print("- Analysis of " + self.eventname + " successfully completed!")
322
351
  print("o " + time.asctime())
323
352
  self.done = True
@@ -435,6 +464,8 @@ class RTModel:
435
464
  chunks = line.split()
436
465
  if(chunks[0]=='nfits'):
437
466
  self.LevMar_nfits = int(chunks[2])
467
+ if(chunks[0]=='offsetdegeneracy'):
468
+ self.LevMar_offsetdegeneracy = int(chunks[2])
438
469
  elif(chunks[0]=='maxsteps'):
439
470
  self.LevMar_maxsteps = int(chunks[2])
440
471
  elif(chunks[0]=='timelimit'):
@@ -1,4 +1,4 @@
1
- __version__ = "2.2"
1
+ __version__ = "2.4"
2
2
  __author__ = 'Valerio Bozza'
3
3
  __credits__ = 'University of Salerno, Italy'
4
4
 
@@ -14,6 +14,7 @@ public:
14
14
  int nps;
15
15
  char modelcode[16];
16
16
  int il;
17
+ bool duplicate;
17
18
  bumper(double *,int);
18
19
  ~bumper();
19
20
  void SetCurvature(double *,double);
@@ -29,4 +30,4 @@ double Determinant(double *,int);
29
30
  void Inverse(double*, double*, int);
30
31
  void CombineCovariances(bumper*, bumper*, double *Cov, double * Curv, int);
31
32
 
32
- #endif
33
+ #endif
@@ -44,6 +44,7 @@ int main(int argc, char* argv[]) {
44
44
  bumper* bumperlist = 0, * scanbumper, * scanbumper2;
45
45
 
46
46
 
47
+ setbuf(stdout, nullptr);
47
48
  printf("******************************************\n");
48
49
  printf("********** Finalizer *********\n");
49
50
  printf("******************************************\n\n\n");
@@ -285,69 +286,99 @@ int main(int argc, char* argv[]) {
285
286
  }
286
287
 
287
288
  // Making assessment. Each category is tested against nested ones
289
+ vector<int> dependencies[] = { {},
290
+ {0},
291
+ {0},
292
+ {0,1,2},
293
+ {0},
294
+ {0,1,4},
295
+ {0,1,4,5},
296
+ {0,1,4,5,6},
297
+ {0,4},
298
+ {0,1,4,5},
299
+ };
300
+ double modelthrs[ncategories];
288
301
 
289
- if (chis[1] > chis[0] - thrs[npss[1] - npss[0]]) {
290
- chis[1] = 1.e100;
291
- }
292
- if (chis[2] > chis[0] - thrs[npss[2] - npss[0]]) {
293
- chis[2] = 1.e100;
294
- }
295
- if (chis[3] > chis[0] - thrs[npss[3] - npss[0]] || chis[3] > chis[1] - thrs[npss[3] - npss[1]] || chis[3] > chis[2] - thrs[npss[3] - npss[2]]) {
296
- chis[3] = 1.e100;
297
- }
298
- if (chis[4] > chis[0] - thrs[npss[4] - npss[0]]) {
299
- chis[4] = 1.e100;
300
- }
301
- if (chis[5] > chis[0] - thrs[npss[5] - npss[0]] || chis[5] > chis[1] - thrs[npss[5] - npss[1]] || chis[5] > chis[4] - thrs[npss[5] - npss[4]]) {
302
- chis[5] = 1.e100;
303
- }
304
- if (chis[6] > chis[0] - thrs[npss[6] - npss[0]] || chis[6] > chis[1] - thrs[npss[6] - npss[1]] || chis[6] > chis[4] - thrs[npss[6] - npss[4]] || chis[6] > chis[5] - thrs[npss[6] - npss[5]]) {
305
- chis[6] = 1.e100;
306
- }
307
- if (chis[7] > chis[0] - thrs[npss[7] - npss[0]] || chis[7] > chis[1] - thrs[npss[7] - npss[1]] || chis[7] > chis[4] - thrs[npss[7] - npss[4]] || chis[7] > chis[5] - thrs[npss[7] - npss[5]] || chis[7] > chis[6] - thrs[npss[7] - npss[6]]) {
308
- chis[7] = 1.e100;
309
- }
310
- if (chis[8] > chis[0] - thrs[npss[8] - npss[0]] || chis[8] > chis[4] - thrs[npss[8] - npss[4]]) {
311
- chis[8] = 1.e100;
312
- }
313
- if (chis[9] > chis[0] - thrs[npss[9] - npss[0]] || chis[9] > chis[1] - thrs[npss[9] - npss[1]] || chis[9] > chis[4] - thrs[npss[9] - npss[4]] || chis[9] > chis[5] - thrs[npss[9] - npss[5]]) {
314
- chis[9] = 1.e100;
302
+ for (int icat = 0; icat < ncategories; icat++) {
303
+ modelthrs[icat] = thsigma;
304
+ for (int jdep = 0; jdep < dependencies[icat].size(); jdep++) {
305
+ double thr= chis[dependencies[icat][jdep]] - thrs[npss[icat] - npss[dependencies[icat][jdep]]];
306
+ if (thr < modelthrs[icat]) modelthrs[icat] = thr;
307
+ }
308
+ if (chis[icat] > modelthrs[icat]) {
309
+ chis[icat] = 1.e100;
310
+ }
315
311
  }
316
312
 
313
+ //if (chis[1] > chis[0] - thrs[npss[1] - npss[0]]) {
314
+ // chis[1] = 1.e100;
315
+ //}
316
+ //if (chis[2] > chis[0] - thrs[npss[2] - npss[0]]) {
317
+ // chis[2] = 1.e100;
318
+ //}
319
+ //if (chis[3] > chis[0] - thrs[npss[3] - npss[0]] || chis[3] > chis[1] - thrs[npss[3] - npss[1]] || chis[3] > chis[2] - thrs[npss[3] - npss[2]]) {
320
+ // chis[3] = 1.e100;
321
+ //}
322
+ //if (chis[4] > chis[0] - thrs[npss[4] - npss[0]]) {
323
+ // chis[4] = 1.e100;
324
+ //}
325
+ //if (chis[5] > chis[0] - thrs[npss[5] - npss[0]] || chis[5] > chis[1] - thrs[npss[5] - npss[1]] || chis[5] > chis[4] - thrs[npss[5] - npss[4]]) {
326
+ // chis[5] = 1.e100;
327
+ //}
328
+ //if (chis[6] > chis[0] - thrs[npss[6] - npss[0]] || chis[6] > chis[1] - thrs[npss[6] - npss[1]] || chis[6] > chis[4] - thrs[npss[6] - npss[4]] || chis[6] > chis[5] - thrs[npss[6] - npss[5]]) {
329
+ // chis[6] = 1.e100;
330
+ //}
331
+ //if (chis[7] > chis[0] - thrs[npss[7] - npss[0]] || chis[7] > chis[1] - thrs[npss[7] - npss[1]] || chis[7] > chis[4] - thrs[npss[7] - npss[4]] || chis[7] > chis[5] - thrs[npss[7] - npss[5]] || chis[7] > chis[6] - thrs[npss[7] - npss[6]]) {
332
+ // chis[7] = 1.e100;
333
+ //}
334
+ //if (chis[8] > chis[0] - thrs[npss[8] - npss[0]] || chis[8] > chis[4] - thrs[npss[8] - npss[4]]) {
335
+ // chis[8] = 1.e100;
336
+ //}
337
+ //if (chis[9] > chis[0] - thrs[npss[9] - npss[0]] || chis[9] > chis[1] - thrs[npss[9] - npss[1]] || chis[9] > chis[4] - thrs[npss[9] - npss[4]] || chis[9] > chis[5] - thrs[npss[9] - npss[5]]) {
338
+ // chis[9] = 1.e100;
339
+ //}
340
+
317
341
  // If more complicated category has survived, all nested categories are removed
318
342
 
319
- if (chis[9] < 1.e99) {
320
- chis[5] = chis[4] = chis[1] = chis[0] = 1.e100;
321
- }
322
- if (chis[8] < 1.e99) {
323
- chis[4] = chis[0] = 1.e100;
324
- }
325
- if (chis[7] < 1.e99) {
326
- chis[6] = chis[5] = chis[4] = chis[1] = chis[0] = 1.e100;
327
- }
328
- if (chis[6] < 1.e99) {
329
- chis[5] = chis[4] = chis[1] = chis[0] = 1.e100;
330
- }
331
- if (chis[5] < 1.e99) {
332
- chis[4] = chis[1] = chis[0] = 1.e100;
333
- }
334
- if (chis[4] < 1.e99) {
335
- chis[0] = 1.e100;
336
- }
337
- if (chis[3] < 1.e99) {
338
- chis[2] = chis[1] = chis[0] = 1.e100;
339
- }
340
- if (chis[2] < 1.e99) {
341
- chis[0] = 1.e100;
342
- }
343
- if (chis[1] < 1.e99) {
344
- chis[0] = 1.e100;
343
+ for (int icat = ncategories - 1; icat > 0; icat--) {
344
+ if (chis[icat] < 1.e99) {
345
+ for (int jdep = 0; jdep < dependencies[icat].size(); jdep++) {
346
+ chis[dependencies[icat][jdep]] = 1.e100;
347
+ }
348
+ }
345
349
  }
350
+ //if (chis[9] < 1.e99) {
351
+ // chis[5] = chis[4] = chis[1] = chis[0] = 1.e100;
352
+ //}
353
+ //if (chis[8] < 1.e99) {
354
+ // chis[4] = chis[0] = 1.e100;
355
+ //}
356
+ //if (chis[7] < 1.e99) {
357
+ // chis[6] = chis[5] = chis[4] = chis[1] = chis[0] = 1.e100;
358
+ //}
359
+ //if (chis[6] < 1.e99) {
360
+ // chis[5] = chis[4] = chis[1] = chis[0] = 1.e100;
361
+ //}
362
+ //if (chis[5] < 1.e99) {
363
+ // chis[4] = chis[1] = chis[0] = 1.e100;
364
+ //}
365
+ //if (chis[4] < 1.e99) {
366
+ // chis[0] = 1.e100;
367
+ //}
368
+ //if (chis[3] < 1.e99) {
369
+ // chis[2] = chis[1] = chis[0] = 1.e100;
370
+ //}
371
+ //if (chis[2] < 1.e99) {
372
+ // chis[0] = 1.e100;
373
+ //}
374
+ //if (chis[1] < 1.e99) {
375
+ // chis[0] = 1.e100;
376
+ //}
346
377
 
347
378
  // Models of discarded categories or with chi square higher than threshold are removed
348
379
 
349
380
  for (scanbumper = bumperlist; scanbumper; scanbumper = scanbumper->next) {
350
- if (scanbumper->Amp > thsigma || chis[scanbumper->il] > 1.e99) scanbumper->modelcode[0] = 'N';
381
+ if (scanbumper->Amp > modelthrs[scanbumper->il] || chis[scanbumper->il] > 1.e99) scanbumper->modelcode[0] = 'N';
351
382
  }
352
383
 
353
384
  // Counting good models
@@ -21,7 +21,7 @@ char systemslash = '/';
21
21
 
22
22
  // Main global parameters
23
23
  int nobspeaks = 2; // Number of peaks in the observed light curve to be considered for setting initial conditions.
24
- double sigmathr = 5.; // Number of sigmas for spline approximation
24
+ double sigmathr = 5.; // Number of sigmas for spline approximation currently set to 0.5 peakthr
25
25
  double peakthr = 10.; // Number of sigmnas necessary for a deviation to be identified as a maximum or a minimum.
26
26
  int maxoldmodels = 4; // Maximum number of old models to include in new run as initial conditions
27
27
  bool override = false; // Override peak identification and manually set peak times
@@ -72,6 +72,7 @@ int main(int argc, char* argv[])
72
72
  dataset** peaklist, * cpeaks, * newpeaks;
73
73
  datapoint* p, * pm, * pmm, * pl, * pr, * pasy = 0, * highestpeak, * minimum, * startsection, * endsection, * sectionpeak;
74
74
 
75
+ setbuf(stdout, nullptr);
75
76
 
76
77
  // Directory preliminaries. Reads event name from arguments.
77
78
 
@@ -93,6 +94,9 @@ int main(int argc, char* argv[])
93
94
 
94
95
  printf("\n\n- Event: %s\n", eventname);
95
96
 
97
+ if (!exists(eventname)) {
98
+ throw(1);
99
+ }
96
100
  current_path(eventname);
97
101
 
98
102
 
@@ -146,7 +150,7 @@ int main(int argc, char* argv[])
146
150
  if (strcmp(command, "override") == 0) {
147
151
  fscanf(f, " %lf", &value2);
148
152
  override = true;
149
- sscanf(value,"%lf",&t1);
153
+ sscanf(value, "%lf", &t1);
150
154
  t2 = value2;
151
155
  }
152
156
  if (strcmp(command, "npeaks") == 0) {
@@ -223,7 +227,7 @@ int main(int argc, char* argv[])
223
227
  if (onlyupdate) {
224
228
  newpeaks = new dataset;
225
229
  newpeaks->length = 0;
226
- newpeaks->first = newpeaks->last=0;
230
+ newpeaks->first = newpeaks->last = 0;
227
231
  }
228
232
  else {
229
233
 
@@ -254,6 +258,10 @@ int main(int argc, char* argv[])
254
258
 
255
259
  f = fopen("LCToFit.txt", "r");
256
260
  fscanf(f, "%d", &np);
261
+ if (np == 0) {
262
+ printf("\n! No data !");
263
+ return -1;
264
+ }
257
265
 
258
266
  nfil = 1;
259
267
  dn = 0;
@@ -271,6 +279,10 @@ int main(int argc, char* argv[])
271
279
  dn = ifil;
272
280
  }
273
281
  fclose(f);
282
+ if (np == 0) {
283
+ printf("\n! No datasets match the chosen satellite!\n Check your usesatellite option.");
284
+ return -1;
285
+ }
274
286
  np++;
275
287
 
276
288
  tt = (double*)malloc(sizeof(double) * np);
@@ -878,7 +890,7 @@ int main(int argc, char* argv[])
878
890
 
879
891
  current_path(eventname);
880
892
 
881
- dn = 0;
893
+ dn = 0;
882
894
  if (strstr(modelcategories, "PS") != 0) {
883
895
  filebest = regex("PS.*\\.txt");
884
896
  strcpy(fileinit, "InitCondPS.txt");
@@ -3,10 +3,10 @@
3
3
 
4
4
  #include "LevMarFit.h"
5
5
 
6
- int main(int argc, char *argv[])
6
+ int main(int argc, char* argv[])
7
7
  {
8
- LevMar *MyLevMar= new LevMar(argc,argv);
9
- MyLevMar->Run();
8
+ LevMar* MyLevMar = new LevMar(argc, argv);
9
+ int err = MyLevMar->Run();
10
10
  delete MyLevMar;
11
- return 0;
11
+ return err;
12
12
  }