五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

R語言 熱浪(Heatwave)識別(ERA5數(shù)據(jù))

2023-02-22 18:12 作者:村上ヤンゴン  | 我要投稿

R語言初學(xué)者,歡迎大家交流學(xué)習(xí)

本代碼基于R語言?

重點(diǎn)的包為heatwaveR包

使用的氣溫數(shù)據(jù)為?ERA5-Land Daily Aggregated?

下載自GEE

https://developers.google.com/earth-engine/datasets/catalog/ECMWF_ERA5_LAND_DAILY_RAW

下面是代碼


#清空變量

rm(list = ls())

gc()


#安裝包

#install.packages("terra")

#install.packages("heatwaveR")

#install.packages("magrittr")

#install.packages("tidyverse")

#install.packages("tidyr")

#install.packages("lubridate")

#install.packages("dplyr")


#加載包

library(magrittr)

library(terra)

library(heatwaveR)

library(tidyverse,warn.conflicts = FALSE)

library(ggplot2)

library(tidyr)

library(scales)

library(lubridate)

library(trend)

library(dplyr)



#加載矢量邊界數(shù)據(jù)

iliPath <- "E:/Desktop/ili_riverbasin_1984/ili_riverbasin_1984.shp"

ili_vect <- vect(iliPath)


#文件夾路徑

path = "E:/Desktop/ERA5_Daily_ili _1"


#提取所有文件路徑

dataPath <-? list.files(path, recursive = TRUE, pattern = ".tif$",

? ? ? ? ? ? ? ? ? ? ? ? full.names = TRUE, include.dirs = TRUE)

#提取文件時間

dataname <- substr(dataPath,46,53) %>%?

? ? ? ? ? ? as.character() %>%?

? ? ? ? ? ? as.Date(.,"%Y%m%d")


#提取復(fù)合圖層中的溫度層

era_tem_2m <- rast()

##溫度數(shù)據(jù)

for (i in 1:length(dataPath)) {

? #lyrs=2是2米大氣溫度

? heatdata <- rast(dataPath[i],lyrs=2) %>%?

? ? ? ? ? ? ? crop(.,ili_vect) %>%?

? ? ? ? ? ? ? mask(.,ili_vect)

? #為每層數(shù)據(jù)命名

? names(heatdata) <- substr(dataPath[i],46,53)

? #將每層數(shù)據(jù)添加到數(shù)據(jù)集中

? add(era_tem_2m) <- heatdata

}

era_tem_2m


#保存結(jié)果

filename <- "E:/Desktop/ERA5_air_tem_2m.tif"

writeRaster(era_tem_2m, filename = filename , overwrite=TRUE)


##################################################################



#全局計算

##計算平均值

tempData <- global(era_tem_2m,"mean",na.rm=T,cores=4) %>%?

? ? ? ? ? ? as.data.frame(.)


#準(zhǔn)備熱浪識別數(shù)據(jù)

tempData$date <- dataname

tempData$mean <- tempData$mean - 273.15

names(tempData) <- c("temp","t")


#寫文件

filename <- "E:/Desktop/ili_global_mean.csv"

write.csv(tempData,file = filename)


#繪圖

ggplot(data = tempData, mapping = aes(x=t,y=temp, group = 1))+

? xlab("year")+geom_line(size=0.5)+

? scale_x_date(breaks = "8 years",date_labels="%Y")

#######################

#detect_heatwave

# Make a climatology from a daily time series

heatwave <- ts2clm(tempData, x=t,y=temp,

? ? ? ? ? ? ? ? ? ?climatologyPeriod = c("1963-03-08","1993-03-08"),

? ? ? ? ? ? ? ? ? ?pctile = 90 ,roundClm = 4) %>%?

? ? ? ? ? ? # Detect heatwaves

? ? ? ? ? ? detect_event(., x=t, y=temp,

? ? ? ? ? ? ? ? ? ? ? ? ?minDuration = 3,

? ? ? ? ? ? ? ? ? ? ? ? ?maxGap = 2,

? ? ? ? ? ? ? ? ? ? ? ? ?categories = TRUE)?


heatwave

heatwave$event_no[length(heatwave$event_no)]

sum(heatwave$duration)

mean(heatwave$duration)

max(heatwave$intensity_cumulative)


# Create a line plot of heatwaves .

event_line(heatwave,

? ? ? ? ? ?min_duration = 5,

? ? ? ? ? ?metric = "intensity_cumulative",

? ? ? ? ? ?category = TRUE,

? ? ? ? ? ?spread = 150,

? ? ? ? ? ?start_date = "2000-01-01",?

? ? ? ? ? ?end_date = "2020-01-01")


event_line(heatwave,

? ? ? ? ? ?min_duration = 5,

? ? ? ? ? ?metric = "intensity_mean",

? ? ? ? ? ?category = TRUE,

? ? ? ? ? ?spread = 150,

? ? ? ? ? ?start_date = "2000-01-01",?

? ? ? ? ? ?end_date = "2020-01-01")


#Detect consecutive days in exceedance of a given threshold.

EX_heatwave <-? exceedance(data = tempData,threshold = 35,minDuration = 3,maxGap = 2)


EX_heatwave


filename <- "E:/Desktop/ili_global_EX_heatwave.csv"

write.csv(EX_heatwave$threshold,file = filename)


R語言 熱浪(Heatwave)識別(ERA5數(shù)據(jù))的評論 (共 條)

分享到微博請遵守國家法律
远安县| 巴林左旗| 蓬安县| 永丰县| 怀宁县| 枞阳县| 河南省| 静宁县| 玉屏| 桦川县| 塔城市| 新郑市| 老河口市| 黄山市| 曲靖市| 东明县| 聂拉木县| 海阳市| 旌德县| 定南县| 柘荣县| 东阿县| 曲周县| 罗定市| 东台市| 陈巴尔虎旗| 浪卡子县| 常熟市| 西林县| 大庆市| 饶阳县| 荆门市| 新宾| 嘉荫县| 通河县| 嘉义县| 鄂尔多斯市| 黔江区| 聂荣县| 哈密市| 绵阳市|