gimli-org / transform2022

Repository for installation routines and Jupyter Notebooks for talk on Transform 2022
Apache License 2.0
6 stars 5 forks source link

ImportError: cannot import name 'register_cmap' from 'matplotlib.cm' in hemmodelling.py #2

Closed Einvon closed 1 month ago

Einvon commented 1 month ago

In hemmodelling.py

The original version has an ImportError, which works nicht. It should be changed to:

"""Classes for modelling helicopter electromagnetics (HEM) using VMD solvers""" from math import sqrt, pi import numpy as np

from matplotlib.colors import LinearSegmentedColormap from matplotlib import colormaps

import pygimli as pg from pygimli.frameworks import Block1DModelling

def registerDAEROcmap(): """Standardized colormap from A-AERO projects (purple=0.3 to red=500).""" CMY = np.array([ [127, 255, 31], [111, 255, 47], [95, 255, 63], [79, 255, 79], [63, 255, 95], [47, 255, 111], [31, 255, 127], [16, 255, 159], [0, 223, 159], [0, 191, 159], [0, 159, 207], [0, 127, 175], [0, 95, 175], [0, 63, 175], [0, 47, 175], [0, 31, 191], [0, 0, 255], [0, 0, 159], [15, 0, 127], [47, 0, 143], [79, 0, 143], [111, 0, 143], [143, 0, 127], [159, 31, 63], [175, 47, 31], [207, 63, 0], [223, 111, 0], [231, 135, 0], [239, 159, 0], [255, 191, 47], [239, 199, 63], [223, 207, 79], [207, 239, 111]], dtype=float) RGB = 1.0 - CMY/255 daero = LinearSegmentedColormap.from_list('D-AERO', RGB) colormaps(name='daero', cmap=daero) return daero

halbmy commented 1 month ago

I guess you are referring to the pyGIMLi code https://github.com/gimli-org/gimli

Yes, there is a bug occurring with modern versions of matplotlib that has already been fixed. We will create a new version next week. Thank you for reporting.