Skip to content
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

plotting of a DimArray leads to a Segmentation Fault #290

Closed
felixcremer opened this issue Jul 21, 2021 · 2 comments
Closed

plotting of a DimArray leads to a Segmentation Fault #290

felixcremer opened this issue Jul 21, 2021 · 2 comments

Comments

@felixcremer
Copy link
Contributor

I am trying to plot a DimArray that I got converted from a yaxarray and then I run into a segmentation fault this is an example cube, that leads to the segfault with the following code. You need to unzip the zarr file before opening it in julia
s1_hidalgo_deforestation_zoom.zarr.zip

julia
julia> using DimensionalData

julia> using YAXArrays

julia> using Zarr

julia> cube = Cube("pathto/s1_hidalgo_deforestation_zoom.zarr")
YAXArray with the following dimensions
lon                 Axis with 82 Elements from -98.62577203503945 to -98.61121932743671
lat                 Axis with 51 Elements from 20.619481135755912 to 20.61049798291472
time                Axis with 1098 Elements from 2014-01-02T00:00:00 to 2020-01-01T00:00:00
Variable            Axis with 4 elements: sentinel1_vv_d sentinel1_vh_a sentinel1_vh_d sentinel1_vv_a 
Total size: 70.07 MB


julia> using YAXArrayBase


julia> dimsub = yaxconvert(DimArray, cube);

julia> typeof(dimsub)
DimArray{Union{Missing, Float32}, 4, Tuple{Dim{:lon, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, Sampled{Ordered{ForwardIndex, ForwardArray, ForwardRelation}, Regular{Float64}, Points}, NoMetadata}, Dim{:lat, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, Sampled{Ordered{ReverseIndex, ForwardArray, ForwardRelation}, Regular{Float64}, Points}, NoMetadata}, Dim{:time, Vector{DateTime}, Sampled{Ordered{ForwardIndex, ForwardArray, ForwardRelation}, Irregular{DimensionalData.AutoBounds}, Points}, NoMetadata}, Dim{:Variable, Vector{String}, Categorical{Unordered{ForwardRelation}}, NoMetadata}}, Tuple{}, DiskArrayTools.DiskArrayStack{Union{Missing, Float32}, 4, ZArray{Union{Missing, Float32}, 3, Zarr.BloscCompressor, DirectoryStore}, 1}, NoName, Dict{String, Any}}

julia> plot(dimsub)
[1]    512 segmentation fault  julia

This is on DimensionalData version 0.17.10

@rafaqz
Copy link
Owner

rafaqz commented Jul 22, 2021

Plotting a DimArray wont give you a heatmap, but whatever a generic plot() does to underlying data, with explicit axis values. I would guess you are breaking GR with a 3d array plot with three axis ranges? I doubt the segmentation fault is in Julia code or in DimensionalData.jl.

Testing it without DD, this doesn't work for me either:

plot(rand(50, 80, 1000))

Do you actually want to take a heatmap of a single time slice?

This use case is pretty much what GeoData.jl is for, and has specific plot recipes for. Although here it will still try to tile 1098 time slices in a single plot... but you can select sections of the timespan to do that. GeoData.jl just needs a zarr source, see https://github.com/rafaqz/GeoData.jl/issues/42.

Or you can probably do GeoArray(dimsub) to use GeoData.jl recipes.

@felixcremer
Copy link
Contributor Author

Thanks, yes, I actually was using GeoData for that but I got a segmentation fault there as well.
You are right, that I should select the proper time slices and variable before plotting and this works now.with GeoArray.
I just tested the above code with the plotly backend and there I also get an error, but at least it doesn't segfault so the segfault seems to happen somewhere in GR or in the Plots backend of GR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants