import numpy as np
import matplotlib.pyplot as plt
import copy
import wavepal as wv

mypath = "../figures/ODP1148_example/"

# Read the data
data = np.genfromtxt("data/ODP1148-BF-18O.txt")
myt = data[:, 0]
mydata = data[:, 1]

# Initialize the class called Wavepal (which is a class of the package wv)
x = wv.Wavepal(myt,
               mydata,
               "Age",
               "$\delta{}^{18}O$",
               t_units="ka",
               mydata_units="permil")

# Check the data set
x.check_data()

# Choose the degree of the polynomial for the subsequent analyses
x.choose_trend_degree(7)

# Compute some variables related to the trend
x.trend_vectors()

# Sensitivity analysis for the background noise (MCMC CL)
# -------------------------------------------------------
nmcmc = 10000
Esempio n. 2
0
t=np.linspace(1.,1000.,453)
y=np.sqrt(5.)*np.sin(2.*np.pi*t/20.)
myplot=CWT_Morlet_regularly_sampled(t,y)
myplot.show()

# Test 2
t=np.linspace(5.,5000.,1000)
y=np.sin(2.*np.pi*t/20.)+np.sin(2.*np.pi*t/400.)+np.sqrt(0.5)*np.sin(2.*np.pi*t/100.)
myplot=CWT_Morlet_regularly_sampled(t,y,Tmin=15.)
myplot.show()

## Test 3 - Pure noise
t=np.linspace(1.,5000.,383)
y=gen_car1(t,0.45*np.ones(1),1.7689*np.ones(1))
y=y[:,0]+np.sin(2.*np.pi*t/300.)
x=wv.Wavepal(t,y)
x.check_data()
x.choose_trend_degree(-1)
x.trend_vectors()
x.carma_params(signif_level_type="a",nmcmc_carma_max=100000)
sig_wn=x.sigwn_unique
alpha_rn=x.alpha_unique
x.timefreq_analysis(w0=8.7,smoothing_coeff=0.,shannonnyquistexclusionzone=True,weighted_CWT=True,computes_global_scalogram=False)
plot_scalogram=x.plot_scalogram(linewidth_cl=4,with_global_scalogram=False)
plot_scalogram.savefig("wavepal_scal.pdf")
plot_scalogram.show()
myplot=CWT_Morlet_regularly_sampled(t,y,alpha_rn=alpha_rn,sigma_wn=sig_wn,linewidth_cl=4,w0=8.7)
myplot.show()

# Test 4 - with wavepal for the background noise
data=np.genfromtxt("GISP2d18O_splineinterp_30yr.txt")
Esempio n. 3
0
#plt.title("Computing times")
#plt.xlabel("# data points")
#plt.ylabel("Computing time (s)")
#plt.legend(fancybox=True,fontsize='small')
#plt.savefig(here+"CPU_wn_95_loglog.pdf")
#plt.close()

## 1.2 Red noise
for k in range(len(nt)):
    print "rn 95%: iteration " + str(k + 1) + "/" + str(len(nt))
    t = np.linspace(1., float(nt[k]), nt[k])
    alpha = 1. / 10. * np.ones(1)
    sig = 2. * np.ones(1)
    data = np.sin(2. * np.pi * t / 10.) + gen_car1(t, alpha, sig)
    data = data[:, 0]
    x = wv.Wavepal(t, data)
    x.check_data()
    x.choose_trend_degree(-1)
    x.trend_vectors()
    # case 1: analytical
    time1 = time()
    x.carma_params(signif_level_type="a")
    x.timefreq_analysis(percentile=percentile)
    time2 = time()
    time95_anal[k] = time2 - time1
    # Fig. of the results of the last iteration
    if k == (len(nt) - 1):
        plot_scalogram = x.plot_scalogram()
        fig = plt.gcf()
        fig.set_size_inches(52, 26)
        plot_scalogram.savefig(here + "scalogram_rn_95_anal_" + str(nt[-1]) +
Esempio n. 4
0
from gen_car1_wv33 import gen_car1
import copy

path_to_figure_folder="../figures/"

# Generate a red noise on the time grid of ODP1148
data=np.genfromtxt("data/ODP1148-BF-18O.txt")
t=data[:,0]
sig=np.zeros(1)
sig[0]=2.
tau=np.zeros(1)
tau[0]=20.
mydata=gen_car1(t,1./tau,sig)
mydata=mydata[:,0]
# D=6000.
out1=wv.Wavepal(t, mydata)
out1.check_data()
out1.choose_trend_degree(-1)
out1.trend_vectors()
out1.carma_params(nmcmc=100000)
out1.freq_analysis(n_moments=2,freqstep=0.0001,weighted_WOSA=False,WOSA_segments="max",freqmin=0.003,freqmax=0.022,D=6000.,mywindow=8)
# D=2000.
out2=copy.copy(out1)
out2.freq_analysis(n_moments=2,freqstep=0.0001,weighted_WOSA=False,WOSA_segments="max",freqmin=0.003,freqmax=0.022,D=2000.,mywindow=8)
# D=1000.
out3=copy.copy(out1)
out3.freq_analysis(n_moments=2,freqstep=0.0001,weighted_WOSA=False,WOSA_segments="max",freqmin=0.003,freqmax=0.022,D=1000.,mywindow=8)
# D=600.
out4=copy.copy(out1)
out4.freq_analysis(n_moments=2,freqstep=0.0001,weighted_WOSA=False,WOSA_segments="max",freqmin=0.003,freqmax=0.022,D=600.,mywindow=8)
# Units and labels