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

issue when mapping data with surface! and missing data #133

Closed
eum64295 opened this issue Nov 1, 2022 · 9 comments · Fixed by MakieOrg/Makie.jl#3113
Closed

issue when mapping data with surface! and missing data #133

eum64295 opened this issue Nov 1, 2022 · 9 comments · Fixed by MakieOrg/Makie.jl#3113

Comments

@eum64295
Copy link

eum64295 commented Nov 1, 2022

Hello,
I get some sort of artefact when mapping a physical parameter (cloud top height) on the Earth's disk.
Basically, I have data in a 160x160 matrix and the corresponding lat/lon coordinates, each of which being also in a 160x160 matrix.
the grid is irregular. Some of the data are missing and set to NaN. Same for the corresponding coordinates as shown in the following heatmaps:

lat
lon
And this is the map I get. Several data point to the center of the disk:
cth

This is the code I use:

using GeoMakie, CairoMakie, Colors
using HDF5
h5open("test.h5") do file
global cth = file["cth"][:,:]
global lat = file["lat"][:,:]
global lon = file["lon"][:,:]
end
colormap = :turbo
fig = Figure()
ax = GeoAxis(fig[2,1]; coastlines = true, lonlims = (-90,90), latlims=(-90,90), source = "+proj=lonlat +datum=WGS84", dest = "+proj=ortho")
sf = surface!(ax, lon, lat, cth; colormap = colormap, shading = false, colorrange = (300,20000))
cb = Colorbar(fig[1,1]; colormap = colormap, limits = (300,20000), label = "cth", vertical= false, height = 15, minorticksvisible=true) #height = Relative(0.15))
rowsize!(fig.layout, 2, Aspect(1,0.6))

A different projection (like eqc) does not solve the problem.
I plotted these very same data using Python Cartopy and it works fine.
If any of you could help me to fix this, I would greatly appreciate. The test data file "test.zip" attached contains the HDF5 data read in the code above.

test.zip

@haakon-e
Copy link
Contributor

haakon-e commented Nov 3, 2022

I simplified your setup a little and it basically seems to work for me locally:

julia> using GeoMakie, GLMakie, HDF5

julia> h5open("test.h5") do file
    global cth = file["cth"][:,:]
    global lat = file["lat"][:,:]
    global lon = file["lon"][:,:]
 end

julia> fig = Figure()

julia> ga = GeoAxis(fig[1,1]; coastlines=true, dest = "+proj=ortho", lonlims = (-10,10), latlims=(35,55));

julia> sf = surface!(ga, lon, lat, cth; shading=false);

image

julia/system info:
julia> versioninfo()
Julia Version 1.8.2
Commit 36034abf260 (2022-09-29 15:21 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores

(test) pkg> st
Status `~/Documents/test/Project.toml`
  [13f3f980] CairoMakie v0.9.1
  [e9467ef8] GLMakie v0.7.1
  [db073c08] GeoMakie v0.4.6
⌃ [f67ccb44] HDF5 v0.14.2
Info Packages marked with ⌃ have new versions available and may be upgradable.

@asinghvi17
Copy link
Member

Maybe try to crop your data to fit the image (i.e., no longitudes outside +-90)? I seem to recall that being an issue sometimes.

@eum64295
Copy link
Author

eum64295 commented Nov 4, 2022

Thank you very much for having looked at it.

@haakon-e Actually, my problem is precisely that I cannot use the GLMakie backend because I work on a virtual machine without graphic adapter and GLMakie woud not compile. Hence, CairoMakie.
Your (correct) results with GLMakie make me think the implementation of the surface function in CairoMakie may differ from that in GLMakie.

@asinghvi17 the image is already cropped (western Europe). In other regions near the disk edge, I take care of setting to NaN the out-of-range coordinates.
As a collaborator, do you think the difference in implementation might me the issue ?

@SimonDanisch
Copy link
Member

Actually, my problem is precisely that I cannot use the GLMakie backend because I work on a virtual machine without graphic adapter

Have you seen: https://docs.makie.org/v0.18.2/documentation/headless/index.html#glmakie ?

@eum64295
Copy link
Author

eum64295 commented Nov 8, 2022

Thank you very much for having looked at it.

@haakon-e Actually, my problem is precisely that I cannot use the GLMakie backend because I work on a virtual machine without graphic adapter and GLMakie woud not compile. Hence, CairoMakie.
Your (correct) results with GLMakie make me think the implementation of the surface function in CairoMakie may differ from that in GLMakie.

@asinghvi17 the image is already cropped (western Europe). In other regions near the disk edge, I take care of setting to NaN the out-of-range coordinates.
As a collaborator, do you think the difference in implementation might me the issue ?

@SimonDanisch

Actually, my problem is precisely that I cannot use the GLMakie backend because I work on a virtual machine without graphic adapter

Have you seen: https://docs.makie.org/v0.18.2/documentation/headless/index.html#glmakie ?

Thank you for the link. Unfortunately, I do not have control on the server in my organization, so installing virtualGL is not an option. I use the X2GO client.
It is really frustrating not to be able to directly display on screen simple plots although the GeoMakie is great.

@asinghvi17
Copy link
Member

asinghvi17 commented Jan 15, 2023

Should be solved by MakieOrg/Makie.jl#2598 - surface in CairoMakie was accidentally changing all instances of NaN to 0.

Here are some renders off that branch:

download-1

download-2

@eum64295
Copy link
Author

@asinghvi17 Hi, I update the packages as follows (Pkg status output):
CairoMakie v0.10.3
GLMakie v0.8.3
GeoMakie v0.5.0
Makie v0.19.3
WGLMakie v0.8.7

but applying the same code as in my initial post, I still get the "0-centered" data. Did you preprocess the data in a way or another, or use another code ?

@asinghvi17
Copy link
Member

It looks like that PR still hasn't merged, there were some bugs in the implementation for certain plot types. You could probably still run ]add Makie#as/cairomakie_surface_nan CairoMakie#as/cairomakie_surface_nan MakieCore#as/cairomakie_surface_nan and be fine, though.

@eum64295
Copy link
Author

@asinghvi17 Thank you for your prompt detailed response. Much appreciated ! It works as it could now. Thanks again.

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