I have to use data with one time dimension and two spatial dimensions (longitude and latitude). I use the Rasters.jl library to manage them, that creates DimensionalData.jl arrays.
Sometimes, I have a variable, say slp, with three dimensions: Ti, longitude and latitude.
But sometimes, I can have the same variable, slp, with to dimensions: Ti and points. Points are integer numbers running from one to the number of grid points. Additionaly, in the same data set, I have two variables: longitude and latitude. And each of these two variables has one dimension: points. So, points is a dimension that is shared among slp, longitude and latitude.
If I want to select a spatial window of my data, between lon1 and lon2, and lat1 and lat2, then I can do as follows:
ds[points = Where( p -> ds["longitude"][p] ∈ lon1..lon2 && ds["latitude"][p] ∈ lat1..lat2 )]
But it is the case that sometimes, I do not know the name of the dimension points
, so that it can be, instead of points
, values
(for example). I can detect the name of this dimension and store it as a string variable, say, spatial_dim_name
. But I do not know how to use it. I have tried:
julia> spatial_dim_name = "values"
julia> ds[spatial_dim_name = Where(p->
ds[lon_name][p] ∈ lon1..lon2
&&
ds[lat_name][p] ∈ lat1..lat2
)
]
┌ Warning: (Dim{:spatial_dim_name},) dims were not found in object.
└ @ DimensionalData.Dimensions ~/.julia/packages/DimensionalData/BoJag/src/Dimensions/primitives.jl:777
┌ Warning: (Dim{:spatial_dim_name},) dims were not found in object.
└ @ DimensionalData.Dimensions ~/.julia/packages/DimensionalData/BoJag/src/Dimensions/primitives.jl:777
And the selection is not made.
Does anybody know how I can do this?