# Calculation of temperature extremes of grid data based on MATLAB

For each station year, we summed the number of frost days (Tn <= 0℃) and warm days (Tm > 15℃) andexamined the temporal trends over the study period... Therefore, for interstation comparisons of the variability in the extreme (relatively rare) cold and warm events, we calculated the time-varying percentiles of the daily Tn (for cold events) and daily Tm (for warm events), respectively. For each month, the daily Tn and Tm of a given station were ranked, then the temperature values at various percentile breaks were selected. For a hypothetical example, in January of 1990 the ninetieth percentile of daily Tm (or the tenth percentile of daily Tn) of station A as 5℃ (or -10℃) would mean that 10% of the 31 observations of that month were higher (or lower) than this specific value. We then examined the temporal trends in the temperature percentiles for each month of the year after averaging the monthly percentiles for the entire study region. For example, temperatures of relatively rare warm extreme events can be defined as the temperature of those days that exceed the ninetieth percentile of Tm, while temperatures of the cold extreme events can be defined as the temperature of those days that are below the tenth percentile of Tn.

For temperature extremes, we found a literature, Temporal trends and variability of daily maximum and minimum,extreme temperature events, and growing season length over the eastern and central Tibetan Plateau during 1961-2003. mention:

"Calculate the days of Tn < = 0 Frost / cold day, Tm > 15 warm day for each station Therefore, for the comparison of site differences between extreme (relatively rare) cold events and warm events, we calculated the time-varying percentiles of daily Tn (cold event) and Tm (warm event), respectively. The daily Tn and Tm of each given station are sorted, and then the temperature values of different percentile discontinuities are selected. For example, in January 1990, as 5 ℃ (or - 10 ℃) of station a at the 90th percentile of Tm per day (or the 10th percentile of Tn per day) indicated that 10% of the 31 observations in that month were higher (or lower) than that specific value. Then, after averaging the monthly percentiles for the entire study area, we examined the time trend of the temperature percentiles for each month of the year. For example, warm extreme events with relatively rare temperature can be defined as those with temperature higher than the 90th percentile Tm, and cold extreme events can be defined as those with temperature lower than the 10th percentile Tn. "

## data

1961-2018 three-dimensional days Tmax, Tmin.

## method

Using percentile function

## Tm temperature extremes

yTmax=SW_Tmax; [m,n]=size(yTmax(:,:,1)); yTmax=reshape(yTmax,m*n,21184); ayTmax=zeros(m*n,58); c=zeros(365,1); d=zeros(366,1); a=1961; k=0; h = waitbar(0,'Please wait...'); for b=1:58 if (( rem(a,4) ~= 0 )) for j=1:m*n for i=1:365 c(i)=yTmax(j,i+k); end ayTmax(j,b)=prctile(c(:),90); end k=k+365; a=a+1; else for j=1:m*n for i=1:366 d(i)=yTmax(j,i+k); end ayTmax(j,b)=prctile(d(:),90); end k=k+366; a=a+1; end waitbar(b/58,h) end aymeanTmax=nanmean(ayTmax,1);

## Warm event

a=1961; k=0; Day=zeros(m*n,58); Day(isnan(ayTmax))=nan; h = waitbar(0,'Please wait...'); for b=1:58 if (( rem(a,4) ~= 0 )) for j=1:m*n for i=1:365 if yTmax(j,i+k)>aymeanTmax(1,b) Day(j,b)=Day(j,b)+1; end end end k=k+365; a=a+1; else for j=1:m*n for i=1:366 if yTmax(j,i+k)>aymeanTmax(1,b) Day(j,b)=Day(j,b)+1; end end end k=k+366; a=a+1; end waitbar(b/58,h) end

## Tn temperature extremes

Similar to the Tm extreme calculation above, only PRC (x, 10) is required.