ecmwf / magics

Plotting package to visualise meteorological data in GRIB, NetCDF, BUFR and ODB format.
Apache License 2.0
58 stars 15 forks source link

Issue with user-defined text legend scale #106

Open Lucanta opened 10 months ago

Lucanta commented 10 months ago

What happened?

There is a magics bug in python/metview by which when specifying a user-defined text legend scale (egend_text_composition="user_text_only"), the penultimate value of the legend is missing and is instead moved to the last position, while the last element doesn't appear at all. See image attached below.

spr_norm_t

What are the steps to reproduce the bug?

Below the python script I run. NB. file is available in a public path in my home


import metview as mv

ens_t = mv.read(source="ens_t.grib",number=[1,2,3,4,5,6,7,8,9,10])

spr_t = mv.stdev(ens_t) max_t = mv.maxvalue(ens_t) spr_t_norm = spr_t/max_t

print(mv.minvalue(spr_t_norm),mv.maxvalue(spr_t_norm))

cont_spread = mv.mcont( legend = "on", contour = "off", contour_label = "off", contour_level_selection_type = "level_list", contour_max_level = 1000., contour_min_level = 0., contour_level_list = [0,0.001,0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.009,0.01], contour_shade = "on", contour_shade_colour_method = "palette", contour_shade_method = "area_fill", contour_shade_palette_name = "colorbrewer_ext_YlGn_10_r", )

coast = mv.mcoast( map_coastline_colour="charcoal", map_coastline_resolution="medium", map_coastline_land_shade="on", map_coastline_land_shade_colour="beige", map_coastline_sea_shade="on", map_coastline_sea_shade_colour="RGB(0.8178,0.9234,0.9234)", map_grid_colour="RGB(0.4,0.4,0.4)", map_label_height=0.35, )

title = mv.mtext(text_line_1="Normalised spread",text_font_size=1.2) legend = mv.mlegend(legend_text_font_size=0.5,legend_title_font_size=1.0,legend_text_composition="user_text_only",legend_user_lines=["0","0.1%","0.2%","0.3%","0.4%","0.5%","0.6%","0.7%","0.8%","0.9%","1%"])

view = mv.geoview(coastlines=coast)

dw = mv.plot_superpage(pages=mv.mvl_regular_layout(view,1,1,1,1,[0,100,0,100]))

mv.setoutput(mv.png_output(output_name="spr_norm_t",output_name_first_page_number="off",output_width=1600)) mv.plot(dw,spr_t_norm,cont_spread,legend,title)

Version

Python 3.6.8, metview-python 1.14.0

Platform (OS and architecture)

Linux VDI (release 1.40)

Relevant log output

No log available (no error is produced).

Accompanying data

/home/dalc/Public/ens_t.grib

Organisation

ECMWF

sylvielamythepaut commented 9 months ago

Hi, Thanks for your bug report. I think I have enough information to reproduce the problem. Sylvie

sylvielamythepaut commented 9 months ago

Hi, I am trying to fix this issue, but I have a question that will help me to understand : Was it working in a previous version of Metview ?
Thanks a lot for your help Sylvie

Lucanta commented 8 months ago

Hi Sylvie,

I only joined in June 2021 but as far as I remember, this has never worked since I have been at the centre.

Have a good weekend! Luca

On Tue, 5 Mar 2024, 18:14 Sylvie, @.***> wrote:

Hi, I am trying to fix this issue, but I have a question that will help me to understand : Was it working in a previous version of Metview ? Thanks a lot for your help Sylvie

— Reply to this email directly, view it on GitHub https://github.com/ecmwf/magics/issues/106#issuecomment-1979255751, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADE3OYRRYII2E4XVOEI6TY3YWX4OPAVCNFSM6AAAAABC3VMJJSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZZGI2TKNZVGE . You are receiving this because you authored the thread.Message ID: @.***>

sylvielamythepaut commented 8 months ago

Thanks a lot , that is the information I was looking for before implementing the fix . I should be able to get that fix soon and will liaise with the Metview teamSylvieOn 8 Mar 2024, at 09:05, Luca Cantarello @.***> wrote: Hi Sylvie,

I only joined in June 2021 but as far as I remember, this has never worked

since I have been at the centre.

Have a good weekend!

Luca

On Tue, 5 Mar 2024, 18:14 Sylvie, @.***> wrote:

Hi,

I am trying to fix this issue, but I have a question that will help me to

understand :

Was it working in a previous version of Metview ?

Thanks a lot for your help

Sylvie

Reply to this email directly, view it on GitHub

https://github.com/ecmwf/magics/issues/106#issuecomment-1979255751, or

unsubscribe

https://github.com/notifications/unsubscribe-auth/ADE3OYRRYII2E4XVOEI6TY3YWX4OPAVCNFSM6AAAAABC3VMJJSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZZGI2TKNZVGE

.

You are receiving this because you authored the thread.Message ID:

@.***>

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>