|
42 | 42 |
|
43 | 43 | allowmissing(x::AbstractArray{T}) where {T} = convert(AbstractArray{Union{T, Missing}}, x)
|
44 | 44 |
|
45 |
| -""" |
46 |
| - data = CommonDataModel.filter(ncv, indices...; accepted_status_flags = nothing) |
47 | 45 |
|
48 |
| -Load and filter observations by replacing all variables without an acepted status |
49 |
| -flag to `missing`. It is used the attribute `ancillary_variables` to identify |
50 |
| -the status flag. |
51 | 46 |
|
52 |
| -``` |
53 |
| -# da["data"] is 2D matrix |
54 |
| -good_data = NCDatasets.filter(ds["data"],:,:, accepted_status_flags = ["good_data","probably_good_data"]) |
55 |
| -``` |
56 |
| -
|
57 |
| -""" |
58 |
| -function filter(ncv::AbstractVariable, indices...; accepted_status_flags = nothing) |
59 |
| -#function filter_(ncv, indices...) |
60 |
| -# accepted_status_flags = ("good_value", "probably_good_value") |
| 47 | +function _filter(ncv::AbstractVariable, indices::Union{<:Integer,AbstractVector{<:Integer},Colon}...; accepted_status_flags = nothing) |
61 | 48 | data = allowmissing(ncv[indices...])
|
62 | 49 |
|
63 | 50 | if (accepted_status_flags != nothing)
|
@@ -99,6 +86,27 @@ function filter(ncv::AbstractVariable, indices...; accepted_status_flags = nothi
|
99 | 86 | return data
|
100 | 87 | end
|
101 | 88 |
|
| 89 | +""" |
| 90 | + data = CommonDataModel.filter(ncv, indices...; accepted_status_flags = nothing) |
| 91 | +
|
| 92 | +Load and filter observations by replacing all variables without an acepted status |
| 93 | +flag to `missing`. It is used the attribute `ancillary_variables` to identify |
| 94 | +the status flag. |
| 95 | +
|
| 96 | +``` |
| 97 | +# da["data"] is 2D matrix |
| 98 | +good_data = NCDatasets.filter(ds["data"],:,:, accepted_status_flags = ["good_data","probably_good_data"]) |
| 99 | +``` |
| 100 | +
|
| 101 | +""" |
| 102 | +filter(ncv::AbstractVariable, indices::TIndices...; kwargs...) = |
| 103 | + _filter(ncv, indices...; kwargs...) |
| 104 | + |
| 105 | +filter(ncv::AbstractVariable, indices::Vector{<:Integer}; kwargs...) = |
| 106 | + _filter(ncv, indices...; kwargs...) |
| 107 | + |
| 108 | +filter(ncv::AbstractVariable, indices::BitVector; kwargs...) = |
| 109 | + _filter(ncv, indices...; kwargs...) |
102 | 110 |
|
103 | 111 | """
|
104 | 112 | cv = coord(v::Union{CFVariable,Variable},standard_name)
|
|
0 commit comments