Open ketozhang opened 2 days ago
Not addressing the issue itself, but this has been quite difficult to debug due to lacking error handling in RTModel. Here I have to understand what ModelSelector()
is writing to a new directory Models/
, so an actual success is only indicated by the existence of files in this directory.
A lot of the code in RTModel Python looks like this
Notable issues are:
stdout=subprocess.DEVNULL
further hides any useful information from the C++ executable. Changing this to capture_output=True
and passing stdout and stderr to python logging module would allow users more control over its verbosity.``` ********************* **** RTModel **** ********************* Event name: /tmp/pytest-of-root/pytest-6/test_levmar_solution_shape_PS_0 Number of processors: 4 >>> rtm.ModelSelector("PS") - Selecting models for Single-lens-Single-source fits ****************************************** ********** Model selector ********* ****************************************** This program finds the best independent models of a given class - Event: /tmp/pytest-of-root/pytest-6/test_levmar_solution_shape_PS_0 - Reading options in ModelSelector.ini Number of sigmas used to declare overlap between two models: 3.000000 Number of sigmas in chi square distribution for model acceptance: 1.000000 Maximum number of models reported: 10 - Model code: PS Reading data Reading models ! No models for this class OK ```
I'm happy to contribute error handling code.
Hi @ketozhang, you are right I did not spend too much time to make the output from the C++ code available to the user, but it is indeed very useful to track simple errors. You are welcome to change the error message to a regular exception, since I am currently busy with the improvement of the efficiency.
In your specific case, it seems that no fits were actually executed. Are your data in the correct format?
Hi @valboz,
From what I can tell in the logs and output directory, I believe the fit did ran. There are subfolders under PreModels/
.
I turned on the stdout of ModelSelector and this is what it returns:
******************************************
********** Model selector *********
******************************************
This program finds the best independent models of a given class
- Event: /tmp/pytest-of-root/pytest-6/test_levmar_solution_shape_PS_0
- Reading options in ModelSelector.ini
Number of sigmas used to declare overlap between two models: 3.000000
Number of sigmas in chi square distribution for model acceptance: 1.000000
Maximum number of models reported: 10
- Model code: PS
Reading data
Reading models
! No models for this class OK
Subfolders with files inside? Can you send me one of these files, e.g. "PreModels/PS0000/0.txt"?
Here is one of those files 0.txt
...and I attached the entire RTModel results directory results.tar.gz
Great! I see that your LCToFit.txt has unreasonably small errors. It seems that for some unknown reason the re-normalization of the error bars failed in Reader. However, I have run RTModel on your original data and I obtain a perfectly fine LCToFit.txt. Can you remove all files and try again and tell me if you obtain exactly the same LCToFit.txt?
On a minor point, you should use HJD-2450000 to allow for more digits in the time stamps to be recorded in double precision.
Good catch. I also notice that the first row is correct then followed by bad rows:
0 2.4595805000e+06 1.7481053421e-09 1.4973600043e-13 0
0 2.4595805901e+06 1.7485240090e-09 7.7283465933e-94 0
...
I have experimented with what you suggested. I attempted with multiple copies of the results, remove all files but the Data directory, then run Reader. This consistently return a good LCToFit.txt file for the ~100 attempts I did.
If I go back to my script and run this in the suite of data I have. I get non-deterministic failures. Every failure has bad LCToFit.txt similar to the example above.
HJD-2450000 Noted. Thank you!
If I go back to my script and run this in the suite of data I have. I get non-deterministic failures. Every failure has bad LCToFit.txt similar to the example above.
That's very strange and I am currently unable to reproduce this bug. However, since this seems to depend on error-bar renormalization, you may try to switch off renormalization by rtm.config_Reader(renormalize = 0)
In some microlensing light curves, I am getting RTModel silently failing despite all stdout printing success.
Here an example in PSPL:
The
Models/
directory is missingThe logs reports everything is success