Skip to content

Enhancements/multisample - #67

Open
christophra wants to merge 150 commits into
ruff_formattingfrom
enhancements/multisample
Open

christophra wants to merge 150 commits into
ruff_formattingfrom
enhancements/multisample

Conversation

@christophra

Copy link
Copy Markdown

(draft PR just so it's on the radar)

…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
…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
…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.
…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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@jessiethw jessiethw left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Suggested change
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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread fast_response/AlertFollowup.py Resolved
Comment thread fast_response/MultiGWFollowup.py Outdated
This works with a MultiPointSourceLLH.
"""
if self.ts is None:
raise ValueError("Need to scan & unblind TS before finding events")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this just call self.unblind_ts() in this case?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see why not, done.

Comment thread fast_response/MultiGWFollowup.py Outdated
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this should be moved to /data/ana by the tech leads during your reproducibility review.

Comment thread setup.py
'zmq==0.0.0',
'py27hash==1.0.2',
'pygcn==1.1.2'
# 'astropy==2.0.16',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

christophra and others added 11 commits December 3, 2026 13:25
…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

@christophra christophra Dec 4, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@christophra
christophra changed the base branch from master to ruff_formatting December 4, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants