Skip to content

How to use

Daniel Philipp edited this page Apr 19, 2021 · 4 revisions

Input data can be 1d numpy arrays (timeseries) or 3d numpy arrays with dimensions (time, lat, lon).

Run processing of statistics

from granger4climate import G4C, G4CPlotting

import numpy as np

cfc = 1d_or_3d_numpy_array

sic = 1d_or_3d_numpy_array

processor = G4C(cfc, sic, 'cfc', 'sic') Create instance

processor.run_causalitytest(maxlag=15, do_correlation=True) Run tests

processor.save_results('/path/to/save/result/ncfile') Saves results as netCDF4 file

Plot results (can also be run with path to saved netCDF file instead of G4C instance)

plotter = G4CPlotting(processor) OR plotter = G4CPlotting('/path/to/save/result/ncfile/*.nc')

Plotting of 1D input data results

If /path/to/save/filename.png is passed as argument data are saved, only shown else.

plotter.plot_1d_lags() Visualizes F-statistics and p-value for every model order

plotter.plot_1d_auxdata() Shows raw and prepared input data timeseries

Plotting of 3D input data results

If /path/to/save/filename.png is passed as argument data are saved, only shown else.

import cartopy.crs as ccrs

Define projections for gridded plotting

proj_params = {'iproj': ccrs.PlateCarree(), 'oproj': ccrs.NorthPolarStereo(), 'extent': [-180, 180, 60, 90], 'resolution': 0.5}

Run 2D plotting.

plotter.plot_2d_maps(orders=[1, 5, 10], proj_params=proj_params)