From 76341b7566b4de59f2ffe84bac8aef5344af9bb8 Mon Sep 17 00:00:00 2001 From: Dongdong Kong Date: Sun, 23 Jul 2023 11:14:56 +0800 Subject: [PATCH] fix docs --- docs/src/index.md | 27 ++++++++++++++++++++++++++- src/Climate/anomaly.jl | 24 ++++++++++-------------- src/Climate/threshold.jl | 25 +++++++++++-------------- src/Statistics/NanQuantile_low.jl | 5 +++-- src/par.jl | 2 +- src/precompile.jl | 4 ++-- 6 files changed, 53 insertions(+), 34 deletions(-) diff --git a/docs/src/index.md b/docs/src/index.md index 5294ba5..6f8ac25 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -22,6 +22,7 @@ cal_climatology_full ```@docs cal_mTRS_base! cal_mTRS_base3! +NanQuantile_low ``` @@ -33,9 +34,11 @@ cal_warming_level ## Quantile ```@docs -NanQuantile_low +NanQuantile_3d! + movmean linreg_simple +linreg_fast ``` @@ -64,6 +67,28 @@ show_pdf ## cmd ```@docs +dir path_mnt writelines ``` + +## R base + +```@docs +duplicated +list +match2 +``` + +### Missing + +```@docs +drop_missing +to_missing +``` + +## Parallel + +```@docs +isCurrentWorker +``` diff --git a/src/Climate/anomaly.jl b/src/Climate/anomaly.jl index 19c4d79..c7fe491 100644 --- a/src/Climate/anomaly.jl +++ b/src/Climate/anomaly.jl @@ -62,8 +62,10 @@ Calculate the anomaly of a 3D array of temperature data. - `A` : the 3D array of temperature data - `dates` : an array of dates corresponding to the temperature data - `parallel` : whether to use parallel processing (default `false`) -- `use_mov` : whether to use a moving window to calculate the threshold (default `true`) -- `method` : the method to use for calculating the threshold, one of `["full", "season", "base"]` (default `"full"`) +- `use_mov` : whether to use a moving window to calculate the threshold + (default `true`) +- `method` : the method to use for calculating the threshold, one of `["full", + "season", "base"]` (default `"full"`) - `probs` : default `[0.5]` - `p1` : the start year for the reference period (default `1981`) - `p2` : the end year for the reference period (default `2010`) @@ -76,9 +78,9 @@ An array of the same shape as `A` containing the temperature anomaly. # References 1. Vogel, M. M., Zscheischler, J., Fischer, E. M., & Seneviratne, S. I. (2020). - Development of Future Heatwaves for Different Hazard Thresholds. Journal of - Geophysical Research: Atmospheres, 125(9). - https://doi.org/10.1029/2019JD032070 + Development of Future Heatwaves for Different Hazard Thresholds. Journal of + Geophysical Research: Atmospheres, 125(9). + """ function cal_anomaly_quantile( @@ -109,6 +111,8 @@ end """ +$(TYPEDSIGNATURES) + Calculate the anomaly of an array relative to its climatology. # Arguments @@ -168,15 +172,7 @@ end """ - cal_threshold( - A::AbstractArray{T}, dates; - parallel::Bool=false, - use_mov=true, na_rm=true, - method="full", - p1=1981, p2=2010, - probs::Vector=[0.90, 0.95, 0.99, 0.999, 0.9999], - options... - ) +$(TYPEDSIGNATURES) Calculate the threshold value for a given dataset `A` and dates. The threshold value is calculated based on the specified method. diff --git a/src/Climate/threshold.jl b/src/Climate/threshold.jl index 563ed1c..5e52813 100644 --- a/src/Climate/threshold.jl +++ b/src/Climate/threshold.jl @@ -30,10 +30,7 @@ end """ -# Arguments - -- `method_q`: method to calculate quantile, one of `base`, `mapslices`. - `base` is about 3 times faster and reduce used memory in 20 times. +$(TYPEDSIGNATURES) """ function cal_mTRS_base!(Q::AbstractArray{T}, arr::AbstractArray{T,N}, mmdd; @@ -61,9 +58,9 @@ end """ -Moving Threshold for Heatwaves Definition + $(TYPEDSIGNATURES) - $(TYPEDSIGNATURES) +Moving Threshold for Heatwaves Definition # Arguments - `type`: The matching type of the moving `doys`, "md" (default) or "doy". @@ -73,9 +70,9 @@ Moving Threshold for Heatwaves Definition # References 1. Vogel, M. M., Zscheischler, J., Fischer, E. M., & Seneviratne, S. I. (2020). - Development of Future Heatwaves for Different Hazard Thresholds. Journal of - Geophysical Research: Atmospheres, 125(9). - https://doi.org/10.1029/2019JD032070 + Development of Future Heatwaves for Different Hazard Thresholds. Journal of + Geophysical Research: Atmospheres, 125(9). + """ function cal_mTRS_base(arr::AbstractArray{T,N}, dates; dims=N, @@ -110,10 +107,10 @@ cal_mTRS = cal_mTRS_base """ -Moving Threshold for Heatwaves Definition - $(TYPEDSIGNATURES) +Moving Threshold for Heatwaves Definition + # Arguments - `use_mov`: Boolean (default true). @@ -125,9 +122,9 @@ $(TYPEDSIGNATURES) # References 1. Vogel, M. M., Zscheischler, J., Fischer, E. M., & Seneviratne, S. I. (2020). - Development of Future Heatwaves for Different Hazard Thresholds. Journal of - Geophysical Research: Atmospheres, 125(9). - https://doi.org/10.1029/2019JD032070 + Development of Future Heatwaves for Different Hazard Thresholds. Journal of + Geophysical Research: Atmospheres, 125(9). + """ function cal_mTRS_full(arr::AbstractArray{T,N}, dates; dims=N, diff --git a/src/Statistics/NanQuantile_low.jl b/src/Statistics/NanQuantile_low.jl index 27ae4f0..559011a 100644 --- a/src/Statistics/NanQuantile_low.jl +++ b/src/Statistics/NanQuantile_low.jl @@ -37,7 +37,10 @@ end NanQuantile_low(A::AbstractArray{T,N}; probs::Vector=[0, 0.25, 0.5, 0.75, 1], dims::Integer=N, na_rm::Bool=true, dtype=nothing) where {T<:Real,N} +`NanQuantile_low(na_rm=rue)` is 3~4 times faster than `_nanquantile(na_rm=true)` + # Examples + ```julia using Test @@ -57,8 +60,6 @@ arr2 = copy(arr) @test r2_0 == 20 @test arr2 == arr ``` - -!!!`NanQuantile_low(na_rm=rue)` is 3~4 times faster than `_nanquantile(na_rm=true)` """ function NanQuantile_low(A::AbstractArray{T,N}; probs::Vector=[0, 0.25, 0.5, 0.75, 1], dims::Integer=N, na_rm::Bool=true, dtype=nothing) where {T<:Real,N} diff --git a/src/par.jl b/src/par.jl index 3a52b45..ac7cb1f 100644 --- a/src/par.jl +++ b/src/par.jl @@ -21,7 +21,7 @@ get_clusters() = Threads.nthreads() """ - $(TYPEDSIGNATURES) + $(TYPEDSIGNATURES) # Example ```julia diff --git a/src/precompile.jl b/src/precompile.jl index 261136b..8000506 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -72,11 +72,11 @@ precompile(str_extract_strip, (String, String)) @time anom_season = cal_anomaly_quantile(A, dates; kw..., method="season") @time anom_base = cal_anomaly_quantile(A, dates; kw..., method="base") - @time anom_full = cal_anomaly_quantile(A, dates; kw..., method="full") + # @time anom_full = cal_anomaly_quantile(A, dates; kw..., method="full") @assert size(anom_base) == (dims..., ntime, length(kw.probs)) - @assert size(anom_base) == size(anom_full) @assert size(anom_base) == size(anom_season) + # @assert size(anom_base) == size(anom_full) end # set_seed(1) l_dims = [(), (2,), (2, 2), (2, 2, 2)]