-
Notifications
You must be signed in to change notification settings - Fork 2
Installation [old]
Weather library requires the following modules:
Library is implemented in Python and it requires the newest version of Python 2 together with the numpy package.
- virtual-env: For a clearer overview of the installed modules the use of virtualenv is recommended.
- ecmwf-api: Detailed instruction for ecmwf-api installation can be found here under the section Install client libraries
- pygrib: Detailed instructions for pygrib module installation can be found here
All the libraries and modules in this guide are installed in the directory /home/weather/. First create the directory
~$ mkdir weather
~$ cd weather
Check the python version and install virtual-env:
~/weather$ python --version
Python 2.7.12
~/weather$ pip --version
pip 9.0.1
~/weather$ sudo pip install virtualenv
~/weather$ virtualenv --version
15.1.0
Create the virtual enviroment called weather-env and activate it:
~/weather$ virtualenv weather-env
~/weather$ source weather-env/bin/activate
Install numpy and ecmwf-api:
(weather-env) ~/weather$ pip install numpy
(weather-env) ~/weather$ pip install https://software.ecmwf.int/wiki/download/attachments/56664858/ecmwf-api-client-python.tgz
Now we are set for accessing the MARS dataset through weather.WeatherApi interface - for downloading GRIB files. We need to install pygrib along with its dependencies to be able to read the data from the GRIB file using weather.WeatherExtractor interface.
In order to install pygrib we first have to install matplotlib with basemap toolkit. Detailed instructions are available here
(weather-env) ~/weather$ pip install matplotlib
(weather-env) ~/weather$ wget https://github.com/matplotlib/basemap/archive/v1.1.0.tar.gz
(weather-env) ~/weather$ tar -xzf v1.1.0.tar.gz
(weather-env) ~/weather$ cd basemap-1.1.0
Basemap requires additional dependency geos whose source code is included in basemap. We need to install geos first:
(weather-env) ~/weather/basemap-1.1.0$ cd geos-3.3.3
(weather-env) ~/weather/basemap-1.1.0/geos-3.3.3$ export GEOS_DIR=~/weather/geos/
(weather-env) ~/weather/basemap-1.1.0/geos-3.3.3$ ./configure --prefix=$GEOS_DIR
(weather-env) ~/weather/basemap-1.1.0/geos-3.3.3$ make; make install
Now we can install basemap:
(weather-env) ~/weather/basemap-1.1.0/geos-3.3.3> cd ..
(weather-env) ~/weather/basemap-1.1.0> python setup.py install
Basemap requires pyproj:
(weather-env) ~/weather/basemap-1.1.0> pip install pyproj
Check if installation was successful:
(weather-env) ~/weather/basemap-1.1.0$ cd examples
(weather-env) ~/weather/basemap-1.1.0/examples$ python simpletest.py
The next step is installation of GRIB API. Installation guide is available here:
(weather-env) ~/weather$ mkdir tmp; cd tmp
(weather-env) ~/weather/tmp$ wget -O grib_api-source.tar.gz https://software.ecmwf.int/wiki/download/attachments/3473437/grib_api-1.24.0-Source.tar.gz?api=v2
(weather-env) ~/weather/tmp$ tar -xzf grib_api-source.tar.gz
(weather-env) ~/weather/tmp$ mkdir build; cd build
(weather-env) ~/weather/tmp/build$ cmake ../grib_api-1.24.0-Source -DCMAKE_INSTALL_PREFIX=~/weather/grib_api/
If you get the error message regarding Fortran compiler similar to this:
-- The Fortran compiler identification is unknown
CMake Error at cmake/ecbuild_enable_fortran.cmake:43 (enable_language):
No CMAKE_Fortran_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "FC" or the CMake cache entry CMAKE_Fortran_COMPILER to the full
path to the compiler, or to the compiler name if it is in the PATH.
Call Stack (most recent call first):
CMakeLists.txt:73 (ecbuild_enable_fortran)
-- Configuring incomplete, errors occurred!
REMOVE the following lines from ~/weather/tmp/grib_api-1.24.0-Source/CMakeLists.txt to disable Fortran features:
ecbuild_add_option( FEATURE FORTRAN
DESCRIPTION "build the GRIB_API Fortran interface"
DEFAULT OFF
# REQUIRED_LANGUAGES Fortran # TODO
)
# TODO Remove this after REQUIRED_LANGUAGES
if( ENABLE_FORTRAN )
# will set EC_HAVE_FORTRAN with the result
ecbuild_enable_fortran( MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/fortran/modules )
set( HAVE_FORTRAN ${EC_HAVE_FORTRAN} )
else()
set( HAVE_FORTRAN 0 )
endif()
and repeat the command:
(weather-env) ~/weather/tmp/build$ cmake ../grib_api-1.24.0-Source -DCMAKE_INSTALL_PREFIX=~/weather/grib_api/
And finally run:
(weather-env) ~/weather/tmp/build$ make; ctest; make install
If everything went fine GRIB API is installed in ~/weather/grib_api/
Detailed instructions for pygrib installation can be found here
First download the source code (as zip file) from the git repository and store it at ~/weather/pygrib-master.zip
(weather-env) ~/weather/$ unzip pygrib-master.zip
Open file ~/weather/pygrib-master/setup.cfg.template and set grib_api_dir to absolute path of grib api directory -> grib_api_dir=/home/user/weather/grib_api
Rename ~/weather/pygrib-master/setup.cfg.template to ~/weather/pygrib-master/setup.cfg
Now we can build and install pygrib:
(weather-env) ~/weather/$ cd pygrib-master
(weather-env) ~/weather/pygrib-master$ python setup.py build; python setup.py install
Check the installation with:
(weather-env) ~/weather/pygrib-master$ python test.py
...
**********************************************************************
1 items had failures:
8 of 105 in __main__.test
105 tests in 2 items.
97 passed and 8 failed.
***Test Failed*** 8 failures.
using GRIB API version 1.24.0
Download the code from git repository as zip file and store it at ~/weather/weather-data-master.zip
(weather-env) ~/weather/$ unzip weather-data-master.zip
(weather-env) ~/weather/$ cd weather-data
(weather-env) ~/weather/weather-data$ python setup.py install
Run the example:
(weather-env) ~/weather/weather-data$ python example.py
Note that virtual enviroment weather-env has to be activated and you need to have .ecmwfapirc stored in home directory!