library(Ipaper) library(lubridate) library(RHtests) library(tidymet) library(tidyfst) # library(latticeGrob) devtools::load_all() devtools::load_all("../RHtests.R")
f_input <- "data-raw/INPUT/INPUT_met2474_Tmax&RHmax_for_HImax_1951-2022_V2.fst" # export_fst(df2, f_input) df = import_fst(f_input) sites <- df[, .N, .(site)]$site
# devtools::load_all("../RHtests.R") varnames <- c("Tair_max", "Tair_avg", "RH_avg") varname <- "RH_avg" version <- "v20230331" # profvis::profvis({ # proffer::pprof({ res <- homogenize_monthly(df, st_moveInfo, sites[1:10], varname, .parallel = FALSE) # }) str(res, 2)
合并TP
TP_mergeYM_sites(res)
# InitCluster(10) varnames = c("Tair_max", "Tair_avg", "RH_avg") varname <- "Tair_max" version <- "v20230331" # sites_bad <- c(50548, 54416, 54916, 58942, 59265) %>% as.character() run_noRef <- function(varname) { f_month <- glue("OUTPUT/ChinaHI/RHtests_{version}_{varname}_noRef_monthly.RDS") f_day <- glue("OUTPUT/ChinaHI/RHtests_{version}_{varname}_noRef_daily.RDS") if (!file.exists(f_month)) { # sink("log.txt") lst_mon <- homogenize_monthly(df, st_moveInfo, sites, varname, .parallel = TRUE) saveRDS(lst_mon, f_month) # sink(NULL) } else { lst_mon = readRDS(f_month) } # # merge yearly and monthly TP lst_mon2 <- RHtests_rm_empty(lst_mon) info <- TP_mergeYM_sites(lst_mon2) info2 <- info[abs(year(date) - year(date_year)) <= 1, ][Idc != "No ", ] sites_adj = info2[, .N, .(site)][, site] # res_adj = lst_mon2[sites_adj] lst_TP <- split(info2, info2$site) out <- homogenize_daily(df, lst_TP, varname, .parallel = TRUE) saveRDS(out, f_day) } foreach(varname = varnames, i = icount()) %do% { run_noRef(varname) }
# profvis::profvis({ # system.time({ # px <- proffer::pprof({ # out <- homogenize_daily(df, lst_TP, varname, nsite = 10) # }) varname = "RH_avg" sitename = 50247 #"sites[50247] l = get_Input(df, sitename, varname) prefix <- "./OUTPUT/example01" r_month <- RHtests_process(l$month, NULL, l$metadata, prefix, is_plot = FALSE, maxgap = 366) r_year <- RHtests_process(l$year, NULL, l$metadata, prefix, is_plot = FALSE, maxgap = 366) plot_output(r_month$data, "month.pdf", show=TRUE) plot_output(r_year$data, "year.pdf", show = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.