Create multiple matrix in which with synthesized precipitation values

1 次查看(过去 30 天)
Objective: to estimate the daily precipitaiton raster (in the format of matrices) for a month
Recently, I have written a function that can generate the precipitation statistically with its rainfall frequency. However, I would like to apply it to generate multiple matrices of the rainfall for the entire month
For example, if i have the matrix data that represents the January rainfall value; each grid represents the average monthly precipitaiton of each area presented in the grid.
1.5 0.6 2.33
2.5 3.5 2.4
3.5 0.5 1.5
The result of I wish to generate the daily rainfall result will be 31 matrices, that each grid stores the daily rainfall I generated statistically. Please let me know how I can make it work. Thank you.
Sincerely
  2 个评论
dpb
dpb 2019-11-29
3D array or cell array.
We can't do much more than that w/o seeing how you've constructed your function...
Pai-Feng Teng
Pai-Feng Teng 2019-11-29
编辑:Pai-Feng Teng 2019-11-29
dpb,
Thank you for your reply. the tif I imput and the result will be cell array.
Here is the unsuccessful codes.
clc; clear all
%Imput the mean monthly data raster files that I wish to simulate daily precipitation
[p01,R] =geotiffread('~/rasters/p201501.tif');
[p02,R] =geotiffread('~/rasters/p201502.tif');
[p03,R] =geotiffread('~/rasters/p201503.tif');
[p04,R] =geotiffread('~/rasters/p201504.tif');
[p05,R] =geotiffread('~/rasters/p201505.tif');
[p06,R] =geotiffread('~/rasters/p201506.tif');
[p07,R] =geotiffread('~/rasters/p201507.tif');
[p08,R] =geotiffread('~/rasters/p201508.tif');
[p09,R] =geotiffread('~/rasters/p201509.tif');
[p10,R] =geotiffread('~/rasters/p201510.tif');
[p11,R] =geotiffread('~/rasters/p201511.tif');
[p12,R] =geotiffread('~/rasters/p201512.tif');
%find the "monthly frequency", or 1/mean
freq01 = 1./p01;
freq02 = 1./p02;
freq03 = 1./p03;
freq04 = 1./p04;
freq05 = 1./p05;
freq06 = 1./p06;
freq07 = 1./p07;
freq08 = 1./p08;
freq09 = 1./p09;
freq10 = 1./p10;
freq11 = 1./p11;
freq12 = 1./p12;
%input coefficients
M = 10;%number of iteration
dt = 0.1;
%use for estimating precipitation
int01 = 0.2960339;
int02 = 0.7460724;
int03 = 1.3267461;
int04 = 2.3548115;
int05 = 2.4087414;
int06 = 6.1265225;
int07 = 4.2885165;
int08 = 5.0477728;
int09 = 2.7911814;
int10 = 2.7261879;
int11 = 0.2936842;
int12 = 0.5160813;
%entering monthly
Jan = 31;
Feb = 30;
Mar = 31;
Apr = 30;
May = 31;
Jun = 30;
Jul = 31;
Aug = 31;
Sep = 30;
Oct = 31;
Nov = 30;
Dec = 31;
Mtt = zeros(72,62); %this is only used as an examplematrix for generating simulated rasters. Ideally
% I with to generate as many as number of each month in the function
R01 = simulaterainfall(freq01(1,1), mean(p01,'all'), M, dt, Jan);
%this code will be the sample for developing the "simulated" daily rainfall at
%the location at (1,1) of the matrix. I wish my result to be applied to the entire
% 72x62 grids, the result of daily data will be saved in rasters
%the following is the example I tried to develop, but it didn't work out. Ideally
%the final products should be
for i = 1: %the numbers of rows
Ri = simulaterainfall(freq01(i,1),mean(p01,'all'), M, dt, Jan);%this is only the
% experimental one for January
Mtt(i,1)=Rn(1);
for j = 2: %the numbers for columns
Rj = simulaterainfall(freq01(1,j),mean(p01,'all'), M, dt, Jan);%this is only the
% ideally I wish to use thie loop to fill the rest of matrix
Mtt(i,1)=Rn(1);
end
end %ideally, this loop supposed to fill the entire matrix. If this loop works,
function Pr = simulaterainfall(freq, int, M, dt, dmonth)
% simulate monthly rainfall using M storms
t = exprnd(1./freq.*ones(1,M)); % Timing for M storms
tprime = cumsum(t); % time for each storm
a = find(tprime>dmonth); % We only want each month
tprime(a)=[]; % Removes times > 365 days
P = exprnd(int.* ones(size(tprime))); % Depth of storms
% stem(tprime, P)
% expand indices of rainfall occurrence
tprimedt0 = round(tprime, 1)*1/dt;
tprimedt = round(tprimedt0, 0); % round to integers
Pr = zeros(1, dmonth./dt); % reorganize rainfall at designated increments
Pr(tprimedt) = P; % combine days it did and did not rain
end

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by