问题

最近用到了py-eddy-tracker, 参照官方文档进行漩涡区域填充时发现调用py_eddy_tracker.observations.observation.EddiesObservations.filled 报错:

'EddiesObservations' object has no attribute 'filled'

尝试

filled函数的官方文档
查看官网提供的源码发现是有filled函数的,但是自己本地的库中没有.

检查版本发现本地版本为3.2.0, 官方文档版本为3.5.0

> pip show pyEddyTracker
Name: pyEddyTracker
Version: 3.2.0
...

而且pip无法安装3.5.0

> pip install pyEddyTracker==3.5.0
ERROR: Could not find a version that satisfies the requirement pyEddyTracker==3.5.0 (from versions: 3.0.0, 3.1.0, 3.2.0)
ERROR: No matching distribution found for pyEddyTracker==3.5.0

尝试使用文档提供的办法手动安装最新版本:
最后提示版本过低, 我的python3.6无法安装最新版的py-eddy-tracker

RuntimeError: Cannot install on Python version 3.6.4; only versions >=3.7,<3.10 are supported

解决方法

升级python
升级python版本是不可能的, 这辈子都不可能的.

手动修改observation.py源码

# 32行+
from matplotlib.cm import get_cmap
from matplotlib.collections import PolyCollection
from matplotlib.colors import Normalize# 1259行+def parse_varname(self, name):return self[name] if isinstance(name, str) else namedef format_label(self, label):t0, t1 = self.periodreturn label.format(t0=t0,t1=t1,nb_obs=len(self),)def filled(self,ax,varname=None,ref=None,intern=False,cmap="magma_r",lut=10,vmin=None,vmax=None,factor=1,**kwargs,):""":param matplotlib.axes.Axes ax: matplotlib axe used to draw:param str,array,None varname: variable used to fill the contours, or an array of same size than obs:param float,None ref: if defined, all coordinates are wrapped with ref as western boundary:param bool intern: if True draw speed contours instead of effective contours:param str cmap: matplotlib colormap name:param int,None lut: Number of colors in the colormap:param float,None vmin: Min value of the colorbar:param float,None vmax: Max value of the colorbar:param float factor: multiply value by:return: Collection drawed:rtype: matplotlib.collections.PolyCollection.. minigallery:: py_eddy_tracker.EddiesObservations.filled"""x_name, y_name = self.intern(intern)x, y = self[x_name], self[y_name]if ref is not None:# TODO : maybe buggy with global displayshape_out = x.shapex, y = wrap_longitude(x.reshape(-1), y.reshape(-1), ref)x, y = x.reshape(shape_out), y.reshape(shape_out)verts = list()for x_, y_ in zip(x, y):verts.append(create_vertice(x_, y_))if "facecolors" not in kwargs:kwargs = kwargs.copy()cmap = get_cmap(cmap, lut)v = self.parse_varname(varname) * factorif vmin is None:vmin = v.min()if vmax is None:vmax = v.max()v = (v - vmin) / (vmax - vmin)colors = [cmap(v_) for v_ in v]kwargs["facecolors"] = colorsif "label" in kwargs:kwargs["label"] = self.format_label(kwargs["label"])c = PolyCollection(verts, **kwargs)ax.add_collection(c)c.cmap = cmapc.norm = Normalize(vmin=vmin, vmax=vmax)return c

结果

成功调用

fig = plt.figure(figsize=(3, 2))
ax = fig.add_axes([.03, .03, .94, .94])
ax.set_ylim(4, 30)
ax.set_xlim(105.5, 150)
plt.axis('off')
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
plt.margins(0, 0)
ax.set_aspect('equal')
a.filled(ax, 'amplitude', vmin=0, vmax=.5, color='b')     # 填充
c.filled(ax, 'amplitude', vmin=0, vmax=.5, color='r')
plt.show()

