indica-mcf / Indica

Integrated DiagnostiC Analysis
GNU General Public License v3.0
6 stars 0 forks source link

Write tests for operators #15

Open cmacmackin opened 3 years ago

cmacmackin commented 3 years ago

For unit tests, I can choose a good fit and then generate data from that. For integration tests, I can make use of my existing test scripts (found in the snippets direcotry). If I use property-based testing at all for the unit tests then it will have to be quite constrained.

cmacmackin commented 3 years ago

I have now written tests for the common functionality contained in the abstract operator class.

cmacmackin commented 3 years ago

@marcosertoli I've tested the radiation inversion against SXR fluxes calculated from a known emissivity profile. The idea is that the inversion should be able to reproduce that emissivity profile. However, it seems that the problem is not very well constrained, as we can easily get order 10-3 errors in the symmetric emissivity profile and even 10-1 errors for the asymmetry parameter. Differences between the flux and the back-integral are generally kept near or below 10-4.

Edit: It does seem to be the asymmetry that really throws it. When I set that to zero I get much better quality fits.

marcosertoli commented 3 years ago

Hi Chris, I partly agree with you, but since the details matter, can you show the radiation patterns you've chosen for the tests and comparison of input Vs back calculated data? As for everything else, we should restrict the operational space to physically sensible parameters.


From: Chris MacMackin @.> Sent: Tuesday, July 6, 2021 12:49:33 PM To: ukaea/Indica @.> Cc: marcosertoli @.>; Mention @.> Subject: Re: [ukaea/Indica] Write tests for operators (#15)

@marcosertolihttps://github.com/marcosertoli I've tested the radiation inversion against SXR fluxes calculated from a known emissivity profile. The idea is that the inversion should be able to reproduce that emissivity profile. However, it seems that the problem is not very well constrained, as we can easily get order 10-3 errors in the symmetric emissivity profile and even larger errors for the asymmetry parameter.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ukaea/Indica/issues/15#issuecomment-874692618, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARZSM6BBYXHXSFT7P4AHGEDTWLUU3ANCNFSM4WSTDG2A.

cmacmackin commented 3 years ago

You can find the test tests/unit/operators/test_invert_radiation.py in the cmacmackin/15_operator_tests branch (see PR #48). Probably the easiest way to visualise the profiles would be to insert breakpoint() after line 150 and then run poetry run pytest tests/unit/operators/test_invert_radiation.py. This will cause the program to enter the debugger at the line where breakpoint() was called. This will give you an interactive terminal where you can print data to the screen, produce plots, etc.