diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml index 3152e82..31e2a89 100644 --- a/.JuliaFormatter.toml +++ b/.JuliaFormatter.toml @@ -1,6 +1,6 @@ -style = "blue" +style = "sciml" +format_markdown = false whitespace_in_kwargs = false -always_use_return = true margin = 92 indent = 4 format_docstrings = true diff --git a/Project.toml b/Project.toml index 603c76d..01b9133 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SpectralIndices" uuid = "df0093a1-273d-40bc-819a-796ec3476907" authors = ["MartinuzziFrancesco "] -version = "0.2.12" +version = "0.2.13" [deps] Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" diff --git a/README.md b/README.md index 26be48c..d515b7e 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ [julia-img]: https://img.shields.io/badge/julia-v1.10+-blue.svg [julia-url]: https://julialang.org/ -[style-img]: https://img.shields.io/badge/code%20style-blue-4495d1.svg -[style-url]: https://github.com/invenia/BlueStyle +[style-img]: https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826 +[style-url]: https://github.com/SciML/SciMLStyle [aqua-img]: https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg [aqua-url]: https://github.com/JuliaTesting/Aqua.jl diff --git a/docs/make.jl b/docs/make.jl index 6563484..be7a902 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -14,12 +14,12 @@ makedocs(; format=DocumenterVitepress.MarkdownVitepress(; repo="github.com/awesome-spectral-indices/SpectralIndices.jl", # this must be the full URL! devbranch="main", - devurl="dev", + devurl="dev" ), draft=false, source="src", build="build", - pages=pages, + pages=pages ) deploydocs(; @@ -27,5 +27,5 @@ deploydocs(; target="build", # this is where Vitepress stores its output branch="gh-pages", devbranch="main", - push_preview=true, + push_preview=true ) diff --git a/docs/package.json b/docs/package.json index bfd4da9..772361a 100644 --- a/docs/package.json +++ b/docs/package.json @@ -2,7 +2,7 @@ "devDependencies": { "markdown-it": "^14.0.0", "markdown-it-mathjax3": "^4.3.2", - "vitepress": "^1.0.0-rc.43", + "vitepress": "1.5.0", "vitepress-plugin-tabs": "^0.5.0", "vitest": "^1.3.0" }, diff --git a/docs/pages.jl b/docs/pages.jl index 558f993..a702a2f 100644 --- a/docs/pages.jl +++ b/docs/pages.jl @@ -4,11 +4,11 @@ pages = [ "Tutorials" => [ "Basics" => "tutorials/basic_types.md", "DataFrames.jl" => "tutorials/dataframes.md", - "YAXArrays.jl" => "tutorials/yaxarrays.md", + "YAXArrays.jl" => "tutorials/yaxarrays.md" ], "API Documentation" => [ "Axioms" => "api/axioms.md", "Compute" => "api/compute.md", - "Datasets" => "api/datasets.md", - ], + "Datasets" => "api/datasets.md" + ] ] diff --git a/ext/SpectralIndicesDataFramesExt.jl b/ext/SpectralIndicesDataFramesExt.jl index 0be1f79..611700f 100644 --- a/ext/SpectralIndicesDataFramesExt.jl +++ b/ext/SpectralIndicesDataFramesExt.jl @@ -3,17 +3,17 @@ module SpectralIndicesDataFramesExt using SpectralIndices using DataFrames import SpectralIndices: - create_params, - AbstractSpectralIndex, - compute_index, - create_indices, - linear, - poly, - RBF, - load_dataset, - load_json - -function create_params(kw_args::Pair{Symbol,DataFrame}...) + create_params, + AbstractSpectralIndex, + compute_index, + create_indices, + linear, + poly, + RBF, + load_dataset, + load_json + +function create_params(kw_args::Pair{Symbol, DataFrame}...) combined_df = DataFrame() for pair in kw_args @@ -25,20 +25,19 @@ function create_params(kw_args::Pair{Symbol,DataFrame}...) end function compute_index( - index::AbstractSpectralIndex, params::DataFrame; indices = create_indices() + index::AbstractSpectralIndex, params::DataFrame; indices=create_indices() ) # Convert DataFrame to a dictionary for each row and compute the index - results = [ - compute_index(index, Dict(zip(names(params), row)); indices=indices) for - row in eachrow(params) - ] + results = [compute_index(index, Dict(zip(names(params), row)); indices=indices) + for + row in eachrow(params)] # Return the results as a DataFrame with the column named after the index return DataFrame(Symbol(index.short_name) => results) end function compute_index( - index::Vector{<:AbstractSpectralIndex}, params::DataFrame; indices = create_indices() + index::Vector{<:AbstractSpectralIndex}, params::DataFrame; indices=create_indices() ) # Similar conversion and computation for a vector of indices result_dfs = DataFrame() @@ -68,7 +67,7 @@ function RBF(params::DataFrame) return result_df end -function load_dataset(dataset::String, ::Type{T}) where {T<:DataFrame} +function load_dataset(dataset::String, ::Type{T}) where {T <: DataFrame} datasets = Dict("spectral" => "spectral.json") if dataset in keys(datasets) @@ -88,7 +87,7 @@ function load_dataset(dataset::String, ::Type{T}) where {T<:DataFrame} df = DataFrame(; index=all_indices) for col_name in keys(ds) - df[!, col_name] = Vector{Union{Missing,Any}}(missing, length(all_indices)) + df[!, col_name] = Vector{Union{Missing, Any}}(missing, length(all_indices)) end for (col_name, col_data) in ds diff --git a/ext/SpectralIndicesYAXArraysExt.jl b/ext/SpectralIndicesYAXArraysExt.jl index 67cd66b..62bf6f8 100644 --- a/ext/SpectralIndicesYAXArraysExt.jl +++ b/ext/SpectralIndicesYAXArraysExt.jl @@ -4,25 +4,25 @@ using SpectralIndices using YAXArrays using DimensionalData import SpectralIndices: - check_params, - create_params, - order_params, - AbstractSpectralIndex, - compute_index, - create_indices, - linear, - poly, - RBF, - load_dataset, - load_json + check_params, + create_params, + order_params, + AbstractSpectralIndex, + compute_index, + create_indices, + linear, + poly, + RBF, + load_dataset, + load_json function check_params(index::AbstractSpectralIndex, params::YAXArray) for band in index.bands if !(band in params.Variables) throw( ArgumentError( - "'$band' is missing in the parameters for $index computation!" - ), + "'$band' is missing in the parameters for $index computation!" + ), ) end end @@ -37,7 +37,7 @@ function order_params(index::AbstractSpectralIndex, params::YAXArray) return new_params end -function create_params(kw_args::Pair{Symbol,<:YAXArray}...) +function create_params(kw_args::Pair{Symbol, <:YAXArray}...) params_yaxa = [] names_yaxa = [] for (key, value) in kw_args @@ -52,7 +52,7 @@ end ## TODO: simplify even further # this is same function contente as dispatch on Dict function compute_index( - index::AbstractSpectralIndex, params::YAXArray; indices = create_indices() + index::AbstractSpectralIndex, params::YAXArray; indices=create_indices() ) check_params(index, params) params = order_params(index, params) @@ -62,7 +62,7 @@ function compute_index( end function compute_index( - index::Vector{<:AbstractSpectralIndex}, params::YAXArray; indices = create_indices() + index::Vector{<:AbstractSpectralIndex}, params::YAXArray; indices=create_indices() ) results = [] for (nidx, idx) in enumerate(index) @@ -75,8 +75,8 @@ function compute_index( end function _compute_index( - ::Type{T}, idx::AbstractSpectralIndex, prms::YAXArray... -) where {T<:Number} + ::Type{T}, idx::AbstractSpectralIndex, prms::YAXArray... +) where {T <: Number} return idx.(T, prms...) end @@ -89,7 +89,7 @@ function poly(params::YAXArray) params[Variable=At("a")], params[Variable=At("b")], params[Variable=At("c")], - params[Variable=At("p")], + params[Variable=At("p")] ) end @@ -99,7 +99,7 @@ function RBF(params::YAXArray) ) end -function load_dataset(dataset::String, ::Type{T}) where {T<:YAXArray} +function load_dataset(dataset::String, ::Type{T}) where {T <: YAXArray} datasets = Dict("sentinel" => "S2_10m.json") if dataset in keys(datasets) diff --git a/src/SpectralIndices.jl b/src/SpectralIndices.jl index 760f8ed..ea4024d 100644 --- a/src/SpectralIndices.jl +++ b/src/SpectralIndices.jl @@ -1,12 +1,9 @@ module SpectralIndices -using Compat: @compat #for @compat public -using Dates -using Downloads -using JSON - -abstract type AbstractSpectralIndex end -abstract type AbstractPlatformBand end +using Compat: @compat +using Dates: Date, @dateformat_str +using Downloads: Downloads +using JSON: parsefile indices_funcs = Dict() include("utils.jl") @@ -24,13 +21,14 @@ indices = create_indices() bands = create_bands() constants = create_constants() -@compat(public, (create_indices, - create_bands, - create_constants, - load_json, - check_params, - create_params, - order_params)) +@compat(public, + (create_indices, + create_bands, + create_constants, + load_json, + check_params, + create_params, + order_params)) export get_indices, create_indexfun export get_datasets, load_dataset diff --git a/src/bands.jl b/src/bands.jl index 042197b..7187527 100644 --- a/src/bands.jl +++ b/src/bands.jl @@ -1,4 +1,4 @@ -struct Band{S<:String,F<:Number,P<:Dict{String,PlatformBand}} +struct Band{S <: String, F <: Number, P <: Dict{String, PlatformBand}} short_name::S long_name::S common_name::S @@ -54,14 +54,14 @@ julia> bands["B"].long_name ``` """ -function Band(band::Dict{String,Any}) +function Band(band::Dict{String, Any}) short_name = band["short_name"] long_name = band["long_name"] common_name = band["common_name"] min_wavelength = band["min_wavelength"] max_wavelength = band["max_wavelength"] - platforms = Dict{String,PlatformBand}() + platforms = Dict{String, PlatformBand}() for (platform, platform_info) in band["platforms"] if isa(platform_info, PlatformBand) @@ -88,7 +88,7 @@ end function create_bands() bands_dict = load_json("bands.json") - bands_class = Dict{String,Band}() + bands_class = Dict{String, Band}() for (key, value) in bands_dict bands_class[key] = Band(value) diff --git a/src/compute_index.jl b/src/compute_index.jl index f23b3bb..d7dff01 100644 --- a/src/compute_index.jl +++ b/src/compute_index.jl @@ -53,13 +53,8 @@ julia> compute_index( ``` """ -function compute_index( - index::AbstractSpectralIndex, - params = nothing, - online::Bool = false; - indices = indices, - kwargs..., -) +function compute_index(index::AbstractSpectralIndex, params=nothing, online::Bool=false; + indices=indices, kwargs...) if isnothing(params) params = create_params(kwargs...) end @@ -67,22 +62,16 @@ function compute_index( return compute_index(index, params; indices=indices) end -function compute_index( - index::String, params = nothing, online::Bool = false; indices=indices, kwargs... -) +function compute_index(index::String, params=nothing, online::Bool=false; + indices=indices, kwargs...) names = keys(indices) @assert index in names "$index is not a valid Spectral Index!" results = compute_index(indices[index], params; indices=indices, kwargs...) return results end -function compute_index( - index::Vector{<:AbstractSpectralIndex}, - params=nothing, - online::Bool=false; - indices=_create_indices(online), - kwargs..., -) +function compute_index(index::Vector{<:AbstractSpectralIndex}, params=nothing, + online::Bool=false; indices=_create_indices(online), kwargs...) if isnothing(params) params = create_params(kwargs...) end @@ -90,13 +79,8 @@ function compute_index( return compute_index(index, params; indices=indices) end -function compute_index( - index::Vector{String}, - params = nothing, - online::Bool = false; - indices = create_indices(online), - kwargs..., -) +function compute_index(index::Vector{String}, params=nothing, online::Bool=false; + indices=create_indices(online), kwargs...) names = keys(indices) for idx in index @assert idx in names "$index is not a valid Spectral Index!" @@ -106,7 +90,7 @@ function compute_index( return results end -function compute_index(index::AbstractSpectralIndex, params::Dict; indices = indices) +function compute_index(index::AbstractSpectralIndex, params::Dict; indices=indices) check_params(index, params) params = order_params(index, params) T = eltype(first(values(params))) @@ -117,9 +101,8 @@ end # TODO: return results in a matrix columnswise #multi_result = compute_index(["NDVI", "SAVI"], N = fill(0.643, 5), R = fill(0.175, 5), L = fill(0.5, 5)) -function compute_index( - index::Vector{<:AbstractSpectralIndex}, params::Dict; indices=indices -) +function compute_index(index::Vector{<:AbstractSpectralIndex}, params::Dict; + indices=indices) results = [] for (nidx, idx) in enumerate(index) result = compute_index(idx, params; indices=indices) @@ -130,16 +113,14 @@ function compute_index( end #_compute_index(idx::AbstractSpectralIndex, prms::Number...) = idx(prms...) -function _compute_index( - ::Type{T}, idx::AbstractSpectralIndex, prms::Number... -) where {T<:Number} +function _compute_index(::Type{T}, idx::AbstractSpectralIndex, + prms::Number...) where {T <: Number} return idx(T, prms...) end #_compute_index(idx::AbstractSpectralIndex, prms::AbstractArray...) = idx.(prms...) -function _compute_index( - ::Type{T}, idx::AbstractSpectralIndex, prms::AbstractArray... -) where {T<:Number} +function _compute_index(::Type{T}, idx::AbstractSpectralIndex, + prms::AbstractArray...) where {T <: Number} return idx.(T, prms...) end @@ -152,10 +133,9 @@ function compute_index(index::AbstractSpectralIndex, params::NamedTuple; indices return result_nt end -function compute_index( - index::Vector{<:AbstractSpectralIndex}, params::NamedTuple; indices=indices -) - results_dict = Dict{Symbol,Any}() +function compute_index(index::Vector{<:AbstractSpectralIndex}, params::NamedTuple; + indices=indices) + results_dict = Dict{Symbol, Any}() for idx in index result_nt = compute_index(idx, params; indices=indices) # TODO @MartinuzziFrancesco: there has to be a better way @@ -198,8 +178,8 @@ function check_params(index::AbstractSpectralIndex, params::Dict) if !(band in keys(params)) throw( ArgumentError( - "'$band' is missing in the parameters for $index computation!" - ), + "'$band' is missing in the parameters for $index computation!" + ), ) end end @@ -235,8 +215,8 @@ function check_params(index::AbstractSpectralIndex, params::NamedTuple) if !(Symbol(band) in keys(params)) throw( ArgumentError( - "'$band' is missing in the parameters for $index computation!" - ), + "'$band' is missing in the parameters for $index computation!" + ), ) end end diff --git a/src/compute_kernel.jl b/src/compute_kernel.jl index 67dbfd9..346e2e0 100644 --- a/src/compute_kernel.jl +++ b/src/compute_kernel.jl @@ -73,7 +73,7 @@ result = linear(df) linear(a::Number, b::Number) = a * b linear(a::AbstractArray, b::AbstractArray) = a .* b -function linear(params::Dict{String,U}) where {U<:Union{<:Number,<:AbstractArray}} +function linear(params::Dict{String, U}) where {U <: Union{<:Number, <:AbstractArray}} result = linear(params["a"], params["b"]) return result end @@ -131,11 +131,11 @@ function poly(a::Number, b::Number, c::Number, p::Number) return (a * b + c)^p end -function poly(a::V, b::V, c::V, p::V) where {V<:AbstractArray} +function poly(a::V, b::V, c::V, p::V) where {V <: AbstractArray} return @. (a * b + c)^p end -function poly(params::Dict{String,P}) where {P<:Union{<:Number,<:AbstractArray}} +function poly(params::Dict{String, P}) where {P <: Union{<:Number, <:AbstractArray}} result = poly(params["a"], params["b"], params["c"], params["p"]) return result end @@ -194,12 +194,12 @@ function RBF(a::Number, b::Number, sigma::Number) return exp((T(-1.0) * (a - b)^T(2.0)) / (T(2.0) * sigma^T(2.0))) end -function RBF(a::V, b::V, sigma::V) where {V<:AbstractArray} +function RBF(a::V, b::V, sigma::V) where {V <: AbstractArray} T = eltype(a) return @. exp((T(-1.0) * (a - b)^T(2.0)) / (T(2.0) * sigma^T(2.0))) end -function RBF(params::Dict{String,V}) where {V<:Union{<:Number,<:AbstractArray}} +function RBF(params::Dict{String, V}) where {V <: Union{<:Number, <:AbstractArray}} return RBF(params["a"], params["b"], params["sigma"]) end diff --git a/src/constants.jl b/src/constants.jl index d063fe0..b771781 100644 --- a/src/constants.jl +++ b/src/constants.jl @@ -1,5 +1,5 @@ -struct Constant{S<:String,D,V} +struct Constant{S <: String, D, V} description::S long_name::S short_name::S @@ -34,7 +34,7 @@ constant_dict = Dict( constant = Constant(constant_dict) ``` """ -function Constant(constant::Dict{String,Any}) +function Constant(constant::Dict{String, Any}) description = constant["description"] short_name = constant["short_name"] default = constant["default"] @@ -62,7 +62,7 @@ end function create_constants() constants = load_json("constants.json") - constants_class = Dict{String,Constant}() + constants_class = Dict{String, Constant}() for (key, value) in constants constants_class[key] = Constant(value) diff --git a/src/datasets.jl b/src/datasets.jl index 1403aa6..dc0dd2c 100644 --- a/src/datasets.jl +++ b/src/datasets.jl @@ -22,17 +22,15 @@ get_datasets(; datasets=["custom_dataset.json"], data_loc="path/to/custom/direct This is particularly useful for setting up local environments with necessary data files for further processing or analysis. """ -function get_datasets(; - datasets = ["S2_10m.json", "spectral.json"], - data_loc = joinpath(dirname(@__FILE__), "..", "data"), -) +function get_datasets(; datasets=["S2_10m.json", "spectral.json"], + data_loc=joinpath(dirname(@__FILE__), "..", "data")) for ds in datasets file_dest = joinpath(data_loc, ds) try Downloads.download( "https://raw.githubusercontent.com/awesome-spectral-indices/spyndex/main/spyndex/data/" * ds, - file_dest, + file_dest ) catch e @warn "Failed to download dataset $ds: $e" diff --git a/src/indices.jl b/src/indices.jl index c9990f0..b174773 100644 --- a/src/indices.jl +++ b/src/indices.jl @@ -4,8 +4,9 @@ struct SpectralIndices{T <: Dict{String, AbstractSpectralIndex}, O} origin::O end =# +abstract type AbstractSpectralIndex end -struct SpectralIndex{S<:String,B,D<:Date,P,F} <: AbstractSpectralIndex +struct SpectralIndex{S <: String, B, D <: Date, P, F} <: AbstractSpectralIndex short_name::S long_name::S bands::B @@ -79,7 +80,7 @@ function SpectralIndex(index::Dict, func::Function) date_of_addition, contributor, platforms, - func, + func ) end @@ -148,10 +149,9 @@ function compute(si::SpectralIndex, params::Dict=Dict(); kwargs...) end end -function _spectral_indices( - indices_dict::Dict{String,Any}, indices_funcs=indices_funcs; origin="SpectralIndices" -) - indices = Dict{String,AbstractSpectralIndex}() +function _spectral_indices(indices_dict::Dict{String, Any}, indices_funcs=indices_funcs; + origin="SpectralIndices") + indices = Dict{String, AbstractSpectralIndex}() for (key, value) in indices_dict indices[key] = SpectralIndex(value, indices_funcs[key]) end diff --git a/src/indices_funcs.jl b/src/indices_funcs.jl index e6ae75c..d85a87f 100644 --- a/src/indices_funcs.jl +++ b/src/indices_funcs.jl @@ -13,55 +13,61 @@ end indices_funcs["WI1"] = WI1_func function NDVIMNDWI_func(::Type{TFL}, N, R, G, S1) where {TFL <: Number} - return ((N - R)/(N + R)) - ((G - S1)/(G + S1)) + return ((N - R) / (N + R)) - ((G - S1) / (G + S1)) end indices_funcs["NDVIMNDWI"] = NDVIMNDWI_func -function BAIS2_func(::Type{TFL}, RE2, RE3, N2, R, S2; const1::Number=TFL(1.0), const2::Number=TFL(0.5), const3::Number=TFL(0.5), const4::Number=TFL(1.0)) where {TFL <: Number} - return (const1 - ((RE2 * RE3 * N2) / R) ^ const2) * (((S2 - N2)/(S2 + N2) ^ const3) + const4) +function BAIS2_func( + ::Type{TFL}, RE2, RE3, N2, R, S2; const1::Number=TFL(1.0), const2::Number=TFL(0.5), + const3::Number=TFL(0.5), const4::Number=TFL(1.0)) where {TFL <: Number} + return (const1 - ((RE2 * RE3 * N2) / R)^const2) * + (((S2 - N2) / (S2 + N2)^const3) + const4) end indices_funcs["BAIS2"] = BAIS2_func function PSRI_func(::Type{TFL}, R, B, RE2) where {TFL <: Number} - return (R - B)/RE2 + return (R - B) / RE2 end indices_funcs["PSRI"] = PSRI_func -function MGRVI_func(::Type{TFL}, G, R; const1::Number=TFL(2.0), const2::Number=TFL(2.0), const3::Number=TFL(2.0), const4::Number=TFL(2.0)) where {TFL <: Number} - return (G ^ const1 - R ^ const2) / (G ^ const3 + R ^ const4) +function MGRVI_func(::Type{TFL}, G, R; const1::Number=TFL(2.0), const2::Number=TFL(2.0), + const3::Number=TFL(2.0), const4::Number=TFL(2.0)) where {TFL <: Number} + return (G^const1 - R^const2) / (G^const3 + R^const4) end indices_funcs["MGRVI"] = MGRVI_func function SR_func(::Type{TFL}, N, R) where {TFL <: Number} - return N/R + return N / R end indices_funcs["SR"] = SR_func function MBI_func(::Type{TFL}, S1, S2, N; const1::Number=TFL(0.5)) where {TFL <: Number} - return ((S1 - S2 - N)/(S1 + S2 + N)) + const1 + return ((S1 - S2 - N) / (S1 + S2 + N)) + const1 end indices_funcs["MBI"] = MBI_func -function CRI700_func(::Type{TFL}, B, RE1; const1::Number=TFL(1.0), const2::Number=TFL(1.0)) where {TFL <: Number} +function CRI700_func(::Type{TFL}, B, RE1; const1::Number=TFL(1.0), + const2::Number=TFL(1.0)) where {TFL <: Number} return (const1 / B) - (const2 / RE1) end indices_funcs["CRI700"] = CRI700_func function WRI_func(::Type{TFL}, G, R, N, S1) where {TFL <: Number} - return (G + R)/(N + S1) + return (G + R) / (N + S1) end indices_funcs["WRI"] = WRI_func -function NDISIg_func(::Type{TFL}, T, G, N, S1; const1::Number=TFL(3.0), const2::Number=TFL(3.0)) where {TFL <: Number} - return (T - (G + N + S1) / const1)/(T + (G + N + S1) / const2) +function NDISIg_func(::Type{TFL}, T, G, N, S1; const1::Number=TFL(3.0), + const2::Number=TFL(3.0)) where {TFL <: Number} + return (T - (G + N + S1) / const1) / (T + (G + N + S1) / const2) end indices_funcs["NDISIg"] = NDISIg_func @@ -72,8 +78,14 @@ end indices_funcs["IRECI"] = IRECI_func -function MTVI2_func(::Type{TFL}, N, G, R; const1::Number=TFL(1.5), const2::Number=TFL(1.2), const3::Number=TFL(2.5), const4::Number=TFL(2.0), const5::Number=TFL(1), const6::Number=TFL(2), const7::Number=TFL(6.0), const8::Number=TFL(5), const9::Number=TFL(0.5), const10::Number=TFL(0.5), const11::Number=TFL(0.5)) where {TFL <: Number} - return (const1 * (const2 * (N - G) - const3 * (R - G))) / ((((const4 * N + const5) ^ const6) - (const7 * N - const8 * (R ^ const9)) - const10) ^ const11) +function MTVI2_func(::Type{TFL}, N, G, R; const1::Number=TFL(1.5), const2::Number=TFL(1.2), + const3::Number=TFL(2.5), const4::Number=TFL(2.0), const5::Number=TFL(1), + const6::Number=TFL(2), const7::Number=TFL(6.0), const8::Number=TFL(5), + const9::Number=TFL(0.5), const10::Number=TFL(0.5), + const11::Number=TFL(0.5)) where {TFL <: Number} + return (const1 * (const2 * (N - G) - const3 * (R - G))) / + ((((const4 * N + const5)^const6) - (const7 * N - const8 * (R^const9)) - + const10)^const11) end indices_funcs["MTVI2"] = MTVI2_func @@ -84,14 +96,17 @@ end indices_funcs["VIG"] = VIG_func -function TCARIOSAVI705_func(::Type{TFL}, RE2, RE1, G; const1::Number=TFL(3), const2::Number=TFL(0.2), const3::Number=TFL(1.16), const4::Number=TFL(0.16)) where {TFL <: Number} - return (const1 * ((RE2 - RE1) - const2 * (RE2 - G) * (RE2 / RE1))) / (const3 * (RE2 - RE1) / (RE2 + RE1 + const4)) +function TCARIOSAVI705_func( + ::Type{TFL}, RE2, RE1, G; const1::Number=TFL(3), const2::Number=TFL(0.2), + const3::Number=TFL(1.16), const4::Number=TFL(0.16)) where {TFL <: Number} + return (const1 * ((RE2 - RE1) - const2 * (RE2 - G) * (RE2 / RE1))) / + (const3 * (RE2 - RE1) / (RE2 + RE1 + const4)) end indices_funcs["TCARIOSAVI705"] = TCARIOSAVI705_func function PI_func(::Type{TFL}, N, R) where {TFL <: Number} - return N/(N + R) + return N / (N + R) end indices_funcs["PI"] = PI_func @@ -103,7 +118,7 @@ end indices_funcs["BaI"] = BaI_func function CCI_func(::Type{TFL}, G1, R) where {TFL <: Number} - return (G1 - R)/(G1 + R) + return (G1 - R) / (G1 + R) end indices_funcs["CCI"] = CCI_func @@ -115,7 +130,7 @@ end indices_funcs["NRFIr"] = NRFIr_func function NBRplus_func(::Type{TFL}, S2, N2, G, B) where {TFL <: Number} - return (S2 - N2 - G - B)/(S2 + N2 + G + B) + return (S2 - N2 - G - B) / (S2 + N2 + G + B) end indices_funcs["NBRplus"] = NBRplus_func @@ -127,13 +142,13 @@ end indices_funcs["NDBI"] = NDBI_func function NDSInw_func(::Type{TFL}, N, S1, beta) where {TFL <: Number} - return (N - S1 - beta)/(N + S1) + return (N - S1 - beta) / (N + S1) end indices_funcs["NDSInw"] = NDSInw_func function DSWI3_func(::Type{TFL}, S1, R) where {TFL <: Number} - return S1/R + return S1 / R end indices_funcs["DSWI3"] = DSWI3_func @@ -144,20 +159,29 @@ end indices_funcs["NIRv"] = NIRv_func -function GEMI_func(::Type{TFL}, N, R; const1::Number=TFL(2.0), const2::Number=TFL(2.0), const3::Number=TFL(2.0), const4::Number=TFL(1.5), const5::Number=TFL(0.5), const6::Number=TFL(0.5), const7::Number=TFL(1.0), const8::Number=TFL(0.25), const9::Number=TFL(2.0), const10::Number=TFL(2.0), const11::Number=TFL(2), const12::Number=TFL(1.5), const13::Number=TFL(0.5), const14::Number=TFL(0.5), const15::Number=TFL(0.125), const16::Number=TFL(1)) where {TFL <: Number} - return ((const1*((N ^ const2)-(R ^ const3)) + const4*N + const5*R)/(N + R + const6))*(const7 - const8*((const9 * ((N ^ const10) - (R ^ const11)) + const12 * N + const13 * R)/(N + R + const14)))-((R - const15)/(const16 - R)) +function GEMI_func(::Type{TFL}, N, R; const1::Number=TFL(2.0), const2::Number=TFL(2.0), + const3::Number=TFL(2.0), const4::Number=TFL(1.5), const5::Number=TFL(0.5), + const6::Number=TFL(0.5), const7::Number=TFL(1.0), const8::Number=TFL(0.25), + const9::Number=TFL(2.0), const10::Number=TFL(2.0), const11::Number=TFL(2), + const12::Number=TFL(1.5), const13::Number=TFL(0.5), const14::Number=TFL(0.5), + const15::Number=TFL(0.125), const16::Number=TFL(1)) where {TFL <: Number} + return ((const1 * ((N^const2) - (R^const3)) + const4 * N + const5 * R) / + (N + R + const6)) * (const7 - + const8 * + ((const9 * ((N^const10) - (R^const11)) + const12 * N + const13 * R) / + (N + R + const14))) - ((R - const15) / (const16 - R)) end indices_funcs["GEMI"] = GEMI_func function FCVI_func(::Type{TFL}, N, R, G, B; const1::Number=TFL(3.0)) where {TFL <: Number} - return N - ((R + G + B)/const1) + return N - ((R + G + B) / const1) end indices_funcs["FCVI"] = FCVI_func function VHVVR_func(::Type{TFL}, VH, VV) where {TFL <: Number} - return VH/VV + return VH / VV end indices_funcs["VHVVR"] = VHVVR_func @@ -174,14 +198,15 @@ end indices_funcs["WDRVI"] = WDRVI_func -function ExGR_func(::Type{TFL}, G, R, B; const1::Number=TFL(2.0), const2::Number=TFL(1.3)) where {TFL <: Number} +function ExGR_func(::Type{TFL}, G, R, B; const1::Number=TFL(2.0), + const2::Number=TFL(1.3)) where {TFL <: Number} return (const1 * G - R - B) - (const2 * R - G) end indices_funcs["ExGR"] = ExGR_func function DSI_func(::Type{TFL}, S1, N) where {TFL <: Number} - return S1/N + return S1 / N end indices_funcs["DSI"] = DSI_func @@ -198,14 +223,17 @@ end indices_funcs["GSAVI"] = GSAVI_func -function ATSAVI_func(::Type{TFL}, sla, N, R, slb; const1::Number=TFL(0.08), const2::Number=TFL(1), const3::Number=TFL(2.0)) where {TFL <: Number} - return sla * (N - sla * R - slb) / (sla * N + R - sla * slb + const1 * (const2 + sla ^ const3)) +function ATSAVI_func(::Type{TFL}, sla, N, R, slb; const1::Number=TFL(0.08), + const2::Number=TFL(1), const3::Number=TFL(2.0)) where {TFL <: Number} + return sla * (N - sla * R - slb) / + (sla * N + R - sla * slb + const1 * (const2 + sla^const3)) end indices_funcs["ATSAVI"] = ATSAVI_func -function MLSWI27_func(::Type{TFL}, N, S2; const1::Number=TFL(1.0), const2::Number=TFL(1.0)) where {TFL <: Number} - return (const1 - N - S2)/(const2 - N + S2) +function MLSWI27_func(::Type{TFL}, N, S2; const1::Number=TFL(1.0), + const2::Number=TFL(1.0)) where {TFL <: Number} + return (const1 - N - S2) / (const2 - N + S2) end indices_funcs["MLSWI27"] = MLSWI27_func @@ -216,20 +244,26 @@ end indices_funcs["SeLI"] = SeLI_func -function NDPI_func(::Type{TFL}, N, alpha, R, S1; const1::Number=TFL(1.0), const2::Number=TFL(1.0)) where {TFL <: Number} - return (N - (alpha * R + (const1 - alpha) * S1))/(N + (alpha * R + (const2 - alpha) * S1)) +function NDPI_func(::Type{TFL}, N, alpha, R, S1; const1::Number=TFL(1.0), + const2::Number=TFL(1.0)) where {TFL <: Number} + return (N - (alpha * R + (const1 - alpha) * S1)) / + (N + (alpha * R + (const2 - alpha) * S1)) end indices_funcs["NDPI"] = NDPI_func -function NDGI_func(::Type{TFL}, lambdaN, lambdaR, lambdaG, G, N, R; const1::Number=TFL(1.0), const2::Number=TFL(1.0)) where {TFL <: Number} - return (((lambdaN - lambdaR)/(lambdaN - lambdaG)) * G + (const1 - ((lambdaN - lambdaR)/(lambdaN - lambdaG))) * N - R)/(((lambdaN - lambdaR)/(lambdaN - lambdaG)) * G + (const2 - ((lambdaN - lambdaR)/(lambdaN - lambdaG))) * N + R) +function NDGI_func(::Type{TFL}, lambdaN, lambdaR, lambdaG, G, N, R; + const1::Number=TFL(1.0), const2::Number=TFL(1.0)) where {TFL <: Number} + return (((lambdaN - lambdaR) / (lambdaN - lambdaG)) * G + + (const1 - ((lambdaN - lambdaR) / (lambdaN - lambdaG))) * N - R) / + (((lambdaN - lambdaR) / (lambdaN - lambdaG)) * G + + (const2 - ((lambdaN - lambdaR) / (lambdaN - lambdaG))) * N + R) end indices_funcs["NDGI"] = NDGI_func function SR2_func(::Type{TFL}, N, G) where {TFL <: Number} - return N/G + return N / G end indices_funcs["SR2"] = SR2_func @@ -252,14 +286,15 @@ end indices_funcs["NDVI705"] = NDVI705_func -function TVI_func(::Type{TFL}, N, R; const1::Number=TFL(0.5), const2::Number=TFL(0.5)) where {TFL <: Number} - return (((N - R)/(N + R)) + const1) ^ const2 +function TVI_func(::Type{TFL}, N, R; const1::Number=TFL(0.5), + const2::Number=TFL(0.5)) where {TFL <: Number} + return (((N - R) / (N + R)) + const1)^const2 end indices_funcs["TVI"] = TVI_func function RNDVI_func(::Type{TFL}, R, N) where {TFL <: Number} - return (R - N)/(R + N) + return (R - N) / (R + N) end indices_funcs["RNDVI"] = RNDVI_func @@ -270,13 +305,16 @@ end indices_funcs["NDBaI"] = NDBaI_func -function CRI550_func(::Type{TFL}, B, G; const1::Number=TFL(1.0), const2::Number=TFL(1.0)) where {TFL <: Number} +function CRI550_func(::Type{TFL}, B, G; const1::Number=TFL(1.0), + const2::Number=TFL(1.0)) where {TFL <: Number} return (const1 / B) - (const2 / G) end indices_funcs["CRI550"] = CRI550_func -function SAVIT_func(::Type{TFL}, L, N, R, T; const1::Number=TFL(1.0), const2::Number=TFL(10000.0), const3::Number=TFL(10000.0)) where {TFL <: Number} +function SAVIT_func( + ::Type{TFL}, L, N, R, T; const1::Number=TFL(1.0), const2::Number=TFL(10000.0), + const3::Number=TFL(10000.0)) where {TFL <: Number} return (const1 + L) * (N - (R * T / const2)) / (N + (R * T / const3) + L) end @@ -289,25 +327,26 @@ end indices_funcs["WI2"] = WI2_func function NBAI_func(::Type{TFL}, S2, S1, G) where {TFL <: Number} - return (S2 - S1/G)/(S2 + S1/G) + return (S2 - S1 / G) / (S2 + S1 / G) end indices_funcs["NBAI"] = NBAI_func function BI_func(::Type{TFL}, S1, R, N, B) where {TFL <: Number} - return ((S1 + R) - (N + B))/((S1 + R) + (N + B)) + return ((S1 + R) - (N + B)) / ((S1 + R) + (N + B)) end indices_funcs["BI"] = BI_func function RDVI_func(::Type{TFL}, N, R; const1::Number=TFL(0.5)) where {TFL <: Number} - return (N - R) / ((N + R) ^ const1) + return (N - R) / ((N + R)^const1) end indices_funcs["RDVI"] = RDVI_func -function TGI_func(::Type{TFL}, R, G, B; const1::Number=TFL(0.5), const2::Number=TFL(190), const3::Number=TFL(120)) where {TFL <: Number} - return - const1 * (const2 * (R - G) - const3 * (R - B)) +function TGI_func(::Type{TFL}, R, G, B; const1::Number=TFL(0.5), const2::Number=TFL(190), + const3::Number=TFL(120)) where {TFL <: Number} + return -const1 * (const2 * (R - G) - const3 * (R - B)) end indices_funcs["TGI"] = TGI_func @@ -318,50 +357,55 @@ end indices_funcs["NRFIg"] = NRFIg_func -function MSR_func(::Type{TFL}, N, R; const1::Number=TFL(1), const2::Number=TFL(1), const3::Number=TFL(0.5)) where {TFL <: Number} - return (N / R - const1) / ((N / R + const2) ^ const3) +function MSR_func(::Type{TFL}, N, R; const1::Number=TFL(1), const2::Number=TFL(1), + const3::Number=TFL(0.5)) where {TFL <: Number} + return (N / R - const1) / ((N / R + const2)^const3) end indices_funcs["MSR"] = MSR_func function FAI_func(::Type{TFL}, N, R, S1, lambdaN, lambdaR, lambdaS1) where {TFL <: Number} - return N - (R + (S1 - R)*((lambdaN - lambdaR)/(lambdaS1 - lambdaR))) + return N - (R + (S1 - R) * ((lambdaN - lambdaR) / (lambdaS1 - lambdaR))) end indices_funcs["FAI"] = FAI_func -function TriVI_func(::Type{TFL}, N, G, R; const1::Number=TFL(0.5), const2::Number=TFL(120), const3::Number=TFL(200)) where {TFL <: Number} +function TriVI_func(::Type{TFL}, N, G, R; const1::Number=TFL(0.5), const2::Number=TFL(120), + const3::Number=TFL(200)) where {TFL <: Number} return const1 * (const2 * (N - G) - const3 * (R - G)) end indices_funcs["TriVI"] = TriVI_func -function ARI_func(::Type{TFL}, G, RE1; const1::Number=TFL(1), const2::Number=TFL(1)) where {TFL <: Number} +function ARI_func(::Type{TFL}, G, RE1; const1::Number=TFL(1), + const2::Number=TFL(1)) where {TFL <: Number} return (const1 / G) - (const2 / RE1) end indices_funcs["ARI"] = ARI_func -function NBRSWIR_func(::Type{TFL}, S2, S1; const1::Number=TFL(0.02), const2::Number=TFL(0.1)) where {TFL <: Number} - return (S2 - S1 - const1)/(S2 + S1 + const2) +function NBRSWIR_func(::Type{TFL}, S2, S1; const1::Number=TFL(0.02), + const2::Number=TFL(0.1)) where {TFL <: Number} + return (S2 - S1 - const1) / (S2 + S1 + const2) end indices_funcs["NBRSWIR"] = NBRSWIR_func function OCVI_func(::Type{TFL}, N, G, R, cexp) where {TFL <: Number} - return (N / G) * (R / G) ^ cexp + return (N / G) * (R / G)^cexp end indices_funcs["OCVI"] = OCVI_func function NormG_func(::Type{TFL}, G, N, R) where {TFL <: Number} - return G/(N + G + R) + return G / (N + G + R) end indices_funcs["NormG"] = NormG_func -function BLFEI_func(::Type{TFL}, G, R, S2, S1; const1::Number=TFL(3.0), const2::Number=TFL(3.0)) where {TFL <: Number} - return (((G+R+S2)/const1)-S1)/(((G+R+S2)/const2)+S1) +function BLFEI_func(::Type{TFL}, G, R, S2, S1; const1::Number=TFL(3.0), + const2::Number=TFL(3.0)) where {TFL <: Number} + return (((G + R + S2) / const1) - S1) / (((G + R + S2) / const2) + S1) end indices_funcs["BLFEI"] = BLFEI_func @@ -372,68 +416,79 @@ end indices_funcs["DVI"] = DVI_func -function MuWIR_func(::Type{TFL}, B, G, N, S2, S1; const1::Number=TFL(4.0), const2::Number=TFL(2.0), const3::Number=TFL(2.0)) where {TFL <: Number} - return -const1 * ((B - G)/(B + G)) + const2 * ((G - N)/(G + N)) + const3 * ((G - S2)/(G + S2)) - ((G - S1)/(G + S1)) +function MuWIR_func(::Type{TFL}, B, G, N, S2, S1; const1::Number=TFL(4.0), + const2::Number=TFL(2.0), const3::Number=TFL(2.0)) where {TFL <: Number} + return -const1 * ((B - G) / (B + G)) + const2 * ((G - N) / (G + N)) + + const3 * ((G - S2) / (G + S2)) - ((G - S1) / (G + S1)) end indices_funcs["MuWIR"] = MuWIR_func -function MNLI_func(::Type{TFL}, L, N, R; const1::Number=TFL(1), const2::Number=TFL(2), const3::Number=TFL(2)) where {TFL <: Number} - return (const1 + L)*((N ^ const2) - R)/((N ^ const3) + R + L) +function MNLI_func(::Type{TFL}, L, N, R; const1::Number=TFL(1), const2::Number=TFL(2), + const3::Number=TFL(2)) where {TFL <: Number} + return (const1 + L) * ((N^const2) - R) / ((N^const3) + R + L) end indices_funcs["MNLI"] = MNLI_func function NDSoI_func(::Type{TFL}, S2, G) where {TFL <: Number} - return (S2 - G)/(S2 + G) + return (S2 - G) / (S2 + G) end indices_funcs["NDSoI"] = NDSoI_func function NDWIns_func(::Type{TFL}, G, alpha, N) where {TFL <: Number} - return (G - alpha * N)/(G + N) + return (G - alpha * N) / (G + N) end indices_funcs["NDWIns"] = NDWIns_func function RI_func(::Type{TFL}, R, G) where {TFL <: Number} - return (R - G)/(R + G) + return (R - G) / (R + G) end indices_funcs["RI"] = RI_func function SARVI_func(::Type{TFL}, L, N, R, B; const1::Number=TFL(1)) where {TFL <: Number} - return (const1 + L)*(N - (R - (R - B))) / (N + (R - (R - B)) + L) + return (const1 + L) * (N - (R - (R - B))) / (N + (R - (R - B)) + L) end indices_funcs["SARVI"] = SARVI_func function kIPVI_func(::Type{TFL}, kNN, kNR) where {TFL <: Number} - return kNN/(kNN + kNR) + return kNN / (kNN + kNR) end indices_funcs["kIPVI"] = kIPVI_func -function TWI_func(::Type{TFL}, RE1, RE2, G, S2, B, N; const1::Number=TFL(2.84), const2::Number=TFL(1.25), const3::Number=TFL(1.25), const4::Number=TFL(0.25)) where {TFL <: Number} - return (const1 * (RE1 - RE2) / (G + S2)) + ((const2 * (G - B) - (N - B)) / (N + const3 * G - const4 * B)) +function TWI_func(::Type{TFL}, RE1, RE2, G, S2, B, N; const1::Number=TFL(2.84), + const2::Number=TFL(1.25), const3::Number=TFL(1.25), + const4::Number=TFL(0.25)) where {TFL <: Number} + return (const1 * (RE1 - RE2) / (G + S2)) + + ((const2 * (G - B) - (N - B)) / (N + const3 * G - const4 * B)) end indices_funcs["TWI"] = TWI_func -function ENDVI_func(::Type{TFL}, N, G, B; const1::Number=TFL(2), const2::Number=TFL(2)) where {TFL <: Number} +function ENDVI_func(::Type{TFL}, N, G, B; const1::Number=TFL(2), + const2::Number=TFL(2)) where {TFL <: Number} return ((N + G) - (const1 * B)) / ((N + G) + (const2 * B)) end indices_funcs["ENDVI"] = ENDVI_func -function MSAVI_func(::Type{TFL}, N, R; const1::Number=TFL(0.5), const2::Number=TFL(2.0), const3::Number=TFL(1), const4::Number=TFL(2), const5::Number=TFL(1), const6::Number=TFL(2), const7::Number=TFL(8), const8::Number=TFL(0.5)) where {TFL <: Number} - return const1 * (const2 * N + const3 - (((const4 * N + const5) ^ const6) - const7 * (N - R)) ^ const8) +function MSAVI_func(::Type{TFL}, N, R; const1::Number=TFL(0.5), const2::Number=TFL(2.0), + const3::Number=TFL(1), const4::Number=TFL(2), + const5::Number=TFL(1), const6::Number=TFL(2), const7::Number=TFL(8), + const8::Number=TFL(0.5)) where {TFL <: Number} + return const1 * (const2 * N + const3 - + (((const4 * N + const5)^const6) - const7 * (N - R))^const8) end indices_funcs["MSAVI"] = MSAVI_func function DpRVIVV_func(::Type{TFL}, VH, VV; const1::Number=TFL(4.0)) where {TFL <: Number} - return (const1 * VH)/(VV + VH) + return (const1 * VH) / (VV + VH) end indices_funcs["DpRVIVV"] = DpRVIVV_func @@ -444,26 +499,28 @@ end indices_funcs["RVI"] = RVI_func -function MRBVI_func(::Type{TFL}, R, B; const1::Number=TFL(2.0), const2::Number=TFL(2.0), const3::Number=TFL(2.0), const4::Number=TFL(2.0)) where {TFL <: Number} - return (R ^ const1 - B ^ const2)/(R ^ const3 + B ^ const4) +function MRBVI_func(::Type{TFL}, R, B; const1::Number=TFL(2.0), const2::Number=TFL(2.0), + const3::Number=TFL(2.0), const4::Number=TFL(2.0)) where {TFL <: Number} + return (R^const1 - B^const2) / (R^const3 + B^const4) end indices_funcs["MRBVI"] = MRBVI_func function NSTv2_func(::Type{TFL}, N, S2, T) where {TFL <: Number} - return (N-(S2+T))/(N+(S2+T)) + return (N - (S2 + T)) / (N + (S2 + T)) end indices_funcs["NSTv2"] = NSTv2_func -function TCI_func(::Type{TFL}, RE1, G, R; const1::Number=TFL(1.2), const2::Number=TFL(1.5), const3::Number=TFL(0.5)) where {TFL <: Number} - return const1 * (RE1 - G) - const2 * (R - G) * (RE1 / R) ^ const3 +function TCI_func(::Type{TFL}, RE1, G, R; const1::Number=TFL(1.2), + const2::Number=TFL(1.5), const3::Number=TFL(0.5)) where {TFL <: Number} + return const1 * (RE1 - G) - const2 * (R - G) * (RE1 / R)^const3 end indices_funcs["TCI"] = TCI_func function OSI_func(::Type{TFL}, G, R, B) where {TFL <: Number} - return (G + R)/B + return (G + R) / B end indices_funcs["OSI"] = OSI_func @@ -481,7 +538,7 @@ end indices_funcs["CIG"] = CIG_func function NDPolI_func(::Type{TFL}, VV, VH) where {TFL <: Number} - return (VV - VH)/(VV + VH) + return (VV - VH) / (VV + VH) end indices_funcs["NDPolI"] = NDPolI_func @@ -492,14 +549,16 @@ end indices_funcs["BCC"] = BCC_func -function SI_func(::Type{TFL}, B, G, R; const1::Number=TFL(1.0), const2::Number=TFL(1.0), const3::Number=TFL(1.0), const4::Number=TFL(1), const5::Number=TFL(3)) where {TFL <: Number} - return ((const1 - B) * (const2 - G) * (const3 - R)) ^ (const4/const5) +function SI_func(::Type{TFL}, B, G, R; const1::Number=TFL(1.0), + const2::Number=TFL(1.0), const3::Number=TFL(1.0), + const4::Number=TFL(1), const5::Number=TFL(3)) where {TFL <: Number} + return ((const1 - B) * (const2 - G) * (const3 - R))^(const4 / const5) end indices_funcs["SI"] = SI_func function mSR705_func(::Type{TFL}, RE2, A) where {TFL <: Number} - return (RE2 - A)/(RE2 + A) + return (RE2 - A) / (RE2 + A) end indices_funcs["mSR705"] = mSR705_func @@ -510,14 +569,15 @@ end indices_funcs["SR555"] = SR555_func -function NBRT1_func(::Type{TFL}, N, S2, T; const1::Number=TFL(10000.0), const2::Number=TFL(10000.0)) where {TFL <: Number} +function NBRT1_func(::Type{TFL}, N, S2, T; const1::Number=TFL(10000.0), + const2::Number=TFL(10000.0)) where {TFL <: Number} return (N - (S2 * T / const1)) / (N + (S2 * T / const2)) end indices_funcs["NBRT1"] = NBRT1_func function ANDWI_func(::Type{TFL}, B, G, R, N, S1, S2) where {TFL <: Number} - return (B + G + R - N - S1 - S2)/(B + G + R + N + S1 + S2) + return (B + G + R - N - S1 - S2) / (B + G + R + N + S1 + S2) end indices_funcs["ANDWI"] = ANDWI_func @@ -529,7 +589,7 @@ end indices_funcs["WDVI"] = WDVI_func function NWI_func(::Type{TFL}, B, N, S1, S2) where {TFL <: Number} - return (B - (N + S1 + S2))/(B + (N + S1 + S2)) + return (B - (N + S1 + S2)) / (B + (N + S1 + S2)) end indices_funcs["NWI"] = NWI_func @@ -540,32 +600,34 @@ end indices_funcs["GARI"] = GARI_func -function sNIRvSWIR_func(::Type{TFL}, N, R, S2; const1::Number=TFL(2.0), const2::Number=TFL(2.0)) where {TFL <: Number} - return ((N - R - S2 ^ const1)/(N + R + S2 ^ const2)) * N +function sNIRvSWIR_func(::Type{TFL}, N, R, S2; const1::Number=TFL(2.0), + const2::Number=TFL(2.0)) where {TFL <: Number} + return ((N - R - S2^const1) / (N + R + S2^const2)) * N end indices_funcs["sNIRvSWIR"] = sNIRvSWIR_func -function MCARI705_func(::Type{TFL}, RE2, RE1, G; const1::Number=TFL(0.2)) where {TFL <: Number} +function MCARI705_func( + ::Type{TFL}, RE2, RE1, G; const1::Number=TFL(0.2)) where {TFL <: Number} return ((RE2 - RE1) - const1 * (RE2 - G)) * (RE2 / RE1) end indices_funcs["MCARI705"] = MCARI705_func function NormNIR_func(::Type{TFL}, N, G, R) where {TFL <: Number} - return N/(N + G + R) + return N / (N + G + R) end indices_funcs["NormNIR"] = NormNIR_func function SWM_func(::Type{TFL}, B, G, N, S1) where {TFL <: Number} - return (B + G)/(N + S1) + return (B + G) / (N + S1) end indices_funcs["SWM"] = SWM_func function mND705_func(::Type{TFL}, RE2, RE1, A) where {TFL <: Number} - return (RE2 - RE1)/(RE2 + RE1 - A) + return (RE2 - RE1) / (RE2 + RE1 - A) end indices_funcs["mND705"] = mND705_func @@ -582,8 +644,9 @@ end indices_funcs["EVI2"] = EVI2_func -function DPDD_func(::Type{TFL}, VV, VH; const1::Number=TFL(2.0), const2::Number=TFL(0.5)) where {TFL <: Number} - return (VV + VH)/const1 ^ const2 +function DPDD_func(::Type{TFL}, VV, VH; const1::Number=TFL(2.0), + const2::Number=TFL(0.5)) where {TFL <: Number} + return (VV + VH) / const1^const2 end indices_funcs["DPDD"] = DPDD_func @@ -600,14 +663,15 @@ end indices_funcs["VHVVD"] = VHVVD_func -function EVIv_func(::Type{TFL}, N, R, B; const1::Number=TFL(2.5), const2::Number=TFL(6), const3::Number=TFL(7.5), const4::Number=TFL(1.0)) where {TFL <: Number} - return const1 * ((N - R)/(N + const2 * R - const3 * B + const4)) * N +function EVIv_func(::Type{TFL}, N, R, B; const1::Number=TFL(2.5), const2::Number=TFL(6), + const3::Number=TFL(7.5), const4::Number=TFL(1.0)) where {TFL <: Number} + return const1 * ((N - R) / (N + const2 * R - const3 * B + const4)) * N end indices_funcs["EVIv"] = EVIv_func function SR3_func(::Type{TFL}, N2, G, RE1) where {TFL <: Number} - return N2/(G * RE1) + return N2 / (G * RE1) end indices_funcs["SR3"] = SR3_func @@ -618,31 +682,37 @@ end indices_funcs["NBR"] = NBR_func -function EMBI_func(::Type{TFL}, S1, S2, N, G; const1::Number=TFL(0.5), const2::Number=TFL(0.5), const3::Number=TFL(0.5), const4::Number=TFL(1.5)) where {TFL <: Number} - return ((((S1 - S2 - N)/(S1 + S2 + N)) + const1) - ((G - S1)/(G + S1)) - const2)/((((S1 - S2 - N)/(S1 + S2 + N)) + const3) + ((G - S1)/(G + S1)) + const4) +function EMBI_func( + ::Type{TFL}, S1, S2, N, G; const1::Number=TFL(0.5), const2::Number=TFL(0.5), + const3::Number=TFL(0.5), const4::Number=TFL(1.5)) where {TFL <: Number} + return ((((S1 - S2 - N) / (S1 + S2 + N)) + const1) - ((G - S1) / (G + S1)) - const2) / + ((((S1 - S2 - N) / (S1 + S2 + N)) + const3) + ((G - S1) / (G + S1)) + const4) end indices_funcs["EMBI"] = EMBI_func function GDVI_func(::Type{TFL}, N, nexp, R) where {TFL <: Number} - return ((N ^ nexp) - (R ^ nexp)) / ((N ^ nexp) + (R ^ nexp)) + return ((N^nexp) - (R^nexp)) / ((N^nexp) + (R^nexp)) end indices_funcs["GDVI"] = GDVI_func -function MCARIOSAVI_func(::Type{TFL}, RE1, R, G, N; const1::Number=TFL(0.2), const2::Number=TFL(1.16), const3::Number=TFL(0.16)) where {TFL <: Number} - return (((RE1 - R) - const1 * (RE1 - G)) * (RE1 / R)) / (const2 * (N - R) / (N + R + const3)) +function MCARIOSAVI_func(::Type{TFL}, RE1, R, G, N; const1::Number=TFL(0.2), + const2::Number=TFL(1.16), const3::Number=TFL(0.16)) where {TFL <: Number} + return (((RE1 - R) - const1 * (RE1 - G)) * (RE1 / R)) / + (const2 * (N - R) / (N + R + const3)) end indices_funcs["MCARIOSAVI"] = MCARIOSAVI_func function EBI_func(::Type{TFL}, R, G, B, epsilon) where {TFL <: Number} - return (R + G + B)/((G/B) * (R - B + epsilon)) + return (R + G + B) / ((G / B) * (R - B + epsilon)) end indices_funcs["EBI"] = EBI_func -function AWEInsh_func(::Type{TFL}, G, S1, N, S2; const1::Number=TFL(4.0), const2::Number=TFL(0.25), const3::Number=TFL(2.75)) where {TFL <: Number} +function AWEInsh_func(::Type{TFL}, G, S1, N, S2; const1::Number=TFL(4.0), + const2::Number=TFL(0.25), const3::Number=TFL(2.75)) where {TFL <: Number} return const1 * (G - S1) - const2 * N + const3 * S2 end @@ -667,31 +737,31 @@ end indices_funcs["ARVI"] = ARVI_func function IPVI_func(::Type{TFL}, N, R) where {TFL <: Number} - return N/(N + R) + return N / (N + R) end indices_funcs["IPVI"] = IPVI_func function NDSIWV_func(::Type{TFL}, G, Y) where {TFL <: Number} - return (G - Y)/(G + Y) + return (G - Y) / (G + Y) end indices_funcs["NDSIWV"] = NDSIWV_func function DSWI4_func(::Type{TFL}, G, R) where {TFL <: Number} - return G/R + return G / R end indices_funcs["DSWI4"] = DSWI4_func function VVVHR_func(::Type{TFL}, VV, VH) where {TFL <: Number} - return VV/VH + return VV / VH end indices_funcs["VVVHR"] = VVVHR_func function kNDVI_func(::Type{TFL}, kNN, kNR) where {TFL <: Number} - return (kNN - kNR)/(kNN + kNR) + return (kNN - kNR) / (kNN + kNR) end indices_funcs["kNDVI"] = kNDVI_func @@ -709,49 +779,50 @@ end indices_funcs["OSAVI"] = OSAVI_func function sNIRvNDVILSWIP_func(::Type{TFL}, N, R, S2) where {TFL <: Number} - return ((N - R)/(N + R)) * ((N - S2)/(N + S2)) * N + return ((N - R) / (N + R)) * ((N - S2) / (N + S2)) * N end indices_funcs["sNIRvNDVILSWIP"] = sNIRvNDVILSWIP_func -function AFRI2100_func(::Type{TFL}, N, S2; const1::Number=TFL(0.5), const2::Number=TFL(0.5)) where {TFL <: Number} +function AFRI2100_func(::Type{TFL}, N, S2; const1::Number=TFL(0.5), + const2::Number=TFL(0.5)) where {TFL <: Number} return (N - const1 * S2) / (N + const2 * S2) end indices_funcs["AFRI2100"] = AFRI2100_func function GNDVI_func(::Type{TFL}, N, G) where {TFL <: Number} - return (N - G)/(N + G) + return (N - G) / (N + G) end indices_funcs["GNDVI"] = GNDVI_func function LSWI_func(::Type{TFL}, N, S1) where {TFL <: Number} - return (N - S1)/(N + S1) + return (N - S1) / (N + S1) end indices_funcs["LSWI"] = LSWI_func function UI_func(::Type{TFL}, S2, N) where {TFL <: Number} - return (S2 - N)/(S2 + N) + return (S2 - N) / (S2 + N) end indices_funcs["UI"] = UI_func function S2WI_func(::Type{TFL}, RE1, S2) where {TFL <: Number} - return (RE1 - S2)/(RE1 + S2) + return (RE1 - S2) / (RE1 + S2) end indices_funcs["S2WI"] = S2WI_func function VIBI_func(::Type{TFL}, N, R, S1) where {TFL <: Number} - return ((N-R)/(N+R))/(((N-R)/(N+R)) + ((S1-N)/(S1+N))) + return ((N - R) / (N + R)) / (((N - R) / (N + R)) + ((S1 - N) / (S1 + N))) end indices_funcs["VIBI"] = VIBI_func function NSDSI1_func(::Type{TFL}, S1, S2) where {TFL <: Number} - return (S1-S2)/S1 + return (S1 - S2) / S1 end indices_funcs["NSDSI1"] = NSDSI1_func @@ -762,8 +833,9 @@ end indices_funcs["VVVHS"] = VVVHS_func -function VI6T_func(::Type{TFL}, N, T; const1::Number=TFL(10000.0), const2::Number=TFL(10000.0)) where {TFL <: Number} - return (N - T/const1)/(N + T/const2) +function VI6T_func(::Type{TFL}, N, T; const1::Number=TFL(10000.0), + const2::Number=TFL(10000.0)) where {TFL <: Number} + return (N - T / const1) / (N + T / const2) end indices_funcs["VI6T"] = VI6T_func @@ -780,26 +852,31 @@ end indices_funcs["BWDRVI"] = BWDRVI_func -function BAIM_func(::Type{TFL}, N, S2; const1::Number=TFL(1.0), const2::Number=TFL(0.05), const3::Number=TFL(2.0), const4::Number=TFL(0.2), const5::Number=TFL(2.0)) where {TFL <: Number} - return const1/((const2 - N) ^ const3) + ((const4 - S2) ^ const5) +function BAIM_func(::Type{TFL}, N, S2; const1::Number=TFL(1.0), const2::Number=TFL(0.05), + const3::Number=TFL(2.0), const4::Number=TFL(0.2), + const5::Number=TFL(2.0)) where {TFL <: Number} + return const1 / ((const2 - N)^const3) + ((const4 - S2)^const5) end indices_funcs["BAIM"] = BAIM_func function VDDPI_func(::Type{TFL}, VV, VH) where {TFL <: Number} - return (VV + VH)/VV + return (VV + VH) / VV end indices_funcs["VDDPI"] = VDDPI_func -function BIXS_func(::Type{TFL}, G, R; const1::Number=TFL(2.0), const2::Number=TFL(2.0), const3::Number=TFL(2.0), const4::Number=TFL(0.5)) where {TFL <: Number} - return (((G^const1)+(R^const2))/const3)^const4 +function BIXS_func(::Type{TFL}, G, R; const1::Number=TFL(2.0), const2::Number=TFL(2.0), + const3::Number=TFL(2.0), const4::Number=TFL(0.5)) where {TFL <: Number} + return (((G^const1) + (R^const2)) / const3)^const4 end indices_funcs["BIXS"] = BIXS_func -function MCARIOSAVI705_func(::Type{TFL}, RE2, RE1, G; const1::Number=TFL(0.2), const2::Number=TFL(1.16), const3::Number=TFL(0.16)) where {TFL <: Number} - return (((RE2 - RE1) - const1 * (RE2 - G)) * (RE2 / RE1)) / (const2 * (RE2 - RE1) / (RE2 + RE1 + const3)) +function MCARIOSAVI705_func(::Type{TFL}, RE2, RE1, G; const1::Number=TFL(0.2), + const2::Number=TFL(1.16), const3::Number=TFL(0.16)) where {TFL <: Number} + return (((RE2 - RE1) - const1 * (RE2 - G)) * (RE2 / RE1)) / + (const2 * (RE2 - RE1) / (RE2 + RE1 + const3)) end indices_funcs["MCARIOSAVI705"] = MCARIOSAVI705_func @@ -811,7 +888,7 @@ end indices_funcs["NDSI"] = NDSI_func function NDVI_func(::Type{TFL}, N, R) where {TFL <: Number} - return (N - R)/(N + R) + return (N - R) / (N + R) end indices_funcs["NDVI"] = NDVI_func @@ -822,32 +899,37 @@ end indices_funcs["MCARI"] = MCARI_func -function MLSWI26_func(::Type{TFL}, N, S1; const1::Number=TFL(1.0), const2::Number=TFL(1.0)) where {TFL <: Number} - return (const1 - N - S1)/(const2 - N + S1) +function MLSWI26_func(::Type{TFL}, N, S1; const1::Number=TFL(1.0), + const2::Number=TFL(1.0)) where {TFL <: Number} + return (const1 - N - S1) / (const2 - N + S1) end indices_funcs["MLSWI26"] = MLSWI26_func function VgNIRBI_func(::Type{TFL}, G, N) where {TFL <: Number} - return (G - N)/(G + N) + return (G - N) / (G + N) end indices_funcs["VgNIRBI"] = VgNIRBI_func -function TCARIOSAVI_func(::Type{TFL}, RE1, R, G, N; const1::Number=TFL(3), const2::Number=TFL(0.2), const3::Number=TFL(1.16), const4::Number=TFL(0.16)) where {TFL <: Number} - return (const1 * ((RE1 - R) - const2 * (RE1 - G) * (RE1 / R))) / (const3 * (N - R) / (N + R + const4)) +function TCARIOSAVI_func( + ::Type{TFL}, RE1, R, G, N; const1::Number=TFL(3), const2::Number=TFL(0.2), + const3::Number=TFL(1.16), const4::Number=TFL(0.16)) where {TFL <: Number} + return (const1 * ((RE1 - R) - const2 * (RE1 - G) * (RE1 / R))) / + (const3 * (N - R) / (N + R + const4)) end indices_funcs["TCARIOSAVI"] = TCARIOSAVI_func -function AVI_func(::Type{TFL}, N, R; const1::Number=TFL(1.0), const2::Number=TFL(1), const3::Number=TFL(3)) where {TFL <: Number} - return (N * (const1 - R) * (N - R)) ^ (const2/const3) +function AVI_func(::Type{TFL}, N, R; const1::Number=TFL(1.0), const2::Number=TFL(1), + const3::Number=TFL(3)) where {TFL <: Number} + return (N * (const1 - R) * (N - R))^(const2 / const3) end indices_funcs["AVI"] = AVI_func function NormR_func(::Type{TFL}, R, N, G) where {TFL <: Number} - return R/(N + G + R) + return R / (N + G + R) end indices_funcs["NormR"] = NormR_func @@ -859,31 +941,33 @@ end indices_funcs["VHVVP"] = VHVVP_func function NSDS_func(::Type{TFL}, S1, S2) where {TFL <: Number} - return (S1 - S2)/(S1 + S2) + return (S1 - S2) / (S1 + S2) end indices_funcs["NSDS"] = NSDS_func function NDSWIR_func(::Type{TFL}, N, S1) where {TFL <: Number} - return (N - S1)/(N + S1) + return (N - S1) / (N + S1) end indices_funcs["NDSWIR"] = NDSWIR_func -function REDSI_func(::Type{TFL}, RE3, R, RE1; const1::Number=TFL(705.0), const2::Number=TFL(665.0), const3::Number=TFL(783.0), const4::Number=TFL(665.0), const5::Number=TFL(2.0)) where {TFL <: Number} +function REDSI_func(::Type{TFL}, RE3, R, RE1; const1::Number=TFL(705.0), + const2::Number=TFL(665.0), const3::Number=TFL(783.0), + const4::Number=TFL(665.0), const5::Number=TFL(2.0)) where {TFL <: Number} return ((const1 - const2) * (RE3 - R) - (const3 - const4) * (RE1 - R)) / (const5 * R) end indices_funcs["REDSI"] = REDSI_func function DBI_func(::Type{TFL}, B, T1, N, R) where {TFL <: Number} - return ((B - T1)/(B + T1)) - ((N - R)/(N + R)) + return ((B - T1) / (B + T1)) - ((N - R) / (N + R)) end indices_funcs["DBI"] = DBI_func function ND705_func(::Type{TFL}, RE2, RE1) where {TFL <: Number} - return (RE2 - RE1)/(RE2 + RE1) + return (RE2 - RE1) / (RE2 + RE1) end indices_funcs["ND705"] = ND705_func @@ -894,32 +978,33 @@ end indices_funcs["MNDWI"] = MNDWI_func -function RGBVI_func(::Type{TFL}, G, B, R; const1::Number=TFL(2.0), const2::Number=TFL(2.0)) where {TFL <: Number} - return (G ^ const1 - B * R)/(G ^ const2 + B * R) +function RGBVI_func(::Type{TFL}, G, B, R; const1::Number=TFL(2.0), + const2::Number=TFL(2.0)) where {TFL <: Number} + return (G^const1 - B * R) / (G^const2 + B * R) end indices_funcs["RGBVI"] = RGBVI_func function bNIRv_func(::Type{TFL}, N, B) where {TFL <: Number} - return ((N - B)/(N + B)) * N + return ((N - B) / (N + B)) * N end indices_funcs["bNIRv"] = bNIRv_func function MSI_func(::Type{TFL}, S1, N) where {TFL <: Number} - return S1/N + return S1 / N end indices_funcs["MSI"] = MSI_func function RGRI_func(::Type{TFL}, R, G) where {TFL <: Number} - return R/G + return R / G end indices_funcs["RGRI"] = RGRI_func function GRVI_func(::Type{TFL}, N, G) where {TFL <: Number} - return N/G + return N / G end indices_funcs["GRVI"] = GRVI_func @@ -931,24 +1016,25 @@ end indices_funcs["VARI"] = VARI_func function NMDI_func(::Type{TFL}, N, S1, S2) where {TFL <: Number} - return (N - (S1 - S2))/(N + (S1 - S2)) + return (N - (S1 - S2)) / (N + (S1 - S2)) end indices_funcs["NMDI"] = NMDI_func function RENDVI_func(::Type{TFL}, RE2, RE1) where {TFL <: Number} - return (RE2 - RE1)/(RE2 + RE1) + return (RE2 - RE1) / (RE2 + RE1) end indices_funcs["RENDVI"] = RENDVI_func function NSDSI2_func(::Type{TFL}, S1, S2) where {TFL <: Number} - return (S1-S2)/S2 + return (S1 - S2) / S2 end indices_funcs["NSDSI2"] = NSDSI2_func -function TCARI_func(::Type{TFL}, RE1, R, G; const1::Number=TFL(3), const2::Number=TFL(0.2)) where {TFL <: Number} +function TCARI_func(::Type{TFL}, RE1, R, G; const1::Number=TFL(3), + const2::Number=TFL(0.2)) where {TFL <: Number} return const1 * ((RE1 - R) - const2 * (RE1 - G) * (RE1 / R)) end @@ -960,56 +1046,60 @@ end indices_funcs["kEVI"] = kEVI_func -function ARI2_func(::Type{TFL}, N, G, RE1; const1::Number=TFL(1), const2::Number=TFL(1)) where {TFL <: Number} +function ARI2_func(::Type{TFL}, N, G, RE1; const1::Number=TFL(1), + const2::Number=TFL(1)) where {TFL <: Number} return N * ((const1 / G) - (const2 / RE1)) end indices_funcs["ARI2"] = ARI2_func function GM1_func(::Type{TFL}, RE2, G) where {TFL <: Number} - return RE2/G + return RE2 / G end indices_funcs["GM1"] = GM1_func function sNIRvLSWI_func(::Type{TFL}, N, S2) where {TFL <: Number} - return ((N - S2)/(N + S2)) * N + return ((N - S2) / (N + S2)) * N end indices_funcs["sNIRvLSWI"] = sNIRvLSWI_func function SLAVI_func(::Type{TFL}, N, R, S2) where {TFL <: Number} - return N/(R + S2) + return N / (R + S2) end indices_funcs["SLAVI"] = SLAVI_func -function GVMI_func(::Type{TFL}, N, S2; const1::Number=TFL(0.1), const2::Number=TFL(0.02), const3::Number=TFL(0.1), const4::Number=TFL(0.02)) where {TFL <: Number} +function GVMI_func(::Type{TFL}, N, S2; const1::Number=TFL(0.1), const2::Number=TFL(0.02), + const3::Number=TFL(0.1), const4::Number=TFL(0.02)) where {TFL <: Number} return ((N + const1) - (S2 + const2)) / ((N + const3) + (S2 + const4)) end indices_funcs["GVMI"] = GVMI_func -function NBSIMS_func(::Type{TFL}, G, R, N, B, S2, S1; const1::Number=TFL(0.36)) where {TFL <: Number} - return const1 * (G + R + N) - (((B + S2)/G) + S1) +function NBSIMS_func( + ::Type{TFL}, G, R, N, B, S2, S1; const1::Number=TFL(0.36)) where {TFL <: Number} + return const1 * (G + R + N) - (((B + S2) / G) + S1) end indices_funcs["NBSIMS"] = NBSIMS_func function NBLIOLI_func(::Type{TFL}, R, T1) where {TFL <: Number} - return (R - T1)/(R + T1) + return (R - T1) / (R + T1) end indices_funcs["NBLIOLI"] = NBLIOLI_func -function AWEIsh_func(::Type{TFL}, B, G, N, S1, S2; const1::Number=TFL(2.5), const2::Number=TFL(1.5), const3::Number=TFL(0.25)) where {TFL <: Number} +function AWEIsh_func(::Type{TFL}, B, G, N, S1, S2; const1::Number=TFL(2.5), + const2::Number=TFL(1.5), const3::Number=TFL(0.25)) where {TFL <: Number} return B + const1 * G - const2 * (N + S1) - const3 * S2 end indices_funcs["AWEIsh"] = AWEIsh_func function RFDI_func(::Type{TFL}, HH, HV) where {TFL <: Number} - return (HH - HV)/(HH + HV) + return (HH - HV) / (HH + HV) end indices_funcs["RFDI"] = RFDI_func @@ -1021,13 +1111,15 @@ end indices_funcs["SIPI"] = SIPI_func function DpRVIHH_func(::Type{TFL}, HV, HH; const1::Number=TFL(4.0)) where {TFL <: Number} - return (const1 * HV)/(HH + HV) + return (const1 * HV) / (HH + HV) end indices_funcs["DpRVIHH"] = DpRVIHH_func -function NDISImndwi_func(::Type{TFL}, T, G, S1, N; const1::Number=TFL(3.0), const2::Number=TFL(3.0)) where {TFL <: Number} - return (T - (((G - S1)/(G + S1)) + N + S1) / const1)/(T + (((G - S1)/(G + S1)) + N + S1) / const2) +function NDISImndwi_func(::Type{TFL}, T, G, S1, N; const1::Number=TFL(3.0), + const2::Number=TFL(3.0)) where {TFL <: Number} + return (T - (((G - S1) / (G + S1)) + N + S1) / const1) / + (T + (((G - S1) / (G + S1)) + N + S1) / const2) end indices_funcs["NDISImndwi"] = NDISImndwi_func @@ -1039,7 +1131,7 @@ end indices_funcs["MBWI"] = MBWI_func function GM2_func(::Type{TFL}, RE2, RE1) where {TFL <: Number} - return RE2/RE1 + return RE2 / RE1 end indices_funcs["GM2"] = GM2_func @@ -1051,73 +1143,80 @@ end indices_funcs["VVVHD"] = VVVHD_func function VrNIRBI_func(::Type{TFL}, R, N) where {TFL <: Number} - return (R - N)/(R + N) + return (R - N) / (R + N) end indices_funcs["VrNIRBI"] = VrNIRBI_func function SEVI_func(::Type{TFL}, N, R, fdelta; const1::Number=TFL(1.0)) where {TFL <: Number} - return (N/R) + fdelta * (const1/R) + return (N / R) + fdelta * (const1 / R) end indices_funcs["SEVI"] = SEVI_func function NSTv1_func(::Type{TFL}, N, S2, T) where {TFL <: Number} - return ((N-S2)/(N+S2))*T + return ((N - S2) / (N + S2)) * T end indices_funcs["NSTv1"] = NSTv1_func -function NDISIndwi_func(::Type{TFL}, T, G, N, S1; const1::Number=TFL(3.0), const2::Number=TFL(3.0)) where {TFL <: Number} - return (T - (((G - N)/(G + N)) + N + S1) / const1)/(T + (((G - N)/(G + N)) + N + S1) / const2) +function NDISIndwi_func(::Type{TFL}, T, G, N, S1; const1::Number=TFL(3.0), + const2::Number=TFL(3.0)) where {TFL <: Number} + return (T - (((G - N) / (G + N)) + N + S1) / const1) / + (T + (((G - N) / (G + N)) + N + S1) / const2) end indices_funcs["NDISIndwi"] = NDISIndwi_func function NDGlaI_func(::Type{TFL}, G, R) where {TFL <: Number} - return (G - R)/(G + R) + return (G - R) / (G + R) end indices_funcs["NDGlaI"] = NDGlaI_func function GBNDVI_func(::Type{TFL}, N, G, B) where {TFL <: Number} - return (N - (G + B))/(N + (G + B)) + return (N - (G + B)) / (N + (G + B)) end indices_funcs["GBNDVI"] = GBNDVI_func function BRBA_func(::Type{TFL}, R, S1) where {TFL <: Number} - return R/S1 + return R / S1 end indices_funcs["BRBA"] = BRBA_func function CSI_func(::Type{TFL}, N, S2) where {TFL <: Number} - return N/S2 + return N / S2 end indices_funcs["CSI"] = CSI_func -function NDVIT_func(::Type{TFL}, N, R, T; const1::Number=TFL(10000.0), const2::Number=TFL(10000.0)) where {TFL <: Number} - return (N - (R * T / const1))/(N + (R * T / const2)) +function NDVIT_func(::Type{TFL}, N, R, T; const1::Number=TFL(10000.0), + const2::Number=TFL(10000.0)) where {TFL <: Number} + return (N - (R * T / const1)) / (N + (R * T / const2)) end indices_funcs["NDVIT"] = NDVIT_func function MNDVI_func(::Type{TFL}, N, S2) where {TFL <: Number} - return (N - S2)/(N + S2) + return (N - S2) / (N + S2) end indices_funcs["MNDVI"] = MNDVI_func -function sNIRvNDPI_func(::Type{TFL}, N, alpha, R, S2; const1::Number=TFL(1.0), const2::Number=TFL(1.0)) where {TFL <: Number} - return (N - (alpha * R + (const1 - alpha) * S2))/(N + (alpha * R + (const2 - alpha) * S2)) * N +function sNIRvNDPI_func(::Type{TFL}, N, alpha, R, S2; const1::Number=TFL(1.0), + const2::Number=TFL(1.0)) where {TFL <: Number} + return (N - (alpha * R + (const1 - alpha) * S2)) / + (N + (alpha * R + (const2 - alpha) * S2)) * N end indices_funcs["sNIRvNDPI"] = sNIRvNDPI_func -function BAI_func(::Type{TFL}, R, N; const1::Number=TFL(1.0), const2::Number=TFL(0.1), const3::Number=TFL(2.0), const4::Number=TFL(0.06), const5::Number=TFL(2.0)) where {TFL <: Number} - return const1 / ((const2 - R) ^ const3 + (const4 - N) ^ const5) +function BAI_func(::Type{TFL}, R, N; const1::Number=TFL(1.0), const2::Number=TFL(0.1), + const3::Number=TFL(2.0), const4::Number=TFL(0.06), + const5::Number=TFL(2.0)) where {TFL <: Number} + return const1 / ((const2 - R)^const3 + (const4 - N)^const5) end indices_funcs["BAI"] = BAI_func @@ -1135,19 +1234,20 @@ end indices_funcs["EVI"] = EVI_func function DBSI_func(::Type{TFL}, S1, G, N, R) where {TFL <: Number} - return ((S1 - G)/(S1 + G)) - ((N - R)/(N + R)) + return ((S1 - G) / (S1 + G)) - ((N - R) / (N + R)) end indices_funcs["DBSI"] = DBSI_func function NDPonI_func(::Type{TFL}, S1, G) where {TFL <: Number} - return (S1-G)/(S1+G) + return (S1 - G) / (S1 + G) end indices_funcs["NDPonI"] = NDPonI_func -function NLI_func(::Type{TFL}, N, R; const1::Number=TFL(2), const2::Number=TFL(2)) where {TFL <: Number} - return ((N ^ const1) - R)/((N ^ const2) + R) +function NLI_func(::Type{TFL}, N, R; const1::Number=TFL(2), + const2::Number=TFL(2)) where {TFL <: Number} + return ((N^const1) - R) / ((N^const2) + R) end indices_funcs["NLI"] = NLI_func @@ -1158,25 +1258,28 @@ end indices_funcs["NDSaII"] = NDSaII_func -function MSR705_func(::Type{TFL}, RE2, RE1; const1::Number=TFL(1), const2::Number=TFL(1), const3::Number=TFL(0.5)) where {TFL <: Number} - return (RE2 / RE1 - const1) / ((RE2 / RE1 + const2) ^ const3) +function MSR705_func(::Type{TFL}, RE2, RE1; const1::Number=TFL(1), const2::Number=TFL(1), + const3::Number=TFL(0.5)) where {TFL <: Number} + return (RE2 / RE1 - const1) / ((RE2 / RE1 + const2)^const3) end indices_funcs["MSR705"] = MSR705_func -function MTVI1_func(::Type{TFL}, N, G, R; const1::Number=TFL(1.2), const2::Number=TFL(1.2), const3::Number=TFL(2.5)) where {TFL <: Number} +function MTVI1_func(::Type{TFL}, N, G, R; const1::Number=TFL(1.2), const2::Number=TFL(1.2), + const3::Number=TFL(2.5)) where {TFL <: Number} return const1 * (const2 * (N - G) - const3 * (R - G)) end indices_funcs["MTVI1"] = MTVI1_func function IKAW_func(::Type{TFL}, R, B) where {TFL <: Number} - return (R - B)/(R + B) + return (R - B) / (R + B) end indices_funcs["IKAW"] = IKAW_func -function MIRBI_func(::Type{TFL}, S2, S1; const1::Number=TFL(10.0), const2::Number=TFL(9.8), const3::Number=TFL(2.0)) where {TFL <: Number} +function MIRBI_func(::Type{TFL}, S2, S1; const1::Number=TFL(10.0), const2::Number=TFL(9.8), + const3::Number=TFL(2.0)) where {TFL <: Number} return const1 * S2 - const2 * S1 + const3 end @@ -1188,14 +1291,15 @@ end indices_funcs["CSIT"] = CSIT_func -function TDVI_func(::Type{TFL}, N, R; const1::Number=TFL(1.5), const2::Number=TFL(2.0), const3::Number=TFL(0.5), const4::Number=TFL(0.5)) where {TFL <: Number} - return const1 * ((N - R)/((N ^ const2 + R + const3) ^ const4)) +function TDVI_func(::Type{TFL}, N, R; const1::Number=TFL(1.5), const2::Number=TFL(2.0), + const3::Number=TFL(0.5), const4::Number=TFL(0.5)) where {TFL <: Number} + return const1 * ((N - R) / ((N^const2 + R + const3)^const4)) end indices_funcs["TDVI"] = TDVI_func function DSWI2_func(::Type{TFL}, S1, G) where {TFL <: Number} - return S1/G + return S1 / G end indices_funcs["DSWI2"] = DSWI2_func @@ -1206,14 +1310,16 @@ end indices_funcs["CIRE"] = CIRE_func -function NDISIr_func(::Type{TFL}, T, R, N, S1; const1::Number=TFL(3.0), const2::Number=TFL(3.0)) where {TFL <: Number} - return (T - (R + N + S1) / const1)/(T + (R + N + S1) / const2) +function NDISIr_func(::Type{TFL}, T, R, N, S1; const1::Number=TFL(3.0), + const2::Number=TFL(3.0)) where {TFL <: Number} + return (T - (R + N + S1) / const1) / (T + (R + N + S1) / const2) end indices_funcs["NDISIr"] = NDISIr_func function NDDI_func(::Type{TFL}, N, R, G) where {TFL <: Number} - return (((N - R)/(N + R)) - ((G - N)/(G + N)))/(((N - R)/(N + R)) + ((G - N)/(G + N))) + return (((N - R) / (N + R)) - ((G - N) / (G + N))) / + (((N - R) / (N + R)) + ((G - N) / (G + N))) end indices_funcs["NDDI"] = NDDI_func @@ -1225,49 +1331,53 @@ end indices_funcs["NDREI"] = NDREI_func function NDTI_func(::Type{TFL}, R, G) where {TFL <: Number} - return (R-G)/(R+G) + return (R - G) / (R + G) end indices_funcs["NDTI"] = NDTI_func -function QpRVI_func(::Type{TFL}, HV, HH, VV; const1::Number=TFL(8.0), const2::Number=TFL(2.0)) where {TFL <: Number} - return (const1 * HV)/(HH + VV + const2 * HV) +function QpRVI_func(::Type{TFL}, HV, HH, VV; const1::Number=TFL(8.0), + const2::Number=TFL(2.0)) where {TFL <: Number} + return (const1 * HV) / (HH + VV + const2 * HV) end indices_funcs["QpRVI"] = QpRVI_func function DSWI1_func(::Type{TFL}, N, S1) where {TFL <: Number} - return N/S1 + return N / S1 end indices_funcs["DSWI1"] = DSWI1_func -function EBBI_func(::Type{TFL}, S1, N, T; const1::Number=TFL(10.0), const2::Number=TFL(0.5)) where {TFL <: Number} - return (S1 - N) / (const1 * ((S1 + T) ^ const2)) +function EBBI_func(::Type{TFL}, S1, N, T; const1::Number=TFL(10.0), + const2::Number=TFL(0.5)) where {TFL <: Number} + return (S1 - N) / (const1 * ((S1 + T)^const2)) end indices_funcs["EBBI"] = EBBI_func -function MCARI1_func(::Type{TFL}, N, R, G; const1::Number=TFL(1.2), const2::Number=TFL(2.5), const3::Number=TFL(1.3)) where {TFL <: Number} +function MCARI1_func( + ::Type{TFL}, N, R, G; const1::Number=TFL(1.2), const2::Number=TFL(2.5), + const3::Number=TFL(1.3)) where {TFL <: Number} return const1 * (const2 * (N - R) - const3 * (N - G)) end indices_funcs["MCARI1"] = MCARI1_func function BNDVI_func(::Type{TFL}, N, B) where {TFL <: Number} - return (N - B)/(N + B) + return (N - B) / (N + B) end indices_funcs["BNDVI"] = BNDVI_func function NDSII_func(::Type{TFL}, G, N) where {TFL <: Number} - return (G - N)/(G + N) + return (G - N) / (G + N) end indices_funcs["NDSII"] = NDSII_func function sNIRvNDVILSWIS_func(::Type{TFL}, N, R, S2) where {TFL <: Number} - return (((N - R)/(N + R)) + ((N - S2)/(N + S2))) * N + return (((N - R) / (N + R)) + ((N - S2) / (N + S2))) * N end indices_funcs["sNIRvNDVILSWIS"] = sNIRvNDVILSWIS_func @@ -1278,26 +1388,30 @@ end indices_funcs["NIRvH2"] = NIRvH2_func -function NBRT2_func(::Type{TFL}, N, T, S2; const1::Number=TFL(10000.0), const2::Number=TFL(10000.0)) where {TFL <: Number} +function NBRT2_func(::Type{TFL}, N, T, S2; const1::Number=TFL(10000.0), + const2::Number=TFL(10000.0)) where {TFL <: Number} return ((N / (T / const1)) - S2) / ((N / (T / const2)) + S2) end indices_funcs["NBRT2"] = NBRT2_func function CVI_func(::Type{TFL}, N, R, G; const1::Number=TFL(2.0)) where {TFL <: Number} - return (N * R) / (G ^ const1) + return (N * R) / (G^const1) end indices_funcs["CVI"] = CVI_func -function DVIplus_func(::Type{TFL}, lambdaN, lambdaR, lambdaG, G, N, R; const1::Number=TFL(1.0)) where {TFL <: Number} - return ((lambdaN - lambdaR)/(lambdaN - lambdaG)) * G + (const1 - ((lambdaN - lambdaR)/(lambdaN - lambdaG))) * N - R +function DVIplus_func(::Type{TFL}, lambdaN, lambdaR, lambdaG, G, N, R; + const1::Number=TFL(1.0)) where {TFL <: Number} + return ((lambdaN - lambdaR) / (lambdaN - lambdaG)) * G + + (const1 - ((lambdaN - lambdaR) / (lambdaN - lambdaG))) * N - R end indices_funcs["DVIplus"] = DVIplus_func -function RI4XS_func(::Type{TFL}, R, G; const1::Number=TFL(2.0), const2::Number=TFL(4.0)) where {TFL <: Number} - return (R^const1)/(G^const2) +function RI4XS_func(::Type{TFL}, R, G; const1::Number=TFL(2.0), + const2::Number=TFL(4.0)) where {TFL <: Number} + return (R^const1) / (G^const2) end indices_funcs["RI4XS"] = RI4XS_func @@ -1308,7 +1422,8 @@ end indices_funcs["kRVI"] = kRVI_func -function AFRI1600_func(::Type{TFL}, N, S1; const1::Number=TFL(0.66), const2::Number=TFL(0.66)) where {TFL <: Number} +function AFRI1600_func(::Type{TFL}, N, S1; const1::Number=TFL(0.66), + const2::Number=TFL(0.66)) where {TFL <: Number} return (N - const1 * S1) / (N + const2 * S1) end @@ -1320,55 +1435,66 @@ end indices_funcs["SR705"] = SR705_func -function IBI_func(::Type{TFL}, S1, N, R, L, G; const1::Number=TFL(1.0), const2::Number=TFL(2.0), const3::Number=TFL(1.0), const4::Number=TFL(2.0)) where {TFL <: Number} - return (((S1-N)/(S1+N))-(((N-R)*(const1+L)/(N+R+L))+((G-S1)/(G+S1)))/const2)/(((S1-N)/(S1+N))+(((N-R)*(const3+L)/(N+R+L))+((G-S1)/(G+S1)))/const4) +function IBI_func( + ::Type{TFL}, S1, N, R, L, G; const1::Number=TFL(1.0), const2::Number=TFL(2.0), + const3::Number=TFL(1.0), const4::Number=TFL(2.0)) where {TFL <: Number} + return (((S1 - N) / (S1 + N)) - + (((N - R) * (const1 + L) / (N + R + L)) + ((G - S1) / (G + S1))) / const2) / + (((S1 - N) / (S1 + N)) + + (((N - R) * (const3 + L) / (N + R + L)) + ((G - S1) / (G + S1))) / const4) end indices_funcs["IBI"] = IBI_func -function VARI700_func(::Type{TFL}, RE1, R, B; const1::Number=TFL(1.7), const2::Number=TFL(0.7), const3::Number=TFL(1.3), const4::Number=TFL(1.3)) where {TFL <: Number} +function VARI700_func( + ::Type{TFL}, RE1, R, B; const1::Number=TFL(1.7), const2::Number=TFL(0.7), + const3::Number=TFL(1.3), const4::Number=TFL(1.3)) where {TFL <: Number} return (RE1 - const1 * R + const2 * B) / (RE1 + const3 * R - const4 * B) end indices_funcs["VARI700"] = VARI700_func function NBLI_func(::Type{TFL}, R, T) where {TFL <: Number} - return (R - T)/(R + T) + return (R - T) / (R + T) end indices_funcs["NBLI"] = NBLI_func function NDII_func(::Type{TFL}, N, S1) where {TFL <: Number} - return (N - S1)/(N + S1) + return (N - S1) / (N + S1) end indices_funcs["NDII"] = NDII_func -function S2REP_func(::Type{TFL}, RE3, R, RE1, RE2; const1::Number=TFL(705.0), const2::Number=TFL(35.0), const3::Number=TFL(2.0)) where {TFL <: Number} +function S2REP_func(::Type{TFL}, RE3, R, RE1, RE2; const1::Number=TFL(705.0), + const2::Number=TFL(35.0), const3::Number=TFL(2.0)) where {TFL <: Number} return const1 + const2 * ((((RE3 + R) / const3) - RE1) / (RE2 - RE1)) end indices_funcs["S2REP"] = S2REP_func function NDMI_func(::Type{TFL}, N, S1) where {TFL <: Number} - return (N - S1)/(N + S1) + return (N - S1) / (N + S1) end indices_funcs["NDMI"] = NDMI_func -function NBUI_func(::Type{TFL}, S1, N, T, R, L, G; const1::Number=TFL(10.0), const2::Number=TFL(0.5), const3::Number=TFL(1.0)) where {TFL <: Number} - return ((S1 - N)/(const1 * (T + S1) ^ const2)) - (((N - R) * (const3 + L))/(N - R + L)) - (G - S1)/(G + S1) +function NBUI_func(::Type{TFL}, S1, N, T, R, L, G; const1::Number=TFL(10.0), + const2::Number=TFL(0.5), const3::Number=TFL(1.0)) where {TFL <: Number} + return ((S1 - N) / (const1 * (T + S1)^const2)) - + (((N - R) * (const3 + L)) / (N - R + L)) - (G - S1) / (G + S1) end indices_funcs["NBUI"] = NBUI_func function GRNDVI_func(::Type{TFL}, N, G, R) where {TFL <: Number} - return (N - (G + R))/(N + (G + R)) + return (N - (G + R)) / (N + (G + R)) end indices_funcs["GRNDVI"] = GRNDVI_func -function NBRT3_func(::Type{TFL}, N, T, S2; const1::Number=TFL(10000.0), const2::Number=TFL(10000.0)) where {TFL <: Number} +function NBRT3_func(::Type{TFL}, N, T, S2; const1::Number=TFL(10000.0), + const2::Number=TFL(10000.0)) where {TFL <: Number} return ((N - (T / const1)) - S2) / ((N - (T / const2)) + S2) end @@ -1387,12 +1513,14 @@ end indices_funcs["NDWI"] = NDWI_func function NSDSI3_func(::Type{TFL}, S1, S2) where {TFL <: Number} - return (S1-S2)/(S1+S2) + return (S1 - S2) / (S1 + S2) end indices_funcs["NSDSI3"] = NSDSI3_func -function PISI_func(::Type{TFL}, B, N; const1::Number=TFL(0.8192), const2::Number=TFL(0.5735), const3::Number=TFL(0.0750)) where {TFL <: Number} +function PISI_func( + ::Type{TFL}, B, N; const1::Number=TFL(0.8192), const2::Number=TFL(0.5735), + const3::Number=TFL(0.0750)) where {TFL <: Number} return const1 * B - const2 * N + const3 end @@ -1404,13 +1532,21 @@ end indices_funcs["MTCI"] = MTCI_func -function MCARI2_func(::Type{TFL}, N, R, G; const1::Number=TFL(1.5), const2::Number=TFL(2.5), const3::Number=TFL(1.3), const4::Number=TFL(2.0), const5::Number=TFL(1), const6::Number=TFL(2), const7::Number=TFL(6.0), const8::Number=TFL(5), const9::Number=TFL(0.5), const10::Number=TFL(0.5), const11::Number=TFL(0.5)) where {TFL <: Number} - return (const1 * (const2 * (N - R) - const3 * (N - G))) / ((((const4 * N + const5) ^ const6) - (const7 * N - const8 * (R ^ const9)) - const10) ^ const11) +function MCARI2_func( + ::Type{TFL}, N, R, G; const1::Number=TFL(1.5), const2::Number=TFL(2.5), + const3::Number=TFL(1.3), const4::Number=TFL(2.0), const5::Number=TFL(1), + const6::Number=TFL(2), const7::Number=TFL(6.0), const8::Number=TFL(5), + const9::Number=TFL(0.5), const10::Number=TFL(0.5), + const11::Number=TFL(0.5)) where {TFL <: Number} + return (const1 * (const2 * (N - R) - const3 * (N - G))) / + ((((const4 * N + const5)^const6) - (const7 * N - const8 * (R^const9)) - + const10)^const11) end indices_funcs["MCARI2"] = MCARI2_func -function GLI_func(::Type{TFL}, G, R, B; const1::Number=TFL(2.0), const2::Number=TFL(2.0)) where {TFL <: Number} +function GLI_func(::Type{TFL}, G, R, B; const1::Number=TFL(2.0), + const2::Number=TFL(2.0)) where {TFL <: Number} return (const1 * G - R - B) / (const2 * G + R + B) end @@ -1422,20 +1558,25 @@ end indices_funcs["VI700"] = VI700_func -function NDISIb_func(::Type{TFL}, T, B, N, S1; const1::Number=TFL(3.0), const2::Number=TFL(3.0)) where {TFL <: Number} - return (T - (B + N + S1) / const1)/(T + (B + N + S1) / const2) +function NDISIb_func(::Type{TFL}, T, B, N, S1; const1::Number=TFL(3.0), + const2::Number=TFL(3.0)) where {TFL <: Number} + return (T - (B + N + S1) / const1) / (T + (B + N + S1) / const2) end indices_funcs["NDISIb"] = NDISIb_func -function WI2015_func(::Type{TFL}, G, R, N, S1, S2; const1::Number=TFL(1.7204), const2::Number=TFL(171), const3::Number=TFL(3), const4::Number=TFL(70), const5::Number=TFL(45), const6::Number=TFL(71)) where {TFL <: Number} +function WI2015_func(::Type{TFL}, G, R, N, S1, S2; const1::Number=TFL(1.7204), + const2::Number=TFL(171), const3::Number=TFL(3), const4::Number=TFL(70), + const5::Number=TFL(45), const6::Number=TFL(71)) where {TFL <: Number} return const1 + const2 * G + const3 * R - const4 * N - const5 * S1 - const6 * S2 end indices_funcs["WI2015"] = WI2015_func -function BITM_func(::Type{TFL}, B, G, R; const1::Number=TFL(2.0), const2::Number=TFL(2.0), const3::Number=TFL(2.0), const4::Number=TFL(3.0), const5::Number=TFL(0.5)) where {TFL <: Number} - return (((B^const1)+(G^const2)+(R^const3))/const4)^const5 +function BITM_func(::Type{TFL}, B, G, R; const1::Number=TFL(2.0), const2::Number=TFL(2.0), + const3::Number=TFL(2.0), const4::Number=TFL(3.0), + const5::Number=TFL(0.5)) where {TFL <: Number} + return (((B^const1) + (G^const2) + (R^const3)) / const4)^const5 end indices_funcs["BITM"] = BITM_func @@ -1446,14 +1587,16 @@ end indices_funcs["S3"] = S3_func -function TTVI_func(::Type{TFL}, RE3, RE2, N2; const1::Number=TFL(0.5), const2::Number=TFL(865.0), const3::Number=TFL(740.0), const4::Number=TFL(783.0), const5::Number=TFL(740)) where {TFL <: Number} +function TTVI_func(::Type{TFL}, RE3, RE2, N2; const1::Number=TFL(0.5), + const2::Number=TFL(865.0), const3::Number=TFL(740.0), + const4::Number=TFL(783.0), const5::Number=TFL(740)) where {TFL <: Number} return const1 * ((const2 - const3) * (RE3 - RE2) - (N2 - RE2) * (const4 - const5)) end indices_funcs["TTVI"] = TTVI_func function NDCI_func(::Type{TFL}, RE1, R) where {TFL <: Number} - return (RE1 - R)/(RE1 + R) + return (RE1 - R) / (RE1 + R) end indices_funcs["NDCI"] = NDCI_func @@ -1471,14 +1614,13 @@ end indices_funcs["SAVI2"] = SAVI2_func function DSWI5_func(::Type{TFL}, N, G, S1, R) where {TFL <: Number} - return (N + G)/(S1 + R) + return (N + G) / (S1 + R) end indices_funcs["DSWI5"] = DSWI5_func function IAVI_func(::Type{TFL}, N, R, gamma, B) where {TFL <: Number} - return (N - (R - gamma * (B - R)))/(N + (R - gamma * (B - R))) + return (N - (R - gamma * (B - R))) / (N + (R - gamma * (B - R))) end indices_funcs["IAVI"] = IAVI_func - diff --git a/src/platforms.jl b/src/platforms.jl index f1d1219..de0c3cc 100644 --- a/src/platforms.jl +++ b/src/platforms.jl @@ -1,4 +1,6 @@ -struct PlatformBand{S<:String,W<:Number,B<:Number} <: AbstractPlatformBand +abstract type AbstractPlatformBand end + +struct PlatformBand{S <: String, W <: Number, B <: Number} <: AbstractPlatformBand platform::S band::S name::S @@ -34,7 +36,7 @@ platform_band_dict = Dict( "band" => "B2", "name" => "Blue", "wavelength" => 492.4, - "bandwidth" => 66.0, + "bandwidth" => 66.0 ) platform_band = PlatformBand(platform_band_dict) diff --git a/src/utils.jl b/src/utils.jl index 82a3540..9051d37 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -24,7 +24,7 @@ data = load_json("my-custom-indices.json") function load_json(filename::String="spectral-indices-dict.json") fileloc = joinpath(dirname(@__FILE__), "..", "data", filename) if isfile(fileloc) - return JSON.parsefile(fileloc) + return parsefile(fileloc) else error("The JSON file is not in the SpectralIndices/data folder") end @@ -54,18 +54,15 @@ indices = get_indices(true) ''' ``` """ -function get_indices( - online::Bool=false; - filename="spectral-indices-dict.json", - fileloc=joinpath(dirname(@__FILE__), "..", "data"), -) +function get_indices(online::Bool=false; filename::String="spectral-indices-dict.json", + fileloc::String=joinpath(dirname(@__FILE__), "..", "data")) final_file = joinpath(fileloc, filename) if online indices_loc = Downloads.download( "https://raw.githubusercontent.com/awesome-spectral-indices/awesome-spectral-indices/main/output/spectral-indices-dict.json", - final_file, + final_file ) - indices = JSON.parsefile(indices_loc) + indices = parsefile(indices_loc) else indices = load_json() end @@ -73,11 +70,9 @@ function get_indices( return indices["SpectralIndices"] end -function create_indexfun( - index_dict::Dict{String,Any}=_get_indices(); - filename::String="indices_funcs.jl", - fileloc=joinpath(dirname(@__FILE__), filename), -) +function create_indexfun(index_dict::Dict{String, Any}=_get_indices(); + filename::String="indices_funcs.jl", + fileloc::String=joinpath(dirname(@__FILE__), filename)) open(fileloc, "w") do file write(file, "indices_funcs = Dict()\n\n") @@ -92,16 +87,15 @@ function create_indexfun( default_values = [] formula = replace( formula, - r"\b\d+(\.\d+)?\b" => - match -> begin - const_name = "const$(counter)" - default_value = match - push!(const_defs, "$const_name::Number=TFL($default_value)") - push!(untyped_const_defs, "$const_name=$const_name") - push!(default_values, default_value) - counter += 1 - return const_name - end, + r"\b\d+(\.\d+)?\b" => match -> begin + const_name = "const$(counter)" + default_value = match + push!(const_defs, "$const_name::Number=TFL($default_value)") + push!(untyped_const_defs, "$const_name=$const_name") + push!(default_values, default_value) + counter += 1 + return const_name + end ) bands = index_info["bands"] diff --git a/test/DataFrames/compute_index.jl b/test/DataFrames/compute_index.jl index 648db95..9207a3d 100644 --- a/test/DataFrames/compute_index.jl +++ b/test/DataFrames/compute_index.jl @@ -14,8 +14,7 @@ function convert_to_kwargs(df::DataFrame) return kwargs end -@testset "DataFrames compute_index $T single index tests: $idx_name" for (idx_name, idx) in - indices, +@testset "DataFrames compute_index $T single index tests: $idx_name" for (idx_name, idx) in indices, T in floats @testset "as Params" begin diff --git a/test/YAXArrays/compute_index.jl b/test/YAXArrays/compute_index.jl index ea685da..0ad9be0 100644 --- a/test/YAXArrays/compute_index.jl +++ b/test/YAXArrays/compute_index.jl @@ -19,8 +19,7 @@ end xdim = Dim{:x}(range(1, 10; length=10)) ydim = Dim{:x}(range(1, 10; length=15)) -@testset "YAXArrays compute_index $T single index tests: $idx_name" for (idx_name, idx) in - indices, +@testset "YAXArrays compute_index $T single index tests: $idx_name" for (idx_name, idx) in indices, T in floats @testset "as Params" begin diff --git a/test/bands.jl b/test/bands.jl index 1698718..037aeee 100644 --- a/test/bands.jl +++ b/test/bands.jl @@ -11,8 +11,8 @@ using SpectralIndices "common_name" => "Blue", "min_wavelength" => 450.0, "max_wavelength" => 495.0, - "platforms" => - Dict("sentinel2a" => dummy_platform_band, "sentinel2b" => dummy_platform_band), + "platforms" => Dict( + "sentinel2a" => dummy_platform_band, "sentinel2b" => dummy_platform_band) ) sample_band = Band(sample_band_dict) diff --git a/test/compute_index.jl b/test/compute_index.jl index f10befb..f60b0fb 100644 --- a/test/compute_index.jl +++ b/test/compute_index.jl @@ -20,8 +20,8 @@ end #end @testset "Built-in types compute_index $T single index tests: $idx_name" for ( - idx_name, idx - ) in indices, + idx_name, idx +) in indices, T in floats @testset "Single Values as Params" begin diff --git a/test/compute_kernel.jl b/test/compute_kernel.jl index 4ac8331..181ec1e 100644 --- a/test/compute_kernel.jl +++ b/test/compute_kernel.jl @@ -30,8 +30,8 @@ floats = [Float64, Float32, Float16] @test RBF(a, b, sigma) ≈ expected_number_result @test eltype(RBF(a, b, sigma)) == T - expected_array_result = - T.(exp.((-1.0 .* ((a_v .- b_v) .^ 2.0)) ./ (2.0 .* (sigma_v .^ 2.0)))) + expected_array_result = T.(exp.((-1.0 .* ((a_v .- b_v) .^ 2.0)) ./ + (2.0 .* (sigma_v .^ 2.0)))) @test all(RBF(a_v, b_v, sigma_v) .≈ expected_array_result) @test eltype(RBF(a_v, b_v, sigma_v)) == T end diff --git a/test/constants.jl b/test/constants.jl index 93ab479..35bc35f 100644 --- a/test/constants.jl +++ b/test/constants.jl @@ -8,7 +8,7 @@ using SpectralIndices "Sample Short Name", "Sample Standard", "Sample Default", - "Sample Value", + "Sample Value" ) # Test Machine-readable Output diff --git a/test/indices.jl b/test/indices.jl index d83f2e0..4fb10f7 100644 --- a/test/indices.jl +++ b/test/indices.jl @@ -9,7 +9,7 @@ custom_index = Dict( "formula" => "(C - I) / (C + I)", "date_of_addition" => "1984-01-01", "contributor" => "John Doe", - "platforms" => ["Landsat 8", "MODIS"], + "platforms" => ["Landsat 8", "MODIS"] ) custom_index_func(C, I) = (C - I) / (C + I) @@ -27,7 +27,7 @@ si = SpectralIndex(custom_index, custom_index_func) @test si.platforms == ["Landsat 8", "MODIS"] computed_index = si(0.6, 0.2) - @test computed_index ≈ 0.5 atol = 0.01 + @test computed_index≈0.5 atol=0.01 C_vals = fill(0.6, 5) I_vals = fill(0.2, 5) diff --git a/test/test_utils.jl b/test/test_utils.jl index 9e2fd62..b5adb4d 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -1,9 +1,9 @@ using SpectralIndices function custom_key_combinations( - dict::Dict{String,SpectralIndices.AbstractSpectralIndex}, - combo_size::Int, - num_combos::Int, + dict::Dict{String, SpectralIndices.AbstractSpectralIndex}, + combo_size::Int, + num_combos::Int ) keys_list = collect(keys(dict)) all_combos = combinations(keys_list, combo_size)