Skip to content

Posterior Skymap Development - #63

Open
Samhori wants to merge 41 commits into
ruff_formattingfrom
PosteriorDevelopment
Open

Samhori wants to merge 41 commits into
ruff_formattingfrom
PosteriorDevelopment

Conversation

@Samhori

@Samhori Samhori commented Mar 18, 2025 •

Copy link
Copy Markdown

Pull request for the development of the posterior skymap request. This PR adds support for the creation of posterior skymaps as an additional localization product for prior follow-ups as well as bug fixes/replacements to plotting functions

Comment thread fast_response/plotting_utils.py Resolved
@jessiethw
jessiethw self-requested a review June 19, 2025 16:13

@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 for the new code @Samhori ! A few suggestions to make parts a bit clearer + some formatting. Overall looks very good!

One comment I made a couple times but not everywhere is to add docstrings to each function for the documentation. Most of the info you already included, but please format so that they appear correctly in the documentation when it's generated

Comment thread fast_response/AlertFollowup.py Resolved
Comment thread fast_response/FastResponseAnalysis.py Resolved
Comment thread fast_response/FastResponseAnalysis.py Resolved
Comment thread fast_response/FastResponseAnalysis.py Outdated
events = self.llh.exp
events = events[(events['time'] < self.stop) & (events['time'] > self.start)]

