| Total Complexity | 5 |
| Total Lines | 73 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from ..HAL import HAL |
||
|
|
|||
| 2 | |||
| 3 | from threeML import DataList, JointLikelihood |
||
| 4 | |||
| 5 | |||
| 6 | def fit_point_source(roi, |
||
| 7 | maptree, |
||
| 8 | response, |
||
| 9 | point_source_model, |
||
| 10 | bin_list, |
||
| 11 | confidence_intervals=False, |
||
| 12 | liff=False, |
||
| 13 | pixel_size=0.17, |
||
| 14 | verbose=False): |
||
| 15 | |||
| 16 | data_radius = roi.data_radius.to("deg").value |
||
| 17 | |||
| 18 | if not liff: |
||
| 19 | |||
| 20 | # This is a 3ML plugin |
||
| 21 | hawc = HAL("HAWC", |
||
| 22 | maptree, |
||
| 23 | response, |
||
| 24 | roi, |
||
| 25 | flat_sky_pixels_size=pixel_size) |
||
| 26 | |||
| 27 | hawc.set_active_measurements(bin_list=bin_list) |
||
| 28 | |||
| 29 | else: |
||
| 30 | |||
| 31 | from threeML import HAWCLike |
||
| 32 | |||
| 33 | hawc = HAWCLike("HAWC", |
||
| 34 | maptree, |
||
| 35 | response, |
||
| 36 | fullsky=True) |
||
| 37 | |||
| 38 | hawc.set_bin_list(bin_list) |
||
| 39 | |||
| 40 | ra_roi, dec_roi = roi.ra_dec_center |
||
| 41 | |||
| 42 | hawc.set_ROI(ra_roi, dec_roi, data_radius) |
||
| 43 | |||
| 44 | if not liff: |
||
| 45 | |||
| 46 | hawc.display() |
||
| 47 | |||
| 48 | data = DataList(hawc) |
||
| 49 | |||
| 50 | jl = JointLikelihood(point_source_model, data, verbose=verbose) |
||
| 51 | |||
| 52 | point_source_model.display(complete=True) |
||
| 53 | |||
| 54 | try: |
||
| 55 | |||
| 56 | jl.set_minimizer("minuit") |
||
| 57 | |||
| 58 | except: |
||
| 59 | |||
| 60 | jl.set_minimizer("minuit") |
||
| 61 | |||
| 62 | param_df, like_df = jl.fit() |
||
| 63 | |||
| 64 | if confidence_intervals: |
||
| 65 | |||
| 66 | ci = jl.get_errors() |
||
| 67 | |||
| 68 | else: |
||
| 69 | |||
| 70 | ci = None |
||
| 71 | |||
| 72 | return param_df, like_df, ci, jl.results |
||
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.