Skip to content

solbes/climatology

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Global historical climatology data API

Download and utilize historical weather data (temperature, solar radiation, wind, rain, ...) for any global geolocation as hourly time-series data.

Based on Copernicus Climate Data Store service. This project provides tools for

  • Querying and caching locally a dataset from the archive
  • Running a HTTP api in localhost for utilizing e.g. location specific weather histories

Setting up

Create account in the Copernicus service

This is needed so that the loader can query data. You need to create a configuration file ~/.cdsapirc:

url: https://cds.climate.copernicus.eu/api
key: SECRET-KEY-OBTAINED-FROM-WEBSITE

Clone git repository

git clone [email protected]:solbes/climatology.git

Create directory for climatology data

mkdir ~/.climatology/europe
mkdir ~/.climatology/beijing

Create your data loader config file

For example ~/.climatology/configs.json:

{
  "europe": {
    "variables": ["2m_temperature", "surface_net_solar_radiation"],
    "area": [73.0, -15.0, 30.0, 45.0],
    "start": 2018,
    "path": "/home/foobar/.climatology"
  },
  "beijing": {
    "variables": ["2m_temperature", "surface_net_solar_radiation"],
    "area": [45.0, 120.0, 35.0, 110.0],
    "start": 2018,
    "path": "/home/foobar/.climatology"
  }
}

NOTE The values of the area property define the lat/lon grid where data is queried to. The list is of form [North, West, South, East] where West/East is between -180...180 and North/South between -90...90.

Install virtual environment and activate it

python -m venv /PATH/TO/VENVS/climatology
source /PATH/TO/VENVS/bin/activate

Install the package

cd /PATH/TO/ROOT/FOLDER
pip install --editable .

Start data loader

python load_data.py --configs-file ~/.climatology/configs.json

Start local historical weather service

python api.py --configs-file ~/.climatology/configs.json

or, alternatively using the Flask CLI:

flask --app 'api:create_app(configs_file="/home/foo/bar/cfg.json")' run --port 5555 --host 127.0.0.2

In the latter case all Flask's arguments can be utilized.

Test query

# NOTE: Make sure your geographical region contains the lat/lon coordinates
curl http://127.0.0.1:5000/api/by_range?variable=2m_temperature&lat=62.0&lon=22.5&start=2021-01-01

API spec

TODO

Examples

TODO

About

Climatology data API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages