-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
open_mfdataset leads to UndefVarError:
diskstack not defined
#476
Comments
ohh... |
Thanks for the report. I was indeed a bit quick in merging this. There was a missing import and also another small bug for the case where the arrays were concatenated along a new dimension not yet present in the existing datasets. Should be fixed by #477 |
Yes, It works on my end with #477 newds = Cube(open_mfdataset(DD.DimArray(files[end-1:end],DD.Dim{:Year}(dates))))
╭──────────────────────────────────────────────────╮
│ 251×199×2×2 YAXArray{Union{Missing, Float64}, 4} │
├──────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────── dims ┐
↓ longitude Sampled{Float32} -80.0f0:0.1f0:-55.0f0 ForwardOrdered Regular Points,
→ latitude Sampled{Float32} 42.2f0:0.1f0:62.0f0 ForwardOrdered Regular Points,
↗ Year Sampled{Int64} 1:2 ForwardOrdered Regular Points,
⬔ Variable Categorical{String} ["tp", "tmean"] ReverseOrdered
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── metadata ┤
Dict{String, Any} with 1 entry:
"missing_value" => 1.0e32
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── loaded lazily ┤
data size: 1.52 MB However, the new dimension seems to fallback to integer values? dates
2-element Vector{DateTime}:
2020-11-01T00:00:00
2020-12-01T00:00:00
(tmp) > newds.Year
Year Sampled{Int64} ForwardOrdered Regular DimensionalData.Dimensions.Lookups.Points
wrapping: 1:2
(tmp) > collect(newds.Year)
╭──────────────────────────────╮
│ 2-element DimArray{Int64, 1} │
├──────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────── dims ┐
↓ Year Sampled{Int64} 1:2 ForwardOrdered Regular Points
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
1 1
2 2
Trying with a list of string also gives integer values: newds = Cube(open_mfdataset(DD.DimArray(files[end-1:end],DD.Dim{:Year}(["a", "b"]))))
╭──────────────────────────────────────────────────╮
│ 251×199×2×2 YAXArray{Union{Missing, Float64}, 4} │
├──────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────── dims ┐
↓ longitude Sampled{Float32} -80.0f0:0.1f0:-55.0f0 ForwardOrdered Regular Points,
→ latitude Sampled{Float32} 42.2f0:0.1f0:62.0f0 ForwardOrdered Regular Points,
↗ Year Sampled{Int64} 1:2 ForwardOrdered Regular Points,
⬔ Variable Categorical{String} ["tp", "tmean"] ReverseOrdered
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── metadata ┤
Dict{String, Any} with 1 entry:
"missing_value" => 1.0e32
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── loaded lazily ┤
data size: 1.52 MB |
There is still the lastbug, where the new dimension values are not taken into account. files = ["2020_09_crps_ecmwf.nc", "2020_10_crps_ecmwf.nc"]
2-element Vector{String}:
"2020_09_crps_ecmwf.nc"
"2020_10_crps_ecmwf.nc"
julia> dates = [DateTime(2020,9), DateTime(2020,10)]
2-element Vector{DateTime}:
2020-09-01T00:00:00
2020-10-01T00:00:00
julia> import DimensionalData as DD
julia> using NetCDF
[ Info: new driver key :netcdf, updating backendlist.
julia> newds = open_mfdataset(DD.DimArray(files,DD.Dim{:Ti}(dates)))
YAXArray Dataset
Shared Axes:
(↓ longitude Sampled{Float32} -80.0f0:0.1f0:-55.0f0 ForwardOrdered Regular Points,
→ latitude Sampled{Float32} 42.2f0:0.1f0:62.0f0 ForwardOrdered Regular Points,
↗ Ti Sampled{Int64} 1:2 ForwardOrdered Regular Points)
Variables:
tmean, tp
|
If those files are small enough, could you please share them? It might make things easier to debug/fix. |
I'll try to see how I can make a MWE. Files are not transferable due to cybersecurity policies here :) |
Here's a standalone MWE with random array and dates: using YAXArrays
using NetCDF
using Dates
import DimensionalData as DD
a1 = YAXArray(rand(10, 20, 5))
a2 = YAXArray(rand(10, 20, 5))
savecube(a1, "a1.nc")
savecube(a2, "a2.nc")
files = ["a1.nc", "a2.nc"]
dates = [Date(2020, 1, 1) + Dates.Day(i) for i in 1:2]
ds = open_mfdataset(DD.DimArray(files,DD.Dim{:Ti}(dates))) output of ds is the following, with dimension ds = open_mfdataset(DD.DimArray(files,DD.Dim{:Ti}(dates)))
YAXArray Dataset
Shared Axes:
(↓ Dim_1 Sampled{Int64} 1:1:10 ForwardOrdered Regular Points,
→ Dim_2 Sampled{Int64} 1:1:20 ForwardOrdered Regular Points,
↗ Dim_3 Sampled{Int64} 1:1:5 ForwardOrdered Regular Points,
⬔ Ti Sampled{Int64} 1:2 ForwardOrdered Regular Points)
Variables:
layer
|
I have tried the new exported
open_mfdataset
function with a new dimension and I get the following error:Here's the dimensions of the underlying data in the netcdf files:
The text was updated successfully, but these errors were encountered: