‘EddiesObservations‘ object has no attribute ‘filled‘
问题
最近用到了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‘相关推荐
- Python错误:AttributeError: 'generator' object has no attribute 'next'解决办法
今天在学习生成器对象(generation object)运行以下代码时,遇到了一个错误: #定义生成器函数 def liebiao(): for x in range(10): yield x #函 ...
- AttributeError: 'dict' object has no attribute 'status_code'
前端AJAX请求数据,提示错误:"AttributeError: 'dict' object has no attribute 'status_code'". 原因:是提示返回对象 ...
- 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 ...
- 解决:AttributeError: ‘Graph‘ object has no attribute ‘number_of_selfloops‘
解决:AttributeError: 'Graph' object has no attribute 'number_of_selfloops' 目录 解决:AttributeError: 'Grap ...
- AttributeError: ‘FPDF‘ object has no attribute ‘unifontsubset‘
AttributeError: 'FPDF' object has no attribute 'unifontsubset' 目录 AttributeError: 'FPDF' object has ...
- AttributeError: ‘Series‘ object has no attribute ‘as_matrix‘
AttributeError: 'Series' object has no attribute 'as_matrix' 问题: y_test = test_shifted["y_t+1&q ...
- AttributeError: ‘SVC‘ object has no attribute ‘_probA‘
AttributeError: 'SVC' object has no attribute '_probA' 问题: # Save the Modle to file in the current w ...
- sklearn使用FeatureHasher处理字符串特征: AttributeError: ‘str‘ object has no attribute ‘items‘
sklearn使用FeatureHasher处理字符串特征: AttributeError: 'str' object has no attribute 'items' 目录 sklearn使用Fea ...
- Keras问题“AttributeError: 'NoneType' object has no attribute 'update”解决
BUG 在使用Keras训练模型时,在每个epoch完成后save_model时会报错 "AttributeError: 'NoneType' object has no attribute ...
最新文章
- netty发送数据_【Netty】JAVA IO模型
- MSDN-9月杂志推荐
- Launcher代码大全
- Java知识整理——基础知识
- linux 端口号查看
- 华为鸿蒙系统明年8月份,华为鸿蒙系统明年上线,力争第五大操作系统,能否成功?...
- visibility: hidden与display:none的区别
- 程序员杂志为啥没有了_计算机基础知识,程序员必备知识,java必会!新建一个TXT,发生了什么?...
- Java JDK新特性探究-精简的JRE
- 服务器远程桌面日志,Windows记录远程桌面3389登录日志
- 要打理好自己的钱袋子
- 网络性能测试(系统层面、针对Linux、安卓)
- VMware workstations安装黑苹果系统
- jetbrains intellij idea从2021.2.3版本开始需要用户登录之后才能使用,2021.2.2版本以及之前的版本不用登录
- pyqt5 图像上划线_PyQt5如何用QPainter在QScrollArea上画线?
- 用计算机打青春不打烊,彩色的青春不打烊
- 智能睡眠监控APP开发有哪些好处?
- 编译报错unable to initialize decompress status for section .debug_info
- 大话Verilog——Verilog入门(一)
- python爬虫怎么爬小说_Python 新手] 爬虫练习:爬取起点中文网的小说排行并存入 excel 表格中...
热门文章
- python3 poplib.POP3 连接超时问题
- 22考研390分上岸吉林大学计算机学硕详细复习策略
- vue打印插件vue-print-nb
- html怎么把图片当作导航栏,css利用一张背景图制作导航菜单实现思路及代码
- 收藏的JAVA面试题大全(http://www.blogjava.net/bibi/archive/2006/07/18/58701.html)
- plsql developer oracle home为空,Windows 64位下装安装Oracle 11g,PLSQL Developer的配置问题,数据库显示空白的完美解决方案(图文教程)...
- 互联网摸鱼日报(2022-12-06)
- xml注释快捷键 快捷生成<!-- -->
- 网页设计与开发-实验报告-3
- Orcal 64位 配置plSQL 32 位