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

contour don't work #459

Closed
htyeim opened this issue Oct 12, 2020 · 2 comments
Closed

contour don't work #459

htyeim opened this issue Oct 12, 2020 · 2 comments

Comments

@htyeim
Copy link
Contributor

htyeim commented Oct 12, 2020

This may be related to #373

using GMT

gmtbegin()
gmtfig("contour_test", fmt="png")
x, y, z = GMT.peaks(grid=false);
cpt_mlat = makecpt(color=:jet, range=(-9, 9), background=(:blue, :red)); 
contour([x[:] y[:] z[:]],
                    pen=(colored = true,),
                    annot=(labels = (font = 5, prefix = "TEST ",),),
                    # contours=cpt_mlat,
                    Vd=1,
                    )
gmtend()

the output:

        contour  -A+f5+="TEST " -W+c
contour [ERROR]: Option -W: Modifier +c only valid if -C sets a CPT
ERROR: LoadError: Something went wrong when calling the module. GMT error number = 71
Stacktrace:
 [1] error(::String, ::Int32) at ./error.jl:42
 [2] gmt(::String, ::Array{Float64,2}, ::Vararg{Any,N} where N) at /Users/t/.julia/packages/GMT/uSATO/src/gmt_main.jl:267
 [3] finish_PS_module(::Dict{Symbol,Any}, ::String, ::String, ::Bool, ::Bool, ::Bool, ::Array{Float64,2}, ::Vararg{Any,N} where N) at /Users/t/.julia/packages/GMT/uSATO/src/common_options.jl:2746
 [4] contour(::String, ::Array{Float64,2}; first::Bool, kwargs::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:pen, :annot, :Vd),Tuple{NamedTuple{(:colored,),Tuple{Bool}},NamedTuple{(:labels,),Tuple{NamedTuple{(:font, :prefix),Tuple{Int64,String}}}},Int64}}}) at /Users/t/.julia/packages/GMT/uSATO/src/pscontour.jl:154
 [5] #contour#243 at /Users/t/.julia/packages/GMT/uSATO/src/pscontour.jl:159 [inlined]

========

using GMT

gmtbegin()
gmtfig("contour_test", fmt="png")
x, y, z = GMT.peaks(grid=false);
cpt_mlat = makecpt(color=:jet, range=(-9, 9), background=(:blue, :red)); 
contour([x[:] y[:] z[:]],
                    pen=(colored = true,),
                    annot=(labels = (font = 5, prefix = "TEST ",),),
                    contours=cpt_mlat,
                    Vd=1,
                    )
gmtend()

the output:

ERROR: LoadError: Bad argument type (GMT.GMTcpt) to option C
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] add_opt(::String, ::Char, ::Dict{Symbol,Any}, ::Array{Symbol,2}, ::Symbol, ::Array{Any,1}, ::NamedTuple{(:x,),Tuple{String}}, ::Bool) at /Users/t/.julia/packages/GMT/uSATO/src/common_options.jl:1474
 [3] add_opt(::String, ::Char, ::Dict{Symbol,Any}, ::Array{Symbol,2}, ::Symbol, ::Array{Any,1}, ::NamedTuple{(:x,),Tuple{String}}) at /Users/t/.julia/packages/GMT/uSATO/src/common_options.jl:1447
 [4] contour(::String, ::Array{Float64,2}; first::Bool, kwargs::Base.Iterators.Pairs{Symbol,Any,NTuple{4,Symbol},NamedTuple{(:pen, :annot, :contours, :Vd),Tuple{NamedTuple{(:colored,),Tuple{Bool}},NamedTuple{(:labels,),Tuple{NamedTuple{(:font, :prefix),Tuple{Int64,String}}}},GMT.GMTcpt,Int64}}}) at /Users/t/.julia/packages/GMT/uSATO/src/pscontour.jl:109
 [5] #contour#243 at /Users/t/.julia/packages/GMT/uSATO/src/pscontour.jl:159 [inlined]

This code worked fine months ago, but when I return the program today, the same code break....
I have checked the git history of "pscontour.jl" but can not figure out which change of the code causes the problem and don't know how to fix it...

@joa-quim
Copy link
Member

Hmm, did your first case ever worked? Strange because since it's using the modern mode it should have been dealt directly by GMT. It should also been taken care by a fall back mechanism in GMT.jl but it was not.

Try the latest #master but compute the cpt like

cpt_mlat = makecpt(color=:jet, range=(-9, 9, 1), background=(:blue, :red)); 

by using only range=(-9, 9) it creates a 256 levels cpt and GMT complains about the cmap not being discrete. A probably overzealous test that needs to be checked.

Finally, try the contourf module. It should be handier (and powerful) than contour.

@htyeim
Copy link
Contributor Author

htyeim commented Oct 14, 2020

After "add GMT#master", the first case works..... I think it's okay to use range=(-9,9) as the code works fine on my laptop. My work environment has changed a lot, I needed to dig into a large project and locate the related code and then test. Thanks for the reply~

@htyeim htyeim closed this as completed Oct 14, 2020
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