RTModel 2.0__tar.gz → 2.1.0__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 (72) hide show
  1. rtmodel-2.1.0/.github/workflows/run_tests.yml +41 -0
  2. rtmodel-2.1.0/.gitignore +42 -0
  3. rtmodel-2.1.0/CMakeLists.txt +49 -0
  4. {RTModel-2.0 → rtmodel-2.1.0}/LICENSE +3 -2
  5. {RTModel-2.0 → rtmodel-2.1.0}/MANIFEST.in +1 -2
  6. {RTModel-2.0/RTModel.egg-info → rtmodel-2.1.0}/PKG-INFO +76 -61
  7. {RTModel-2.0 → rtmodel-2.1.0}/README.md +23 -7
  8. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/RTModel.py +142 -11
  9. {RTModel-2.0/RTModel/plotmodel → rtmodel-2.1.0/RTModel}/__init__.py +2 -2
  10. rtmodel-2.1.0/RTModel/data/TemplateLibrary.txt +59 -0
  11. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/include/LevMarFit.h +1 -1
  12. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/include/VBBinaryLensingLibrary.h +1 -1
  13. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/lib/Finalizer.cpp +58 -57
  14. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/lib/InitCond.cpp +240 -211
  15. rtmodel-2.1.0/RTModel/lib/LevMarFit.cpp +1299 -0
  16. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/lib/ModelSelector.cpp +139 -135
  17. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/lib/Reader.cpp +4 -4
  18. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/lib/VBBinaryLensingLibrary.cpp +6 -6
  19. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/lib/bumper.cpp +2 -2
  20. rtmodel-2.1.0/RTModel/plotmodel/__init__.py +5 -0
  21. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/plotmodel/plotmodel.py +38 -8
  22. {RTModel-2.0/RTModel → rtmodel-2.1.0/RTModel/templates}/__init__.py +5 -5
  23. rtmodel-2.1.0/RTModel/templates/templates.py +88 -0
  24. rtmodel-2.1.0/changelog.md +4 -0
  25. rtmodel-2.1.0/docs/Animation.md +54 -0
  26. rtmodel-2.1.0/docs/Archive.md +50 -0
  27. rtmodel-2.1.0/docs/DataPreparation.md +46 -0
  28. rtmodel-2.1.0/docs/DataPreprocessing.md +85 -0
  29. rtmodel-2.1.0/docs/FinalAssessment.md +34 -0
  30. rtmodel-2.1.0/docs/Fitting.md +103 -0
  31. rtmodel-2.1.0/docs/InitCond.md +72 -0
  32. rtmodel-2.1.0/docs/LimbDarkening.md +19 -0
  33. rtmodel-2.1.0/docs/ModelCategories.md +152 -0
  34. rtmodel-2.1.0/docs/ModelSelection.md +68 -0
  35. rtmodel-2.1.0/docs/ModelingRun.md +133 -0
  36. rtmodel-2.1.0/docs/PlotModel.md +83 -0
  37. rtmodel-2.1.0/docs/README.md +91 -0
  38. rtmodel-2.1.0/docs/Satellite.md +66 -0
  39. rtmodel-2.1.0/docs/Template.png +0 -0
  40. rtmodel-2.1.0/docs/TemplateLibraries.md +88 -0
  41. rtmodel-2.1.0/docs/ani.gif +0 -0
  42. rtmodel-2.1.0/docs/plotchain.png +0 -0
  43. rtmodel-2.1.0/docs/plotmodel_fig1.png +0 -0
  44. rtmodel-2.1.0/docs/plotmodel_fig2.png +0 -0
  45. rtmodel-2.1.0/events/OB190033.zip +0 -0
  46. rtmodel-2.1.0/events/event001.zip +0 -0
  47. rtmodel-2.1.0/events/event001done.zip +0 -0
  48. rtmodel-2.1.0/events/event002.zip +0 -0
  49. rtmodel-2.1.0/events/readme.md +5 -0
  50. rtmodel-2.1.0/events/satellite1.txt +2691 -0
  51. rtmodel-2.1.0/jupyter/Model_event001.ipynb +94 -0
  52. {RTModel-2.0 → rtmodel-2.1.0}/pyproject.toml +4 -4
  53. rtmodel-2.1.0/tests/build_tests/test_built_executables_exist.py +33 -0
  54. rtmodel-2.1.0/tests/end_to_end_tests/test_ps_run.py +17 -0
  55. rtmodel-2.1.0/tests/end_to_end_tests/test_ps_run_resources/example_event.zip +0 -0
  56. RTModel-2.0/PKG-INFO +0 -61
  57. RTModel-2.0/RTModel/bin/Finalizer.exe +0 -0
  58. RTModel-2.0/RTModel/bin/InitCond.exe +0 -0
  59. RTModel-2.0/RTModel/bin/LevMar.exe +0 -0
  60. RTModel-2.0/RTModel/bin/ModelSelector.exe +0 -0
  61. RTModel-2.0/RTModel/bin/Reader.exe +0 -0
  62. RTModel-2.0/RTModel/data/TemplateLibrary.txt +0 -114
  63. RTModel-2.0/RTModel/lib/LevMarFit.cpp +0 -1277
  64. RTModel-2.0/RTModel.egg-info/SOURCES.txt +0 -32
  65. RTModel-2.0/RTModel.egg-info/dependency_links.txt +0 -1
  66. RTModel-2.0/RTModel.egg-info/requires.txt +0 -5
  67. RTModel-2.0/RTModel.egg-info/top_level.txt +0 -1
  68. RTModel-2.0/setup.cfg +0 -4
  69. RTModel-2.0/setup.py +0 -29
  70. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/data/ESPL.tbl +0 -0
  71. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/include/bumper.h +0 -0
  72. {RTModel-2.0 → rtmodel-2.1.0}/RTModel/lib/LevMar.cpp +0 -0
