Code Monkey home page Code Monkey logo

magics-python's Introduction

Magics is the latest generation of the ECMWF's meteorological plotting software and can be either accessed directly through its Python or Fortran interfaces or by using Metview.

Features:

  • supports plotting of contours, wind fields, observations, satellite images, symbols, text, axis and graphs (including boxplots)
  • can plot GRIB 1 and 2 coded data, gaussian grid, regularly spaced grid and fitted data

Limitations:

  • development stage: Alpha,

Installation

The package is installed from PyPI with:

$ pip install Magics

System dependencies

The python module depends on the ECMWF Magics and eccodes libraries

They can be installed from PyPI with::
$ pip install ecmwflibs

You may run a simple selfcheck command to ensure that your system is set up correctly:

$ python -m Magics selfcheck
Found: Magics 'Magics 4.10.0'.
Library: /usr/local/lib/python3.9/site-packages/ecmwflibs/.dylibs/libMagPlus.dylib
Magics home: /usr/local/lib/python3.9/site-packages/ecmwflibs
Your system is ready.

Usage

First, you need a well-formed GRIB file, if you don't have one at hand you can download our a 2m temperature grib file:

$ wget http://download.ecmwf.int/test-data/magics/2m_temperature.grib

You may try out the high level API in a python interpreter:

from Magics import macro as magics

name = 'magics'
#Setting of the output file name
output = magics.output(output_formats = ['png'],
             output_name_first_page_number = "off",
             output_name = "magics")

#Import the  data
data =  magics.mgrib(grib_input_file_name  = "2m_temperature.grib", )

#Apply an automatic styling
contour = magics.mcont( contour_automatic_setting = "ecmwf", )
coast = magics.mcoast()
magics.plot(output, data, contour, coast)

Running the test program will create a png named magics.png

You can find notebooks examples : https://github.com/ecmwf/notebook-examples/tree/master/visualisation

Contributing

The main repository is hosted on GitHub, testing, bug reports and contributions are highly welcomed and appreciated:

https://github.com/ecmwf/magics-python

Please see the CONTRIBUTING.rst document for the best way to help.

Lead developer:

Main contributors:

License

Copyright 2017-2018 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-python's People

Contributors

alexamici avatar avibahra avatar b8raoult avatar dtip avatar dvuckovic avatar iainrussell avatar ianvermes avatar stephansiemen avatar sylvielamythepaut 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

Watchers

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

magics-python's Issues

How to list all parameter Names of "magics.mgrib()" and "magics.mmetbufr".

1- I want to select an isobaric level from grib file to plot temperature I tried :

temperature = magics.mgrib(
grib_input_file_name = './pygrib/gfs.t00z.pgrb2.0p25.f006',
grib_input_isobaric_in_hPa = 850,
grib_field_position = 1
)
==> gives error for 'grib_input_isobaric_in_hPa'

2- I want to plot jet streams from SADIS Bufr file I tried using 'magics.mmetbufr' but I didn't figure it out .

Any help is very appreciated .THX

Coastline not showing

Hi,

I try to understand why in my plots i can't see any coastline.
For example this code :

import Magics.macro as magics
magics.plot(magics.mcoast())

give me this plot:
github_issue_mcoast

OS: ubuntu 18.04
Magics installation: conda install -y -c conda-forge Magics=4.0.0

i would like to know if you have some test i can run to help me find why i can't draw coasts ?

Thanks

Generating a wind flags plot using ERA5 GRIBS data

I am trying to generate a wind flags plot from ERA5 GRIBS data using the code shown here in this link

https://confluence.ecmwf.int/display/MAGP/Wind+6+-+Temperature+and+wind+flags

`#importing Magics module
from Magics.macro import *

#Example reference
ref = 'wind2'

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

#Setting the coordinates of the geographical area
world = mmap(subpage_upper_right_longitude= 180.,
subpage_upper_right_latitude= 90.,
subpage_lower_left_longitude= -180.,
subpage_map_projection= 'cylindrical',
subpage_lower_left_latitude= -90.)

#Background Coastlines
background = mcoast( map_coastline_sea_shade_colour= 'white',
map_coastline_land_shade_colour= 'cream',
map_grid= 'off',
map_coastline_land_shade= 'on',
map_coastline_sea_shade= 'on',
map_label= 'off',
map_coastline_colour= 'tan')
#Define the shading for the wind speed
speed200_contour = mcont(
legend= 'on',
contour_level_selection_type= 'level_list',
contour_level_list= [30., 40., 50., 60., 70., 80., 90., 100.],
contour_shade= 'on',
contour_shade_min_level_colour= 'blue_green',
contour_shade_max_level_colour= 'blue_purple',
contour_shade_method= 'area_fill',
contour_reference_level= 0.,
contour_highlight= 'off',
contour_hilo= 'off',
contour_hilo_format= '(F3.0)',
contour_hilo_height= 0.2,
contour_hilo_type= 'number',
contour_hilo_suppress_radius= 30.,
contour_hi_min_value= 15.,
contour_label= 'off')

#Import the wind at 200hPa uv200
uv200 = mgrib( grib_input_file_name = './download.grib',grib_wind_position_1=1,grib_wind_position_2=2)

uv200_wind = mwind(
legend= 'on',
wind_field_type = 'flags',
wind_flag_length = 0.8,
wind_thinning_factor= 6.,
wind_flag_calm_below = 15,
wind_flag_origin_marker = 'circle',
wind_flag_min_speed = 10.0,
wind_flag_colour = 'chestnut')

title = mtext( text_lines = ["Wind flags where speed is over 10 m/s"],
text_justification = 'left',
text_font_size = 0.5,
text_colour = 'charcoal')

#add a legend
legend = mlegend(legend= 'on',
legend_text_colour= 'charcoal',
legend_box_mode= 'positional',
legend_box_x_position= 27.5,
legend_box_y_position= 4.,
legend_box_x_length= 2.,
legend_box_y_length= 12.,
legend_border= 'off',
legend_border_colour= 'charcoal',
legend_box_blanking= 'on',
legend_display_type= 'continuous',
legend_title = 'on',
legend_title_text= 'Wind speed at 200 hPa',
legend_text_font_size = '0.5')

#To the plot
plot(output, world, background,uv200, uv200_wind, title, legend)
`

But in the image I get the wind flags outside the world map and they are all clustered together and not visible.

I would like my output to be either like this https://confluence.ecmwf.int/display/MAGP/Wind+3+-+Wind+flags or having them colored like this - https://confluence.ecmwf.int/display/MAGP/Wind+4+-+Coloured+wind+flags
https://imgur.com/a/JJWFFpw

Lambert projection is not working in magics 4.1.2.

Hi,
I use "conda install -c conda-forge magics" install magics 4.1.2. And in jupyter notebook, when I run the example "projection-lambert.ipynb", I get the erros:

import Magics.macro as magics

# Setting the projection
projection = magics.mmap(
    subpage_map_projection        = "lambert",
    subpage_lower_left_latitude   = -0.00,
    subpage_lower_left_longitude  = -80.00,  
    subpage_upper_right_latitude  = 70.00,
    subpage_upper_right_longitude = 160.00,
    subpage_map_area_definition   = "corners",
    page_id_line                  = "on")

# Defining the coastlines
coast = magics.mcoast(
    map_coastline_resolution        = "automatic",
    map_coastline_colour            = "tan",
    map_coastline_land_shade        = "on",    
    map_coastline_land_shade_colour = "cream",
    map_grid                        = "on",
    map_grid_line_style             = "dot",
    map_grid_colour                 = "tan"
)

magics.plot(projection, coast)
---------------------------------------------------------------------------
MagicsError                               Traceback (most recent call last)
<ipython-input-1-307c16173ba6> in <module>
     22 )
     23 
---> 24 magics.plot(projection, coast)

~/anaconda3/lib/python3.7/site-packages/Magics/macro.py in _jplot(*args)
    609         all.extend(args)
    610 
--> 611         _plot(all)
    612 
    613         image = Image(tmp)

~/anaconda3/lib/python3.7/site-packages/Magics/macro.py in _plot(*args)
    518     Magics.init()
    519     for n in args:
--> 520         _execute(n)
    521 
    522     #Collect the drivers!

~/anaconda3/lib/python3.7/site-packages/Magics/macro.py in _execute(o)
    506         if isinstance(o, list) or isinstance(o, tuple):
    507                 for x in o:
--> 508                         _execute(x)
    509 
    510         else:

~/anaconda3/lib/python3.7/site-packages/Magics/macro.py in _execute(o)
    510         else:
    511 
--> 512                 o.execute()
    513 
    514 def _plot(*args):

~/anaconda3/lib/python3.7/site-packages/Magics/macro.py in execute(self)
    396                 if self.action == Magics.legend :
    397                     Magics.setc("legend", "on")
--> 398                 self.action()
    399                 if self.action != Magics.obs and self.action != Magics.minput:
    400                     for key in list(self.args.keys()):

~/anaconda3/lib/python3.7/site-packages/Magics/Magics.py in wrapped(*args)
    178         err = fn(*args)
    179         if err:
--> 180             raise MagicsError(err)
    181 
    182     return wrapped

MagicsError: Magics Error - No Plot Produced!!! (1083945801)

So how can i solve this, very thanks!

Trying to generate a vertical cross section plot of a geopotential height anomaly

I am trying to generate a vertical cross section of a geopotential height anomaly from NOAA reanalysis data. as shown in this link https://imgur.com/a/ASUVWFn

The data is organized as follows - the latitude is chosen from 25 to 40 degrees north. And the longitude is from 60 to 100 degrees east. So the pressure data is at 17 levels. And it is a netCDF data file that is having the variable name 'hgt'. What I want is a plot of longitude by height and by that I mean - I have a longitude range (will be x-axis) and then I choose a latitude range over which the data is averaged over. If the two latitudes are the same, then the plot is of a single latitude..

When I run the following code this is the plot I get - https://imgur.com/a/1qRMKHt

This is the link of netCDF file - https://filebin.net/jsj7lzf62zfhvj3n

Where am I going wrong ?

`# importing Magics module

from Magics.macro import *

ref = 'xsection'

def xsection(title_size=0.4, axis_size=0.6, tick_size=0.2, thumbnail = True) :
# Setting the cartesian view

projection = mmap(
	subpage_map_projection='cartesian',
	subpage_x_axis_type='geoline',
	subpage_y_axis_type='logarithmic',
	subpage_x_min_latitude=25.,
	subpage_x_max_latitude=40.,
	subpage_x_min_longitude=60.,
	subpage_x_max_longitude=100.,
	subpage_y_min=1000.,
	subpage_y_max=10.,
	)
	

# Vertical axis

vertical = maxis(
	axis_orientation='vertical',
	axis_grid='on',
	axis_type='logarithmic',
	axis_tick_label_height=tick_size,
	axis_tick_label_colour='charcoal',
	axis_grid_colour='charcoal',
	axis_grid_thickness=1,
	axis_grid_reference_level=0.,
	axis_grid_reference_line_style='solid',
	axis_grid_reference_thickness=1,
	axis_grid_line_style='dash',
	axis_title='on',
	axis_title_text='Pressure',
	axis_title_height=axis_size,
	)

# Horizontal axis

horizontal = maxis(
	axis_orientation='horizontal',
	axis_type='geoline',
	axis_tick_label_height=tick_size,
	axis_tick_label_colour='charcoal',
	axis_grid='on',
	axis_grid_colour='charcoal',
	axis_grid_thickness=1,
	axis_grid_line_style='dash',
	)
# Definition of the Netcdf data and interpretation
data = mnetcdf(netcdf_filename = "section.nc",
  netcdf_value_variable = "hgt",
  netcdf_field_scaling_factor = 100000.,
  netcdf_y_variable = "levels",
  netcdf_x_variable = "longitude",
  netcdf_x_auxiliary_variable = "latitude"
)
# Definition of the contour 
contour = mcont(contour= "on",
			contour_highlight= "off",
			contour_hilo= "off",
			contour_label= "off",
			legend='on',
			contour_level_list= [-200., -100., -75., -50., -30., -20., 
				-15., -13., -11., -9., -7., -5., -3., -1., 1., 3., 5., 
				7., 9., 11., 13., 15., 20., 30., 50., 75., 100., 200],
			contour_level_selection_type= "level_list",
			contour_shade= "on",
			contour_shade_colour_list= ["rgb(0,0,0.3)", "rgb(0,0,0.5)", 
				"rgb(0,0,0.7)", "rgb(0,0,0.9)", "rgb(0,0.15,1)", 
				"rgb(0,0.3,1)", "rgb(0,0.45,1)", "rgb(0,0.6,1)", 
				"rgb(0,0.75,1)", "rgb(0,0.85,1)", "rgb(0.2,0.95,1)", 
				"rgb(0.45,1,1)", "rgb(0.75,1,1)", "none", "rgb(1,1,0)", 
				"rgb(1,0.9,0)", "rgb(1,0.8,0)", "rgb(1,0.7,0)", 
				"rgb(1,0.6,0)", "rgb(1,0.5,0)", "rgb(1,0.4,0)", 
				"rgb(1,0.3,0)", "rgb(1,0.15,0)", "rgb(0.9,0,0)", 
				"rgb(0.7,0,0)", "rgb(0.5,0,0)", "rgb(0.3,0,0)"],
			contour_shade_colour_method= "list",
			contour_shade_method= "area_fill")
lines = \
	['Example of Xsection to demonstrate the use of NetCDF data...', 
	'<magics_title/>']
	 

title = mtext(
	text_lines= lines,
	text_html= 'true',
	text_justification= 'left',
	text_font_size= title_size,
	text_colour= 'charcoal',
	)
if ( thumbnail ) :
	legend = mlegend(legend='on', 
			legend_display_type='continuous', 
			legend_text_colour='charcoal',		 
			legend_text_font_size=tick_size, 
			legend_box_mode = "positional",
			legend_box_x_position = 13.00,
			legend_box_y_position = 2.5,
			legend_box_x_length = 1.00,
			legend_box_y_length = 6.00,
			legend_box_blanking = "on",
			legend_border = "on",
			legend_border_colour='charcoal'
		)
else :
	legend = mlegend(legend='on', 
			legend_display_type='continuous', 
			legend_text_colour='charcoal',		 
			legend_text_font_size=0.4, 
			legend_box_mode = "positional",
			legend_box_x_position = 27.00,
			legend_box_y_position = 3.00,
			legend_box_x_length = 2.00,
			legend_box_y_length = 13.00,
			legend_box_blanking = "on",
			legend_border = "on",
			legend_border_colour='charcoal'
		)
return [projection, vertical, horizontal, data, contour, legend, title]

if ( name == "main"):
# Setting of the output file name
output = output(output_formats=['png'],
output_name_first_page_number='off',
output_name=ref)
# To the plot
plot(output, xsection(title_size=1.0, axis_size=0.8, tick_size=0.4, thumbnail=False))
`

How to put wind field into minput?

Hi,
I want to plot wind flags with data fields. But I can not find the examples which show how to put data filed into minput, just like:

  data =  magics.minput(
        input_type = "geographical",
        input_x_component_field = uwind_field,    # 2D array, [nlat, nlon]
        input_y_component_field = vwind_field,    # 2D array, [nlat, nlon]
        input_latitude_list = lat,         # 1D vector
        input_longitude_list = lon,     # 1D vector
        input_metadata = metadata)

but this is not working. Very thanks!

Dave

mcont using U/V wind component

Hey, I'm trying to make a wind speed map using the U and V wind components coming from the same grib file.
I had no problem making one using mwind, but If I'm not mistaken I can only plot flags/streamlines/arrows using this one. I tried the same kind of code replacing mwind with mcont, but the output only seems to either take the U component or the V component.

I'm using this to open the grib file:
uv = mgrib(grib_input_file_name = "SP1.grib2", grib_wind_mode = "uv", grib_wind_position_1 = 97, grib_wind_position_2 = 98, grib_automatic_scaling='off', grib_scaling_factor=3.6, )

Plotting using mwind:
wgust_shade = mwind(wind_arrow_unit_system= "automatic", wind_arrow_unit_velocity= 10.0, wind_field_type= "Flags", wind_flag_colour= "black", wind_flag_length= 0.3, wind_flag_origin_marker= "dot", wind_flag_origin_marker_size= 0.1, wind_legend_text= "Black wind flags (in knots)", wind_thinning_factor= 1., wind_thinning_method= "automatic", contour_hilo= "off", legend = "on", wind_advanced_method = "on", wind_advanced_colour_parameter = "speed", wind_advanced_colour_selection_type = "count", wind_advanced_colour_table_colour_method = "calculate" )