print(custom_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 you make this a bit clearer? I think it's a good idea to print any custom events injected, but can you give the user a message about what is being printed and the names (assuming this is the normal structured ndarray as events). something like

Custom events injected:
run, event, ra, dec
<array>

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.

Would it make sense to move this somewhere else? It is in there for debugging for now, but I don't think this is the right place to print custom events if we want to keep that

Comment thread fast_response/FastResponseAnalysis.py Resolved
Comment thread fast_response/FastResponseAnalysis.py Resolved
Comment thread fast_response/FastResponseAnalysis.py Outdated
temporal_weights = self.llh.temporal_model.signal(self.llh._events)
msk = spatial_weights * energy_ratio * temporal_weights > 10
self.coincident_events = []
if(custom_events!=None):

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.

comment above about distinguishing injected events also applies here

Comment thread fast_response/plotting_utils.py Resolved
Comment thread fast_response/scripts/test_1.sh Resolved
@Samhori Samhori self-assigned this Jul 11, 2025
@Samhori
Samhori requested a review from physics-png July 11, 2025 19:00
@jessiethw jessiethw added the enhancement New feature or request label Nov 11, 2026
@Samhori
Samhori requested a review from jessiethw November 12, 2026 22:51
@Samhori
Samhori marked this pull request as ready for review November 12, 2026 22:53
@jessiethw

Copy link
Copy Markdown
Collaborator

Thanks @Samhori, will take a look. Right away I noticed that many files have an executable permission added which shouldn't need it (files in doc, circular_templates, etc). Can you please correct that in this PR?

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

First pass at some of these files, I have not gone through everything, but will submit these comments/suggestions now so you have time to start them.

One larger comment is that there is a lot of duplicate code here. It would be better to use inheritance to get these methods directly from either base reports, or main analysis classes, rather than in copied classes. I tried to mark the locations that I noticed this happening the most as places to inherit the base classes.

Other comment is more procedural, please change the permissions back to 644 for most of the files so that this PR doesn't look like it's affecting every file in the repository. Thanks.

{
\centering

{\Large Posterior Skymap}

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 you add some text to each section of the report, to make it clear what is shown in each plot?

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 agree with Jessie that each figure should have captions associated with them

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.

Added

{\Large Zoomed Posterior Skymap}
\includegraphics[width=0.9\textwidth]{\PosteriorSkymapZoom}
\clearpage
{\Large Posterior Skymap W/ Nu Overlay}

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.

please spell out the title here

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


{
\centering
{\Large $N_s$ Profile Plot}

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.

especially this plot, please add some description for the ROC members to understand what is shown here

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.

Added a few sentences

Comment thread fast_response/reports/__init__.py Outdated
from .ReportGenerator import AlertReport
from .ReportGenerator import GravitationalWaveReport
from .ReportGenerator import FastResponseReport
from .PosteriorReportGenerator import \

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.

Please separate this onto multiple lines for clarity.

Suggested change
from .PosteriorReportGenerator import \
from .PosteriorReportGenerator import FastResponsePosteriorReport, PosteriorReportGenerator
from .PosteriorReportGenerator import GravitationalWavePosteriorReport, AlertPosteriorReport

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.

Resolved

Comment thread fast_response/reports/__init__.py Outdated
from .ReportGenerator import GravitationalWaveReport
from .ReportGenerator import FastResponseReport
from .PosteriorReportGenerator import \
FastResponsePosteriorReport,GravitationalWavePosteriorReport,PosteriorReportGenerator,AlertPosteriorReport

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.

Suggested change
FastResponsePosteriorReport,GravitationalWavePosteriorReport,PosteriorReportGenerator,AlertPosteriorReport

(continued suggestion from previous)

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.

Resolved (by deletion)

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.

Why does this need to be a direct copy of the previous analysis?
Is it possible to just initialize the analysis/llh and load the results from the previous analysis instead? If additional parameters need to be saved, that can be added to the save_items call in the main FRA

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.

Agreed with above, please do not clone code.

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.

What do you mean? We don't need the results of the previous analysis but because the scripts have been written as one-offs rather than something modular, there is no way to load the appropriate analysis. This script isn't complete yet because I haven't yet decided how to implement it with a minimal number of scripts.

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.

See new scripts. Its not particularly elegant because FRA is not really written to accommodate these kinds of parallel products in an elegant way

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.

That works, thanks. This is better

Comment thread fast_response/FastResponseAnalysis.py Resolved
Comment thread fast_response/FastResponseAnalysis.py Resolved
if skipped is not None:
self.exp = self.remove_event(self.exp, self.dset, skipped)

if self.extension is not None:
src_extension = float(self.extension)
self.save_items['extension'] = src_extension
self.save_items["extension"] = src_extension
else:
src_extension = None

llh = PointSourceLLH(

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 prefer the previous spacing here between code/comments, it makes it more readable.

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.

See comment here Can return things to column alignment, but its generally discouraged by python styl. @physics-png too. Could you let me know if you agree with the choice to keep column alignment for at least the imports in FastResponseAnalysis.py/plotting_utils and the comments here and I will change it back

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 agree with Jessie.

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.

Commented above, after discussing it let's leave the spaces in for readability.

events = events[(events['time'] < self.stop) & (events['time'] > self.start)]

events = events[(events["time"] < self.stop) & (events["time"] > self.start)]
if custom_events is not None:

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.

These custom_events are injected events? I think it would be nice to indicate that they are injected or somehow added in the plot, rather than just plotting them as regular events.

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.

I'd prefer not to deviate from the existing standards of FRA for this. The custom events could be (and typically are) injected events, but IIRC options like unblind_TS also take custom events? It seems like bad idea to treat these differently than other spots in FRA and I was unable to find any place where injected events are currently separated from experimental ones or examples.

If you could point me to how they are handled in the standard plotting, I'm happy to switch over to keep the same formatting but I worry about ending up in a situation where we have multiple plotting styles for injected events. Also, injected events generally ought to be treated identically to real events in any computations, so I am a little worried that marking events as injected might bias people looking at plots when they should be treating those neutrinos the same as other neutrinos. Not a big deal either way, but I would like to make sure what we don't end up a situation where I am using white to indicate injected neutrinos and the rest of FRA is using dashed lines or something

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.

This was likely hard to find because we don't really use injected events in FRA (custom_events in unblind_ts is actually currently unused and should probably be dropped, see docstring L922). I think it was likely for the per-event p-values before that became its own function).

Because we don't use them, there isn't a way they are currently plotted differently. I agree that they should be treated the same in the analysis, but a visual difference is one more confirmation that they are only present when we expect them to be. Right now the only special plotting format is when we run an alert event: the removed alert's reco direction and error as it is in GFU is plotted in grey dashed (see L559). So any slightly different choice is fine, most likely a different linestyle is cleanest.

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 agree with Jessie that there should be a visual cue when we use custom_events.

@physics-png physics-png 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.

First round of comments for some of the files. Thank you for the work on this. As a general note, I notice that a lot of the code/files here are duplicated of preexisting code in FRA. Please do not duplicate code and instead use inheritance where possible.

It also looks like a lot of preexisting code was passed through a formatter of some sort. While I am not opposed in general to automatic formatting of code, it makes it difficult in some parts to tell what changes you are making to FRA and what changes are the formatter. I would prefer if reformatting existing code was done as part of a separate PR but I will discuss that @jessiethw .

Finally, have you and @christophra checked to see if there are major merge conflicts between your PRs? I noticed that you both have changes to plotting_utils.py, GWFollowup.py, and FastResponseAnalysis.py.

Comment thread doc/source/alert.rst

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.

A lot of these files have permission changes that don't need them.

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.

fixed

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.

Have you checked to see if your changes will conflict with Chris' at all?

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.

No all of them but we have confirmed that the core mechanics are inherited properly.

Comment thread fast_response/plotting_utils.py Resolved
Comment thread fast_response/plotting_utils.py Resolved
Comment thread fast_response/plotting_utils.py Outdated
)


def plot_events2(dec, ra, sigmas, col="k",density=1):

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.

Why are there two versions of this function?

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.

Because the original one which exists in Fast Response Analysis is flawed and seems to produce incorrect answers for most values of the arguments. This is a little slower so I didn't want to tear out all of the other ones.

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.

If plot_events is producing incorrect results, I don't think we should introduce a near-identical implementation as a new function. This creates more code for maintenance and makes it unclear in the future which should be used. Instead, I'd rather you fix the bugs in plot_events directly and update the calling as needed.

Could you please update plot_events with the necessary fix and perform (and show) tests demonstrating the incorrect behavior and the new fixed behavior?

mpl.use('agg')
mpl.rcParams['text.usetex'] = True
mpl.use("agg")
mpl.rcParams["text.usetex"] = True

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.

this line will conflict with Chris' code

@christophra christophra Dec 3, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For context, this is needed for old MPL (e.g. < 3), but breaks in new environments, where new MPL (>=3) can render equations quite fine by itself. I set this rcParam accordingly where it was used; following this comment I do this once, with a global called plotting_utils.USETEX.

Comment thread fast_response/plotting_utils.py Outdated
-----------
ra: ndarray
Array of ra for events
Array of ra for 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.

Did you put your code through some kind of formatter? Its hard to tell what changes you made and what is just the formatter

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.

This was put through standard ruff formatting.

Comment thread fast_response/plotting_utils.py Outdated
vy = np.cos(delta) * np.sin(dec) * np.sin(ra) + np.sin(delta) * (
-np.cos(ra) * np.cos(phi) + np.cos(dec) * np.sin(ra) * np.sin(phi)
)
vz = np.cos(dec) * np.cos(delta) - np.sin(dec) * np.sin(delta) * np.sin(phi)

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.

Is this not what compute_ang_err does? Why is this code repeated?

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.

Contour is a preexisting function. It should do something very similar to compute_ang_error, but then makes a choice to bin in healpy which IIRC I believe to create artifacts. Its possible that maintenance of FRA should include replacing this with compute ang error, but I didn't want to change unrelated functions so I have left it as it was originally implemented.

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.

Please see above comment on line 318

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.

Similar to Jessie's comment. A lot of this is a duplicate of code from ReportGenerator.py, please make this inherit that class rather than cloning code.

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

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.

Agreed with above, please do not clone code.

@physics-png physics-png 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.

Second review, first pass on remaining files.

I would like to see an example of the report generated by the posterior skymap analysis, as well as an example of custom_events being used.

Please also remove the ruff formatting so that it is easier to see what your changes are.

\vspace{1cm}
{\Large Report Generated On:\\ \reportdate \par}
\end{titlepage}

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.

You're missing sections for source information (I understand this will be different than usual for this type of analysis but it should still be included), on-time data, skylab analysis information, detector operations, etc. that are usually included in these reports. Please provide the relevant information for the analysis that is run.

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.

That doesn't really make sense to duplicate I think here. We should always have the main report to compare against.

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 that's fine for this to be a supplementary report. I suggest keeping the tables in Section 1 of the original reports, though, as Alicia suggests - which machine the report is made on, version of skylab, version of dataset, and general analysis parameters. (These things should all be initialized immediately when starting the analysis anyway and don't require other queries.) But section 2 can be dropped since it's in the main report already

{
\centering

{\Large Posterior Skymap}

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 agree with Jessie that each figure should have captions associated with them

Comment thread README.md

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.

Could you please add an example to the readme of running a posterior map analysis?

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.

Added to readme. Scripts are identical to the primary scripts in how you call them but add a posterior to script name. Right now, those where its relevant do 1000s by default.

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.

Hi Sam, thank you for adding notes to the readme. For your tutorials, could you please be more explicit and give an example command that can be run as well as a description of the expected output similar to what is done for the tutorials for GW and external alerts

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.

Added specific example

Sam Hori added 4 commits November 17, 2026 17:16
Unfortunately each script contains unique material to construct
analysis. I'd like to do it with only one script, but reconsidering best
way to integrate since scripts aren't super flexible here. One option is
that we pickle the analysis object but more likely there will be another
commit tonight which just adds this as a rather ugly option to the
existing scripts
parser.add_argument('--deltallh_skymap', action='store_true', default=False,
help='Option MUST be raised if using deltaLLH map (default: False, assumes probability map)')
parser.add_argument('--do_posterior_analysis', type=bool, default=False,
help='Whether to do the posterior map calculation')

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.

If you're adding new scripts which run a posterior analysis for tracks, I don't think this is needed here.

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.

Yeah, that was an oversight. Will be removed in next commit

if skipped is not None:
self.exp = self.remove_event(self.exp, self.dset, skipped)

if self.extension is not None:
src_extension = float(self.extension)
self.save_items['extension'] = src_extension
self.save_items["extension"] = src_extension
else:
src_extension = None

llh = PointSourceLLH(

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 agree with Jessie.

Comment thread README.md

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.

Hi Sam, I saw you replied to an earlier comment that you added a specific example but it is still missing from this version of the PR. Please add a specific example with expected output, etc. like what is done for GW and external alerts

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.

What do you mean? Do you want an output folder?

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.

Nevermind, this had not gotten committed and pushed. There is now a small readme section with an example command. No specific outputs are printed here (since the only outputs are skymaps) so a brief description of the expected messages and files is contained

Comment thread fast_response/plotting_utils.py Outdated
)


def plot_events2(dec, ra, sigmas, col="k",density=1):

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.

If plot_events is producing incorrect results, I don't think we should introduce a near-identical implementation as a new function. This creates more code for maintenance and makes it unclear in the future which should be used. Instead, I'd rather you fix the bugs in plot_events directly and update the calling as needed.

Could you please update plot_events with the necessary fix and perform (and show) tests demonstrating the incorrect behavior and the new fixed behavior?

)


def compute_ang_err(ra, dec, sigma, density=1):

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.

Hi Sam, I have a similar comment here that I had for plot_events2:

If compute_ang_err is meant to correct bugs in contour you should instead be fixing the bugs in contour rather than introducing a new function. Rather than leaving a note that contour should eventually be replaced by compute_ang_err, please address the underlying issues in contour directly as part of this PR and provide tests demonstrating the incorrect and correct behavior pre and post-fix.

If there is a bug that you notice on this PR that affects your code, please fix the bug directly and include tests demonstrating both the incorrect behavior and the correctness of the fix.

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.

These do slightly different things. I assume that the version in contour which snaps to pixels is intended to have its behavior, but compute_ang_err is required for the scales I plot in.

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.

Looking at the differences here, the difference is quite minor, so I am in support of keeping only one and am fine with the choice to keep only compute_ang_err (which I prefer the naming of, since contour has always made me think it's drawing a 90% contour). I am not sure why we would need to make sure the contours fell on the centers of pixels, so I don't see any issue with removing the old function here.

Comment thread fast_response/plotting_utils.py Outdated
vy = np.cos(delta) * np.sin(dec) * np.sin(ra) + np.sin(delta) * (
-np.cos(ra) * np.cos(phi) + np.cos(dec) * np.sin(ra) * np.sin(phi)
)
vz = np.cos(dec) * np.cos(delta) - np.sin(dec) * np.sin(delta) * np.sin(phi)

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.

Please see above comment on line 318

Sam Hori added 8 commits November 24, 2026 16:45
Removed older plot_events function and contour and replaced them with
updated versions. plot_events changed to produce correct contours by
plotting exact points. contour moved to compute_ang_errs which compute
exact points rather than snapping to healpix grid
…n back in to

scripts and changed center of zoom since these won't have the standard
best fit position

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.

Some general comments on the report:

  1. Prior Skymap
  • The declination and right ascension labels overlap with the tick labels. Please add padding between the label axes labels and the tick labels for legibility
  • Please make the plot smaller so that it doesn't move itself to another page (page 2 is empty and the plot overflows onto page 3
  1. Posterior Maps
  • Could you please label the color bar?
  • Please crop the image so that there is not a bunch of whitespace between the "Posterior skymap" at the top of the page and the start of the plot towards the middle of the page
  • Similar comments for axes labels for the zoomed posterior map
  • What is the colorbar for the zoomed posterior skymap plot?
  • Similar comments for posterior skymap (log p)
  • Could you please add a tick for the bottom of the color bar for the posterior skymap (log p) plot?
  1. Profile plots
  • Could you make the tick labels larger please?

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.

Following up on this since not all of the suggestions were addressed/implemented. Additionally, can you move detector operations onto its own page similar to what is already done for FRA, or as discussed in another comment just omit it entirely?


def generate_report(self):
#just to ensure call to generate report don't create an error
self.generate_report()

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 for adding error protection!

help='path to skymap')
parser.add_argument('--time', type=float, default=None,
help='Time of the alert event (mjd)')
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.

Most of this looks really good! Could you change --deltaT to --tw so it matches the convention already established in run_gw_followup.py?

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

help='Option to print events within 5 degrees of best-fit to the screen (default False)')
parser.add_argument('--deltallh_skymap', action='store_true', default=False,
help='Option MUST be raised if using deltaLLH map (default: False, assumes probability map)')
parser.add_argument('--do_posterior_analysis', type=bool, default=False,

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.

Is this argument needed here? Shouldn't the posterior code always do the posterior analysis?

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.

Agree, suggest dropping this arg

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.

Removed

"Event name given by IceCube-yymmdd + suffix.")
parser.add_argument('--print_nearby', action='store_true', default=False,
help='Option to print events within 5 degrees of best-fit to the screen (default False)')
parser.add_argument('--deltallh_skymap', action='store_true', default=False,

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.

This argument doesn't look like its used anywhere

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.

This is the arg for replicating historical analyses with IceCat-1. It's used below to select the correct class to load, but I don't know you really need it here since this won't be used in current alert follow-ups.

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.

As long as we aren't deleting it for the main script, best to leave it as compatible as possible I think

parser.add_argument('--suffix', type=str, default='A',
help="letter to differentiate multiple alerts on the same day (default = A)."
"Event name given by IceCube-yymmdd + suffix.")
parser.add_argument('--print_nearby', action='store_true', default=False,

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.

This argument doesn't look like its used anywhere in this code

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 this is a holdover from the run_track_followup.py script and will not be used here. Can drop this arg

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.

deleted

Comment thread fast_response/plotting_utils.py Resolved
Comment thread README.md Outdated


## Tutorial: Posterior Skymaps
For tracks, cascades and GW the script each has a X_posterior.py script. These should have the same arguments as the primary script and can be called with the same arguments.

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.

Could you please add information for how to run on scrambles and how to run on unblinded data?

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.

Added. Same as all FRA analyses

@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 for addressing things, @Samhori. I like the choice to switch to your version of the two plotting functions. Some smaller comments from me here.

One other thing is that there are more plots generated automatically than are currently included in the report. I suggest adding all of them to the posterior supplementary report, since I think all are helpful in various ways and are already generated anyway, so would be nice to include.

Can you also update the description of this PR? That will eventually become the commit message here. Please include a (brief) description of what this feature does, as well as any fixed bugs along the way.

\vspace{1cm}
{\Large Report Generated On:\\ \reportdate \par}
\end{titlepage}

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 that's fine for this to be a supplementary report. I suggest keeping the tables in Section 1 of the original reports, though, as Alicia suggests - which machine the report is made on, version of skylab, version of dataset, and general analysis parameters. (These things should all be initialized immediately when starting the analysis anyway and don't require other queries.) But section 2 can be dropped since it's in the main report already


\newcommand{\degree}{$^{\circ}$}

\newcommand{\plotpage}[3]{%

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.

This command seems to be making the formatting have a lot of difficulty. Is there a reason you defined a new command here? The \newpage at the beginning is giving extra space, as is the \vspace calls, which I think is making the formatting for the reports strange. Do you need this as a separate command here?

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.

Yeah, new page was also giving weird formatting before. Its a little hard to tell because I think my container has some latex issues. The plot page formatting also isn't great (and maybe I should get rid of vspaces)

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.

Okay. I think removing vspaces is a good idea. I also suggest removing the centering for the text in each section, to be more consistent with current reports

('reportdate', datetime.date.today().strftime("%Y-%m-%d")),
('obsdate', obsdate)]:
self.make_new_command(f, name, command)
print(self.analysisid)

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.

Is this for debugging? Can remove

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.

Removed

base = os.path.dirname(fast_response.__file__)
return os.path.join(base, 'latex/posterior_report_general.tex')

def generate_report(self):

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.

add docstring

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.

just deleted instead. Not required

Comment thread fast_response/FastResponseAnalysis.py Outdated
plt.savefig(plotting_location + "PosteriorMapZoomed1Deg.png")
plt.close()

# plot ns vs probability for some specific points, could use a cleaner method of choosing points

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.

This also can be its own function here

self.save_items["ns"] = ns
return ts, ns

def find_coincident_events(self, print_events=False):

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.

print_events needs to be here, it is called later in this function. But you can add custom_events here in addition, although please add it to the docstring and add a similar loud warning to my suggestion above

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.

Added it back

Comment thread fast_response/GWFollowup.py Outdated
events['gamma'][i] = self.ts_scan['gamma'][idx[0]]

if(custom_events is not None):
'''

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.

are these comments needed?

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.

Deleted

)


def compute_ang_err(ra, dec, sigma, density=1):

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.

Looking at the differences here, the difference is quite minor, so I am in support of keeping only one and am fine with the choice to keep only compute_ang_err (which I prefer the naming of, since contour has always made me think it's drawing a 90% contour). I am not sure why we would need to make sure the contours fell on the centers of pixels, so I don't see any issue with removing the old function here.

Comment thread README.md
## Tutorial: Posterior Skymaps
For tracks, cascades and GW the script each has a X_posterior.py script. These should have the same arguments as the primary script and can be called with the same arguments.

python run_gw_followup_posterior.py --name="S191216ap Update" --time=58833.89836 --skymap="https://gracedb.ligo.org/api/superevents/S191216ap/files/LALInference.fits.gz,0"

@jessiethw jessiethw Nov 29, 2026 •

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.

Make markdown happier by making this a python console
(ugh. suggestion didn't work because of syntax. basically, please just add ```python before line 169 and 3 of the ` character in a line after)

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.

Added

events = events[(events['time'] < self.stop) & (events['time'] > self.start)]

events = events[(events["time"] < self.stop) & (events["time"] > self.start)]
if custom_events is not None:

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 agree with Jessie that there should be a visual cue when we use custom_events.

Comment thread fast_response/FastResponseAnalysis.py Resolved
Comment thread fast_response/FastResponseAnalysis.py Outdated
self.save_items["tsd"] = tsd

def find_coincident_events(self, print_events=False):
def find_coincident_events(self, custom_events=None,print_events=False):

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.

missing a space here between comma and next item

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.

fixed

@physics-png physics-png Nov 30, 2026 •

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 know in the past, we have discussed concerns with running multiple processes in parallel on the realtime machine because of a concern associated with the amount of memory available on that machine. Have you done any baseline checks to see how much memory a posterior scan uses and if it is at risk of crashing on the realtime machine at all? Could you provide those metrics in this pull request somewhere?

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.

Peaks around 6 GB in one test. Most memory usage comes from loading the data files any ways.

Sam Hori and others added 2 commits December 1, 2026 16:37
feature. Also allowed user control of the sigma to scan in the posterior
skymap

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.

Following up on this since not all of the suggestions were addressed/implemented. Additionally, can you move detector operations onto its own page similar to what is already done for FRA, or as discussed in another comment just omit it entirely?

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.

This is now very similar to the original ReportGenerator.py code again. Since this code is very similar to what already exists in ReportGenerator.py please the code to that file and implement it similar to what is done for ExternalFollowups, GWFollowups, and AlertFollowups for example:

class GravitationalWaveReport(ReportGenerator):
    """Generates a FastResponse Report for a GW.
    Includes additional plot of skymap PDF versus dec, 
    with PS sensitivity overlaid
    """
    _figure_list = [('decPDF', 'decPDF.png')]

    def get_report_source(self):
        """Find base path of the general report TeX document.
        Looks for the directory location fast_response, 
        returns fast_response/latex/report_gw.tex
        """
        base = os.path.dirname(fast_response.__file__)
        return os.path.join(base, 'latex/report_gw.tex')

If you need to extend the current implementation of the ReportGenerator class so that it can accommodate extra plots, etc. That is fine, and a welcome new feature to FRA.

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.

This would require changing the current ReportGenerator code. I don't think we want to do this. Its unfortunate that the original ReportGenerator code was written in a fixed format, but we do not have the required information to call generate_report so this is not simply an extension of the output which ReportGenerator creates. I do not believe that such a change is worth making here, although we are reusing much of what is in the generate_report function.

@jessiethw jessiethw Dec 6, 2026 •

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.

Looking at a comparison of the two, I think this can be done with minimal changes to ReportGenerator. It will require changing the main class (generate_report method) slightly, but the changes are not that large, and will be more easily generalized to new reports (for example, the ones Chris will have for multi-FRA or DNNCascades.

My suggestions would be:

  1. Move PosteriorReportGenerator and FastResponsePosteriorReport classes to the main ReportGenerator.py file
  2. Use the original self._figure_list (currently this is unused in the call here) at L118 to use your needed figures (will add as suggestions below). These will need to be included in the posterior_report_general.tex file to ensure they get included. If you don't like the formatting that gives, then it can be a different list self._posterior_figures which is initialized as a blank list in the main class but included here.
  3. Add a boolean posterior to the args of generate_report (default False) but that is turned on for posterior reports. It would then go at L464 and turn on/off the rest of the report in the main report.
  4. The same boolean can be used to turn on/off the rate and other plots in the main report L344-373
  5. We discussed this via slack, but I would also keep the table at L453 for the posterior report.

parser.add_argument('--time', type=float, default=None,
help='Time of the alert event (mjd)')
parser.add_argument('--tw', type=float, default=1000,
help='Time of the analysis (s)')

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!

Comment thread README.md
For tracks, cascades and GW the script each has a X_posterior.py script. These should have the same arguments as the primary script and can be called with the same arguments. This uses the same FRA standard where if "test" is in the name (including suffix) of the analysis the experimental data will be scrambled

```python
python run_gw_followup_posterior.py --name="S191216ap Update" --time=58833.89836 --skymap="https://gracedb.ligo.org/api/superevents/S191216ap/files/LALInference.fits.gz,0"

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 tried running this example and got an error. Will post in slack.

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.

Should be fixed. Added an extra assert

@Samhori
Samhori added this pull request to stack #83 December 4, 2026 20:01

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.

seems this is a copy, likely committed accidentally - remove?


\newcommand{\degree}{$^{\circ}$}

\newcommand{\plotpage}[3]{%

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.

Okay. I think removing vspaces is a good idea. I also suggest removing the centering for the text in each section, to be more consistent with current reports

@jessiethw jessiethw Dec 6, 2026 •

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.

Looking at a comparison of the two, I think this can be done with minimal changes to ReportGenerator. It will require changing the main class (generate_report method) slightly, but the changes are not that large, and will be more easily generalized to new reports (for example, the ones Chris will have for multi-FRA or DNNCascades.

My suggestions would be:

  1. Move PosteriorReportGenerator and FastResponsePosteriorReport classes to the main ReportGenerator.py file
  2. Use the original self._figure_list (currently this is unused in the call here) at L118 to use your needed figures (will add as suggestions below). These will need to be included in the posterior_report_general.tex file to ensure they get included. If you don't like the formatting that gives, then it can be a different list self._posterior_figures which is initialized as a blank list in the main class but included here.
  3. Add a boolean posterior to the args of generate_report (default False) but that is turned on for posterior reports. It would then go at L464 and turn on/off the rest of the report in the main report.
  4. The same boolean can be used to turn on/off the rate and other plots in the main report L344-373
  5. We discussed this via slack, but I would also keep the table at L453 for the posterior report.

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

Suggestions for the report generation

('reportdate', datetime.date.today().strftime("%Y-%m-%d")),
('obsdate', obsdate)]:
self.make_new_command(f, name, command)
for plot_name, plot_path in [

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.

Suggested change
for plot_name, plot_path in [
for plot_name, plot_path in self._figure_list:

And remove the hardcoded list here

"""Generates a general FastResponse Report for a point source.
Includes additional plots of the 1D LLH ns scan
"""
_figure_list = [('nsscan', 'llh_ns_scan.png')]

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.

Suggested change
_figure_list = [('nsscan', 'llh_ns_scan.png')]
_figure_list = [
('PriorSkymap', self.analysisid +"_PriorSkymap.png"),
('PosteriorSkymap', self.analysisid +"_PosteriorMap.png"),
('PosteriorSkymapZoom',self.analysisid +"_PosteriorMapZoomed.png"),
('NsProfilePlot',self.analysisid +"_nsProfilePlot.png"),
("PosteriorSkymapZoomWNeutrinos",self.analysisid +"_PosteriorMapZoomedLog.png")
]

Move figure list to here

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.

4 participants