@@ -0,0 +1,41 @@
1
+ name: run_tests
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ run_tests:
7
+ name: run_tests_on_${{ matrix.os }}_python_${{ matrix.python_version }}_pip_install_flag_${{ matrix.pip_install_flag }}
8
+ runs-on: ${{ matrix.os }}
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ os: [ubuntu-latest, windows-latest, macos-latest]
13
+ python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
14
+ pip_install_flag: ["none", "editable", "user"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+
19
+ - name: setup_python_${{ matrix.python_version }}
20
+ uses: actions/setup-python@v4
21
+ with:
22
+ python-version: ${{ matrix.python_version }}
23
+
24
+ - name: install
25
+ shell: bash
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ if [ "${{ matrix.pip_install_flag }}" = "editable" ]; then
29
+ pip_install_flag="--editable"
30
+ elif [ "${{ matrix.pip_install_flag }}" = "user" ]; then
31
+ pip_install_flag="--user"
32
+ else
33
+ pip_install_flag=""
34
+ fi
35
+ pip install -v ${pip_install_flag} .
36
+
37
+ - name: test
38
+ run: |
39
+ pip install pytest
40
+ cd ..
41
+ python -m pytest RTModel/tests
@@ -0,0 +1,42 @@
1
+ ### C++ template
2
+ # Prerequisites
3
+ *.d
4
+
5
+ # Compiled Object files
6
+ *.slo
7
+ *.lo
8
+ *.o
9
+ *.obj
10
+
11
+ # Precompiled Headers
12
+ *.gch
13
+ *.pch
14
+
15
+ # Compiled Dynamic libraries
16
+ *.so
17
+ *.dylib
18
+ *.dll
19
+
20
+ # Fortran module files
21
+ *.mod
22
+ *.smod
23
+
24
+ # Compiled Static libraries
25
+ *.lai
26
+ *.la
27
+ *.a
28
+ *.lib
29
+
30
+ # Executables
31
+ *.exe
32
+ *.out
33
+ *.app
34
+
35
+ ### Example user template template
36
+ ### Example user template
37
+
38
+ # IntelliJ project files
39
+ .idea
40
+ *.iml
41
+ out
42
+ gen
@@ -0,0 +1,49 @@
1
+ cmake_minimum_required(VERSION 3.19)
2
+
3
+ project(RTModel LANGUAGES CXX)
4
+
5
+ set(CMAKE_CXX_STANDARD 17)
6
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
7
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
8
+ set(MINIMUM_GCC_VERSION "9.0")
9
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MINIMUM_GCC_VERSION)
10
+ message(FATAL_ERROR "GCC must be ${MINIMUM_GCC_VERSION} or greater.")
11
+ endif()
12
+ endif()
13
+
14
+ # Build executables
15
+ # =================
16
+
17
+ add_executable(Reader RTModel/lib/Reader.cpp)
18
+ target_include_directories(Reader PRIVATE RTModel/include)
19
+
20
+ add_executable(InitCond RTModel/lib/InitCond.cpp)
21
+ target_include_directories(InitCond PRIVATE RTModel/include)
22
+
23
+ add_executable(LevMar RTModel/lib/bumper.cpp RTModel/lib/LevMar.cpp RTModel/lib/LevMarFit.cpp
24
+ RTModel/lib/VBBinaryLensingLibrary.cpp)
25
+ target_include_directories(LevMar PRIVATE RTModel/include)
26
+
27
+ add_executable(ModelSelector RTModel/lib/bumper.cpp RTModel/lib/ModelSelector.cpp)
28
+ target_include_directories(ModelSelector PRIVATE RTModel/include)
29
+
30
+ add_executable(Finalizer RTModel/lib/bumper.cpp RTModel/lib/Finalizer.cpp)
31
+ target_include_directories(Finalizer PRIVATE RTModel/include)
32
+
33
+ # Install executables
34
+ # ===================
35
+
36
+ if(SKBUILD) # Only run if called through scikit-build-core. That is, don't run when called through CMake directly.
37
+ set(binary_directory "${SKBUILD_PLATLIB_DIR}/RTModel/bin")
38
+
39
+ install(TARGETS Reader DESTINATION ${binary_directory})
40
+ install(TARGETS InitCond DESTINATION ${binary_directory})
41
+ install(TARGETS LevMar DESTINATION ${binary_directory})
42
+ install(TARGETS ModelSelector DESTINATION ${binary_directory})
43
+ install(TARGETS Finalizer DESTINATION ${binary_directory})
44
+
45
+ # Ensure data files are present in platlib.
46
+ add_custom_command(TARGET Reader POST_BUILD
47
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
48
+ "${CMAKE_CURRENT_LIST_DIR}/RTModel/data" "${SKBUILD_PLATLIB_DIR}/RTModel/data")
49
+ endif()
@@ -1,7 +1,8 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+
2
3
  Version 3, 29 June 2007
