Code Monkey home page Code Monkey logo

ecmwf / magics Goto Github PK

View Code? Open in Web Editor NEW
54.0 18.0 16.0 245.89 MB

Plotting package to visualise meteorological data in GRIB, NetCDF, BUFR and ODB format.

License: Apache License 2.0

CMake 0.16% Shell 0.05% C++ 15.17% Perl 0.37% Python 1.15% Fortran 2.66% C 0.51% GLSL 0.01% HTML 0.05% PostScript 0.01% JavaScript 0.15% CSS 0.01% Jupyter Notebook 79.69% Dockerfile 0.01% Makefile 0.01%
weather grib bufr odb netcdf visualization meteorology earth-science

magics's Introduction

Magics README

Linux & macOS: master Linux & macOS: develop Windows: master Windows: develop

Python Package: Pypi or conda

PyPI version Conda version Conda download

Gallery of Notebooks

Binder

Docker Image

DockerHub Docker Pulls

Installation

Please read the installation guide:

https://software.ecmwf.int/magics/Installation+Guide

License

Copyright 1996-2019 European Centre for Medium-Range Weather Forecasts (ECMWF).

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

magics's People

Contributors

avibahra avatar b8raoult avatar carletes avatar dtip avatar dvuckovic avatar eddycmwf avatar eduardrosert avatar iainrussell avatar ianvermes avatar jjdd avatar kynan avatar milanavuckovic avatar oiffrig avatar pmaciel avatar sandorkertesz avatar shahramn avatar simondsmart avatar stephansiemen avatar sylvielamythepaut avatar tlmquintino avatar wdeconinck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

magics's Issues

html codes not plotted for PS and EPS output

What happened?

Magics does not plot html codes correctly in title when PS and EPS output is chosen.

What are the steps to reproduce the bug?

This is reproduced using the following Python script (based on Axis example 2):

#importing Magics module
from Magics.macro import *

ref = 'axis2'

#Setting of the output file name
output = output(
                output_formats = ['png','ps','eps','pdf'], 
                output_name_first_page_number = "off",
                output_name = ref
               )

#Setting the cartesian view
projection = mmap(
                  subpage_y_position= 2., 
                  subpage_map_projection = 'cartesian',
                  subpage_x_axis_type = 'date',
                  subpage_y_axis_type = 'regular',
                  subpage_x_date_min = "2012-04-10",
                  subpage_x_date_max = "2012-04-28",
                  subpage_y_min = -20.,
                  subpage_y_max = 20.
                 )

#Vertical axis
vertical = maxis(
                 axis_orientation = "vertical",
                 axis_grid =  "on",
                 axis_type =  "regular",
                 axis_grid_colour = "grey",
                 axis_grid_thickness = 1,
                 axis_grid_reference_level = 0.,
                 axis_grid_reference_line_style='solid',
                 axis_grid_reference_thickness=2,
                 axis_grid_line_style = "dot"
                )

#Horizontal axis
horizontal = maxis(
                   axis_orientation = "horizontal",
                   axis_type =  "date",
                   axis_grid =  "on",
                   axis_days_label_height =  0.4,
                   axis_months_label_height =  0.4,
                   axis_years_label_height =  0.4,
                   axis_grid_colour = "grey",
                   axis_grid_thickness = 1,
                   axis_grid_line_style = "dot"
                  )

lines =["Using time series...for units μm - should be  micrometres with a Greek letter mu"]

title = mtext({
               "text_lines" : lines,
               "text_html" : "true",
               "text_justification": "left",
               "text_font_size": 0.75,
               "text_colour" : "charcoal"
             })

#To the plot
plot(output, projection, vertical, horizontal, title)

Run as:

python3 axis2.py

The title should read:

"Using time series...for units µm - should be micrometres with a Greek letter mu"

This is correct for PNG and PDF output but the "µ" is not printed in the PS or EPS output.

Also fails to print in PS/EPS if tried with HTML decimal (μ), HTML hex (μ;, or as "\u03BC).

See also plots attached to linked ticket MAGP-1343.

Version

4.14.1 and older

Platform (OS and architecture)

Linux ac6-200.bullx 4.18.0-372.52.1.el8_6.x86_64 #1 SMP Fri Mar 31 06:22:44 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux

Relevant log output

No response

Accompanying data

No response

Organisation

ECMWF (reporting on behalf of AEMET)

Contouring leaves blank some parts of a shade

What happened?

I have two data sets, whose names begin with "SS" and "DU", respectively. Metview leaves blank some parts of the shade. When it leaves some blank for one of the data sets, the shade for the other data set is fine, and vice-versa.

I have played with the contour_internal_reduction_factor option of the contouring object. When I set it to 4, the graphic for SS is fine, but the one for DU has some blank areas. When I set it to 1, the graphic for SS presents one blank area, and the one for DU is fine.

I have read in the documentation that the contouring parameter "contour_internal_reduction_factor" produces a more accurate result when set to one, and a less accurate one when set to four. So I think that it should not produce blank areas when set to one, but it does.

I attach 7 files:

The two data sets::
DU_ug_m-3.grb
SS_ug_m-3.grb
The python script that procudes the graphics: vert_hov_blank.py
The four output graphics:
For the DU_ug_m-3.grb dataset:
DU_ug_m-3.factor1.png made with contour_internal_reduction_factor = 1
DU_ug_m-3.factor4.png made with contour_internal_reduction_factor = 4
For the SS_ug_m-3.grb data set:
SS_ug_m-3.factor1.png made with contour_internal_reduction_factor = 1
SS_ug_m-3.factor4.png made with contour_internal_reduction_factor = 4
You can place all of them in the same directory and run the script.

In lines 7 and 8, the input file name is established. You can comment one of them in order to load the dataset stated in the other one.

In line 63, you can modify the contour_internal_reduction_factor.

I have to produce graphics for both types of data sets (and some others) in an automatic way. So, I need an automatic way to determine what contour_internal_reduction_factor is best for the data being used at any moment. Does that way exist or is there another solution for my problem?
SUP-3633.zip

What are the steps to reproduce the bug?

I've condensed it down into a smaller script that might make it easier to diagnose. I couldn't get the exact same plot without using a Hovmoeller View, but what I've attached produces something quite similar.

test.pyhov.nc

Version

4.15.0

Platform (OS and architecture)

Darwin

Relevant log output

No response

Accompanying data

No response

Organisation

No response

Loop fieldset wind direction

What happened?

Hello,
I would like to create loop all fieldset from wind direction
parameter, but i dont know how.
I know how to make from another fields, but wind direction setting is
different.
I would like to plot wind direction on wind gust plot.
I attached one script loop fieldset windgust.

I have one more question. How to set wind automatic setting
parameters in Magics 4.9.1?

What are the steps to reproduce the bug?

Data and program provided
SUP-3598.zip

Version

4.15.0

Platform (OS and architecture)

DARWIN

Relevant log output

No response

Accompanying data

No response

Organisation

No response

Strange line plots with Magics using python3/3.10.10-01

What happened?

Hello,

We've noticed some strange random results on a few EFAS line plots. I tracked it down to this example below where you can reproduce it. It's basically a "step plot" with dates on the x-axis, strangely the first point of the blue plot starts at a different tick x position, but only for the blue plot, even though both lines have the same dates.

I tried changing the plotting order, changing colours and other things and still just got errors with the blue plot. It looks like Magics does not like something about the data itself but what could it be!?

What are the steps to reproduce the bug?

//

from Magics.macro import *
xaxis = maxis(
axis_orientation='horizontal',
axis_type='date',
axis_days_label_height=0.47,
axis_months_label_height=0.47,
axis_years_label_height=0.47,
axis_grid='on',
axis_grid_colour='grey',
axis_grid_line_style='dot',
axis_days_sunday_label_colour='black',
axis_title='off',
)

yaxis = maxis(
axis_orientation='vertical',
axis_type='regular',
axis_position='left',
axis_tick_label_height=0.47,
axis_tick_position_list=[1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0, 500.0, 1000.0],
axis_grid='on',
axis_grid_colour='grey',
axis_grid_line_style='dot',
axis_title='on',
axis_title_text='Upstream precipitation [mm/h]',
axis_title_height=0.53,
)

projection = mmap(
super_page_x_length=30.0,
super_page_y_length=12.0,
subpage_x_position=3.18,
subpage_y_position=2.15,
subpage_x_length=30.0 - 3.18 - 2.66,
subpage_y_length=12.0 - 2.15 - 2.43,
subpage_map_projection='cartesian',
subpage_x_axis_type='date',
subpage_y_axis_type='regular',
subpage_x_date_min='2023-09-11 06:00',
subpage_x_date_max='2023-09-13 18:00',
subpage_y_min=0.0,
subpage_y_max=4.8519707202911375,
page_id_line="off",
)
eud = minput(
input_x_type = 'date',
input_date_x_values = [
'2023-09-12 06:00', '2023-09-12 12:00', '2023-09-12 12:00', '2023-09-12 18:00',
'2023-09-12 18:00', '2023-09-13 00:00', '2023-09-13 00:00', '2023-09-13 06:00',
'2023-09-13 06:00', '2023-09-13 12:00'
],
input_y_values = [
.00000300183592, .00000300183595, .549081087, .549081093,
.00137403957, .00137403958, 1.72107053, 1.72107055,
4.41088247, 4.41088252,
],
)

eudg = mgraph(
graph_line_colour='rgb(1.0, 0.0, 0.0)',
graph_line_thickness=2,
graph_symbol='off',
graph_symbol_colour='rgb(1.0, 0.0, 0.0)',
graph_symbol_height=0.5,
graph_symbol_marker_index=15,
graph_symbol_outline='on',
graph_symbol_outline_thickness=2,
legend='on',
legend_user_text='WB(ECMWF-DET)',
)

dwd = minput(
input_x_type = 'date',
input_date_x_values = [
'2023-09-12 06:00', '2023-09-12 12:00', '2023-09-12 12:00', '2023-09-12 18:00',
'2023-09-12 18:00', '2023-09-13 00:00', '2023-09-13 00:00', '2023-09-13 06:00',
'2023-09-13 06:00', '2023-09-13 12:00'
],
input_y_values = [
.881707549, .881707558, .265411973, .265411976,
.00317582721, .00317582724, 2.47310567, 2.47310569,
3.23703074, 3.23703078,
]
)

dwdg = mgraph(
graph_line_colour='rgb(0, 0., 1.0)',
graph_line_thickness=2,
graph_symbol='off',
graph_symbol_colour='rgb(0., 0., 1.0)',
graph_symbol_height=0.5,
graph_symbol_marker_index=15,
graph_symbol_outline='on',
graph_symbol_outline_thickness=2,
legend='on',
legend_user_text='WB(DWD-DET)',
)

myoutput = output(
output_formats=['png'],
output_name_first_page_number='off',
output_cairo_antialias='on',
output_name='example_Rups_errorDWD'
)

plot(
myoutput, projection, yaxis, xaxis,
dwd, dwdg,
eud, eudg
)

Version

4.15.0

Platform (OS and architecture)

Darwin

Relevant log output

No response

Accompanying data

No response

Organisation

No response

Magics does not plot all weekday names correctly for PNG/PDF output with LC_TIME=es_ES.UTF-8

What happened?

Magics does not plot all weekday names correctly for PNG/PDF output with LC_TIME=es_ES.UTF-8 (i.e., when CAIRO-PANGO is called).

What are the steps to reproduce the bug?

This is reproduced using the following Python script (based on Axis example 2):

#importing Magics module
from Magics.macro import *

ref = 'axis2'

#Setting of the output file name
output = output(
                output_formats = ['png','ps','eps','pdf'], 
                output_name_first_page_number = "off",
                output_name = ref
               )

#Setting the cartesian view
projection = mmap(
                  subpage_y_position= 2., 
                  subpage_map_projection = 'cartesian',
                  subpage_x_axis_type = 'date',
                  subpage_y_axis_type = 'regular',
                  subpage_x_date_min = "2012-04-10",
                  subpage_x_date_max = "2012-04-28",
                  subpage_y_min = -20.,
                  subpage_y_max = 20.
                 )

#Vertical axis
vertical = maxis(
                 axis_orientation = "vertical",
                 axis_grid =  "on",
                 axis_type =  "regular",
                 axis_grid_colour = "grey",
                 axis_grid_thickness = 1,
                 axis_grid_reference_level = 0.,
                 axis_grid_reference_line_style='solid',
                 axis_grid_reference_thickness=2,
                 axis_grid_line_style = "dot"
                )

#Horizontal axis
horizontal = maxis(
                   axis_orientation = "horizontal",
                   axis_type =  "date",
                   axis_grid =  "on",
                   axis_days_label_height =  0.4,
                   axis_months_label_height =  0.4,
                   axis_years_label_height =  0.4,
                   axis_grid_colour = "grey",
                   axis_grid_thickness = 1,
                   axis_grid_line_style = "dot"
                  )

lines =["Using time series...for units μm - should be  micrometres with a Greek letter mu"]

title = mtext({
               "text_lines" : lines,
               "text_html" : "true",
               "text_justification": "left",
               "text_font_size": 0.75,
               "text_colour" : "charcoal"
             })

#To the plot
plot(output, projection, vertical, horizontal, title)

Run as:

$ env LC_TIME=es_ES.UTF-8 python3 axis2.py 

Output shows error messages from CAIRO-PANGO:

b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc311\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc311</span>\n'
b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc318\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc318</span>\n'  
b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc325\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc325</span>\n'
b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc311\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc311</span>\n' 
b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc318\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc318</span>\n'
b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc325\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc325</span>\n'

Plot shows the day of the week for Wednesday - (mi)ércoles - isn't plotted:

Compare with eps output which correctly shows "mi":

This also happens with other locales (LC_TIME settings) - not just es_ES.UTF-8.

See also plots attached to MAGP-1343 and SD-60066.

Version

4.14.1 and older

Platform (OS and architecture)

Linux ac6-200.bullx 4.18.0-372.52.1.el8_6.x86_64 #1 SMP Fri Mar 31 06:22:44 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux

Relevant log output

No response

Accompanying data

No response

Organisation

ECMWF (reporting on behalf of AEMET)

Issue with user-defined text legend scale

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.