Then, an iterative procedure is needed for the calculation of the matrix of initial probability (P matrix):

##Initial value of the P matrix
P0<-diag(fdpWind);
##Initial value of the p vector
p0<-fdpWind;
#The iterative procedure should stop when reaching a predefined error. However, for simplicity I have only constructed a for loop. To be improved!
steps=10;
P=P0;
p=p0;
for (i in 1:steps){
r<-P%*%G%*%p;
r<-as.vector(r/sum(r))
p=p+0.5*(p0-r)#vector
P=diag(p)}#matrix

With this cumulated MTM we are able to simulate a wind speed time series:

##One value per minute for 1 day
LSerie<-24*60;
#Random number for choosing the state
RandNum1<-runif(LSerie);
State<-InitialState<-1;
StatesSeries=InitialState;
##The next iterative procedure chooses the next state whose random number is greater than the cumulated probability defined by the MTM
for (i in 2:LSerie) {
State=min(which(RandNum1[i]<=MTMcum[State,]));
StatesSeries=c(StatesSeries,State)}
##Another random number to choose wind speeds inside each category
RandNum2<-runif(LSerie);
##And the wind speed series is
SpeedSeries=WindSpeed[StatesSeries]-0.5+RandNum2*LCateg;
##where the 0.5 correction is needed since the the WindSpeed vector is centered around the mean value of each category.

A result of this procedure is displayed in the next figure:

We can check that the distribution of this wind speed series is correct:

You mention that this procedure is implemented in the software Homer, but this one uses three extra parameters, apart from the Mean Speed and the Weibull shape, both included in your R script:
– autocorrelation: “a measure of how strongly the wind speed in one hour depends on the wind speeds in previous hours”
– diurnal pattern strength: “measure of how strongly the wind speed tends to depend on the time of day”
– hour of peak windspeed: “the hour of the day that tends to be the windiest, on average”

I’m very interested in modifying your script to include these three parameters, and wonder if there is a modified version of it.

Hi,
I wrote this provisional script for a data analysis. Finally I didn’t get involved in that analysis and couldn’t find time to improve this script.
Please, let me know if you modify it to include more parameters.
Thanks!
Oscar

Very interesting!! Do you think its posible to obtain the wind rose? and the distribution depending the elevation? I am thinking to include your script in our project to study the feasibility for an offshore wind power plant in different locations.

But first you have to generate the wind directions sequence. You can use the procedure I described provided you know some information about the probabilistic distribution of the wind directions. For wind speeds Rayleigh and Weibull functions are particularly recommendable, but I am not so sure if it’s correct for directions.