‘EddiesObservations‘ object has no attribute ‘filled‘相关推荐

  1. Python错误:AttributeError: 'generator' object has no attribute 'next'解决办法

    今天在学习生成器对象(generation object)运行以下代码时,遇到了一个错误: #定义生成器函数 def liebiao(): for x in range(10): yield x #函 ...

  2. AttributeError: 'dict' object has no attribute 'status_code'

    前端AJAX请求数据,提示错误:"AttributeError: 'dict' object has no attribute 'status_code'". 原因:是提示返回对象 ...

  3. Traceback (most recent call last): File AttributeError: 'NoneType' object has no attribute 'group'

    Traceback (most recent call last):File "<stdin>", line 1, in <module> Attribut ...

  4. 解决:AttributeError: ‘Graph‘ object has no attribute ‘number_of_selfloops‘

    解决:AttributeError: 'Graph' object has no attribute 'number_of_selfloops' 目录 解决:AttributeError: 'Grap ...

  5. AttributeError: ‘FPDF‘ object has no attribute ‘unifontsubset‘

    AttributeError: 'FPDF' object has no attribute 'unifontsubset' 目录 AttributeError: 'FPDF' object has ...

  6. AttributeError: ‘Series‘ object has no attribute ‘as_matrix‘

    AttributeError: 'Series' object has no attribute 'as_matrix' 问题: y_test = test_shifted["y_t+1&q ...

  7. AttributeError: ‘SVC‘ object has no attribute ‘_probA‘

    AttributeError: 'SVC' object has no attribute '_probA' 问题: # Save the Modle to file in the current w ...

  8. sklearn使用FeatureHasher处理字符串特征: AttributeError: ‘str‘ object has no attribute ‘items‘

    sklearn使用FeatureHasher处理字符串特征: AttributeError: 'str' object has no attribute 'items' 目录 sklearn使用Fea ...

  9. Keras问题“AttributeError: 'NoneType' object has no attribute 'update”解决

    BUG 在使用Keras训练模型时,在每个epoch完成后save_model时会报错 "AttributeError: 'NoneType' object has no attribute ...

最新文章

  1. netty发送数据_【Netty】JAVA IO模型
  2. MSDN-9月杂志推荐
  3. Launcher代码大全
  4. Java知识整理——基础知识
  5. linux 端口号查看
  6. 华为鸿蒙系统明年8月份,华为鸿蒙系统明年上线,力争第五大操作系统,能否成功?...
  7. visibility: hidden与display:none的区别
  8. 程序员杂志为啥没有了_计算机基础知识,程序员必备知识,java必会!新建一个TXT,发生了什么?...
  9. Java JDK新特性探究-精简的JRE
  10. 服务器远程桌面日志,Windows记录远程桌面3389登录日志
  11. 要打理好自己的钱袋子
  12. 网络性能测试(系统层面、针对Linux、安卓)
  13. VMware workstations安装黑苹果系统
  14. jetbrains intellij idea从2021.2.3版本开始需要用户登录之后才能使用,2021.2.2版本以及之前的版本不用登录
  15. pyqt5 图像上划线_PyQt5如何用QPainter在QScrollArea上画线?
  16. 用计算机打青春不打烊,彩色的青春不打烊
  17. 智能睡眠监控APP开发有哪些好处?
  18. 编译报错unable to initialize decompress status for section .debug_info
  19. 大话Verilog——Verilog入门(一)
  20. python爬虫怎么爬小说_Python 新手] 爬虫练习:爬取起点中文网的小说排行并存入 excel 表格中...

热门文章

  1. python3 poplib.POP3 连接超时问题
  2. 22考研390分上岸吉林大学计算机学硕详细复习策略
  3. vue打印插件vue-print-nb
  4. html怎么把图片当作导航栏,css利用一张背景图制作导航菜单实现思路及代码
  5. 收藏的JAVA面试题大全(http://www.blogjava.net/bibi/archive/2006/07/18/58701.html)
  6. plsql developer oracle home为空,Windows 64位下装安装Oracle 11g,PLSQL Developer的配置问题,数据库显示空白的完美解决方案(图文教程)...
  7. 互联网摸鱼日报(2022-12-06)
  8. xml注释快捷键 快捷生成<!-- -->
  9. 网页设计与开发-实验报告-3
  10. Orcal 64位 配置plSQL 32 位