def get_data_S():
    '''
    可以检测读取到的图片波段数与参数fac是否对应,不对应则try-except报错
    '''
    XY = read_xy(path_tiff + path1)
    cdnX, cdnY = XY[0], XY[1]

    CHLA = read_tiff(path_tiff + path1)
    SD = read_tiff(path_tiff + path2)
    TN = read_tiff(path_tiff + path3)
    TP = read_tiff(path_tiff + path4)
    NDVI = read_tiff(path_tiff + path5)
    FAI = read_tiff(path_tiff + path6)
    dict = {'X': cdnX, 'Y': cdnY, 'CHLA': CHLA,
            'SD': SD, 'TP': TP, 'TN': TN,'NDVI':NDVI,'FAI':FAI}
    df = pd.DataFrame(data=dict)
    for col in df.columns:  # df1.columns : 列名称的list
        # print(col)  # col为一个个列名
        # df.drop(index=(df.loc[(df[col] == -999)].index), inplace=True)
        df.drop(index=(df[df[col].isin([-999])].index), inplace=True)  # 清洗4个指标
        df.drop(index=(df[df[col].isin([-2])].index), inplace=True)  # 清洗NDVI
        # df.reset_index(inplace=True)  # 重置索引,但会保留原索引
        df.reset_index(drop=True, inplace=True)  # 重置索引,不会保留原索引
    Write(df,output_data_path)
    return output_data_path
def read_single_band():

    XY = read_xy(path_tiff + path1)

    cdnX, cdnY = XY[0], XY[1]
    CHLA = read_tiff(path_tiff + path1)
    COD = read_tiff(path_tiff + path2)
    NTU = read_tiff(path_tiff + path3)
    TP = read_tiff(path_tiff + path4)
    TSM = read_tiff(path_tiff + path5)
    FAI01 = read_tiff(path_tiff + path6)
    NDVI = read_tiff(path_tiff + path7, 1)

    dict = {
        'X': cdnX,
        'Y': cdnY,
        'CHLA': CHLA,
        'COD': COD,
        'NTU': NTU,
        'TP': TP,
        'TSM ': TSM,
        'FAI01': FAI01,
        'NDVI': NDVI
    }
    df = pd.DataFrame(data=dict)
    '''
     for col in df.columns:  # df1.columns : 列名称的list
        df.drop(index=(df[df[col].isin([-999])].index), inplace=True)  # 清洗4个指标
        df.drop(index=(df[df[col].isin([-2])].index), inplace=True)  # 清洗NDVI
        # df.reset_index(inplace=True)  # 重置索引,但会保留原索引
        df.reset_index(drop=True, inplace=True)  # 重置索引,不会保留原索引
    '''

    Write(df, output_data_path)
    """写入部分"""
Esempio n. 3
0
def Get_wenzi():
    df = read_band(output_data_path)
    surface = surface_rank(df=df, list_tar=["TP", "TN"])
    TLI = TLI_rank(df=df, list_tar=["CHLA", "SD", "TP", "TN"])
    TSI = TSI_rank(df=df, list_tar=["CHLA", "SD", "TP"])
    df_tar = df[["X", "Y"]]  # 多列时要写成列表形式
    df_tar["surface"] = surface
    df_tar["TLI"] = TLI
    df_tar["TSI"] = TSI
    Write(df, evaluate2_data_path)
def evaluation2():
    '''读取部分'''
    df = read_band(output_data_path, evaluate2_data_path)
    '''计算部分'''
    surface = surface_rank(df=df, list_tar=["TP"])
    '''整合部分'''
    df_tar = df[["X", "Y"]]  # 多列时要写成列表形式
    df_tar["surface"] = surface
    '''写入部分'''
    Write(df_tar, evaluate2_data_path)
def evaluation1():
    '''读取部分'''

    df = read_band(output_data_path, evaluate1_data_path)
    '''计算部分'''
    surface = surface_rank(df=df, list_tar=["TP"])
    TLI = TLI_rank(df=df, list_tar=["CHLA", "COD", "TP"])
    TSI = TSI_rank(df=df, list_tar=["CHLA", "TP"])
    '''整合部分'''
    df_tar = df[["X", "Y"]]  # 多列时要写成列表形式
    df_tar["surface"] = surface
    df_tar["TLI"] = TLI
    df_tar["TSI"] = TSI
    df_tar["NDVI"] = df["NDVI"]
    '''写入部分'''

    Write(df_tar, evaluate1_data_path)
Esempio n. 6
0
def Cal_NDVI():

    #read_band(path6, target=output_multipband)
    # 读全波段并生成excel
    # exit()

    XY = read_xy(path_tiff + path1)

    cdnX, cdnY = XY[0], XY[1]
    CHLA = read_tiff(path_tiff + path1)
    COD = read_tiff(path_tiff + path2)
    NTU = read_tiff(path_tiff + path3)
    TP = read_tiff(path_tiff + path4)
    TSM = read_tiff(path_tiff + path5)

    NIR_8 = read_tiff(path6, num=8, key=True)
    R = read_tiff(path6, num=4, key=True)
    NDVI_8 = [0] * len(NIR_8)
    for i in range(len(NIR_8)):
        NDVI_8[i] = (NIR_8[i] - R[i]) / (NIR_8[i] + R[i])
        # NDVI_9[i] = (NIR_9[i]-R[i]) / (NIR_9[i]+R[i])
    dict = {
        'X': cdnX,
        'Y': cdnY,
        'CHLA': CHLA,
        'COD': COD,
        'NTU': NTU,
        'TP': TP,
        'TSM': TSM,
        'NDVI_8': NDVI_8
    }
    df = pd.DataFrame(data=dict)
    """清洗异常值"""

    for col in df.columns:  # df1.columns : 列名称的list
        df.drop(index=(df[df[col].isin([-999])].index), inplace=True)  # 清洗4个指标

        #df.drop(index=(df[df[col].isin([-2])].index), inplace=True)  # 清洗NDVI
        df.drop(index=(df[df['NDVI_8'] <= 0].index), inplace=True)  # 清洗NDVI
        # df.reset_index(inplace=True)  # 重置索引,但会保留原索引
        df.reset_index(drop=True, inplace=True)  # 重置索引,不会保留原索引
    """写入部分"""
    Write(df, output_NDVI_path)
Esempio n. 7
0
def Cal_FAI():
    read_band(path6, target=output_multipband)  # 读全波段并生成excel 与 SH4文件功能重复


    XY = read_xy(path_tiff + path1)

    cdnX, cdnY = XY[0], XY[1]
    CHLA = read_tiff(path_tiff + path1)
    COD = read_tiff(path_tiff + path2)
    NTU = read_tiff(path_tiff + path3)
    TP = read_tiff(path_tiff + path4)
    TSM = read_tiff(path_tiff + path5)


    '''FAI'''
    # 红光波段 R665 是rand(4)
    # 近红外波段有两个 R842 是rand(8); R865 是rand(9)
    # 短波红外波段有两个 R1610 是rand(11); R2190 是rand(12)
    R665 = read_tiff(path6, num=4, key=True)
    R842 = read_tiff(path6, num=8, key=True)
    R1610 = read_tiff(path6, num=11, key=True)
    R842_ = [R665[i] + (R1610[i] - R665[i]) * (842 - 665) / (2190 - 665)
             for i in range(len(R665))]
    # FAI = R842 - R842_
    FAI = [R842[i] - R842_[i] for i in range(len(R842))]
    # FAI = [1 if i >= 0.02 else 0 for i in FAI]
    dict = {'X': cdnX, 'Y': cdnY, 'CHLA': CHLA,
            'COD': COD, 'NTU': NTU, 'TP': TP, 'TSM': TSM, 'FAI': FAI}
    df = pd.DataFrame(data=dict)

    """清洗异常值"""
    for col in df.columns:  # df1.columns : 列名称的list
        # print(col)  # col为一个个列名
        df.drop(index=(df.loc[(df[col] == -999)].index), inplace=True)
        # df.reset_index(inplace=True)  # 重置索引,但会保留原索引
        df.reset_index(drop=True, inplace=True)  # 重置索引,不会保留原索引

    """写入部分"""
    Write(df,output_FAI_path)