MATLAB | Calculation Method for Single Point Extreme Precipitation Index

MATLAB | Calculation Method for Single Point Extreme Precipitation Index

Click/Hit/Blue/Words Follow/Us

MATLAB | Calculation Method for Single Point Extreme Precipitation Index

{

MATLAB|

Calculation Method for Single Point Extreme Precipitation Index

Author: Galaxy Eight – Li Zhi

Email: [email protected]

}

MATLAB | Calculation Method for Single Point Extreme Precipitation Index

1

Rx1day

The maximum daily precipitation, which is straightforward and can be solved using the max() function.

MATLAB | Calculation Method for Single Point Extreme Precipitation IndexMATLAB | Calculation Method for Single Point Extreme Precipitation Index

2

Rx5day

The maximum precipitation over 5 consecutive days, which includes several conditions: 1) 5 consecutive days; 2) maximum value. The maximum value does not need explanation. When calculating the 5-day consecutive precipitation, it is important to ensure that the precipitation amount for all 5 days is not zero. Since this 5-day period is a sliding window, care must be taken to break the sliding window at zero values and NaN.

Thus, we introduce the movsum() function for calculation.

MATLAB | Calculation Method for Single Point Extreme Precipitation Index

3

SDII

The intensity of precipitation on wet days (daily precipitation > 1mm), this index first limits daily precipitation to be greater than 1mm, and then calculates the precipitation intensity. Precipitation intensity = cumulative precipitation / cumulative precipitation time.

MATLAB | Calculation Method for Single Point Extreme Precipitation Index

4

R10

The number of days with precipitation ≥ 10mm.

MATLAB | Calculation Method for Single Point Extreme Precipitation Index

5

R20

The number of days with precipitation ≥ 20mm.

MATLAB | Calculation Method for Single Point Extreme Precipitation Index

6

R95p

This is defined as the number of days with precipitation greater than the 95th percentile precipitation, which I honestly do not understand, but the percentile must use the prctile() function. So I checked the literature.

https://www.sciencedirect.com/science/article/pii/S1674927823001533

MATLAB | Calculation Method for Single Point Extreme Precipitation IndexMATLAB | Calculation Method for Single Point Extreme Precipitation Index

7

R99p

Similarly.

MATLAB | Calculation Method for Single Point Extreme Precipitation IndexMATLAB | Calculation Method for Single Point Extreme Precipitation Index

8

R98pTOT

The percentage of total precipitation on very wet days. After reading, I still did not understand, so I checked again:

MATLAB | Calculation Method for Single Point Extreme Precipitation IndexMATLAB | Calculation Method for Single Point Extreme Precipitation IndexMATLAB | Calculation Method for Single Point Extreme Precipitation Index

9

R99pTOT

Similarly.

MATLAB | Calculation Method for Single Point Extreme Precipitation IndexMATLAB | Calculation Method for Single Point Extreme Precipitation Index

10

CDD and CWD

This is slightly more complex. It requires the combination of the find(), diff(), and max() functions.

MATLAB | Calculation Method for Single Point Extreme Precipitation IndexMATLAB | Calculation Method for Single Point Extreme Precipitation IndexMATLAB | Calculation Method for Single Point Extreme Precipitation Index

Complete Code

