Skip to content

Commit

Permalink
Create autocorrelation.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Balinus authored Sep 12, 2024
1 parent 05ff519 commit 334ef39
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/autocorrelation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function autocorrelation(xout, xin; lags=30)
xout .= LongMemory.autocorrelation(Array(xin), lags)
end


"""
autocorrelation(ds; lags=30)
Compute the autocorrelation of a dataset `ds` along the time dimension.
# Arguments
- `ds`: The input dataset.
- `lags`: The number of lags to compute autocorrelation for. Default is 30.
# Returns
The autocorrelation of the input dataset `ds` along the time dimension.
"""
function autocorrelation(ds; lags=30)

# Dimensions
indims = InDims("Ti")
outdims = OutDims(Dim{:lags}(collect(1:lags)))

return mapCube(Climat.autocorrelation, ds, indims=indims, outdims=outdims, lags=lags, nthreads=Threads.nthreads())

end

0 comments on commit 334ef39

Please sign in to comment.