首页 > 解决方案 > 如何添加 auxil.py 模块?

问题描述

我正在尝试使用 Sentinel 1 执行图像分类。我是编码新手,所以我使用这个:http ://mortcanty.github.io/src/s1class.html 我收到一条错误消息:auxil 不是模块所以我想过从 git hub 安装 auxil.py:https://github.com/mortcanty/CRCPython/blob/master/src/auxil/auxil.py

但是有些模块/库已经过时了,所以我不断收到错误,非常感谢任何帮助

标签: pythonfilterclassificationsentinel1

解决方案


您可以在自己的代码中定义该存储库中的类和方法,它们将起作用。例如,我需要这个类Cpm

class Cpm(object):
'''Provisional means algorithm'''
def __init__(self,N):
    self.mn = np.zeros(N)
    self.cov = np.zeros((N,N))
    self.sw = 0.0000001

def update(self,Xs,Ws=None):
    n,N = np.shape(Xs)
    if Ws is None:
        Ws = np.ones(n)
    sw = ctypes.c_double(self.sw)
    mn = self.mn
    cov = self.cov
    provmeans(Xs,Ws,N,n,ctypes.byref(sw),mn,cov)
    self.sw = sw.value
    self.mn = mn
    self.cov = cov

def covariance(self):
    c = np.mat(self.cov/(self.sw-1.0))
    d = np.diag(np.diag(c))
    return c + c.T - d

def means(self):
    return self.mn

推荐阅读