And something I tried with mcont:
wgust_shade = mcont( contour_level_selection_type= "level_list", contour="off", contour_hilo= "off", contour_label="off", contour_level_list=[0., 5., 10., 15., 20., 25., 30., 35., 40., 45., 50., 55., 60., 65., 70., 75., 80., 85., 90., 95., 100., 105., 110., 115., 120., 125., 130., 135., 140., 145., 150.,], contour_shade= "on", contour_shade_method= "area_fill", contour_shade_colour_method= "palette", contour_shade_palette_name = "eccharts_rainbow_white_grey_30", legend='on', contour_legend_text="Wind test")

Is there a way to get the mcont one working with the actual wind speed, and not only the U or V component ?

Thanks, and sorry if this is not the right place to ask for it!

Can not input xarray data

Hi,
I try to input xarray to magics, like:

from Magics import macro as magics
import xarray as xr

data = xr.open_mfdataset('2t.nc')
data = magics.mxarray(data, 't2m')

but I get the following errors, so why? Much thanks!


NameError Traceback (most recent call last)
in
1 data = xr.open_mfdataset('2t.nc')
----> 2 data = magics.mxarray(data, 't2m')

~/anaconda3/lib/python3.7/site-packages/Magics/macro.py in mxarray(dataset, var)
423
424
--> 425 return data
426
427

NameError: name 'data' is not defined

`dll.version` symbol not accessible starting with libMagPlus 4.7.0

Hi there,

when invoking python -m Magics selfcheck on our recent installation [1] on macOS, it slightly croaks like:

$ python -m Magics selfcheck
Found: Magics 'You are using an old version of magics ( < 4.0.0)'.
Library: /usr/local/opt/magics-4.9.3/lib/libMagPlus.dylib
Magics home: /usr/local/opt/magics-4.9.3
Your system is ready.

Other than this, the library appears to be fully functional, so we just wanted to bring this to your attention. Also, #37 and #38 are two outcomes from us approaching this issue, maybe you like them.

With kind regards,
Andreas.

[1] Python 3.9.7, MagPlus 4.9.3, Magics HEAD

Can not make wind plot using mnetcdf,mwind.

problem fixed!

Hi!
I want to make vector figure to display netcdf wind data.
So, I write a code showing below.

from Magics.macro import *
ncfile = "../data/surface_2020-12-28_0" #netcdf
output = output(
                output_formats                = ['png'],
                output_name                   = "windtest",
                output_name_first_page_number = "off",
                output_width                  = 800)
center = page(
             layout           = 'automatic',
             page_x_length    = 45.,
             page_y_length    = 20.,
             page_id_line     = 'off',# erase ECMWF logo↲
             page_x_position  = 0.,
             page_y_position  = 0.,)
area = mmap(
            subpage_map_projection        = "cylindrical",
            subpage_lower_left_longitude  = 120,
            subpage_lower_left_latitude   = 25,
            subpage_upper_right_longitude = 150,
            subpage_upper_right_latitude  = 50,)

coast = mcoast(
            map_coastline_land_shade         = "on",
            map_coastline_land_shade_colour  = "cream",
            map_grid_line_style              = "dash",
            map_grid_colour                  = "charcoal",
            map_grid_thickness               = 2.0,
            map_grid_latitude_increment      = 10,
            map_grid_longitude_increment     = 10,
            map_label                        = "on",
            map_coastline_colour             = "black",
            map_coastline_thickness          = 2.7,
            )
# My problem!
vector = mnetcdf(
        netcdf_type                 = "vector",
        netcdf_filename             = ncfile,
        netcdf_x_component_variable = "u10", #something wrong?
        netcdf_y_component_variable = "v10", #something wrong?
        )

wind = mwind(
        legend                = "on",
        wind_field_type       = "arrows",
        wind_arrow_thickness  = 1,
        wind_thinning_factor  = 1,
        wind_arrow_calm_below = 0.5, # min
        wind_arrow_head_ratio = 0.3,
        wind_arrow_colour     = 'evergreen',)
