icecube_tools.utils.data module

class icecube_tools.utils.data.Events

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 ang_err
property dec
abstract classmethod load_from_h5()
abstract period()
property periods
property ra
property reco_energy
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

Bases: Events

Class to handle reading real event files of 2021 release.

ang_err_ = 2
dec_ = 4
classmethod from_event_files(*periods: str)

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

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
write_to_h5(path)

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

class icecube_tools.utils.data.SimEvents

Bases: Events

Class to store simulated events.

property arrival_energy
keys = ['true_energy', 'arrival_energy', 'reco_energy', 'ra', 'dec', 'ang_err', 'source_label']
classmethod load_from_h5(path: str)

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

period(p: str)

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

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

Bases: object

Class to handle calculations of detector live time.

find_obs_time(**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.

time_obs(period: str)
Parameters

period – String of data period.

Returns

Return total observation time of data period.

time_span(period: str)
Parameters

period – String of data period.

Returns

total time between start and end of data period.

icecube_tools.utils.data.crawl_delay()

Delay between sending HTML requests.

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.