Skip to content

Reading data from the IFCB dashboard

Joe Futrelle edited this page Jul 31, 2019 · 7 revisions

pyifcb provides a simple means of reading data from the web-based IFCB dashboard. It is not a full-featured client for the data dashboard; it only provides access to raw data from known URLs and does not provide access to other dashboard features such as time range queries and tags/comments.

If you know the URL of a bin that is available through the data dashboard, you can access it using the open_url function:

url = 'http://ifcb-data.whoi.edu/IFCB101_BigelowJun2016/D20160709T210837_IFCB101.html'

with ifcb.open_url(url) as sample_bin:
    lid = sample_bin.lid
    print('{} has {} image(s)'.format(lid, len(sample_bin.images)))

open_url only provides a context manager interface, because it downloads all three raw data files into a temporary directory, which is deleted when the context manager exits. As with other sample bin implementations, you can use the read method to read all data from these files, exit the context manager, and then still access the data even though all the temporary files have been deleted.

Downloading images can be slow. If you don't need the images you can pass images=False to open_url.

Technical note

open_url doesn't only work for files served by the IFCB data dashboard. In fact, if any set of three raw data files is accessible from a web server where each file has the same URL prefix, open_url will work. For example, if an ADC file is accessible at this URL:

http://myserver.org/some/directory/D20160101T123456_IFCB102.adc

then as long as the other files are accessible at these URLs:

http://myserver.org/some/directory/D20160101T123456_IFCB102.roi
http://myserver.org/some/directory/D20160101T123456_IFCB102.hdr

then the sample bin data can be accessed using open_url which can be given any one of those three URLs.