plot(center,output,area,coast,vector,wind)

Then, I run this code. Unkown Error is occured.↓

# error
Magics-warning: Netcdf MagException:  Can not find variable ---> x
Magics-ERROR: Netcdf MagException:  Can not find variable ---> x

I think "netcdf_x_component_variable" is needed other information but, I'm not sure what kind of information is needed.

Here is information of data .
I tryid to replace "u10" "v10" to 1,2(index number), but I cannot fix this problem.

$ cdo infon data/surface_2020-12-28_0
    -1 :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter name
     1 : 2020-12-28 00:00:00       0   259920       0 :     -23.178   -0.059718      22.385 : u10           
     2 : 2020-12-28 00:00:00       0   259920       0 :     -23.545    -0.27896      23.001 : v10           
     3 : 2020-12-28 00:00:00       0   259920       0 :      220.35      276.99      310.51 : t2m           
     4 : 2020-12-28 00:00:00       0   259920       0 :      5.0713      82.041      100.01 : r2            
     5 : 2020-12-28 00:00:00       0   259920       0 :      94224.  1.0107e+05  1.0836e+05 : prmsl         
     6 : 2020-12-28 00:00:00       0   259920       0 :      48682.      96751.  1.0571e+05 : sp            
     7 : 2020-12-28 00:00:00       0   259920       0 :      0.0000      36.312      100.00 : lcc           
     8 : 2020-12-28 00:00:00       0   259920       0 :      0.0000      22.342      100.00 : mcc           
     9 : 2020-12-28 00:00:00       0   259920       0 :      0.0000      21.905      100.00 : hcc           
cdo    infon: Processed 9 variables over 1 timestep [0.03s 53MB].

I also gogled this problem but, I cannot find answer.
If you have the idea to fix this problem, plase tell me.
※My environment is macOS catarina and Ubuntu20.04, python3 version is 3.8.

cannot create magics.mxarray object

Hi,

I'm trying to plot images based on a xarray object.
But the magics.mxarray function returns an error.

Here is the code:

import xarray as xr
import Magics.macro as magics
# open dataset from https://github.com/ecmwf/notebook-examples/tree/master/data/total_precipitation.grib
df = xr.open_dataset('total_precipitation.grib', engine='cfgrib')

magics.mxarray(df, 'tp')

Complete traceback:

Exception ignored on calling ctypes callback function: <function error at 0x7f44ac0c90d0>
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/Magics/macro.py", line 59, in error
    print(msg.decode())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 1394: invalid start byte
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-9517270a2356> in <module>
----> 1 magics.mxarray(df, 'tp')

/opt/conda/lib/python3.8/site-packages/Magics/macro.py in mxarray(xarray_dataset, xarray_variable_name, xarray_dimension_settings)
    565     # lat/lon data in xarray_dataset.data_vars instead.
    566     for ds_attributes in [xarray_dataset.coords, xarray_dataset.data_vars]:
--> 567         ret = _mxarray(
    568             xarray_dataset,
    569             xarray_variable_name,

/opt/conda/lib/python3.8/site-packages/Magics/macro.py in _mxarray(xarray_dataset, xarray_variable_name, ds_attributes, xarray_dimension_settings)
    580     xarray_dataset, xarray_variable_name, ds_attributes, xarray_dimension_settings
    581 ):
--> 582     lat_name, lon_name = detect_lat_lon(xarray_dataset, ds_attributes)
    583 
    584     if lat_name and lon_name:

/opt/conda/lib/python3.8/site-packages/Magics/macro.py in detect_lat_lon(xarray_dataset, ds_attributes)
    552         for ds_attribute in ds_attributes
    553     }
--> 554     lat_name = detect(attrs, "latitude")
    555     lon_name = detect(attrs, "longitude")
    556     return lat_name, lon_name

/opt/conda/lib/python3.8/site-packages/Magics/macro.py in detect(attributes, dimension)
    544 
    545 def detect(attributes, dimension):
--> 546     return Magics.detect(json.dumps(attributes, default=encode_numpy), dimension)
    547 
    548 

/opt/conda/lib/python3.8/site-packages/Magics/Magics.py in wrapped(*args)
    138         r = fn(*new_args)
    139         if fn.restype is c_char_p:
--> 140             r = char_to_string(r)
    141         return r
    142 

/opt/conda/lib/python3.8/site-packages/Magics/Magics.py in _char_to_string(x)
    112 
    113 def _char_to_string(x):
--> 114     return x.decode()
    115 
    116 

AttributeError: 'NoneType' object has no attribute 'decode'

Platform and versions:
Ubuntu 20.04.1 LTS
python 3.8
Magics==1.5.5
xarray==0.15.1
numpy==1.19.5
ecmwflibs==0.0.94

Can not install magics with conda.

Hi, I use 'conda install -c conda-forge magics' to install magics in anaconda environment. But I always get the following message, which means magics is conflict with other packages (may be cartopy, or iris). So how I can solve this, thanks.

WARNING_ conda.base.context:use_only_tar_bz2(632): Conda is constrained to only using the old .tar.bz2 file format because you have conda-build installed, and it is <3.18.3.  Update or remove conda-build to get smaller downloads and faster extractions.
Collecting package metadata (repodata.json): done
Solving environment: failed

UnsatisfiableError: The following specifications were found to be incompatible with each other:

  - anaconda/linux-64::seaborn==0.9.0=py37_0 -> matplotlib[version='>=1.4.3'] -> pyqt -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - anaconda==2019.03=py37_0 -> cairo==1.14.12=h8948797_3 -> glib[version='>=2.56.1,<2.57.0a0']
  - anaconda==2019.03=py37_0 -> importlib_metadata==0.8=py37_0
  - anaconda==2019.03=py37_0 -> pango==1.42.4=h049681c_0
  - cairo
  - conda-forge/linux-64::basemap==1.2.0=py37h673bf1a_2 -> matplotlib[version='>=1.0.0'] -> pyqt -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - conda-forge/linux-64::cartopy==0.17.0=py37h0aa2c8f_1004 -> matplotlib -> pyqt -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - conda-forge/linux-64::iris==2.2.0=py37_1003 -> cartopy[version='>=0.14'] -> matplotlib -> pyqt -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - conda-forge/linux-64::metpy==0.10.0=py37_1001 -> cartopy[version='>=0.15.0'] -> matplotlib -> pyqt -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - conda-forge/linux-64::nodejs==11.14.0=he1b5a44_1
  - conda-forge/noarch::jupyterlab-git==0.6.0=py_0 -> nodejs
  - glib
  - gst-plugins-base -> glib[version='>=2.58.3,<3.0a0']
  - gstreamer -> glib[version='>=2.58.3,<3.0a0']
  - harfbuzz -> cairo[version='>=1.16.0,<1.17.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - magics -> cairo[version='>=1.16.0,<1.17.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - magics -> pango[version='>=1.40.14,<1.41.0a0']
  - pango -> cairo[version='>=1.16.0,<1.17.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - pkgs/main/linux-64::anaconda-navigator==1.9.7=py37_0 -> pyqt[version='>=5.6,<6.0a0'] -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - pkgs/main/linux-64::importlib_metadata==0.8=py37_0
  - pkgs/main/linux-64::jupyter==1.0.0=py37_7 -> qtconsole -> pyqt -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - pkgs/main/linux-64::matplotlib==3.0.3=py37h5429711_0 -> pyqt=5.9 -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - pkgs/main/linux-64::navigator-updater==0.2.1=py37_0 -> pyqt[version='>=5.6'] -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - pkgs/main/linux-64::path.py==11.5.0=py37_0 -> importlib_metadata[version='>=0.5']
  - pkgs/main/linux-64::pyqt==5.9.2=py37h05f1152_2 -> dbus[version='>=1.13.2,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - pkgs/main/linux-64::qtconsole==4.4.3=py37_0 -> pyqt -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - pkgs/main/linux-64::scikit-image==0.14.2=py37he6710b0_0 -> matplotlib[version='>=2.0.0'] -> pyqt -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - pkgs/main/linux-64::spyder==3.3.3=py37_0 -> pyqt=5 -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']
  - qt -> dbus[version='>=1.13.6,<2.0a0'] -> glib[version='>=2.58.3,<3.0a0']_

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.