icecube_tools.utils.data module

class icecube_tools.utils.data.Events(seed: int = 1234)

Bases: ABC

Abstract bass class for event classes For single period event files, the properties return not a dictionary but a single array of data.

property N: Dict
property N_restricted: Dict
property ang_err
property data_periods
property dec
property irf_periods
abstract classmethod load_from_h5()
abstract period()
property periods
property ra
property reco_energy
restrict(dec_low: float = -1.5707963267948966, dec_high: float = 1.5707963267948966, ra_low=0.0, ra_high=6.283185307179586, ereco_low: float = 1.0)

Restrict declination to given range, if None provided respective bound is ignored. For fancier restrictions use self.mask. :param dec_low: Lower declination bound, in rad. :param dec_high: Upper declination bound, in rad.

abstract scramble_ra()
property seed
abstract write_to_h5()
class icecube_tools.utils.data.IceCubeData(base_url='https://icecube.wisc.edu/data-releases', data_directory='/home/runner/.icecube_data', cache_name='.cache', update=False)

Bases: object

Handle the interface with IceCube’s public data releases hosted on their website.

fetch(datasets, overwrite=False, write_to=None)

Downloads and unzips the given datasets.

Parameters:
  • datasets – A list of dataset names

  • overwrite – Overwrite existing files

  • write_to – Optional custom location

fetch_all_to(write_to, overwrite=False)

Download all data to a given location

find(search_string)

Find datasets containing search_string.

get_path_to(dataset)

Get path to a given dataset

ls(verbose=True, update=False)

List the available datasets.

Parameters:
  • verbose – Print the datasets if true

  • update – Refresh the cache if true

class icecube_tools.utils.data.RealEvents(*data_periods, seed=1234)

Bases: Events

Class to handle reading real event files of 2021 release.

STACK = {}
ang_err_ = 2
dec_ = 4
classmethod from_event_files(*periods: str, seed: int = 1234, use_all: bool = False, **kwargs)

Load from files provided by data release, if belonging to IC86_II or later, add to IC86_II keyword because the same IRF is used :param periods: Arbitrary number of period identifiers :param seed: int, seed for rng :param use_all: bool, true if IC86_II should be translated to all data periods with this detector configuration

insert_fake_data(data: SimEvents)

Inserts fake data into real data for e.g. sensitivity testing. Should have some way of distinguishing between fake and real data?! Tested, works! :param data: icecube_tools.utils.data.SimEvents

keys = ['reco_energy', 'ra', 'dec', 'ang_err', 'mjd']
classmethod load_from_h5(path: str)

Load events from hdf5 file :param path: Path to file

property mjd
mjd_ = 0
period(p: str)

Returns dictionary of events belonging to a specified data season :param p: Period identifier

ra_ = 3
reco_energy_ = 1
scramble_ra()

Scrambles the RA of all events that are not inserted fakes. Done by using the size of MJD, which is not provided for fake data. Fake data is excluded s.t. inserted point sources are not accidentally washed out. #TODO: Restricting to unmasked events

write_to_h5(path)

Write selected events to hdf5 file. :param path: Path to hdf5 file

class icecube_tools.utils.data.SimEvents(seed: int = 1234)

Bases: Events

Class to store simulated events.

property arrival_energy
ic86_ii_data_periods = ['IC86_II', 'IC86_III', 'IC86_IV', 'IC86_V', 'IC86_VI', 'IC86_VII']
keys = ['true_energy', 'arrival_energy', 'reco_energy', 'ra', 'dec', 'ang_err', 'source_label']
classmethod load_from_h5(path: str, seed: int = 1234)

Load events from hdf5 file. :param path: Path to file :param seed: Random seed for RA scrambling

period(p: str)

Returns dictionary of events belonging to a specified data season :param p: Period identifier

scramble_ra()

Srcambles RA of all events, no distinction between source and background is made. If a mask is supplied, only unmasked events are scrambled to save time on sampling random numbers.

property source_label
property true_energy
write_to_h5(path: str, sources: List[Source])

Write events to hdf5 file. :param path: Path to file :sources: List of sources used to generate events

class icecube_tools.utils.data.Uptime(*periods, **kwargs)

Bases: object

cumulative_time_obs(IRF: bool = True)
Parameters:

periods – Strings of data periods.

Returns:

Return total observation time of each queried data period in years (without unit)

property data_periods
find_obs_time(IRF: bool = True, **kwargs)
Calculate the amounts of time in each period covered for either:
  • given start and end time (should be MJD)

  • duration and end date

  • duration and start date

Duration should be in float in years.

property irf_periods
time_span(IRF: bool = True)

Return dictionary (keys are data or irf periods) with good time intervals of observations. :param periods: Strings of data/irf periods. :param IRF: bool, if true observation time of IC86_III and later is counted towards IC86_II. :return: Dict of total times in years (without unit) between start and end of each queried data period.

icecube_tools.utils.data.crawl_delay()

Delay between sending HTML requests.

class icecube_tools.utils.data.dddict

Bases: dict

max()
min()
class icecube_tools.utils.data.ddict

Bases: dict

Modified dictionary class, derived from dict. Used to nest dictionaries without having to write [] all the time when adding or calling.

add(value, *keys)

Add value to chain of keys. Careful: this may overwrite existing values! :param value: Value to be added :param keys: Tuple containing ordered keys behind which the value should be added.

icecube_tools.utils.data.find_files(directory, keyword)

Find files in a directory that contain a keyword.

icecube_tools.utils.data.find_folders(directory, keyword)

Find subfolders in a directory that contain a keyword.