monthly_index_picker /

Filename Size Date modified Message
timeseries_files
7.8 KB
8.5 KB
3.9 KB
68.8 KB

README

Clear Science, Inc. Monthly Climate Oscillation Index Value Picker V1.0

This is a simple demonstration of the CSI monthly climate oscillation value picker.

Note that this example provides monthly climate oscillation values for:

- The Pacific Decadal Oscillation Index
- The Arctic Oscillation Index
- The Indian Ocean Dipole Index
- The Multivariate ENSO Index

All that is required to get the dictionary output is to import the monthly_index_picker library.

NOTE: Within the library file (monthly_index_picker.py) you may specify the location of the provided climate index files. See the notes within the library file for details.

import monthly_index_picker

For the purposes of this demonstration, I am invoking a helper library (in an imported lib called monthly_index_picker) that generates multiple timeseries' per the users request

For instance, below we will request a timeseries for JFM for 1979-2011 for the PDO, AO, IOD and MEI oscillations.

The library makes an easy-to-call python dictionary called 'results' where each timeseries can be called separately using a construction such as

results['pdo'][1] ...which would net the PDO timeseries for January.

The montly_index_timeseries module also return a year and month array of the user's request in list format.

With this single command, I can assemble multiple timeseries' for easy-of-use.

EXAMPLE USAGE:

 Note: See the lib details usage within monthly_index_picker.py

The below command (after monthly_index_picker is imported) will provide a standard python dictionary with the monthly index values for the PDO, AO, IOD and MEI for Jan, Feb, Mar from 1979 to 2011.

[results, months, years] = monthly_index_picker.get_monthly_index_timeseries(['pdo','ao','iod','mei'],
                                                                               [1,2,3],
                                                                               range(1979,2011))

Now display the results iteratively...

for result in results:
    print(result)
    print(results[result])
    print(' ')
pdo
{1: [-0.42, 0.06, 1.18, 0.15, 0.39, 1.43, 0.9, 1.03, 1.44, 0.28, -1.26, -0.39, -1.72, 0.06, -0.28, 0.86, -0.87, 0.94, 0.42, 1.12, -0.64, -2.13, 0.64, -0.34, 1.58, -0.42, -0.13, 0.54, -0.63, -1.47, -1.7, 0.06], 2: [-1.26, 0.6, 1.25, -0.1, 0.92, 1.25, 0.52, 1.48, 1.44, 0.49, -1.43, -1.24, -1.09, 0.11, 0.05, 0.4, 0.09, 0.92, 0.28, 1.51, -0.94, -1.22, 0.05, -1.29, 1.32, -0.11, 0.17, 0.38, -0.63, -1.33, -1.76, 0.16], 3: [-0.65, 0.6, 1.16, -0.32, 1.65, 1.55, -0.29, 1.6, 1.34, 0.52, -1.25, -1.24, -1.16, 0.08, 0.23, 0.27, 0.36, 0.83, 0.41, 1.33, -1.09, -0.65, -0.3, -1.13, 1.08, -0.13, 0.69, -0.72, -1.05, -1.26, -2.03, -0.21]}

mei
{1: [0.4755, 0.6405, -0.205, -0.201, 2.81, -0.4445, -0.577, -0.2555, 1.22, 0.909, -1.207, 0.389, 0.3205, 1.806, 0.8185, 0.289, 1.0435, -0.598, -0.436, 2.5505, -1.0815, -1.153, -0.596, -0.084, 1.092, 0.3545, 0.5435, -0.4235, 0.7435, -1.16, -0.7095, 1.335], 2: [0.1885, 0.6265, 0.146, -0.023, 2.9885, -0.196, -0.6495, -0.097, 1.4445, 0.587, -1.1585, 0.7405, 0.3495, 1.943, 0.959, 0.1645, 0.8335, -0.4415, -0.3235, 2.677, -1.025, -1.0965, -0.6205, -0.1245, 0.8675, 0.1395, 0.8545, -0.529, 0.313, -1.442, -0.6955, 1.4565], 3: [0.1615, 0.7765, 0.543, 0.0185, 3.027, 0.272, -0.5915, -0.048, 1.79, 0.3865, -0.8905, 0.6735, 0.365, 2.127, 1.164, 0.29, 0.556, -0.401, 0.1505, 2.615, -0.9575, -0.7255, -0.364, 0.141, 0.58, 0.0745, 0.7425, -0.62, 0.083, -1.216, -0.433, 1.1285]}

