RTModel 2.4__tar.gz → 3.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.
- {rtmodel-2.4 → rtmodel-3.1}/PKG-INFO +7 -7
- {rtmodel-2.4 → rtmodel-3.1}/README.md +5 -5
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/RTModel.py +125 -18
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/__init__.py +1 -1
- rtmodel-3.1/RTModel/data/SunEphemeris.txt +22130 -0
- {rtmodel-2.4/RTModel/lib → rtmodel-3.1/RTModel/include}/LevMarFit.h +15 -29
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/include/bumper.h +5 -1
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/lib/Finalizer.cpp +51 -85
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/lib/InitCond.cpp +164 -92
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/lib/LevMarFit.cpp +764 -570
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/lib/ModelSelector.cpp +233 -178
- rtmodel-3.1/RTModel/lib/Reader.cpp +700 -0
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/lib/bumper.cpp +14 -1
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/plotmodel/__init__.py +1 -1
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/plotmodel/plotmodel.py +295 -49
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/templates/__init__.py +1 -1
- {rtmodel-2.4 → rtmodel-3.1}/changelog.md +4 -0
- {rtmodel-2.4 → rtmodel-3.1}/docs/Animation.md +7 -8
- {rtmodel-2.4 → rtmodel-3.1}/docs/Archive.md +3 -8
- rtmodel-3.1/docs/AstrometricPlots.md +57 -0
- rtmodel-3.1/docs/Astrophotometric.md +68 -0
- {rtmodel-2.4 → rtmodel-3.1}/docs/Constraints.md +5 -1
- {rtmodel-2.4 → rtmodel-3.1}/docs/DataPreparation.md +1 -1
- {rtmodel-2.4 → rtmodel-3.1}/docs/DataPreprocessing.md +4 -4
- {rtmodel-2.4 → rtmodel-3.1}/docs/FinalAssessment.md +1 -1
- {rtmodel-2.4 → rtmodel-3.1}/docs/Fitting.md +37 -7
- rtmodel-3.1/docs/HighResolutionImaging.md +84 -0
- {rtmodel-2.4 → rtmodel-3.1}/docs/InitCond.md +3 -2
- {rtmodel-2.4 → rtmodel-3.1}/docs/ModelCategories.md +19 -17
- {rtmodel-2.4 → rtmodel-3.1}/docs/ModelSelection.md +1 -1
- {rtmodel-2.4 → rtmodel-3.1}/docs/ModelingRun.md +2 -14
- {rtmodel-2.4 → rtmodel-3.1}/docs/PlotModel.md +4 -2
- rtmodel-3.1/docs/PreliminaryModels.md +26 -0
- {rtmodel-2.4 → rtmodel-3.1}/docs/README.md +19 -8
- {rtmodel-2.4 → rtmodel-3.1}/docs/Satellite.md +2 -2
- {rtmodel-2.4 → rtmodel-3.1}/docs/TemplateLibraries.md +2 -2
- rtmodel-3.1/docs/figs/fig.md +1 -0
- rtmodel-3.1/docs/figs/fig_HRimaging.png +0 -0
- rtmodel-3.1/docs/figs/fig_astro.png +0 -0
- rtmodel-3.1/docs/figs/fig_astro_Dec.png +0 -0
- rtmodel-3.1/docs/figs/fig_astro_RA.png +0 -0
- rtmodel-3.1/docs/figs/fig_astrophot.png +0 -0
- rtmodel-3.1/events/HRevent.zip +0 -0
- rtmodel-3.1/events/astroevent001.zip +0 -0
- rtmodel-3.1/events/event001done.zip +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/events/readme.md +7 -1
- {rtmodel-2.4 → rtmodel-3.1}/pyproject.toml +3 -3
- rtmodel-2.4/RTModel/include/LevMarFit.h +0 -91
- rtmodel-2.4/RTModel/lib/Reader.cpp +0 -671
- rtmodel-2.4/events/event001done.zip +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/.github/workflows/build_wheels.yml +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/.github/workflows/run_tests.yml +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/.gitignore +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/CMakeLists.txt +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/LICENSE +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/MANIFEST.in +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/data/ESPL.tbl +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/data/TemplateLibrary.txt +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/lib/LevMar.cpp +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/RTModel/templates/templates.py +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/docs/LimbDarkening.md +0 -0
- {rtmodel-2.4/docs → rtmodel-3.1/docs/figs}/Template.png +0 -0
- {rtmodel-2.4/docs → rtmodel-3.1/docs/figs}/ani.gif +0 -0
- {rtmodel-2.4/docs → rtmodel-3.1/docs/figs}/plotchain.png +0 -0
- {rtmodel-2.4/docs → rtmodel-3.1/docs/figs}/plotmodel_fig1.png +0 -0
- {rtmodel-2.4/docs → rtmodel-3.1/docs/figs}/plotmodel_fig2.png +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/events/OB190033.zip +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/events/event001.zip +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/events/event002.zip +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/events/satellite1.txt +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/fVBM.py +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/jupyter/Model_event001.ipynb +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/tests/build_tests/test_built_executables_exist.py +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/tests/end_to_end_tests/test_ps_run.py +0 -0
- {rtmodel-2.4 → rtmodel-3.1}/tests/end_to_end_tests/test_ps_run_resources/example_event.zip +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: RTModel
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.1
|
|
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>
|
|
@@ -16,11 +16,11 @@ Requires-Dist: pytest
|
|
|
16
16
|
Requires-Dist: matplotlib
|
|
17
17
|
Requires-Dist: tqdm
|
|
18
18
|
Requires-Dist: tabulate
|
|
19
|
-
Requires-Dist: VBMicrolensing>=
|
|
19
|
+
Requires-Dist: VBMicrolensing>=5.0
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
|
|
22
22
|
# RTModel
|
|
23
|
-
`RTModel` is a package for modeling and interpretation of microlensing events. It uses photometric time series collected from ground and/or space telescopes to propose one or more possible models among the following:
|
|
23
|
+
`RTModel` is a package for modeling and interpretation of microlensing events. It uses photometric and/or astrometric time series collected from ground and/or space telescopes to propose one or more possible models among the following:
|
|
24
24
|
- Single-lens-single-source microlensing (i.e. Paczynski)
|
|
25
25
|
- Single-lens-binary-source microlensing (with or without xallarap)
|
|
26
26
|
- Binary-lens-single-source microlensing (including planetary microlensing, parallax and orbital motion)
|
|
@@ -37,11 +37,11 @@ A second subpackage **`RTModel.templates`** helps the user in the visualization
|
|
|
37
37
|
|
|
38
38
|
## Attribution
|
|
39
39
|
|
|
40
|
-
`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](
|
|
40
|
+
`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](https://projects.phys.unisa.it/GravitationAstrophysics/RTModel.htm)).
|
|
41
41
|
|
|
42
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.
|
|
43
43
|
|
|
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
|
+
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, Laura Salmeri, Stela Ishitani Silva, Yiannis Tsapras, Sigfried Vanaverbeke, Keto Zhang.
|
|
45
45
|
|
|
46
46
|
## Installation
|
|
47
47
|
|
|
@@ -61,9 +61,9 @@ In alternative, you may directly install it from PyPI without cloning this repos
|
|
|
61
61
|
pip install RTModel
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
Currently, `RTModel` works on Linux, Windows and MacOS, requiring Python >= 3.
|
|
64
|
+
Currently, `RTModel` works on Linux, Windows and MacOS, requiring Python >= 3.7.
|
|
65
65
|
A C++ compiler compatible with C++17 standard is needed for installation.
|
|
66
|
-
`RTModel`
|
|
66
|
+
`RTModel` uses [`VBMicrolensing`](https://github.com/valboz/VBMicrolensing) for all calculations. You are encouraged to cite the relevant papers listed in that repository as well.
|
|
67
67
|
|
|
68
68
|
## Documentation
|
|
69
69
|
Full [documentation for the use of RTModel](docs/README.md) is available.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# RTModel
|
|
2
|
-
`RTModel` is a package for modeling and interpretation of microlensing events. It uses photometric time series collected from ground and/or space telescopes to propose one or more possible models among the following:
|
|
2
|
+
`RTModel` is a package for modeling and interpretation of microlensing events. It uses photometric and/or astrometric time series collected from ground and/or space telescopes to propose one or more possible models among the following:
|
|
3
3
|
- Single-lens-single-source microlensing (i.e. Paczynski)
|
|
4
4
|
- Single-lens-binary-source microlensing (with or without xallarap)
|
|
5
5
|
- Binary-lens-single-source microlensing (including planetary microlensing, parallax and orbital motion)
|
|
@@ -16,11 +16,11 @@ A second subpackage **`RTModel.templates`** helps the user in the visualization
|
|
|
16
16
|
|
|
17
17
|
## Attribution
|
|
18
18
|
|
|
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](
|
|
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](https://projects.phys.unisa.it/GravitationAstrophysics/RTModel.htm)).
|
|
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. 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.
|
|
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, Laura Salmeri, Stela Ishitani Silva, Yiannis Tsapras, Sigfried Vanaverbeke, Keto Zhang.
|
|
24
24
|
|
|
25
25
|
## Installation
|
|
26
26
|
|
|
@@ -40,9 +40,9 @@ In alternative, you may directly install it from PyPI without cloning this repos
|
|
|
40
40
|
pip install RTModel
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
Currently, `RTModel` works on Linux, Windows and MacOS, requiring Python >= 3.
|
|
43
|
+
Currently, `RTModel` works on Linux, Windows and MacOS, requiring Python >= 3.7.
|
|
44
44
|
A C++ compiler compatible with C++17 standard is needed for installation.
|
|
45
|
-
`RTModel`
|
|
45
|
+
`RTModel` uses [`VBMicrolensing`](https://github.com/valboz/VBMicrolensing) for all calculations. You are encouraged to cite the relevant papers listed in that repository as well.
|
|
46
46
|
|
|
47
47
|
## Documentation
|
|
48
48
|
Full [documentation for the use of RTModel](docs/README.md) is available.
|
|
@@ -32,7 +32,10 @@ class RTModel:
|
|
|
32
32
|
self.eventname = os.getcwd()
|
|
33
33
|
else:
|
|
34
34
|
self.eventname = os.path.realpath(event)
|
|
35
|
-
|
|
35
|
+
if(os.path.exists(self.eventname)):
|
|
36
|
+
print("Event name: " + self.eventname)
|
|
37
|
+
else:
|
|
38
|
+
print("! Invalid path for event: " + self.eventname)
|
|
36
39
|
self.inidir = "ini"
|
|
37
40
|
self.modelcodes = ['PS', 'PX', 'BS', 'BO', 'LS', 'LX', 'LO', 'LK', 'TS', 'TX']
|
|
38
41
|
self.endphase = len(self.modelcodes)*2+3
|
|
@@ -44,15 +47,40 @@ class RTModel:
|
|
|
44
47
|
self.config_LevMar()
|
|
45
48
|
self.config_ModelSelector()
|
|
46
49
|
self.satellitedir = '.'
|
|
47
|
-
|
|
50
|
+
self.astrometric = False
|
|
51
|
+
self.parameters_ranges = {'PS': [[-11.,1.0, 1.0],[-4.6, 7.6, 1.0],[-300,300,5.0],[-11.5,2.3,2.3]],
|
|
52
|
+
'PX': [[-3.0,3.0, 0.5],[-4.6, 7.6, 1.0],[-300,300,5.0],[-11.5,2.3,2.3],[-3.0,3.0,0.1],[-3.0,3.0,0.1]],
|
|
53
|
+
'BS': [[-4.6,7.6,1.0],[-11.5,0.0,0.5],[0,3.0,0.5],[0,3.0,0.5],[-300,300,1.0],[-300,300,1.0],[-11.5,2.3,2.3]],
|
|
54
|
+
'BO': [[-4.6,7.6,1.0],[-11.5,0.0,0.5],[0,3.0,0.5],[0,3.0,0.5],[-300,300,1.0],[-300,300,1.0],[-11.5,2.3,2.3],
|
|
55
|
+
[-3.0,3.0,0.03],[-3.0,3.0,0.03],[-1.0,1.0,0.01],[-1.0,1.0,0.01],[1.e-7,1.0,0.01]],
|
|
56
|
+
'LS': [[-4.0,3.0,.1],[-16.1,16.1,0.5],[-3.0,3.0,0.1], [-12.56,12.56,0.1],[-11.5,-2.5,0.3],[-4.6,7.6,0.6],
|
|
57
|
+
[-300,300,5.0]],
|
|
58
|
+
'LX': [[-4.0,3.0,.1],[-16.1,16.1,0.5],[-3.0,3.0,0.1], [-12.56,12.56,0.1],[-11.5,-2.5,0.3],[-4.6,7.6,0.6],
|
|
59
|
+
[-300,300,5.0],[-3.0,3.0,0.03],[-3.0,3.0,0.03]],
|
|
60
|
+
'LO': [[-4.0,3.0,.1],[-16.1,16.1,0.5],[-3.0,3.0,0.1], [-12.56,12.56,0.1],[-11.5,-2.5,0.3],[-4.6,7.6,0.6],
|
|
61
|
+
[-300,300,5.0],[-3.0,3.0,0.03],[-3.0,3.0,0.03],[-1.0,1.0,0.01],[-1.0,1.0,0.01],[1.e-7,1.0,0.01]],
|
|
62
|
+
'LK': [[-4.0,3.0,.1],[-16.1,16.1,0.5],[-3.0,3.0,0.1], [-12.56,12.56,0.1],[-11.5,-2.5,0.3],[-4.6,7.6,0.6],
|
|
63
|
+
[-300,300,5.0],[-3.0,3.0,0.03],[-3.0,3.0,0.03],[-1.0,1.0,0.01],[-1.0,1.0,0.01],[1.e-7,1.0,0.01],
|
|
64
|
+
[-10,10,0.1],[0.5001,10,0.1]],
|
|
65
|
+
'TS': [[-4.0,3.0,.1],[-16.1,16.1,0.5],[-3.0,3.0,0.1], [-12.56,12.56,0.1],[-11.5,-2.5,0.3],[-4.6,7.6,0.6],
|
|
66
|
+
[-300,300,5.0],[-4.0,3.0,0.3],[-11.5,11.5,0.5], [-12.56,12.56,0.3]],
|
|
67
|
+
'TX': [[-4.0,3.0,.1],[-16.1,16.1,0.5],[-3.0,3.0,0.1], [-12.56,12.56,0.1],[-11.5,-2.5,0.3],[-4.6,7.6,0.6],
|
|
68
|
+
[-300,300,5.0],[-4.0,3.0,0.3],[-11.5,11.5,0.5], [-12.56,12.56,0.3],[-3.0,3.0,0.03],[-3.0,3.0,0.03]],
|
|
69
|
+
'astrometry': [[-30.0,30.0,1.0],[-30.0,30.0,1.0],[0.05,1.0,0.1],[0.001,30.0,0.2]]
|
|
70
|
+
}
|
|
71
|
+
|
|
48
72
|
def set_processors(self, nprocessors):
|
|
49
73
|
self.nprocessors = nprocessors
|
|
50
74
|
|
|
51
75
|
def set_event(self, event):
|
|
52
76
|
self.eventname = os.path.realpath(event)
|
|
77
|
+
if(not os.path.exists(self.eventname)):
|
|
78
|
+
print("! Invalid path for event: " + self.eventname)
|
|
53
79
|
|
|
54
80
|
def set_satellite_dir(self, satellitedir):
|
|
55
|
-
self.satellitedir = satellitedir
|
|
81
|
+
self.satellitedir = os.path.realpath(satellitedir)
|
|
82
|
+
if(not os.path.exists(self.satellitedir)):
|
|
83
|
+
print("! Invalid path for satellite directory: " + self.satellitedir)
|
|
56
84
|
|
|
57
85
|
def set_constraints(self, constraints = None):
|
|
58
86
|
self.constraints = constraints
|
|
@@ -62,7 +90,21 @@ class RTModel:
|
|
|
62
90
|
for cons in constraints:
|
|
63
91
|
f.write(cons[0] + ' = '+ str(cons[1]) + ' '+ str(cons[2]) + ' '+ str(cons[3]) + ' ' + '\n')
|
|
64
92
|
|
|
65
|
-
def
|
|
93
|
+
def set_parameter_ranges(self):
|
|
94
|
+
if(not os.path.exists(self.eventname + '/' + self.inidir)):
|
|
95
|
+
os.makedirs(self.eventname + '/' + self.inidir)
|
|
96
|
+
with open(self.eventname + '/' + self.inidir + '/Parameters_Ranges.ini','w') as f:
|
|
97
|
+
for modelcode in self.modelcodes:
|
|
98
|
+
f.write(modelcode + '\n')
|
|
99
|
+
for par in self.parameters_ranges[modelcode]:
|
|
100
|
+
f.write(str(par[0]) + ' ' + str(par[1]) + ' ' + str(par[2]) + '\n')
|
|
101
|
+
modelcode = 'astrometry'
|
|
102
|
+
f.write(modelcode + '\n')
|
|
103
|
+
for par in self.parameters_ranges[modelcode]:
|
|
104
|
+
f.write(str(par[0]) + ' ' + str(par[1]) + ' ' + str(par[2]) + '\n')
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def config_Reader(self, tau = 0.1, binning = 4000, otherseasons = 100, renormalize = 1, thresholdoutliers = 10):
|
|
66
108
|
self.Reader_tau= tau # conventional correlation time for consecutive points
|
|
67
109
|
self.Reader_binning = binning # maximum number of points left after re-binning
|
|
68
110
|
self.Reader_otherseasons = otherseasons # How to use other seasons (0 = Yes, 1 = decrease significance, 2 = remove)
|
|
@@ -82,6 +124,15 @@ class RTModel:
|
|
|
82
124
|
print(' Pre-processing data...')
|
|
83
125
|
try:
|
|
84
126
|
completedprocess=subprocess.run([self.bindir+self.readerexe,self.eventname], cwd = self.bindir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, text = True)
|
|
127
|
+
with open(self.eventname + '/LCToFit.txt') as f:
|
|
128
|
+
lines = f.readlines()
|
|
129
|
+
del(lines[0])
|
|
130
|
+
self.astrometric = False
|
|
131
|
+
for line in lines:
|
|
132
|
+
if(float(line.split()[6])>0):
|
|
133
|
+
self.astrometric = True
|
|
134
|
+
print(' Astrometric data found: static models will be skipped')
|
|
135
|
+
break
|
|
85
136
|
print(' OK')
|
|
86
137
|
except subprocess.CalledProcessError as e:
|
|
87
138
|
print('\033[30;41m! Error in pre-processing. Please check your data!\033[m')
|
|
@@ -130,9 +181,9 @@ class RTModel:
|
|
|
130
181
|
try:
|
|
131
182
|
completedprocess=subprocess.run([self.bindir+self.initcondexe,self.eventname], cwd = self.bindir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, text = True)
|
|
132
183
|
peaksearch = True
|
|
133
|
-
|
|
184
|
+
imod=0
|
|
134
185
|
while(peaksearch):
|
|
135
|
-
initfils=glob.glob(self.eventname + '/InitCond/InitCond'+ self.modelcodes[
|
|
186
|
+
initfils=glob.glob(self.eventname + '/InitCond/InitCond'+ self.modelcodes[imod] + '*')
|
|
136
187
|
if(len(initfils)!=0):
|
|
137
188
|
peaksearch = False
|
|
138
189
|
with open(initfils[0], 'r') as f:
|
|
@@ -140,6 +191,7 @@ class RTModel:
|
|
|
140
191
|
print('Peaks: ',end ='')
|
|
141
192
|
for i in range(0,npeaks):
|
|
142
193
|
print(f'{float(f.readline().split()[0]):.4f}',end = ' ')
|
|
194
|
+
imod+=1
|
|
143
195
|
print('\n OK')
|
|
144
196
|
except subprocess.CalledProcessError as e:
|
|
145
197
|
print('\033[30;41m! Error in setting initial conditions!\033[m')
|
|
@@ -148,12 +200,20 @@ class RTModel:
|
|
|
148
200
|
print('\033[30;41m! Program stopped here!\033[m')
|
|
149
201
|
self.done = True
|
|
150
202
|
|
|
151
|
-
def config_LevMar(self, nfits = 6, offsetdegeneracy = 3, timelimit = 600.0, maxsteps = 50, bumperpower = 2.0
|
|
203
|
+
def config_LevMar(self, nfits = 6, offsetdegeneracy = 3, timelimit = 600.0, maxsteps = 50, bumperpower = 2.0, \
|
|
204
|
+
mass_luminosity_exponent = None, mass_radius_exponent = None, lens_mass_luminosity_exponent = None, \
|
|
205
|
+
turn_off_secondary_source = False, turn_off_secondary_lens = False):
|
|
152
206
|
self.LevMar_nfits = nfits # Number of models to be calculated from the same initial condition using the bumper method
|
|
153
207
|
self.LevMar_offsetdegeneracy = offsetdegeneracy # Number of models to be fit after applying offset degeneracy to best model found so far
|
|
154
208
|
self.LevMar_maxsteps = maxsteps # Maximum number of steps in each fit
|
|
155
209
|
self.LevMar_timelimit = timelimit # Maximum time in seconds for total execution
|
|
156
210
|
self.LevMar_bumperpower = bumperpower # Repulsion factor of bumpers
|
|
211
|
+
self.LevMar_mass_luminosity_exponent = mass_luminosity_exponent # mass-luminosity exponent for binary sources
|
|
212
|
+
self.LevMar_mass_radius_exponent = mass_radius_exponent # mass-radius exponent for binary sources
|
|
213
|
+
self.LevMar_lens_mass_luminosity_exponent = lens_mass_luminosity_exponent # mass-luminosity exponent for binary lenses
|
|
214
|
+
self.LevMar_turn_off_secondary_lens = turn_off_secondary_lens # Option for dark secondary lenses
|
|
215
|
+
self.LevMar_turn_off_secondary_source = turn_off_secondary_source # Option for dark secondary sources
|
|
216
|
+
self.LevMar_stepchainsave = False # If True, step chains are saved
|
|
157
217
|
|
|
158
218
|
def LevMar(self,strmodel, parameters_file = None, parameters = None):
|
|
159
219
|
if(not os.path.exists(self.eventname + '/' + self.inidir)):
|
|
@@ -165,14 +225,27 @@ class RTModel:
|
|
|
165
225
|
for fl in parameters:
|
|
166
226
|
line = line + str(fl) + ' '
|
|
167
227
|
f.write(line)
|
|
228
|
+
self.set_parameter_ranges()
|
|
168
229
|
with open(self.eventname + '/' + self.inidir + '/LevMar.ini','w') as f:
|
|
169
230
|
f.write('nfits = ' + str(self.LevMar_nfits) + '\n')
|
|
170
231
|
f.write('offsetdegeneracy = ' + str(self.LevMar_offsetdegeneracy) + '\n')
|
|
171
232
|
f.write('maxsteps = ' + str(self.LevMar_maxsteps) + '\n')
|
|
172
233
|
f.write('timelimit = ' + str(self.LevMar_timelimit) + '\n')
|
|
173
234
|
f.write('bumperpower = ' + str(self.LevMar_bumperpower) + '\n')
|
|
235
|
+
if(self.LevMar_mass_luminosity_exponent != None):
|
|
236
|
+
f.write('mass_luminosity_exponent = ' + str(self.LevMar_mass_luminosity_exponent) + '\n')
|
|
237
|
+
if(self.LevMar_mass_radius_exponent != None):
|
|
238
|
+
f.write('mass_radius_exponent = ' + str(self.LevMar_mass_radius_exponent) + '\n')
|
|
239
|
+
if(self.LevMar_mass_luminosity_exponent != None):
|
|
240
|
+
f.write('lens_mass_luminosity_exponent = ' + str(self.LevMar_lens_mass_luminosity_exponent) + '\n')
|
|
241
|
+
if(self.LevMar_turn_off_secondary_lens):
|
|
242
|
+
f.write('turn_off_secondary_lens = True\n')
|
|
243
|
+
if(self.LevMar_turn_off_secondary_source):
|
|
244
|
+
f.write('turn_off_secondary_source = True\n')
|
|
174
245
|
if(parameters_file != None):
|
|
175
246
|
f.write('parametersfile = ' + parameters_file)
|
|
247
|
+
if(self.LevMar_stepchainsave):
|
|
248
|
+
f.write('stepchainsave = True\n')
|
|
176
249
|
print('- Launching: LevMar')
|
|
177
250
|
print(' Fitting ' + strmodel + ' ...')
|
|
178
251
|
try:
|
|
@@ -194,6 +267,18 @@ class RTModel:
|
|
|
194
267
|
f.write('maxsteps = ' + str(self.LevMar_maxsteps) + '\n')
|
|
195
268
|
f.write('timelimit = ' + str(self.LevMar_timelimit) + '\n')
|
|
196
269
|
f.write('bumperpower = ' + str(self.LevMar_bumperpower) + '\n')
|
|
270
|
+
if(self.LevMar_mass_luminosity_exponent != None):
|
|
271
|
+
f.write('mass_luminosity_exponent = ' + str(self.LevMar_mass_luminosity_exponent) + '\n')
|
|
272
|
+
if(self.LevMar_mass_radius_exponent != None):
|
|
273
|
+
f.write('mass_radius_exponent = ' + str(self.LevMar_mass_radius_exponent) + '\n')
|
|
274
|
+
if(self.LevMar_lens_mass_luminosity_exponent != None):
|
|
275
|
+
f.write('lens_mass_luminosity_exponent = ' + str(self.LevMar_lens_mass_luminosity_exponent) + '\n')
|
|
276
|
+
if(self.LevMar_turn_off_secondary_lens):
|
|
277
|
+
f.write('turn_off_secondary_lens = True\n')
|
|
278
|
+
if(self.LevMar_turn_off_secondary_source):
|
|
279
|
+
f.write('turn_off_secondary_source = True\n')
|
|
280
|
+
if(self.LevMar_stepchainsave):
|
|
281
|
+
f.write('stepchainsave = True\n')
|
|
197
282
|
stringfits = {'PS' : '- Single-lens-Single-source fits',
|
|
198
283
|
'PX' : '- Single-lens-Single-source fits with parallax',
|
|
199
284
|
'BS' : '- Single-lens-Binary-source fits',
|
|
@@ -204,6 +289,7 @@ class RTModel:
|
|
|
204
289
|
'LK' : '- Binary-lens-Single-source fits with eccentric orbital motion',
|
|
205
290
|
'TS' : '- Triple-lens-Single-source fits',
|
|
206
291
|
'TX' : '- Triple-lens-Single-source fits with parallax'}
|
|
292
|
+
self.set_parameter_ranges()
|
|
207
293
|
print(stringfits[modelcode])
|
|
208
294
|
initcondfile = self.eventname + '/InitCond/' + 'InitCond'+ modelcode + '.txt'
|
|
209
295
|
if(os.path.exists(initcondfile)):
|
|
@@ -227,13 +313,22 @@ class RTModel:
|
|
|
227
313
|
processes[i].kill()
|
|
228
314
|
timeouts += 1
|
|
229
315
|
crashes -= 1
|
|
230
|
-
premodfiles = glob.glob(self.eventname +'/PreModels/*.txt')
|
|
231
|
-
strmodel = modelcode + '{:0>4}'.format(str(procnumbers[i]))
|
|
232
|
-
with open(self.eventname +'/PreModels/' + strmodel + '/t' + strmodel + '.dat','w') as f:
|
|
233
|
-
|
|
316
|
+
#premodfiles = glob.glob(self.eventname +'/PreModels/*.txt')
|
|
317
|
+
#strmodel = modelcode + '{:0>4}'.format(str(procnumbers[i]))
|
|
318
|
+
#with open(self.eventname +'/PreModels/' + strmodel + '/t' + strmodel + '.dat','w') as f:
|
|
319
|
+
# f.write(f'{len(premodfiles)} {self.LevMar_nfits}')
|
|
234
320
|
if(processes[i].poll() != None):
|
|
235
321
|
if(processes[i].returncode!=0):
|
|
236
322
|
crashes +=1
|
|
323
|
+
# Here we have to append results to main model file
|
|
324
|
+
if(not self.LevMar_stepchainsave):
|
|
325
|
+
strmodel = modelcode + '{:0>4}'.format(str(procnumbers[i])) + ".txt"
|
|
326
|
+
if(os.path.exists(self.eventname +'/PreModels/' + strmodel)):
|
|
327
|
+
with open(self.eventname +'/PreModels/' + strmodel) as f:
|
|
328
|
+
content = f.read()
|
|
329
|
+
with open(self.eventname +'/PreModels/'+ modelcode + ".txt","a") as f:
|
|
330
|
+
f.write(content)
|
|
331
|
+
os.remove(self.eventname +'/PreModels/' + strmodel)
|
|
237
332
|
processes.pop(i)
|
|
238
333
|
procnumbers.pop(i)
|
|
239
334
|
procepochs.pop(i)
|
|
@@ -242,12 +337,12 @@ class RTModel:
|
|
|
242
337
|
i += 1
|
|
243
338
|
while(iinitcond < ninitconds and len(processes) < self.nprocessors):
|
|
244
339
|
strmodel = modelcode + '{:0>4}'.format(str(iinitcond))
|
|
245
|
-
if(glob.glob(self.eventname +'/PreModels/' + strmodel + '/t' + strmodel + '.dat')==[]):
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
else:
|
|
250
|
-
|
|
340
|
+
#if(glob.glob(self.eventname +'/PreModels/' + strmodel + '/t' + strmodel + '.dat')==[]):
|
|
341
|
+
processes.append(subprocess.Popen([self.bindir+self.levmarexe,self.eventname, strmodel,self.satellitedir], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL))
|
|
342
|
+
procnumbers.append(iinitcond)
|
|
343
|
+
procepochs.append(time.time())
|
|
344
|
+
#else:
|
|
345
|
+
# finitcond += 1
|
|
251
346
|
iinitcond += 1
|
|
252
347
|
if(finitcond != finitcondold):
|
|
253
348
|
#print(' Fits launched: {}; completed: {}/{}'.format(iinitcond, finitcond, ninitconds))
|
|
@@ -312,7 +407,9 @@ class RTModel:
|
|
|
312
407
|
print('\033[30;41m! Program stopped here!\033[m')
|
|
313
408
|
self.done = True
|
|
314
409
|
|
|
315
|
-
def run(self, event = None, cleanup =
|
|
410
|
+
def run(self, event = None, cleanup = True):
|
|
411
|
+
if(not cleanup):
|
|
412
|
+
self.LevMar_stepchainsave = True
|
|
316
413
|
phase =0
|
|
317
414
|
if(event!= None):
|
|
318
415
|
self.eventname = os.path.realpath(event)
|
|
@@ -472,6 +569,16 @@ class RTModel:
|
|
|
472
569
|
self.LevMar_timelimit = float(chunks[2])
|
|
473
570
|
elif(chunks[0]=='bumperpower'):
|
|
474
571
|
self.LevMar_bumperpower = float(chunks[2])
|
|
572
|
+
elif(chunks[0] == 'turn_off_secondary_source' and chunks[2] == 'True'):
|
|
573
|
+
self.LevMar_turn_off_secondary_source = True
|
|
574
|
+
elif(chunks[0] == 'turn_off_secondary_lens' and chunks[2] == 'True'):
|
|
575
|
+
self.LevMar_turn_off_secondary_lens = True
|
|
576
|
+
elif(chunks[0] == 'mass_luminosity_exponent'):
|
|
577
|
+
self.LevMar_mass_luminosity_exponent = float(chunks[2])
|
|
578
|
+
elif(chunks[0] == 'mass_radius_exponent'):
|
|
579
|
+
self.LevMar_mass_radius_exponent = float(chunks[2])
|
|
580
|
+
elif(chunks[0] == 'lens_mass_luminosity_exponent'):
|
|
581
|
+
self.LevMar_lens_mass_luminosity_exponent = float(chunks[2])
|
|
475
582
|
if(os.path.exists(pathname + '/' + self.inidir + '/ModelSelector.ini')):
|
|
476
583
|
with open(pathname + '/' + self.inidir + '/ModelSelector.ini','r') as f:
|
|
477
584
|
lines = f.read().splitlines()
|