File:PDO.svg

Uploaded by Rainald62
Upload date 2020-01-05T00:35:31Z
MIME type image/svg+xml
Dimensions 450 × 270 px
File size 259.6 KB

Summary

Description
English: Dots, monthly values for the Pacific decadal oscillation index, 1900 – sep2019

line, smoothed index using a 121-months cosine half-wave as windowing function.

Data source:http://jisao.washington.edu/pdo/PDO.latest
Source Own work
 This W3C-unspecified plot was created with Matplotlib.
Author Rainald62
Other versions

Python

from urllib.request import urlretrieve
url = 'http://research.jisao.washington.edu/pdo/'
file = 'PDO.latest' # Monthly PDO from 1900.
if input(f'''Refresh local copy from {url}?
non-empty input for YES '''): urlretrieve(url+file, file)
data = []
with open(file, 'r') as f:
    for line in f:
        if line.startswith('YEAR'): break
    f.readline()
    for line in f:
        if line == '\n': break
        data += line.split()[1:]
data = [float(_) for _ in data]
import numpy as np
x = 1900. + 1/24. + np.linspace(0., len(data)/12, len(data), endpoint=False)
n = 121
n2 = n//2
kernel = np.sin(np.pi*np.linspace(1/(n+1), 1., n, endpoint=False))
kernel /= np.sum(kernel)
av = np.convolve(data, kernel, mode='valid')
import matplotlib.pyplot as plt
plt.rcParams['svg.fonttype'] = 'none' # text as text, not curves
fig, ax = plt.subplots(figsize=(5,3))
ax.fill_between(x[n2:-n2], av, 0., where= av > 0., facecolor='red',  interpolate=True)
ax.fill_between(x[n2:-n2], av, 0., where= av < 0., facecolor='blue', interpolate=True)
ax.plot(x[n2:-n2], av, 'k-', linewidth=0.4)
ax.plot(x, data, 'ko', markerfacecolor='#00000060', markeredgecolor='#00000000', markersize=2)
ax.set_xlim(x[0]-2., x[-1]+2.)
fig.text(.52,.88, 'PDO Index', horizontalalignment='center', fontname='Verdana', fontsize=14)
fig.tight_layout()
fig.savefig('PDO.svg', format='svg')
fig.show()

Licensing

I, the copyright holder of this work, hereby publish it under the following licenses:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
You may select the license of your choice.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

image/svg+xml

Category:CC-BY-SA-3.0 Category:El Niño/La Niña–Southern Oscillation charts Category:GFDL Category:License migration redundant Category:Pacific Decadal Oscillation Category:Self-published work Category:Unspec SVG created with Matplotlib Category:Valid SVG created with Python code