Open G-Sommani opened 2 months ago
@ric-evans I have moved now 4 functions from plot.py
to plotting_tools.py
. These functions serve to calculate areas or estimating the angular distance of pixels, so not really directly for plotting. Do you think it would be better to move them to a dedicated file?
@ric-evans I have moved now 4 functions from
plot.py
toplotting_tools.py
. These functions serve to calculate areas or estimating the angular distance of pixels, so not really directly for plotting. Do you think it would be better to move them to a dedicated file?
In terms of lines per file, this looks much better. I personally keep to a max of 1000 lines and consider splitting at ~700.
As for how to group functions, you're the expert so whatever you think is best! Files are free, so there's no need to wait until modules reach X lines to split. Really, it's best to avoid splitting in the first place (from the POV of the main
branch) since git line history will be lost for the relocated lines. *_tools.py
modules do naturally tend to bloat over time since they can serve as a catch-all.
Im out of town right now and will try to give this a more careful look when I get back. A quick suggestion if we wanted to fix the area calculation bug would be to split the PR up so that 1 can be merged in since that is a bugfix. 2 and 3 maybe requires a bit more thought. This package is meant to handle the output of skymap scanner and so it would be nice to have a well defined scope.
Not from the PR: I'm concerned that this line https://github.com/icecube/skyreader/blob/ts-map-rude-events/skyreader/plot/plotting_tools.py#L320 will be forgotten about. Would it make sense to move it elsewhere, or is this a common pattern? I know
matplotlib
has anti-patterns (like https://github.com/icecube/skyreader/blob/ts-map-rude-events/skyreader/plot/plotting_tools.py#L19) that I may just need to get over 😆
I moved that line inside the __init__
function of the class SkyScanPlotter
(which handles the plots). It seems necessary to use the AstroMollweideAxes
class defined in plotting_tools.py
. I guess it makes sense to register this class as soon as the SkyScanPlotter
is initialized.
I created a new file areas.py
with two functions, calculate_area
and get_contour_area
, to estimate the areas of contours. I left get_space_angles
inside plotting_tools.py
as it serves to get a specific property (the angular distance of pixels) useful for plotting. And I moved log_gauss
back in plot.py
. This function would serve as a sort of psf model for the circularized contours.
Regarding @tianluyuan's comment, the circularized contours would always be pointed towards the direction of the minimum, so the output of the skymap scanner is always essential here and has to be handled to have the circularized contour. The option to apply a neutrino floor (which requires the possibility of generating circularized contours) may be useful with any reconstruction as 0.1 degree precision could still be affected by systematics as the geometry of the detector.
Maybe there are three main issues.
Maybe there are three main issues.
* Technically, there is an api to access the contour areas and skymap-scanner best fits. Using this api, isn't it possible to do the mock up skymap externally? * Such an external tool would also be useful since the mock up skymap does not necessarily need to be centered on the skymap-scanner's best fit. One can then circularize errors about any minimum, and build the map around that. * I'm not sure there's a strong scientific argument to circularize errors when we have the full likelihood map available. In practice, I think something like a recalibration of the likelihood levels could be a more useful feature i.e. a way to assign probability levels based on different delta-llh values, generalizing from chi2(k=2).
Hi @tianluyuan, thank you for telling me about this api. Could you point me to it? I see no problem in implementing circularization and neutrino floor there. Regarding your last point, two considerations:
This pull request would introduce two main changes/new implementations: