Hydrocron API is a new tool that implements functionalities that will allow hydrologists to have direct access to filtered data from our newest satellites. This innovative tool will provide an effortless way to filter data by feature ID, date range, polygonal area, and more. This data will be returned in formats such as CSV and geoJSON.
Python 3.10+
- Build or pull the hydrocron docker image
- Run docker compose to launch dynamodb local and hydrocron local
- Load test data into dynamodb local
- Execute sample requests
Build the docker container:
docker build . -f docker/Dockerfile -t hydrocron:latest
Pull a pre-built image from https://github.com/podaac/hydrocron/pkgs/container/hydrocron:
docker pull ghcr.io/podaac/hydrocron:latest
Launch dynamodb local on port 8000 and hyrdrocron on port 9000
docker-compose up
If you have not setup a python environment yet, use poetry to first initialize the virtual environment.
poetry install
This will load the data in test/data
into the local dynamo db instance.
poetry run python tests/load_data_local.py
NOTE - By default data will be removed when the container is stopped. There are some commented lines in docker-compose.yml
that can be used to allow the data to persist across container restarts if desired.
The docker container is running a lambda container image. By posting data to port 9000, the lambda handler will be invoked and will return results from the loaded test data. For example:
curl --location 'http://localhost:9000/2015-03-31/functions/function/invocations' \
--header 'Content-Type: application/json' \
--data '{
"body":{
"feature": "Reach",
"feature_id": "71349000323",
"start_time": "2023-06-10T00:00:00+00:00",
"end_time": "2023-06-11T00:00:00+00:00",
"output": "csv",
"fields": "feature_id,time_str,wse,geometry"
}
}'
Instructions for loading the database with data from CMR instead of the single test granule, are described in hydrocron_db/LOAD_DATA_README.md