| ingest |
index /Users/samuelveliveli/Downloads/marine-tracker/src/ingest.py |
Study discovery and location-event ingestion from Movebank, with local caching.
Two data sources are supported, normalized to a common schema:
- **Live API** (``www.movebank.org/movebank/service/direct-read``): near-live
GPS/Argos events. Every request needs HTTP Basic Auth -- there is no
anonymous tier, confirmed by requesting the study list with no credentials
(returns HTTP 401 with ``WWW-Authenticate: BASIC``). First access to a
study's events also requires accepting that study's license terms: the API
returns the terms as HTML, and the caller must echo back the MD5 hash of
that HTML as ``license-md5`` to receive real data. Used only when
``MOVEBANK_USERNAME``/``MOVEBANK_PASSWORD`` are set (see auth.py).
- **Movebank Data Repository** (``datarepository.movebank.org``): a separate,
fully public, DOI-archival system with no auth. Confirmed working via its
DSpace REST API (search -> item -> bundles -> bitstreams -> CSV content).
Used as the always-available fallback so the app works with zero setup,
clearly labeled as historical (not live) data.
Both paths are real research studies with real citations, not synthetic data.
Cached pulls are stored as parquet under data/raw/, named with the study
identifier and pull date, since Movebank tag data changes at most a few
times a day.
| Modules | ||||||
| ||||||
| Functions | ||
| ||
| Data | ||
| DATA_RAW_DIR = PosixPath('/Users/samuelveliveli/Downloads/marine-tracker/data/raw') DEFAULT_LIVE_STUDIES = [{'name': 'Bowhead whale Cumberland Sound', 'study_id': 467034665, 'taxon': 'Balaena mysticetus'}, {'name': 'churchill harbour seals', 'study_id': 3792819345, 'taxon': 'Phoca vitulina'}, {'name': 'Trichechus manatus Sirenia NE Brazil', 'study_id': 1936932457, 'taxon': 'Trichechus manatus'}] DEFAULT_REPOSITORY_STUDIES = [{'bitstream_url': 'https://datarepository.movebank.org/server/api/c...eams/aca1254b-7574-4677-a4d0-5fc23415859f/content', 'citation': 'Andrews-Goff V, Gales N, Childerhouse SJ, Laveri...1:e114729. https://doi.org/10.3897/BDJ.11.e114729', 'doi': '10.5441/001/1.294', 'license': 'CC0 1.0 Universal', 'name': "Movements of Australia's east coast humpback whales", 'taxon': 'Megaptera novaeangliae'}, {'bitstream_url': 'https://datarepository.movebank.org/server/api/c...eams/53183515-d3f3-4a9b-acb4-a90f8b02bcc6/content', 'citation': 'Baker L, Flemming JEM, Jonsen ID, Lidgard DC, Iv...nt Ecology 3(1):20. doi:10.1186/s40462-015-0047-4', 'doi': '10.5441/001/1.910p0c20', 'license': 'CC0 1.0 Universal', 'name': 'Grey seals (Halichoerus grypus) at Sable Island', 'taxon': 'Halichoerus grypus'}, {'bitstream_url': 'https://datarepository.movebank.org/server/api/c...eams/2c398911-0b86-466d-a6d5-8da2d9ca9c18/content', 'citation': 'Andrews-Goff V, Double M. 2022. Deployment detai...ian Antarctic Data Centre. doi:10.26179/jd0n-va59', 'doi': '10.5441/001/1.vr276ns3', 'license': 'CC0 1.0 Universal', 'name': 'Antarctic blue whales, east Antarctic sector of the Southern Ocean', 'taxon': 'Balaenoptera musculus'}] EVENT_COLUMNS = ['timestamp', 'location_lat', 'location_long', 'individual_local_identifier', 'individual_taxon_canonical_name', 'study_name', 'source'] LIVE_API_BASE = 'https://www.movebank.org/movebank/service/direct-read' MARINE_MAMMAL_GENERA = {'arctocephalus', 'balaena', 'balaenoptera', 'berardius', 'callorhinus', 'caperea', ...} REPOSITORY_API_BASE = 'https://datarepository.movebank.org/server/api' | ||