#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 15 11:34:37 2021 author: Xiaoting Yang """ import numpy as np import matplotlib.pyplot as plt plotdir='./Figures/'; # set parameters for the delayed oscillator DT=0.1 # time is in month alpha=0.54# 0.75: standard value; 0.54: growing oscillations; 0.51: decaying (without 2nd mode Rossby wave) delta=round(8/DT) # for 1st mode Rossby wave # set initial conditions: i_start=round(delta) i_end=round(1200/DT); Nh=i_end; # start at fixed point plus a small perturbation h=np.zeros((Nh,1)); h[:i_start]=np.sqrt(1-alpha)+0.001; for ii in range(i_start,Nh): h[ii]=h[ii-1]+DT*(h[ii-1]-alpha*h[ii-delta]-h[ii-1]**3); # make figure # define time axis Time=np.linspace(0,1,Nh)*i_end*DT/12 plt.figure(figsize=(10,10)); plt.clf(); plt.subplot(2,1,1) plt.plot(Time[i_start:],h[i_start:],color='b',linewidth=1.2) plt.xlabel('Time (year)'); plt.ylabel('h'); plt.title('Time series'); plt.xlim(Time[i_start],Time[-1]) plt.subplot(2,1,2) plt.plot(h[(i_start-delta):(-delta)],h[i_start:],color='r',linewidth=1.2) plt.xlabel('h(t)'); plt.ylabel('h(t-year)'); plt.title('Constructed phase space') plt.tight_layout() plt.show() #plt.savefig(plotdir+'delayed_oscillator_alpha'+str(alpha)+'_'+tail+'.png')