Repository navigation
Enhancements/multisample - #67
christophra wants to merge 150 commits into
Conversation
…ultiple datasets, one first implementation for testing. Still several FIXMEs, no support for PriorFollowup, and want to try implementing it with more inheritance for tidier code, keeping the multi-dataset additions away from the single-dataset. Using skylab branch branches/chraab_multi_fra
…analysis information
…fit_ra, dec for PS
…aults from any user matplotlibrc
…GFU from /data/user/apizzuto to a GFU dataset which is still assumed to be GFUOnline_v001p02
…0, ns_scan at best-fit gamma (to be discussed), make upper limit plot state pivot energy if index not 2
…when introducing _single and _multi methods
…report for a MultiPointSourceFollowup, with fixed spectral index. Includes minor modifications to the FRA base class and ReportGenerator.
…dd llh_exp property to base class. Allow changing plot size while keeping circles to scale.
… pivot energy if index is floating
…it goes in the report table.
…y painlessly by adding iteration in base class similar to plot_skymap_zoom. Could keep that code more separate with refactoring, though.
…methods to attributes that child classes can change, eg because they use a different LLH
…mit_e2dnde as requested
…e fallback for ancient numpy versions
There was a problem hiding this comment.
Looks like there are some things that are from a couple of recent PRs from Alicia and me here. Maybe the reference for master is a bit old? Could you check that in this branch?
There was a problem hiding this comment.
Thanks @christophra, I think this is starting to converge. I have a few more suggestions, but thanks a lot for answering all of our questions so far!
Now having looked at #63 more, there will be some conflicts between this PR and that one (particularly in plotting_utils.py functions). I think we can fight those conflicts when both are ready to merge, but I wanted to bring it up now so that you're aware.
Could you also update your PR description when you get a chance? Eventually that will be the merge commit, so a description of what is added here and what the files cover would be very helpful here.
| from fast_response.MultiExternalFollowup import MultiFollowup, GFUFollowup, GrecoFollowup, DNNFollowup, DNNOnlineFollowup, DNNIceManFollowup | ||
|
|
||
| parser = argparse.ArgumentParser(description='Precompute MultiAlertFollowup BG trials') | ||
| parser.add_argument('--deltaT', type=float, default=1000., |
There was a problem hiding this comment.
Yeah, I've never noticed before that it's inconsistent. Please go ahead and change it there as well, thanks!
| else: | ||
| # other direction, set from samples [mHz] | ||
| # which set nbackground = bkg_rate * on_livetime | ||
| args.bkg = [1000 * _llh.nbackground / (_llh.on_livetime * 86400) |
There was a problem hiding this comment.
I've added these magic numbers as suggestions in the main FastResponseAnalysis.py since all of the classes inherit from there. I suggest we just call those here
| args.bkg = [1000 * _llh.nbackground / (_llh.on_livetime * 86400) | |
| args.bkg = [f._Hz_to_mHz * _llh.nbackground / (_llh.on_livetime * f._sec_per_day) |
| # use the estimate provided by the temporal model | ||
| # from the background window(s): (temporal model has estimated it from +/- 60 days) | ||
| rate = round(1000 * llh.nbackground / (llh.on_livetime * 86400), 2) | ||
| f.load_background_trials(rate=rate) |
There was a problem hiding this comment.
I think I would prefer the selection of which rate trials to load to be in the main classes (here inside MultiGWFollowup.py). Then we can do unit conversions there instead
There was a problem hiding this comment.
Done, as DNNOnlineFollowup.load_background_trials. Also changed PriorFollowup.load_background_trials to treat number of trials as a minimum, but return all that are loaded. That matches the new behaviour of PriorFollowup.run_background_trials.
| This works with a MultiPointSourceLLH. | ||
| """ | ||
| if self.ts is None: | ||
| raise ValueError("Need to scan & unblind TS before finding events") |
There was a problem hiding this comment.
Can this just call self.unblind_ts() in this case?
| if self.tsd is None: # can not determine p-values | ||
| for i in range(self.events_rec_array.size): | ||
| self.events_rec_array['pvalue'][i] = None | ||
| elif self.events_rec_array.size > 0: # always scan, most general |
There was a problem hiding this comment.
For DNNC this is probably fine since the rate is so low. But for multi-dataset followup, we may want to consider a speed-up as is done for the current per-event p-values, where if p<0.1 we scan but if 0.1<p<1.0 we just quickly calculate the pvalue for that event at the best-fit location of the event. (see L637).
I also suggest setting these cases based off of self.p, rather than self.tsd not being None
There was a problem hiding this comment.
You have a good point, we should better keep the speed-up. This ties back in with our discussion here: #67 (comment)
So then the best thing would be to just remove this method and inherit/call the one from GWFollowupPlottingMixIn? Less code is best code and all that.
In case you wanted p<0.2 only here and keep p<0.1 in GWFollowup, I could add an extra argument for that.
There was a problem hiding this comment.
Have now removed it from MultiGWFollowup and changed GWFollowup to use self.p as requested. (To make that work I now also set it to None in the constructor.) Can still optionally change to p<0.2.
|
|
||
|
|
||
| class OnlyDNNOnlineFollowup(PriorFollowup): | ||
| _base_dir = "/data/user/chraab/fast_response/multisample/extended_archival_floating" |
There was a problem hiding this comment.
Yes, this should be moved to /data/ana by the tech leads during your reproducibility review.
| 'zmq==0.0.0', | ||
| 'py27hash==1.0.2', | ||
| 'pygcn==1.1.2' | ||
| # 'astropy==2.0.16', |
There was a problem hiding this comment.
Yeah, we may have to have two environments for GFU and this followup if the requirements differ. We can keep an eye on it when we set up the DNNC realtime stuff on the machine, but for now I suggest we leave this file as-is and resolve it in the next PR
…instead, if we already loaded enough return all of them.
…o match other FRA scripts, as requested
…utes Co-authored-by: Jessie Thwaites <thwaites@wisc.edu>
Co-authored-by: Jessie Thwaites <thwaites@wisc.edu>
… Co-authored-by: Jessie Thwaites <thwaites@wisc.edu> Co-authored-by: Jessie Thwaites <thwaites@wisc.edu>
Co-authored-by: Jessie Thwaites <jnt4coll@gmail.com>
Co-authored-by: Jessie Thwaites <jnt4coll@gmail.com>
Define the rate lookup method in the followup class rather than in the script. Use the conversion factors to obtain mHz. Make ntrial just the minimum number, don't discard trials that were loaded.
…or large p-values, so no need to override. (May still change the threshold.) The check for missing unblinding info was requested to use self.p instead, so set that to None in the constructor together with self.ts.
…x == 2 from floating point errors with round()
| ) | ||
| except Exception as e: | ||
| print(e) | ||
| except Exception as e: # TODO be more specific, eg empty scan => argmax fails |
There was a problem hiding this comment.
Does anyone know why this is a try-except block? @jessiethw @physics-png
I'm concerned about unintended side effects that just get printed and can be missed.
I'm itching to replace this like
try: -----> if val.size > 0:
[...]
except: -----> else:
[...]
but maybe there are downsides I don't know about? If there is some other error (though I can't immediately see which one that could be), did we promise to report the same result as if there were no events?
(draft PR just so it's on the radar)