Skip to content

Commit

Permalink
Recover the ability of decoding cubes imported via rasters.jl (at lea…
Browse files Browse the repository at this point in the history
…st some).

Trouble was with the time in z-axis
  • Loading branch information
joa-quim committed Feb 26, 2025
1 parent 5937e4a commit f3a6ed1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,11 @@ function rasters2grid(arg; scale::Real=1f0, offset::Real=0f0)::GMTgrid
endswith(names[1], "T00:00:00") && endswith(names[end], "T00:00:00") &&
(for k = 1:numel(names) names[k] = names[k][1:10] end)
names = collect(names) # Because typeof(names) was of an indescritible exotherism!!!
v = datetime2unix.(DateTime.(names)) # _v was some CFTime, now we know what it is.
v_unit = "UnixTime"
else
v = _v
v_unit = ""
end

dic = !isempty(arg.metadata) ? arg.metadata.val : Dict()
Expand All @@ -1080,7 +1085,7 @@ function rasters2grid(arg; scale::Real=1f0, offset::Real=0f0)::GMTgrid
(eltype(data) == Int16) && (data = convert(Array{Float32, ndims(data)}, data)) # And what about UInt16, UInt8, etc ...?

(is_transp && Yorder == 'B') && (reverse!(data, dims=2); layout = "TRB") # GMT expects grids to be scanline and Top->Bot
mat2grid(data, x=collect(arg.dims[1]), y=_y, v=_v, names=names, tit=string(arg.name), rem="Converted from a Rasters object.", is_transposed=is_transp, layout=layout, proj4=proj, wkt=wkt, epsg=epsg, z_unit=z_unit)
mat2grid(data, x=collect(arg.dims[1]), y=_y, v=v, names=names, tit=string(arg.name), rem="Converted from a Rasters object.", is_transposed=is_transp, layout=layout, proj4=proj, wkt=wkt, epsg=epsg, z_unit=z_unit, v_unit=v_unit)
end

# ---------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit f3a6ed1

Please sign in to comment.