iod
{1: [0.145085, -0.232492, -0.204133, 0.679038, -0.730629, -0.21124, -1.34636, -0.13792, 0.0184277, 0.672269, 0.243904, -0.115175, 0.435698, -0.589886, -0.636193, -0.039813, 0.716504, -0.245148, -1.04315, 2.12433, -1.02079, -0.297101, -0.658001, -0.0330346, 0.235122, 0.612052, -0.975311, -1.17104, 0.432993, -0.498186, -0.0509606, 0.914361], 2: [0.292054, -0.149812, 0.150706, 0.976779, -1.42427, 0.0425636, -1.22769, -0.453795, 0.0586855, 0.580792, -0.031926, -0.201586, 0.671989, -1.0998, -0.5247, 0.293804, 0.275299, -0.353942, -0.44211, 1.13261, -0.559808, -0.120937, -0.334842, -0.144587, 0.0447129, 0.616359, -0.855806, -1.0395, 0.0732125, -0.6288, 0.129337, 1.24823], 3: [0.194786, -0.0689544, 0.563907, 1.2066, -1.29979, -0.07001, -1.13984, -0.192938, 0.46502, 0.125812, -0.56835, -0.299828, 0.996654, -1.54083, -0.25886, 0.914476, -0.080784, -0.589261, -0.0597539, 0.620504, -0.388768, 0.149103, 0.0329719, -0.291065, 0.0932544, 0.0706759, -0.755197, -0.949399, 0.196461, -0.248313, 0.450453, 1.18201]}

ao
{1: [-2.2328, -2.0657, -0.11634, -0.88341, 1.3591, 0.90504, -2.8057, -0.56764, -1.1476, 0.26466, 3.106, 1.0007, 0.72323, 0.55003, 3.4953, -0.28785, -0.15377, -1.2004, -0.45677, -2.0806, 0.11035, 1.2702, -0.95883, 1.3813, -0.47167, -1.6858, 0.35617, -0.17047, 2.0338, 0.81896, 0.79975, -2.5868], 2: [-0.69671, -0.93372, -0.33158, 0.97391, -1.8059, -0.30272, -1.4398, -2.9041, -1.4732, -1.0662, 3.2793, 3.4016, -0.87599, 1.1217, 0.1845, -0.86154, 1.4289, 0.16321, 1.8887, -0.18318, 0.48213, 1.0758, -0.62241, 1.3035, 0.1278, -1.5285, -1.2706, -0.15577, -1.3069, 0.93807, -0.6723, -4.2657], 3: [-0.81414, -1.4333, -1.6447, 1.0741, -0.56707, -2.386, 0.55144, 1.9308, -1.7465, -0.19707, 1.5303, 2.99, -0.5268, 0.98423, 0.76435, 1.881, 0.39323, -1.4832, 1.0908, -0.25442, -1.4916, -0.45136, -1.6865, 0.902, 0.93297, 0.31806, -1.3479, -1.6038, 1.1821, 0.58559, 0.12134, -0.43208]}

So, let's plot the PDO timeseries for JFM (each month separately).

#imports
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

#set up figure object

fig, ax = plt.subplots(figsize=(12, 6))

#plot individual months
ax.plot(years, results['pdo'][1], 'k--', linewidth=2.5, label='January', color='red')
ax.plot(years, results['pdo'][2], 'k--', linewidth=2.5, label='February', color='blue')
ax.plot(years, results['pdo'][3], 'k--', linewidth=2.5, label='March', color='green')

#compute the JFM average
averageJFM = (np.array(results['pdo'][1]) + np.array(results['pdo'][2]) + np.array(results['pdo'][3]))/3.
#no plot it as well
ax.plot(years, averageJFM, 'k-', linewidth=2.5, label='JFM', color='black')

#plotting niceties
ax.grid(True)
ax.legend(loc='upper right')
ax.set_title('JFM PDO Index Values 1979-2010')
ax.set_xlabel('Year')
plt.xticks(years, rotation='vertical')
ax.set_yticks((-2.5, -2.0, -1.5, -1.0, -.5, 0, .5, 1.0, 1.5, 2.0, 2.5))
ax.set_ylabel('PDO Index')

plt.show()

png

For a display of basic information about the climate indices used (invokable) within this library, a handy mode=info is available.

For each index, the following items are callable:

 - start_year
 - end_year
 - source_url   <-- source of the values provided within <index>.txt files
 - local_file   <-- location of the local file (unverified)
info = monthly_index_picker.get_monthly_index_timeseries([], [], [], mode='info')
print(info['pdo'])
{'start_year': 1854, 'end_year': 2015, 'source_url': 'https://www.ncdc.noaa.gov/teleconnections/pdo/', 'local_file': 'timeseries_files/pdo.txt'}
print(info['mei'])
{'start_year': 1979, 'end_year': 2015, 'source_url': 'https://www.esrl.noaa.gov/psd/enso/mei/table.html', 'local_file': 'timeseries_files/mei.txt'}
print(info['ao'])
{'start_year': 1950, 'end_year': 2015, 'source_url': 'http://www.cpc.ncep.noaa.gov/products/precip/CWlink/daily_ao_index/ao.shtml', 'local_file': 'timeseries_files/ao.txt'}
print(info['iod'])
{'start_year': 1958, 'end_year': 2015, 'source_url': 'http://www.jamstec.go.jp/frcgc/research/d1/iod/HTML/Dipole%20Mode%20Index.html', 'local_file': 'timeseries_files/iod.txt'}