Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed Jul 23, 2023
1 parent 257ab2a commit 76341b7
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 34 deletions.
27 changes: 26 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ cal_climatology_full
```@docs
cal_mTRS_base!
cal_mTRS_base3!
NanQuantile_low
```


Expand All @@ -33,9 +34,11 @@ cal_warming_level
## Quantile

```@docs
NanQuantile_low
NanQuantile_3d!
movmean
linreg_simple
linreg_fast
```


Expand Down Expand Up @@ -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
```
24 changes: 10 additions & 14 deletions src/Climate/anomaly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand All @@ -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).
<https://doi.org/10.1029/2019JD032070>
"""
function cal_anomaly_quantile(
Expand Down Expand Up @@ -109,6 +111,8 @@ end


"""
$(TYPEDSIGNATURES)
Calculate the anomaly of an array relative to its climatology.
# Arguments
Expand Down Expand Up @@ -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.
Expand Down
25 changes: 11 additions & 14 deletions src/Climate/threshold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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".
Expand All @@ -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).
<https://doi.org/10.1029/2019JD032070>
"""
function cal_mTRS_base(arr::AbstractArray{T,N}, dates;
dims=N,
Expand Down Expand Up @@ -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).
Expand All @@ -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).
<https://doi.org/10.1029/2019JD032070>
"""
function cal_mTRS_full(arr::AbstractArray{T,N}, dates;
dims=N,
Expand Down
5 changes: 3 additions & 2 deletions src/Statistics/NanQuantile_low.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion src/par.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ get_clusters() = Threads.nthreads()


"""
$(TYPEDSIGNATURES)
$(TYPEDSIGNATURES)
# Example
```julia
Expand Down
4 changes: 2 additions & 2 deletions src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 76341b7

Please sign in to comment.