Skip to content

Commit

Permalink
Merge pull request #80 from PALEOtoolkit/netcdf_update_fixes
Browse files Browse the repository at this point in the history
Fixes for NCDatasets v0.13
  • Loading branch information
sjdaines authored Feb 9, 2024
2 parents 89730ac + 95a0028 commit 6444267
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/OutputWriters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ function load_netcdf!(output::OutputMemory, filename; check_ext=true)
var = dsgvars[dd_coord_name]
attributes = netcdf_to_attributes(var)
!(coords_record in NCDatasets.dimnames(var)) || error("data_dim coord variable $dd_coord_name is not constant! (has a $coords_record dimension)")
push!(dd_coords, PB.FixedCoord(dd_coord_name, var[:], attributes))
push!(dd_coords, PB.FixedCoord(dd_coord_name, Array(var), attributes))
end
push!(data_dims, PB.NamedDimension(ddn, dds, dd_coords))
end
Expand Down Expand Up @@ -1065,7 +1065,7 @@ function netcdf_to_variable(
space = attributes[:space]
data_dims = attributes[:data_dims]

vdata = var[:] # convert to Julia Array
vdata = Array(var) # convert to Julia Array

vdata = netcdf_to_field_data(vdata, field_data)

Expand Down Expand Up @@ -1435,8 +1435,8 @@ function netcdf_to_grid(::Type{PB.Grids.UnstructuredColumnGrid}, ds::NCDatasets.

# convert contiguous ragged array representation
# back to vector-of-vectors
cells_in_column = dsvars["cells_in_column"][:] # number of cells in each column
Icolumns_indices = dsvars["Icolumns"][:] .+ 1 # netcdf is zero based
cells_in_column = Array(dsvars["cells_in_column"]) # number of cells in each column
Icolumns_indices = Array(dsvars["Icolumns"]) .+ 1 # netcdf is zero based
Icolumns = Vector{Vector{Int}}()
colstart = 1
for cells_this_column in cells_in_column
Expand All @@ -1450,12 +1450,12 @@ function netcdf_to_grid(::Type{PB.Grids.UnstructuredColumnGrid}, ds::NCDatasets.
var = dsvars[z_coord_name]
attributes = netcdf_to_attributes(var)
!("records" in NCDatasets.dimnames(var)) || error("z_coord variable $z_coord_name is not constant! (has a records dimension)")
push!(z_coords, PB.FixedCoord(z_coord_name, var[:], attributes))
push!(z_coords, PB.FixedCoord(z_coord_name, Array(var), attributes))
end

# optional column labels
if haskey(dsvars, "columnnames")
columnnames = Symbol.(dsvars["columnnames"][:])
columnnames = Symbol.(Array(dsvars["columnnames"]))
else
columnnames = Symbol[]
end
Expand Down Expand Up @@ -1484,7 +1484,7 @@ function netcdf_to_grid(::Type{PB.Grids.CartesianLinearGrid}, ds::NCDatasets.Dat
push!(dims, ds.dim[dimname])
if haskey(dsvars, dimname)
dimvar = dsvars[dimname]
push!(coords, dimvar[:])
push!(coords, Array(dimvar))
axis = get(dimvar.attrib, "axis", nothing)
if axis == "X"
global londim = i
Expand All @@ -1503,7 +1503,7 @@ function netcdf_to_grid(::Type{PB.Grids.CartesianLinearGrid}, ds::NCDatasets.Dat
isempty(coords_edges) || (length(coords_edges) == length(dimnames)) || error("spatial coordinates edges present but not on all dimensions")

# convert back to linear vectors
linear_index = dsvars["linear_index"][:] .+ 1 # netcdf zero based
linear_index = Array(dsvars["linear_index"]) .+ 1 # netcdf zero based
# reconstruct cartesian index
cartesian_index = Vector{CartesianIndex{length(dims)}}()
lin_cart_index = Int[]
Expand Down

0 comments on commit 6444267

Please sign in to comment.