Repository navigation
Conversation
jessiethw
left a comment
There was a problem hiding this comment.
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
| events = self.llh.exp | ||
| events = events[(events['time'] < self.stop) & (events['time'] > self.start)] | ||
|
|
||
| print(custom_events) |
There was a problem hiding this comment.
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>There was a problem hiding this comment.
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
| 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): |
There was a problem hiding this comment.
comment above about distinguishing injected events also applies here
|
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 |
jessiethw
left a comment
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
Can you add some text to each section of the report, to make it clear what is shown in each plot?
There was a problem hiding this comment.
I agree with Jessie that each figure should have captions associated with them
| {\Large Zoomed Posterior Skymap} | ||
| \includegraphics[width=0.9\textwidth]{\PosteriorSkymapZoom} | ||
| \clearpage | ||
| {\Large Posterior Skymap W/ Nu Overlay} |
There was a problem hiding this comment.
please spell out the title here
|
|
||
| { | ||
| \centering | ||
| {\Large $N_s$ Profile Plot} |
There was a problem hiding this comment.
especially this plot, please add some description for the ROC members to understand what is shown here
| from .ReportGenerator import AlertReport | ||
| from .ReportGenerator import GravitationalWaveReport | ||
| from .ReportGenerator import FastResponseReport | ||
| from .PosteriorReportGenerator import \ |
There was a problem hiding this comment.
Please separate this onto multiple lines for clarity.
| from .PosteriorReportGenerator import \ | |
| from .PosteriorReportGenerator import FastResponsePosteriorReport, PosteriorReportGenerator | |
| from .PosteriorReportGenerator import GravitationalWavePosteriorReport, AlertPosteriorReport |
| from .ReportGenerator import GravitationalWaveReport | ||
| from .ReportGenerator import FastResponseReport | ||
| from .PosteriorReportGenerator import \ | ||
| FastResponsePosteriorReport,GravitationalWavePosteriorReport,PosteriorReportGenerator,AlertPosteriorReport |
There was a problem hiding this comment.
| FastResponsePosteriorReport,GravitationalWavePosteriorReport,PosteriorReportGenerator,AlertPosteriorReport | |
(continued suggestion from previous)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Agreed with above, please do not clone code.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
See new scripts. Its not particularly elegant because FRA is not really written to accommodate these kinds of parallel products in an elegant way
There was a problem hiding this comment.
That works, thanks. This is better
| 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( |
There was a problem hiding this comment.
I prefer the previous spacing here between code/comments, it makes it more readable.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I agree with Jessie that there should be a visual cue when we use custom_events.
physics-png
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
A lot of these files have permission changes that don't need them.
There was a problem hiding this comment.
Have you checked to see if your changes will conflict with Chris' at all?
There was a problem hiding this comment.
No all of them but we have confirmed that the core mechanics are inherited properly.
| ) | ||
|
|
||
|
|
||
| def plot_events2(dec, ra, sigmas, col="k",density=1): |
There was a problem hiding this comment.
Why are there two versions of this function?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
this line will conflict with Chris' code
There was a problem hiding this comment.
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.
| ----------- | ||
| ra: ndarray | ||
| Array of ra for events | ||
| Array of ra for events |
There was a problem hiding this comment.
Did you put your code through some kind of formatter? Its hard to tell what changes you made and what is just the formatter
There was a problem hiding this comment.
This was put through standard ruff formatting.
| 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) |
There was a problem hiding this comment.
Is this not what compute_ang_err does? Why is this code repeated?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Please see above comment on line 318
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Agreed with above, please do not clone code.
physics-png
left a comment
There was a problem hiding this comment.
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} | ||
|
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
That doesn't really make sense to duplicate I think here. We should always have the main report to compare against.
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
I agree with Jessie that each figure should have captions associated with them
There was a problem hiding this comment.
Could you please add an example to the readme of running a posterior map analysis?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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
runs to exclude underscore
| 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') |
There was a problem hiding this comment.
If you're adding new scripts which run a posterior analysis for tracks, I don't think this is needed here.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
What do you mean? Do you want an output folder?
There was a problem hiding this comment.
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
| ) | ||
|
|
||
|
|
||
| def plot_events2(dec, ra, sigmas, col="k",density=1): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
Please see above comment on line 318
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
There was a problem hiding this comment.
Some general comments on the report:
- 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
- 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?
- Profile plots
- Could you make the tick labels larger please?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Most of this looks really good! Could you change --deltaT to --tw so it matches the convention already established in run_gw_followup.py?
| 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, |
There was a problem hiding this comment.
Is this argument needed here? Shouldn't the posterior code always do the posterior analysis?
There was a problem hiding this comment.
Agree, suggest dropping this arg
| "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, |
There was a problem hiding this comment.
This argument doesn't look like its used anywhere
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
This argument doesn't look like its used anywhere in this code
There was a problem hiding this comment.
Yeah this is a holdover from the run_track_followup.py script and will not be used here. Can drop this arg
|
|
||
|
|
||
| ## 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. |
There was a problem hiding this comment.
Could you please add information for how to run on scrambles and how to run on unblinded data?
There was a problem hiding this comment.
Added. Same as all FRA analyses
There was a problem hiding this comment.
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} | ||
|
|
There was a problem hiding this comment.
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]{% |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Is this for debugging? Can remove
| base = os.path.dirname(fast_response.__file__) | ||
| return os.path.join(base, 'latex/posterior_report_general.tex') | ||
|
|
||
| def generate_report(self): |
There was a problem hiding this comment.
just deleted instead. Not required
| plt.savefig(plotting_location + "PosteriorMapZoomed1Deg.png") | ||
| plt.close() | ||
|
|
||
| # plot ns vs probability for some specific points, could use a cleaner method of choosing points |
There was a problem hiding this comment.
This also can be its own function here
| self.save_items["ns"] = ns | ||
| return ts, ns | ||
|
|
||
| def find_coincident_events(self, print_events=False): |
There was a problem hiding this comment.
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
| events['gamma'][i] = self.ts_scan['gamma'][idx[0]] | ||
|
|
||
| if(custom_events is not None): | ||
| ''' |
There was a problem hiding this comment.
are these comments needed?
| ) | ||
|
|
||
|
|
||
| def compute_ang_err(ra, dec, sigma, density=1): |
There was a problem hiding this comment.
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.
| ## 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" |
There was a problem hiding this comment.
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)
| 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: |
There was a problem hiding this comment.
I agree with Jessie that there should be a visual cue when we use custom_events.
| self.save_items["tsd"] = tsd | ||
|
|
||
| def find_coincident_events(self, print_events=False): | ||
| def find_coincident_events(self, custom_events=None,print_events=False): |
There was a problem hiding this comment.
missing a space here between comma and next item
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Peaks around 6 GB in one test. Most memory usage comes from loading the data files any ways.
feature. Also allowed user control of the sigma to scan in the posterior skymap
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
- Move
PosteriorReportGeneratorandFastResponsePosteriorReportclasses to the mainReportGenerator.pyfile - 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 theposterior_report_general.texfile to ensure they get included. If you don't like the formatting that gives, then it can be a different listself._posterior_figureswhich is initialized as a blank list in the main class but included here. - Add a boolean
posteriorto the args ofgenerate_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. - The same boolean can be used to turn on/off the rate and other plots in the main report L344-373
- 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)') |
| 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" |
There was a problem hiding this comment.
I tried running this example and got an error. Will post in slack.
There was a problem hiding this comment.
Should be fixed. Added an extra assert
There was a problem hiding this comment.
seems this is a copy, likely committed accidentally - remove?
|
|
||
| \newcommand{\degree}{$^{\circ}$} | ||
|
|
||
| \newcommand{\plotpage}[3]{% |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
- Move
PosteriorReportGeneratorandFastResponsePosteriorReportclasses to the mainReportGenerator.pyfile - 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 theposterior_report_general.texfile to ensure they get included. If you don't like the formatting that gives, then it can be a different listself._posterior_figureswhich is initialized as a blank list in the main class but included here. - Add a boolean
posteriorto the args ofgenerate_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. - The same boolean can be used to turn on/off the rate and other plots in the main report L344-373
- We discussed this via slack, but I would also keep the table at L453 for the posterior report.
jessiethw
left a comment
There was a problem hiding this comment.
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 [ |
There was a problem hiding this comment.
| 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')] |
There was a problem hiding this comment.
| _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
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