File:SOI.svg

This is a file from the Wikimedia Commons
From English Wikipedia @ Freddythechick

Original file(SVG file, nominally 1,248 × 384 pixels, file size: 138 KB)

Summary

Python code

from urllib.request import urlretrieve
if input('Refresh local copy of SOI data from ftp.bom.gov.au/..?\n'
         'Empty input for NO, anything else for YES '
        ) > '':
    print('Loading...')
    urlretrieve('ftp://ftp.bom.gov.au/anon/home/ncc/www/sco/soi/soiplaintext.html',
                'soiplaintext.html')
data = []
with open('soiplaintext.html', 'r') as f:
    for line in f: # until table header (the line after '"`UNIQ--pre-00000001-QINU`"'
data = [float(_) for _ in data]
import numpy as np
x = 1876. + 1/24. + np.linspace(0., len(data)/12, len(data), endpoint=False)
n = 7
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
from matplotlib.ticker import MultipleLocator
plt.rcParams['svg.fonttype'] = 'none' # text as text, not curves
fig, ax = plt.subplots(1,1)
fig.set_size_inches(13, 4)
ax.fill_between(x[n2:-n2], av, 7., where= av > 7., facecolor='blue', interpolate=True)
ax.fill_between(x[n2:-n2], av,-7., where= av <-7., facecolor='red',  interpolate=True)
ax.plot(x[n2:-n2], av, 'k-', linewidth=0.4)
ax.plot(x, data, 'ko', markerfacecolor='#00000040', markeredgecolor='#00000000', markersize=3)
ax.set_xlim(x[0]-2., x[-1]+2.)
ax.set_ylim(-43., 40.)
ax.xaxis.set_major_locator(MultipleLocator(10.))
fig.tight_layout()
fig.text(.91,.88, 'La-Niña', color='blue', fontname='Verdana', fontsize=15)
fig.text(.91,.12, 'El-Niño', color='red',  fontname='Verdana', fontsize=15)
fig.savefig('SOI.svg', format='svg')
fig.show()
from re import sub
svg = open('SOI.svg', 'r').read() # In the file ...
svg = sub(r'[0-9]+\.[0-9]+', lambda x: str(round(float(x.group()), 1)), svg) # round to .1f,
STYLE = ' style="fill-opacity: 0.3; stroke: #000000; stroke-opacity: 0"'
rest = svg.split(STYLE)                                                   # draw the style info
rest[0] = sub('z\n" style="', 'z\n" style="fill-opacity: 0.3; ', rest[0]) # into the g element,
symbol = rest[1].split('"')[1][1:]    # identify the symbol name for the marker
svg = sub(symbol, 'o', ''.join(rest)) # and shorten it to "o",
svg = sub(' *<use x', '<use x', svg) # and finally unindent the most frequent lines.
open('SOI.svg', 'w').write(svg)

Description
English: Southern Oscillation Index monthly data 1876-2024, black line: smoothed with a 7-months cosine kernel, events colored with a threshold at |SOI| = 7 according to the Bureau of Meteorology description page. The red events are generally associated with El Niño and the blue events with La Niña.
Data Source:ftp://ftp.bom.gov.au/anon/home/ncc/www/sco/soi/soiplaintext.html
Description:http://www.bom.gov.au/climate/glossary/soi.shtml
Date
Source Own work
Author Rainald62
Other versions File:Soi.svg outdated, disallowed to overwrite.

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International 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.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

7 November 2023

image/svg+xml

141,130 byte

384 pixel

1,248 pixel

1b8fb7394ceaaa727dc8ee132ecd36296b4ea755

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current17:57, 1 February 2025Thumbnail for version as of 17:57, 1 February 20251,248 × 384 (138 KB)wikimediacommons>Rainald62Update

The following page uses this file:

Metadata