Public data access¶
Fetch raw events and other data from the public database
This module enables you to access the public database and even the raw
event data. This is intended for specialized use only. For most uses, it is
faster and more convenient to access the event summary data (ESD) using
esd
.
- sapphire.publicdb.get_publicdb_xmlrpc_url()¶
- sapphire.publicdb.download_data(file, group, station_id, start, end, get_blobs=False)¶
Download raw data from the datastore
This function downloads data from the datastore, using the XML-RPC API exposed by the public database.
- Parameters:
file – The PyTables datafile handler
group – The PyTables destination group, which need not exist
station_id – The HiSPARC station number for which to get events
start – a datetime instance defining the start of the search interval
end – a datetime instance defining the end of the search interval
get_blobs – boolean, select whether binary data like traces should be fetched
Example:
>>> import tables >>> import datetime >>> import sapphire.publicdb >>> data = tables.open_file('data.h5', 'w') >>> start = datetime.datetime(2010, 9, 1) >>> end = datetime.datetime(2010, 9, 2) >>> sapphire.publicdb.download_data(data, '/s501', 501, start, end) INFO:sapphire.publicdb:2010-09-01 00:00:00 None INFO:sapphire.publicdb:Getting server data URL (2010-09-01 00:00:00) INFO:sapphire.publicdb:Downloading data... INFO:sapphire.publicdb:Storing data... INFO:sapphire.publicdb:Done.
- sapphire.publicdb.datetimerange(start, stop)¶
Generator for datetime ranges
This is a very specific generator for datetime ranges. Based on a start and stop value, it generates one day intervals. On the first and subsequent full days, it only returns a start value. On the last day, it returns a start and stop value. See example below.
- Parameters:
start – a datetime instance
stop – a datetime instance
Example:
>>> for x in datetimerange(datetime.datetime(2010, 1, 1, 11), datetime.datetime(2010, 1, 1, 13)): ... x ... (datetime.datetime(2010, 1, 1, 11, 0), datetime.datetime(2010, 1, 1, 13, 0)) >>> for x in datetimerange(datetime.datetime(2010, 1, 1, 11), datetime.datetime(2010, 1, 2)): ... x ... (datetime.datetime(2010, 1, 1, 11, 0), None) >>> for x in datetimerange(datetime.datetime(2010, 1, 1, 11), datetime.datetime(2010, 1, 2, 13)): ... x ... (datetime.datetime(2010, 1, 1, 11, 0), None) (datetime.datetime(2010, 1, 2, 0, 0), datetime.datetime(2010, 1, 2, 13, 0)) >>> for x in datetimerange(datetime.datetime(2010, 1, 1, 11), datetime.datetime(2010, 1, 5, 13)): ... x ... (datetime.datetime(2010, 1, 1, 11, 0), None) (datetime.datetime(2010, 1, 2, 0, 0), None) (datetime.datetime(2010, 1, 3, 0, 0), None) (datetime.datetime(2010, 1, 4, 0, 0), None) (datetime.datetime(2010, 1, 5, 0, 0), datetime.datetime(2010, 1, 5, 13, 0))