Skip to content

Commit

Permalink
fix seas anomaly
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed Jul 23, 2023
1 parent 1ce6e57 commit 3ba98c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/Climate/anomaly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,13 @@ function cal_anomaly_quantile(
) where {T<:Real}

kw = (; probs, use_mov, na_rm, parallel, options...)
# TODO: 多个阈值,需要再嵌套for循环了
if method == "base"
mTRS = cal_mTRS_base(A, dates; p1, p2, kw...) |> squeeze_tail
anom = _cal_anomaly(A, mTRS, dates; option=1)
anom = _cal_anomaly(A, mTRS, dates)
elseif method == "season"
mTRS = cal_mTRS_base(A, dates; p1, p2, kw...) |> squeeze_tail
T_wl = cal_warming_level(A, dates; p1, p2)
anom = _cal_anomaly(A, mTRS, dates; option=2, T_wl)
anom = _cal_anomaly(A, mTRS, dates; T_wl)
elseif method == "full"
TRS_full = cal_mTRS_full(A, dates; kw...) |> squeeze_tail
anom = fun.(A, TRS_full)
Expand Down
6 changes: 3 additions & 3 deletions src/Climate/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ using Dates
using Printf: @sprintf

# DateType = Union{Date,DateTime,AbstractCFDateTime,Nothing}
_gte(x::T, trs::T, wl::T=T(0)) where {T<:Real} = x >= trs + wl
_gt(x::T, trs::T, wl::T=T(0)) where {T<:Real} = x > trs + wl
_exceed(x::T, trs::T, wl::T=T(0)) where {T<:Real} = x - trs + wl
_gte(x::T, trs::T, wl::T=T(0)) where {T<:Real} = x >= (trs + wl)
_gt(x::T, trs::T, wl::T=T(0)) where {T<:Real} = x > (trs + wl)
_exceed(x::T, trs::T, wl::T=T(0)) where {T<:Real} = x - (trs + wl)


# format_md(date) = @sprintf("%02d-%02d", month(date), day(date))
Expand Down

0 comments on commit 3ba98c2

Please sign in to comment.