clear;clc% Assume single point precipitation is pr, data contains missing values. pr = [4 NaN 6 0 0 0 15 3 4 5 31 40 15 22 17 58 46 11 75 2 3 5 9 12 23];Rx1day = max(pr);clear;clc% Assume single point precipitation is pr, data contains missing values. pr = [4 NaN 6 0 0 0 15 3 4 5 31 40 15 22 17 58 46 11 75 2 3 5 9 12 23];% Here we convert the data, changing 0 values to NaN, to facilitate sliding calculations without recognizing non-precipitation days. pr(pr==0) = nan;M = movsum(pr,5,'Endpoints','discard');Rx5day = max(M);clear;clc% Assume single point precipitation is pr, data contains missing values. pr = [4 NaN 6 0 0 10 15 3 4 5 31 40 15 22 17 58 46 11 75 2 3 5 9 12 23];% Calculate simple daily precipitation intensity indexthresholdP = 1;wetDays = pr(pr > thresholdP);SDII = sum(wetDays) / length(wetDays);
clear;clc% Assume single point precipitation is pr, data contains missing values. pr = [4 NaN 6 0 0 10 15 3 4 5 31 40 15 22 17 58 46 11 75 2 3 5 9 12 23];% Calculate the number of heavy precipitation daysthresholdP = 10;wetDays = pr(pr >= thresholdP);R10 = length(wetDays);
clear;clc% Assume single point precipitation is pr, data contains missing values. pr = [4 NaN 6 0 0 10 15 3 4 5 31 40 15 22 17 58 46 11 75 2 3 5 9 12 23];% Calculate the number of extreme precipitation daysthresholdP = 20;wetDays = pr(pr >= thresholdP);R20 = length(wetDays);clear;clc% Assume single point precipitation is pr, data contains missing values. pr = [4 NaN 31 1 1 1 1 11 1 1 1 1 1 40 15 22 17 5 46 11 3 2 1 65 52 62 55 49 62 23];% First filter daily precipitation greater than 1thresholdP = 1;wetDays = pr(pr > thresholdP);% Calculate 95th percentile precipitationR95pthresholdP = prctile(wetDays, 95);R95p = length(pr(pr >= R95pthresholdP));
clear;clc% Assume single point precipitation is pr, data contains missing values. pr = [4 NaN 31 1 1 1 1 11 1 1 1 1 1 40 15 22 17 5 46 11 3 2 1 65 52 62 55 49 62 23];% First filter daily precipitation greater than 1thresholdP = 1;wetDays = pr(pr > thresholdP);% Calculate 99th percentile precipitationR99pthresholdP = prctile(wetDays, 99);R99p = length(pr(pr >= R99pthresholdP));clear;clc% Assume single point precipitation is pr, data contains missing values. pr = [4 NaN 31 1 1 1 1 11 1 1 1 1 1 40 15 22 17 5 46 11 3 2 1 65 52 62 55 49 62 23];% First filter daily precipitation greater than 1thresholdP = 1;wetDays = pr(pr > thresholdP);% Calculate 95th percentile precipitationR95pthresholdP = prctile(wetDays, 95);R95p = length(pr(pr >= R95pthresholdP));% Calculate the proportion of total precipitation for 95th percentileAmount95 = sum(pr(pr >= R95pthresholdP));R95pTOT = Amount95 / sum(pr);clear;clc% Assume single point precipitation is pr, data contains missing values. pr = [4 NaN 31 1 1 1 1 11 1 1 1 1 1 40 15 22 17 5 46 11 3 2 1 65 52 62 55 49 62 23];% First filter daily precipitation greater than 1thresholdP = 1;wetDays = pr(pr > thresholdP);% Calculate 99th percentile precipitationR99pthresholdP = prctile(wetDays, 99);R99p = length(pr(pr >= R99pthresholdP));% Calculate the proportion of total precipitation for 99th percentileAmount99 = sum(pr(pr >= R99pthresholdP));R99pTOT = Amount99 / sum(pr);clear;clc% Assume single point precipitation is pr, data contains no missing values. pr = [4 5 0 0.1 0.2 0.3 0.5 1 2 3 4 56 0 0.1 0.3 ];% Calculate consecutive dry daysthresholdP = 1;drySpells = diff(find([1, pr<thresholdP, 1]));CDD = max(drySpells) - 1;wetSpells = diff(find([1, pr>=thresholdP, 1]));CWD = max(drySpells) - 1;

END

Private Message:Galaxy Eight

How to Join the Group

Daily updates and shared data in the group

Please do not reply with words other thanGalaxy Eightto join the group

This article was edited by Galaxy Eight – Xinyue

Leave a Comment