def download_daily_data(station): """Download data from each day for a month""" for d in range(2, 32): path = os.path.join(DATA_PATH, '2013/1/2013_1_%d.h5' % d) with open_file(path, 'a') as data: esd.download_data(data, '/station_%d' % station, station, datetime(2013, 1, d))
def download_data_for_stations(timestamp, stations): t0 = time_util.GPSTime(timestamp - 60).datetime() t1 = time_util.GPSTime(timestamp + 60).datetime() print "Downloading data from %s to %s for stations %s" % (t0, t1, stations) for station in stations: esd.download_data(data, '/s%d' % station, station, start=t0, end=t1)
def download_monthly_data(station): """Download data from first day of each month""" for y in range(2010, 2016): for m in range(1, 13): if y == 2015 and m >= 4: continue path = os.path.join(DATA_PATH, '%d/%d/%d_%d_1.h5' % (y, m, y, m)) with open_file(path, 'a') as data: esd.download_data(data, '/station_%d' % station, station, datetime(y, m, 1))
def download(storage, test): """ Download data from the tijdtest stations This will download data in the given date range from both the swap and reference station into storage. """ print 'tt_data: Downloading data for test %d: %s' % (test.id, test.group) download_data(storage, '/refr/t%d' % test.id, 95, test.start, test.end) download_data(storage, '/swap/t%d' % test.id, 94, test.start, test.end)
def perform_esd_download_data(filename): """Load data from esd/api to h5 (filename)""" filters = tables.Filters(complevel=1) start = datetime.datetime(2012, 1, 1, 0, 0, 0) eind = datetime.datetime(2012, 1, 1, 0, 1, 0) with tables.open_file(filename, 'w', filters=filters) as datafile: esd.download_data(datafile, '/', 501, start, eind, type='events', progress=False) esd.download_data(datafile, '/', 501, start, eind, type='weather', progress=False)
def perform_esd_download_data(filename): """Load data from esd/api to h5 (filename)""" filters = tables.Filters(complevel=1) start = datetime.datetime(2012, 1, 1, 0, 0, 0) end = datetime.datetime(2012, 1, 1, 0, 1, 0) singles_start = datetime.datetime(2017, 1, 1, 0, 0, 0) singles_end = datetime.datetime(2017, 1, 1, 0, 10, 0) lightning_start = datetime.datetime(2015, 7, 17, 0, 0, 0) lightning_end = datetime.datetime(2015, 7, 17, 0, 10, 0) with tables.open_file(filename, 'w', filters=filters) as datafile: esd.download_data(datafile, '/', 501, start, end, type='events', progress=False) esd.download_data(datafile, '/', 501, start, end, type='weather', progress=False) esd.download_data(datafile, '/', 501, singles_start, singles_end, type='singles', progress=False) esd.download_lightning(datafile, '/', 4, lightning_start, lightning_end, progress=False)
def download_data(station): """Download data for the mounlab test - First the test with the lower detector placed in the HiSPARC office - Second the test with the lower detector placed in the Nikhef courtyard """ path = os.path.join(DATA_PATH, 'muonlab_test.h5') with open_file(path, 'a') as data: # Two ranges since the muonlab station was offline part of the time esd.download_data(data, '/station_%d' % station, station, datetime(2015, 5, 28, 15), datetime(2015, 5, 29, 9)) esd.download_data(data, '/station_%d' % station, station, datetime(2015, 6, 1, 8), datetime(2015, 6, 2, 11)) path = os.path.join(DATA_PATH, 'muonlab_test2.h5') with open_file(path, 'a') as data: esd.download_data(data, '/station_%d' % station, station, datetime(2015, 6, 2, 12), datetime(2015, 6, 16)) path = os.path.join(DATA_PATH, 'muonlab_test3.h5') with open_file(path, 'a') as data: esd.download_data(data, '/station_%d' % station, station, datetime(2015, 6, 2, 18), datetime(2015, 6, 25, 15))
import datetime import tables from sapphire import esd DATAFILE = 'data.h5' START = datetime.datetime(2016, 1, 1) END = datetime.datetime(2016, 1, 2) if 'data' not in globals(): data = tables.open_file(DATAFILE, 'w') esd.download_data(data, '/s501', 501, START, END)
import datetime import tables from sapphire import esd DATAFILE = 'data.h5' START = datetime.datetime(2016, 1, 1) END = datetime.datetime(2016, 1, 2) data = tables.open_file(DATAFILE, 'w') esd.download_data(data, '/s501', 501, START, END)
import datetime import tables from sapphire import esd DATAFILE = 'data.h5' STATIONS = [501, 503, 506] START = datetime.datetime(2016, 1, 1) END = datetime.datetime(2016, 1, 2) if __name__ == '__main__': if 'data' not in globals(): data = tables.open_file(DATAFILE, 'a') for station in STATIONS: group = '/s%d' % station if group not in data: esd.download_data(data, group, station, START, END)
# We also have to specify the time of the day # Because if we don't, the time is taken to be 12 am meaning there is no data included for July 25. # Alternatively, we can download data from a two hour interval on July 24 by specifying the hour of day. start = datetime.datetime(2019, 7 , 24, 20) end = datetime.datetime(2019, 7 , 24, 22) # You can specify the time up to second. # We have stored our time window in two arbitrarily-named variables, start and end. # To download data from station 40001 and store it in a group with name /s40001. # We can use the sapphire.esd.download_data() function esd.download_data(data, '/s40001', 40001, start, end) # In[9]: # The function esd.download_data() takes six arguments: file, group, station_number, start, end and type. # The last one has the defaulet artgument'events', and may be omitted. # In our example we have opened a file, mydata.h4, and have stored the file handler in the variable data. # We basically passend data to the function. The group name is /s40001. Group names must start with a letter, # hence the s for station # Group names in Pytables are just like folders in directory hierarchy. # We have specified /path/to/my/hisparc/data/files/for_station/s40001.This has absolutely nothing to do with the files.