Skip to content

Commit 188b1fc

Browse files
committed
Import Git History From Scanner & Trim [major]
1 parent cce323d commit 188b1fc

File tree

3 files changed

+10
-58
lines changed

3 files changed

+10
-58
lines changed

skyreader/event_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Tools for functions/data related to icecube events."""
1+
"""Tools for functions/data related to IceCube events."""
22

33
import dataclasses as dc
44

skyreader/plot/plotting_tools.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Plotting tools."""
22

33
# fmt: off
4+
# flake8: noqa
45

56
import astropy.io.fits as pyfits # type: ignore[import]
67
import healpy # type: ignore[import]
@@ -17,12 +18,12 @@
1718
matplotlib.use('agg')
1819

1920
def format_fits_header(event_id_tuple, mjd, ra, dec, uncertainty):
20-
'''Prepare some of the relevant event information for
21-
a fits file header'''
21+
"""Prepare some of the relevant event information for a fits file
22+
header."""
2223
run_id, event_id, event_type = event_id_tuple
2324

2425
header = [
25-
('RUNID', run_id),
26+
('RUNID', run_id),
2627
('EVENTID', event_id),
2728
('SENDER', 'IceCube Collaboration'),
2829
('EventMJD', mjd),
@@ -63,7 +64,7 @@ def hp_ticklabels(zoom=False, lonra=None, latra=None, rot=None, bounds=None):
6364
min_lon = np.round(lon_offset/2.)*2. - 2
6465
max_lon = lon_offset+lonra[1]-lonra[0] + 2
6566
lons = np.arange(min_lon, max_lon, 2)
66-
67+
6768
min_lat = np.round(lat_offset/2.)*2. - 2
6869
max_lat = lat_offset+latra[1]-latra[0] + 2
6970
lats = np.arange(min_lat, max_lat, 2)
@@ -109,7 +110,7 @@ def hp_ticklabels(zoom=False, lonra=None, latra=None, rot=None, bounds=None):
109110
def plot_catalog(master_map, cmap, lower_ra, upper_ra, lower_dec, upper_dec,
110111
cmap_min=0., cmap_max=250.):
111112
""""Plots the 4FGL catalog in a color that contrasts with the background
112-
healpix map"""
113+
healpix map."""
113114
hdu = pyfits.open('/cvmfs/icecube.opensciencegrid.org/users/steinrob/reference_catalogues/Fermi_4FGL_v18.fit')
114115
fgl = hdu[1]
115116
pe = [path_effects.Stroke(linewidth=0.5, foreground=cmap(0.0)),

skyreader/result.py

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
# fmt: off
44
# pylint: skip-file
55
# mypy: ignore-errors
6+
# flake8: noqa
7+
68

7-
import dataclasses as dc
89
import io
910
import itertools as it
1011
import json
@@ -23,14 +24,11 @@
2324
from matplotlib import pyplot as plt
2425
from matplotlib import text
2526

26-
from .event_tools import EventMetadata
27-
from .pixel_classes import NSidesDict, RecoPixelFinal
27+
from .event_metadata import EventMetadata
2828

2929
###############################################################################
3030
# DATA TYPES
3131

32-
PixelTuple = Tuple[int, float, float, float]
33-
3432

3533
class PyDictNSidePixels(TypedDict):
3634
columns: List[str]
@@ -349,53 +347,6 @@ def get_filename(
349347
filename = output_dir / Path(filename)
350348
return filename
351349

352-
"""
353-
nsides-dict input
354-
"""
355-
356-
@classmethod
357-
def from_nsides_dict(
358-
cls,
359-
nsides_dict: NSidesDict,
360-
event_metadata: Optional[EventMetadata] = None
361-
) -> "SkyScanResult":
362-
"""Factory method for nsides_dict."""
363-
logger = logging.getLogger(__name__)
364-
365-
event_metadata_dict = {}
366-
if event_metadata:
367-
event_metadata_dict = dc.asdict(event_metadata)
368-
369-
result = dict()
370-
for nside, pixel_dict in nsides_dict.items():
371-
_dtype = np.dtype(cls.PIXEL_TYPE, metadata=dict(nside=nside, **event_metadata_dict))
372-
nside_pixel_values = np.zeros(len(pixel_dict), dtype=_dtype)
373-
logger.debug(f"nside {nside} has {len(pixel_dict)} pixels / {12 * nside**2} total.")
374-
375-
for i, (pixel_id, pixfin) in enumerate(sorted(pixel_dict.items())):
376-
nside_pixel_values[i] = cls._pixelreco_to_tuple(pixfin, nside, pixel_id)
377-
378-
result[cls.format_nside(nside)] = nside_pixel_values
379-
380-
return cls(result)
381-
382-
@staticmethod
383-
def _pixelreco_to_tuple(pixfin: RecoPixelFinal, nside: int, pixel_id: int) -> PixelTuple:
384-
if (
385-
not isinstance(pixfin, RecoPixelFinal)
386-
or nside != pixfin.nside
387-
or pixel_id != pixfin.pixel_id
388-
):
389-
msg = f"Invalid {RecoPixelFinal} for {(nside,pixel_id)}: {pixfin}"
390-
logging.error(msg)
391-
raise ValueError(msg)
392-
return (
393-
pixfin.pixel_id, # index
394-
pixfin.llh, # llh
395-
pixfin.reco_losses_inside, # E_in
396-
pixfin.reco_losses_total, # E_tot
397-
)
398-
399350
"""
400351
NPZ input / output
401352
"""

0 commit comments

Comments
 (0)