Skip to main content

A Python library for unified access to multi-source spatiotemporal Earth observation data (ERA5, PO.DAAC, SMAP, SFMR, etc.)

Project description

🌐 English | 🇨🇳 中文

spatiotemporal_data_library

PyPI

PyPI version

To publish:

python -m build
python -m twine upload dist/*

See PyPI project page for more info.

Introduction

spatiotemporal_data_library is a Python library for unified access to multi-source spatiotemporal Earth observation data, supporting major meteorological and oceanographic datasets such as ERA5, PO.DAAC (e.g., CYGNSS, OSCAR), SMAP RSS, and SFMR. Through a unified interface, users can easily search, download, parse, and standardize various remote sensing and reanalysis data.

Installation

It is recommended to use conda or pip to install dependencies:

pip install xarray pandas requests cdsapi netCDF4
# For PO.DAAC support, make sure podaac-data-downloader is installed and .netrc is configured
# For ERA5 support, configure .cdsapirc

Directory Structure

spatiotemporal_data_library/
├── __init__.py
├── fetch.py           # Main entry fetch_data
├── adapters/          # Data source adapters
├── utils.py           # Utility functions
├── config.py          # Configuration
└── test_spatiotemporal_data_library.py  # Test cases

Quick Start

from spatiotemporal_data_library import fetch_data
import datetime

ds = fetch_data(
    dataset_short_name="ECMWF_ERA5",
    variables=["10m_u_component_of_wind", "10m_v_component_of_wind"],
    start_time="2023-01-01T00:00:00Z",
    end_time="2023-01-01T03:00:00Z",
    bbox=[-5, 50, 0, 52]  # [min_lon, min_lat, max_lon, max_lat]
)
print(ds)

API Reference

fetch_data

def fetch_data(dataset_short_name: str,
               variables: list[str],
               start_time: str | datetime.datetime,
               end_time: str | datetime.datetime,
               bbox: list[float] = None,
               point: list[float] = None,
               **kwargs) -> xr.Dataset:
  • dataset_short_name: Dataset short name (see table below)
  • variables: List of standardized variable names
  • start_time/end_time: Query time (ISO string or datetime object)
  • bbox: Optional, geographic bounding box [min_lon, min_lat, max_lon, max_lat]
  • point: Optional, single point [lon, lat]
  • kwargs: Adapter-specific parameters (e.g., pressure_level, storm_name, mission_id, etc.)

Returns: xarray.Dataset, standardized dataset

Supported Datasets and Parameters

Name dataset_short_name Example Main Variables Note
ERA5 ECMWF_ERA5 10m_u_component_of_wind, ... Requires .cdsapirc
NOAA CYGNSS L2 NOAA_CYGNSS_L2_V1.2 surface_wind_speed, ... Requires podaac-data-downloader, .netrc
OSCAR V2 FINAL/NRT OSCAR_V2_FINAL/OSCAR_V2_NRT zonal_surface_current, ... Requires podaac-data-downloader, .netrc
SMAP L3 RSS FINAL SMAP_L3_RSS_FINAL surface_wind_speed Requires FTP account
SFMR HRD SFMR_HRD surface_wind_speed, rain_rate Public/Some require mission_id

For detailed variables and parameters, see the source code of each adapter.

Caching Mechanism

  • All downloaded raw data files are cached by default in the ~/.spatiotemporal_data_cache directory.
  • Files will not be re-downloaded if they already exist.
  • You can manually clear this directory to free up space.

Dependencies

  • xarray, pandas, requests, cdsapi, netCDF4
  • ERA5 requires configuration of ~/.cdsapirc, see CDS API Documentation
  • PO.DAAC requires configuration of ~/.netrc, see Earthdata Login
  • SMAP RSS requires applying for an FTP account and setting the environment variables RSS_FTP_USER and RSS_FTP_PASSWORD
  • SFMR public data does not require authentication, some require mission_id

Testing

pip install pytest
pytest spatiotemporal_data_library/test_spatiotemporal_data_library.py

Contribution & Feedback

Issues, PRs, and suggestions via email are welcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spatiotemporal_data_library-0.1.0.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spatiotemporal_data_library-0.1.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file spatiotemporal_data_library-0.1.0.tar.gz.

File metadata

File hashes

Hashes for spatiotemporal_data_library-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0849e590131789f6c657a790945e69ed59a994ff114526d4abd534941467d435
MD5 f8116c7651bed008354e40060c85e721
BLAKE2b-256 4e764868013d6bdf911956dcec6478d2016fd2fe1d3595f58b3a32f71eb2c8f5

See more details on using hashes here.

File details

Details for the file spatiotemporal_data_library-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for spatiotemporal_data_library-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ed437d73a4051bb637143d7e1db7aa06a7aebf6be9be91c3983631eaee4084ca
MD5 f2d0b8cb4307c4188d29d10e55f912c0
BLAKE2b-256 1f6dcb70915d8922681988101f2278f510570c6c60851356fb5c633e7b78fc51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page