Giter Site home page Giter Site logo

Comments (6)

nilshempelmann avatar nilshempelmann commented on August 15, 2024

subtraction of seasonal mean requires a smoothing:

"sousseasmean"<-function(dat,conv.time,l.mon=1:12,
l.year=unique(conv.time$year),rprint=FALSE)
{
dat.m=dat
seas.cyc=c()
time.cyc=c()

Calcul du cycle saisonnier pour une liste d'annees dans l.year

if(rprint) print("Seasonal cycle")
for(mon in l.mon){
r.day=range(conv.time$day[conv.time$month==mon])
for(day in r.day[1]:r.day[2]){
m.day=apply(dat[conv.time$day==day & conv.time$month==mon &
conv.time$year %in% l.year,],2,mean,na.rm=TRUE)
seas.cyc=rbind(seas.cyc,m.day)
time.cyc$month=c(time.cyc$month,mon)
time.cyc$day=c(time.cyc$day,day)
}
}

Lissage par spline du cycle saisonnier avec preservation des derivees aux bords

if(rprint) print("Seasonal cycle smoothing")
seas.cyc.spl=rbind(seas.cyc,seas.cyc,seas.cyc)
for(i in 1:ncol(seas.cyc)){
seas.cyc.spl[,i]=smooth.spline(seas.cyc.spl[,i],spar=0.8)$y
}
seas.cyc.spl=seas.cyc.spl[(nrow(seas.cyc)+1):(2*nrow(seas.cyc)),]

Soustraction du cycle saisonnier

if(rprint) print("Seasonal anomalies")
for(t in 1:nrow(dat)){
mon=conv.time$month[t]
day=conv.time$day[t]
ii= which(time.cyc$month %in% mon & time.cyc$day %in% day)
dat.m[t,]=dat[t,]-seas.cyc.spl[ii,]
}
datsub=list(anom=dat.m,seascyc=list(seascyc=seas.cyc.spl,timecyc=time.cyc))
}# fin de la definition de fonction

from flyingpigeon.

nilshempelmann avatar nilshempelmann commented on August 15, 2024

mbjncnlidahncflh

That's the R - smooth ....

from flyingpigeon.

nilshempelmann avatar nilshempelmann commented on August 15, 2024

a repoduction with python.
smooth

from flyingpigeon.

nilshempelmann avatar nilshempelmann commented on August 15, 2024

R routine is not handling different calenders:
CMIP5 dataset exists with with 365 days (no 29th feb) calenders.
HadGEM is comming with 360 days

but 'sousseasmean' expect 366 days for the annual cycle

from flyingpigeon.

mcalvcas avatar mcalvcas commented on August 15, 2024

noise-spline

from flyingpigeon.

nilshempelmann avatar nilshempelmann commented on August 15, 2024

Done ;-)

from flyingpigeon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.