3
4
 
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
6
  Everyone is permitted to copy and distribute verbatim copies
6
7
  of this license document, but changing it is not allowed.
7
8
 
@@ -1,6 +1,5 @@
1
- include RTModel/bin/Reader.exe
2
1
  graft RTModel/data
3
2
  graft RTModel/lib
4
3
  graft RTModel/include
5
4
  graft RTModel/bin
6
- global-exclude RTModel/lib/*.o*
5
+ global-exclude RTModel/lib/*.o*
@@ -1,61 +1,76 @@
1
- Metadata-Version: 2.1
2
- Name: RTModel
3
- Version: 2.0
4
- Summary: RTModel is a tool for microlensing event interpretation.
5
- Author-email: Valerio Bozza <valboz@sa.infn.it>
6
- License: GPL-3.0
7
- Project-URL: Homepage, https://github.com/valboz/RTModel
8
- Keywords: Microlensing analysis and fitting
9
- Classifier: Development Status :: 1 - Planning
10
- Classifier: Intended Audience :: Science/Research
11
- Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
12
- Classifier: Programming Language :: Python :: 3
13
- Requires-Python: <4,>=3.6
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
- Requires-Dist: numpy
17
- Requires-Dist: pytest
18
- Requires-Dist: matplotlib
19
- Requires-Dist: tqdm
20
- Requires-Dist: VBBinaryLensing>=3.7.0
21
-
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:
24
- - Single-lens-single-source microlensing (i.e. Paczynski)
25
- - Single-lens-binary-source microlensing (with or without xallarap)
26
- - Binary-lens-single-source microlensing (including planetary microlensing, parallax and orbital motion)
27
-
28
- All models include the finite-size of the source(s).
29
-
30
- The modeling strategy is based on a grid search in the parameter space for single-lens models, whereas a **template library** for binary-lens models is used including all possible geometries of the source trajectory with respect to the caustics. In addition to this global search, planets are searched where maximal deviations from a Paczynski model occurs.
31
-
32
- The library is in the form of a standard Python package that launches specific subprocesses for different tasks. Model fitting is executed in **parallel** exploiting available processors in the machine. The full modeling may take from one to three hours depending on the event and on the machine speed. The results of modeling are given in the form of a text **assessment file**; in addition, **final models** are made available with their parameters and covariance matrices.
33
-
34
- `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.
35
-
36
- ## Attribution
37
-
38
- A paper is in preparation describing all algorithms behind RTModel in detail.
39
- At the moment, any use of this code for scientific publications should be acknowledged by citing this GitHub repository.
40
-
41
- ## Installation
42
-
43
- The easiest way to install `RTModel` is through `pip`
44
- ```
45
- pip install RTModel
46
- ```
47
-
48
- Currently, `RTModel` works on Linux and Windows, requiring Python >= 3.6.
49
- A C++ compiler compatible with C++17 standard is needed for installation.
50
- `RTModel` also incorporates version 3.7 of [`VBBinaryLensing`](https://github.com/valboz/VBBinaryLensing).
51
-
52
- Example Jupyter notebooks will be included in `examples/`.
53
-
54
- ## Documentation
55
- Provisional [documentation for the use of RTModel](docs/README.md) is available and under development.
56
-
57
- ## License
58
- `RTModel` is freely available to the community under the
59
- GNU Lesser General Public License Version 3 included in this repository.
60
-
61
-
1
+ Metadata-Version: 2.1
2
+ Name: RTModel
3
+ Version: 2.1.0
4
+ Summary: RTModel is a tool for microlensing event interpretation.
5
+ Keywords: Microlensing analysis and fitting
6
+ Author-Email: Valerio Bozza <valboz@sa.infn.it>
7
+ License: GPL-3.0
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
11
+ Classifier: Programming Language :: Python :: 3
12
+ Project-URL: Homepage, https://github.com/valboz/RTModel
13
+ Requires-Python: <4,>=3.6
14
+ Requires-Dist: numpy
15
+ Requires-Dist: pytest
16
+ Requires-Dist: matplotlib
17
+ Requires-Dist: tqdm
18
+ Requires-Dist: VBBinaryLensing>=3.7.0
19
+ Description-Content-Type: text/markdown
20
+
21
+ # RTModel
22
+ `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
+ - Single-lens-single-source microlensing (i.e. Paczynski)
24
+ - Single-lens-binary-source microlensing (with or without xallarap)
25
+ - Binary-lens-single-source microlensing (including planetary microlensing, parallax and orbital motion)
26
+
27
+ All models include the finite-size of the source(s).
28
+
29
+ The modeling strategy is based on a grid search in the parameter space for single-lens models, whereas a **template library** for binary-lens models is used including all possible geometries of the source trajectory with respect to the caustics. In addition to this global search, planets are searched where maximal deviations from a Paczynski model occurs.
30
+
31
+ The library is in the form of a standard Python package that launches specific subprocesses for different tasks. Model fitting is executed in **parallel** exploiting available processors in the machine. The full modeling may take from one to three hours depending on the event and on the machine speed. The results of modeling are given in the form of a text **assessment file**; in addition, **final models** are made available with their parameters and covariance matrices.
32
+
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
+
35
+ ## Attribution
36
+
37
+ `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)).
38
+
39
+ 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.
40
+
41
+ We are grateful to Greg Olmschenk, who revised the package installation in order to make it as cross-platform as possible.
42
+
43
+ ## Installation
44
+
45
+ The easiest way to install `RTModel` is through `pip`.
46
+
47
+ First clone this repository.
48
+
49
+ Then go to the repository directory and type
50
+
51
+ ```
52
+ pip install .
53
+ ```
54
+
55
+ In alternative, you may directly install it from PyPI without cloning this repository:
56
+
57
+ ```
58
+ pip install RTModel
59
+ ```
60
+
61
+ Currently, `RTModel` works on Linux, Windows and MacOS, requiring Python >= 3.6.
62
+ A C++ compiler compatible with C++17 standard is needed for installation.
63
+ `RTModel` also incorporates version 3.7 of [`VBBinaryLensing`](https://github.com/valboz/VBBinaryLensing).
64
+
65
+ ## Documentation
66
+ Full [documentation for the use of RTModel](docs/README.md) is available.
67
+
68
+ In the directory [events](events) we provide some microlensing data on which you may practise with `RTModel`.
69
+
70
+ A Jupyter notebook for quick start-up is also available in the [jupyter](jupyter) folder.
71
+
72
+ ## License
73
+ `RTModel` is freely available to the community under the
74
+ GNU Lesser General Public License Version 3 included in this repository.
75
+
76
+
@@ -14,24 +14,40 @@ The library is in the form of a standard Python package that launches specific s
14
14
 
15
15
  ## Attribution
16
16
 
17
- A paper is in preparation describing all algorithms behind RTModel in detail.
18
- At the moment, any use of this code for scientific publications should be acknowledged by citing this GitHub repository.
17
+ `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)).
18
+
19
+ 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.
20
+
21
+ We are grateful to Greg Olmschenk, who revised the package installation in order to make it as cross-platform as possible.
19
22
 
20
23
  ## Installation
21
24
 
22
- The easiest way to install `RTModel` is through `pip`
25
+ The easiest way to install `RTModel` is through `pip`.
26
+
27
+ First clone this repository.
28
+
29
+ Then go to the repository directory and type
30
+
31
+ ```
32
+ pip install .
33
+ ```
34
+
35
+ In alternative, you may directly install it from PyPI without cloning this repository:
36
+
23
37
  ```
24
38
  pip install RTModel
25
39
  ```
26
40
 
27
- Currently, `RTModel` works on Linux and Windows, requiring Python >= 3.6.
41
+ Currently, `RTModel` works on Linux, Windows and MacOS, requiring Python >= 3.6.
28
42
  A C++ compiler compatible with C++17 standard is needed for installation.
29
43
  `RTModel` also incorporates version 3.7 of [`VBBinaryLensing`](https://github.com/valboz/VBBinaryLensing).
30
44
 
31
- Example Jupyter notebooks will be included in `examples/`.
32
-
33
45
  ## Documentation
34
- Provisional [documentation for the use of RTModel](docs/README.md) is available and under development.
46
+ Full [documentation for the use of RTModel](docs/README.md) is available.
47
+
48
+ In the directory [events](events) we provide some microlensing data on which you may practise with `RTModel`.
49
+
50
+ A Jupyter notebook for quick start-up is also available in the [jupyter](jupyter) folder.
35
51
 
36
52
  ## License
37
53
  `RTModel` is freely available to the community under the
@@ -1,10 +1,10 @@
1
-
1
+ import site
2
2
  import subprocess
3
3
  import os
4
4
  import sys
5
5
  import glob
6
6
  import time
7
- import inspect
7
+ from pathlib import Path
8
8
  from tqdm import tqdm
9
9
  import shutil
10
10
 
@@ -15,9 +15,8 @@ class RTModel:
15
15
  print('*********************')
16
16
  print('**** RTModel ****')
17
17
  print('*********************')
18
- self.pathtoRTM = inspect.getfile(RTModel)
19
- self.bindir = os.path.dirname(self.pathtoRTM) + '/bin/'
20
- if os.name =='nt':
18
+ self.bindir = self.find_bin_directory()
19
+ if(os.path.exists(self.bindir + 'Reader.exe')):
21
20
  self.readerexe = 'Reader.exe'
22
21
  self.initcondexe = 'InitCond.exe'
23
22
  self.levmarexe = 'LevMar.exe'
@@ -80,16 +79,20 @@ class RTModel:
80
79
  else:
81
80
  print(' OK')
82
81
 
83
- def config_InitCond(self, npeaks = 2, peakthreshold = 10.0, oldmodels = 4, override = None, nostatic = False, onlyorbital = False, usesatellite = 0):
82
+ def config_InitCond(self, npeaks = 2, peakthreshold = 10.0, oldmodels = 4, override = None, nostatic = False, onlyorbital = False, usesatellite = 0
83
+ , template_library = None):
84
84
  self.InitCond_npeaks = npeaks # Number of peaks in the observed light curve to be considered for setting initial conditions.
85
85
  self.InitCond_peakthreshold = peakthreshold # Number of sigmas necessary for a deviation to be identified as a maximum or a minimum.
86
86
  self.InitCond_oldmodels = oldmodels # Maximum number of old models to include in new run as initial conditions
87
87
  self.InitCond_override = override # Override peak identification and manually set peak times
88
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.
89
+ self.InitCond_onlyorbital = onlyorbital; # Only orbital motion models will be calculated.
90
90
  self.InitCond_usesatellite = usesatellite; # Satellite to be used for initial conditions. Ground telescopes by default.
91
+ self.InitCond_template_library = template_library; # Template library to be used in place of the default one.
91
92
 
92
93
  def InitCond(self):
94
+ ''' Establishes initial conditions for fitting by executing the InitCond external module.
95
+ Options can be assigned through the config_InitCond() method. '''
93
96
  if(not os.path.exists(self.eventname + '/' + self.inidir)):
94
97
  os.makedirs(self.eventname + '/' + self.inidir)
95
98
  with open(self.eventname + '/' + self.inidir + '/InitCond.ini','w') as f:
@@ -99,10 +102,12 @@ class RTModel:
99
102
  f.write('usesatellite = ' + str(self.InitCond_usesatellite) + '\n')
100
103
  if(self.InitCond_nostatic):
101
104
  f.write('nostatic = 1\n')
102
- if(self.InitCond_noparallax):
103
- f.write('noparallax = 1\n')
105
+ if(self.InitCond_onlyorbital):
106
+ f.write('onlyorbital = 1\n')
104
107
  if(self.InitCond_override != None):
105
108
  f.write('override = ' + str(self.InitCond_override[0])+ ' ' + str(self.InitCond_override[1]) + '\n')
109
+ if(self.InitCond_template_library != None):
110
+ f.write('templatelibrary = ' + self.InitCond_template_library + '\n')
106
111
  print('- Launching: InitCond')
107
112
  print(' Setting initial conditions...')
108
113
  completedprocess = subprocess.run([self.bindir+self.initcondexe,self.eventname], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
@@ -110,7 +115,17 @@ class RTModel:
110
115
  print('! Error in setting initial conditions!')
111
116
  self.done = True
112
117
  else:
113
- print(' OK')
118
+ initfils=glob.glob(self.eventname + '/InitCond/*LS*')
119
+ if(len(initfils)==0):
120
+ initfils=glob.glob(self.eventname + '/InitCond/*LX*')
121
+ if(len(initfils)==0):
122
+ initfils=glob.glob(self.eventname + '/InitCond/*LO*')
123
+ with open(initfils[0], 'r') as f:
124
+ npeaks = int(f.readline().split()[0])
125
+ print('Peaks: ',end ='')
126
+ for i in range(0,npeaks):
127
+ print(f'{float(f.readline().split()[0]):.4f}',end = ' ')
128
+ print('\n OK')
114
129
 
115
130
  def config_LevMar(self, nfits = 5, timelimit = 600.0, maxsteps = 50, bumperpower = 2.0):
116
131
  self.LevMar_nfits = nfits # Number of models to be calculated from the same initial condition using the bumper method
@@ -118,14 +133,23 @@ class RTModel:
118
133
  self.LevMar_timelimit = timelimit # Maximum time in seconds for total execution
119
134
  self.LevMar_bumperpower = bumperpower # Repulsion factor of bumpers
120
135
 
121
- def LevMar(self,strmodel):
136
+ def LevMar(self,strmodel, parameters_file = None, parameters = None):
122
137
  if(not os.path.exists(self.eventname + '/' + self.inidir)):
123
138
  os.makedirs(self.eventname + '/' + self.inidir)
139
+ if(parameters != None):
140
+ parameters_file = self.eventname + '/' + self.inidir + '/parameters.ini'
141
+ with open(parameters_file,'w') as f:
142
+ line =''
143
+ for fl in parameters:
144
+ line = line + str(fl) + ' '
145
+ f.write(line)
124
146
  with open(self.eventname + '/' + self.inidir + '/LevMar.ini','w') as f:
125
147
  f.write('nfits = ' + str(self.LevMar_nfits) + '\n')
126
148
  f.write('maxsteps = ' + str(self.LevMar_maxsteps) + '\n')
127
149
  f.write('timelimit = ' + str(self.LevMar_timelimit) + '\n')
128
150
  f.write('bumperpower = ' + str(self.LevMar_bumperpower) + '\n')
151
+ if(parameters_file != None):
152
+ f.write('parametersfile = ' + parameters_file)
129
153
  print('- Launching: LevMar')
130
154
  print(' Fitting ' + strmodel + ' ...')
131
155
  completedprocess = subprocess.run([self.bindir+self.levmarexe,self.eventname, strmodel,self.satellitedir], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL)
@@ -159,6 +183,7 @@ class RTModel:
159
183
  ninitconds = int(line[1])
160
184
  processes = []
161
185
  procnumbers = []
186
+ procepochs = []
162
187
  iinitcond = 0
163
188
  finitcond = 0
164
189
  finitcondold = -1
@@ -166,9 +191,16 @@ class RTModel:
166
191
  while(finitcond < ninitconds):
167
192
  i=0
168
193
  while i < len(processes):
194
+ if(time.time() - procepochs[i] > self.LevMar_timelimit):
195
+ processes[i].kill()
196
+ premodfiles = glob.glob(self.eventname +'/PreModels/*.txt')
197
+ strmodel = modelcode + '{:0>4}'.format(str(procnumbers[i]))
198
+ with open(self.eventname +'/PreModels/' + strmodel + '/t' + strmodel + '.dat','w') as f:
199
+ f.write(f'{len(premodfiles)} {self.LevMar_nfits}')
169
200
  if(processes[i].poll() != None):
170
201
  processes.pop(i)
171
202
  procnumbers.pop(i)
203
+ procepochs.pop(i)
172
204
  finitcond += 1
173
205
  else:
174
206
  i += 1
@@ -177,6 +209,7 @@ class RTModel:
177
209
  if(glob.glob(self.eventname +'/PreModels/' + strmodel + '/t' + strmodel + '.dat')==[]):
178
210
  processes.append(subprocess.Popen([self.bindir+self.levmarexe,self.eventname, strmodel,self.satellitedir], cwd = self.bindir, shell = False, stdout=subprocess.DEVNULL))
179
211
  procnumbers.append(iinitcond)
212
+ procepochs.append(time.time())
180
213
  else:
181
214
  finitcond += 1
182
215
  iinitcond += 1
@@ -291,3 +324,101 @@ class RTModel:
291
324
  for nam in filelist:
292
325
  shutil.move(nam,rundir)
293
326
  os.chdir(olddir)
327
+
328
+ def recover_options(self,run = None):
329
+ if(self.eventname == None):
330
+ print('! No event chosen')
331
+ if(run!=None):
332
+ pathname = run
333
+ else:
334
+ pathname = self.eventname
335
+ if(not(os.path.exists(pathname))):
336
+ print("Invalid path!")
337
+ return
338
+ if(os.path.exists(pathname + '/' + self.inidir + '/Reader.ini')):
339
+ with open(pathname + '/' + self.inidir + '/Reader.ini','r') as f:
340
+ lines = f.read().splitlines()
341
+ print('Reader --- ',lines)
342
+ for line in lines:
343
+ chunks = line.split()
344
+ if(chunks[0]=='tau'):
345
+ self.Reader_tau = float(chunks[2])
346
+ elif(chunks[0]=='binning'):
347
+ self.Reader_binning = int(chunks[2])
348
+ elif(chunks[0]=='otherseasons'):
349
+ self.Reader_otherseasons = int(chunks[2])
350
+ elif(chunks[0]=='renormalize'):
351
+ self.Reader_renormalize = int(chunks[2])
352
+ elif(chunks[0]=='thresholdoutliers'):
353
+ self.Reader_thresholdoutliers = float(chunks[2])
354
+ if(os.path.exists(pathname + '/' + self.inidir + '/InitCond.ini')):
355
+ with open(pathname + '/' + self.inidir + '/InitCond.ini','r') as f:
356
+ lines = f.read().splitlines()
357
+ print('InitCond --- ',lines)
358
+ self.InitCond_nostatic = False
359
+ self.InitCond_onlyorbital = False
360
+ self.InitCond_override = None
361
+ for line in lines:
362
+ chunks = line.split()
363
+ if(chunks[0]=='npeaks'):
364
+ self.InitCond_npeaks = int(chunks[2])
365
+ elif(chunks[0]=='peakthreshold'):
366
+ self.InitCond_peakthreshold = float(chunks[2])
367
+ elif(chunks[0]=='oldmodels'):
368
+ self.InitCond_oldmodels = int(chunks[2])
369
+ elif(chunks[0]=='usesatellite'):
370
+ self.InitCond_usesatellite = int(chunks[2])
371
+ elif(chunks[0]=='nostatic'):
372
+ self.InitCond_nostatic = (int(chunks[2])!=0)
373
+ elif(chunks[0]=='onlyorbital'):
374
+ self.InitCond_onlyorbital = (int(chunks[2])!=0)
375
+ elif(chunks[0]=='override'):
376
+ self.InitCond_override = (float(chunks[2]),float(chunks[3]))
377
+ elif(chunks[0]=='templatelibrary'):
378
+ self.InitCond_template_library = chunks[2]
379
+ if(os.path.exists(pathname + '/' + self.inidir + '/LevMar.ini')):
380
+ with open(pathname + '/' + self.inidir + '/LevMar.ini','r') as f:
381
+ lines = f.read().splitlines()
382
+ print('LevMar --- ',lines)
383
+ for line in lines:
384
+ chunks = line.split()
385
+ if(chunks[0]=='nfits'):
386
+ self.LevMar_nfits = int(chunks[2])
387
+ elif(chunks[0]=='maxsteps'):
388
+ self.LevMar_maxsteps = int(chunks[2])
389
+ elif(chunks[0]=='timelimit'):
390
+ self.LevMar_timelimit = float(chunks[2])
391
+ elif(chunks[0]=='bumperpower'):
392
+ self.LevMar_bumperpower = float(chunks[2])
393
+ if(os.path.exists(pathname + '/' + self.inidir + '/ModelSelector.ini')):
394
+ with open(pathname + '/' + self.inidir + '/ModelSelector.ini','r') as f:
395
+ lines = f.read().splitlines()
396
+ print('ModelSelector --- ',lines)
397
+ for line in lines:
398
+ chunks = line.split()
399
+ if(chunks[0]=='sigmasoverlap'):
400
+ self.ModelSelector_sigmasoverlap = float(chunks[2])
401
+ elif(chunks[0]=='sigmachisquare'):
402
+ self.ModelSelector_sigmachisquare = float(chunks[2])
403
+ elif(chunks[0]=='maxmodels'):
404
+ self.ModelSelector_maxmodels = int(chunks[2])
405
+
406
+ @staticmethod
407
+ def find_bin_directory() -> str:
408
+ """
409
+ Searches for the RTModel/bin directory in the available site-packages directories.
410
+
411
+ :return: The string of the parth to the bin directory.
412
+ """
413
+ bin_directory_string = None
414
+ site_packages_directories = site.getsitepackages()
415
+ site_packages_directories.append(site.getusersitepackages())
416
+ for site_packages_directory in site_packages_directories:
417
+ bin_directory_path = Path(site_packages_directory).joinpath('RTModel/bin')
418
+ if bin_directory_path.exists():
419
+ bin_directory_string = str(bin_directory_path) + '/'
420
+ break
421
+ if bin_directory_string is None:
422
+ raise FileNotFoundError(f'RTModel binary directory not found. Searched {site_packages_directories} '
423
+ f'site-packages directories.')
424
+ return bin_directory_string
@@ -1,5 +1,5 @@
1
- __version__ = "2.0.0"
1
+ __version__ = "2.1.0"
2
2
  __author__ = 'Valerio Bozza'
3
3
  __credits__ = 'University of Salerno, Italy'
4
4
 
5
- from .plotmodel import plotmodel
5
+ from .RTModel import RTModel
@@ -0,0 +1,59 @@
1
+ 113
2
+ 0.7 0.5 0.1 1.35 0.01 0.07511 1.12127
3
+ 0.7 0.1 0.1 4.6 0.01 -0.00676 0.1493
4
+ 0.7 0.1 0.75 4.6 0.01 -0.74331 0.53977
5
+ 0.9 0.03 -0.15 2.0 0.01 0.06576 0.09019
6
+ 0.9 0.03 -0.2 2.3 0.01 -0.47211 0.01011
7
+ 1.5 0.5 0.1 3.2 0.01 -0.32531 0.63255
8
+ 1.5 0.5 0.3 2.8 0.01 0.58817 0.78162
9
+ 0.9 0.03 -0.3 1.8 0.01 -0.28464 0.14202
10
+ 1.5 0.5 0.3 2.9 0.01 -0.48885 0.56195
11
+ 1.5 0.5 0.3 2.9 0.01 0.39245 0.56195
12
+ 1.5 0.5 0.25 2.75 0.01 0.66775 0.73845
13
+ 1.5 0.5 0.35 2.2 0.01 0.06007 0.6458
14
+ 1.5 0.5 0.35 2.2 0.01 0.5378 0.6458
15
+ 1.5 0.5 0.25 2.5 0.01 -0.45776 0.09626
16
+ 1.5 0.5 0.25 2.5 0.01 -0.45776 0.58665
17
+ 1.5 0.5 0.25 2.5 0.01 0.09626 0.58665
18
+ 1.5 0.5 0.25 2.0 0.01 -0.04058 0.2958
19
+ 1.5 0.5 0.25 2.0 0.01 -0.04058 0.47182
20
+ 1.5 0.5 0.25 2.0 0.01 0.2958 0.47182
21
+ 1.5 0.5 0.7 1.5 0.01 -0.07965 -0.01574
22
+ 1.5 0.5 0.7 1.5 0.01 -0.07965 0.34594
23
+ 1.5 0.5 0.7 1.5 0.01 -0.01574 0.34594
24
+ 1.5 0.5 0.45 4.6 0.01 -0.40928 0.27708
25
+ 1.5 0.5 0.45 4.6 0.01 -0.04946 0.27708
26
+ 1.5 0.5 0.33 3.2 0.01 -0.36736 0.65181
27
+ 0.9 0.1 -0.45 1.65 0.01 -0.4663 -0.00103
28
+ 0.9 0.1 -0.45 1.65 0.01 -0.4663 0.37168
29
+ 0.9 0.1 -0.45 1.65 0.01 -0.00103 0.37168
30
+ 2.2 0.5 0.1 3.0 0.01 0.74611 1.18948
31
+ 2.2 0.5 0.1 3.0 0.01 1.06918 1.18948
32
+ 2.2 0.5 0.35 2.9 0.01 1.07297 1.14242
33
+ 2.2 0.5 0.35 2.9 0.01 1.07297 1.28772
34
+ 2.2 0.5 0.35 2.9 0.01 1.14242 1.28772
35
+ 2.2 0.5 0.4 2.8 0.01 0.98474 1.16883
36
+ 2.2 0.5 0.4 2.8 0.01 0.98474 1.21577
37
+ 2.2 0.5 0.4 2.8 0.01 1.16883 1.21577
38
+ 2.2 0.5 1.05 2.0 0.01 0.39398 0.56261
39
+ 2.2 0.5 1.05 2.0 0.01 0.39398 0.6566
40
+ 2.2 0.5 1.05 2.0 0.01 0.56261 0.6566
41
+ 2.2 0.5 0.45 2.7 0.01 -0.67542 0.89586
42
+ 2.2 0.5 0.45 2.7 0.01 -0.67542 1.10689
43
+ 2.2 0.5 0.45 2.7 0.01 0.89586 1.10689
44
+ 2.2 0.5 1.0 1.9 0.01 0.30045 0.39828
45
+ 2.2 0.5 1.0 1.9 0.01 0.30045 0.52621
46
+ 2.2 0.5 1.0 1.9 0.01 0.39828 0.52621
47
+ 2.2 0.5 1.23 1.6 0.01 -0.17028 0.01821
48
+ 2.2 0.5 1.23 1.6 0.01 -0.17028 0.05286
49
+ 2.2 0.5 1.23 1.6 0.01 0.01821 0.05286
50
+ 2.2 0.5 0.35 2.7 0.01 -0.66716 0.7449
51
+ 2.2 0.5 0.35 2.7 0.01 -0.66716 1.14629
52
+ 2.2 0.5 0.35 2.7 0.01 0.7449 1.14629
53
+ 2.2 0.5 0.05 2.95 0.01 -0.64485 0.23071
54
+ 2.2 0.5 0.05 2.95 0.01 -0.64485 1.20146
55
+ 2.2 0.5 0.05 2.95 0.01 0.23071 1.20146
56
+ 2.2 0.5 0.35 3.0 0.01 -0.68509 1.15393
57
+ 1.8 0.03 1.0 2.3 0.01 -0.08517 0.72053
58
+ 1.8 0.03 1.0 2.3 0.01 -0.08517 0.88924
59
+ 1.8 0.03 1.0 2.3 0.01 0.72053 0.88924
@@ -1,7 +1,7 @@
1
1
  // LevMarFit.h
2
2
  // Definition of the LevMar and bumper classes for Levenberg-Marquardt fitting
3
3
 
4
- #include <stdio.h>
4
+ #include <cstdio>
5
5
  #include "bumper.h"
6
6
  #include <regex>
7
7
  #include <filesystem>