diff --git a/.gitignore b/.gitignore index e8d6e643..9628a74b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,13 +30,8 @@ /vegetationPhenology/tool/ /vegetationPhenology/VegetationPhenology/ /backScattering/baseTool/ -/landcover_c_sar/dist/ -/leafAreaIndex/dist/ - -/soilSalinity/tool/ -/landcover_c_sar/tool/ /atmosphericDelay-C-SAR/tool/ /deformation-C-SAR/tool/ /dem-C-SAR/tool/ /soilMoistureTop/tool/ -/backScattering/dist/ + diff --git a/Ortho/Ortho.xml b/Ortho/Ortho.xml index b74b5504..567c635e 100644 --- a/Ortho/Ortho.xml +++ b/Ortho/Ortho.xml @@ -45,7 +45,7 @@ File tar.gz Cal - E:\202306hb\sar_img\GF3B_SYC_QPSI_008316_E116.1_N43.3_20230622_L1A_AHV_L10000202892.tar.gz + E:\VegetationPhenology-likun\lijiang\GF3B_KSC_QPSI_007906_E100.2_N27.0_20230525_L1A_AHV_L10000190531.tar.gz True False File @@ -60,7 +60,7 @@ File File Cal - E:\202306hb\dem + E:\VegetationPhenology-likun\lijiang\dem True True File @@ -92,7 +92,7 @@ File tar.gz Cal - D:\micro\WorkSpace\Ortho\Output\GF3B_SYC_QPSI_008316_E116.1_N43.3_20230622_L1A_AHV_L10000202892-ortho.tar.gz + D:\micro\WorkSpace\Ortho\Output\GF3B_KSC_QPSI_007906_E100.2_N27.0_20230525_L1A_AHV_L10000190531-ortho.tar.gz DEFAULT DEFAULT DEFAULT diff --git a/atmosphericDelay-C-SAR/Delay_test.py b/atmosphericDelay-C-SAR/Delay_test.py index f0ebd150..01c0ae3f 100644 --- a/atmosphericDelay-C-SAR/Delay_test.py +++ b/atmosphericDelay-C-SAR/Delay_test.py @@ -4,9 +4,10 @@ from tool.algorithm.image import ImageHandle from tool.algorithm.algtools.PreProcess import PreProcess as pp import gc import os +import sys from pathlib import Path -env_str = os.path.split(os.path.realpath(__file__))[0] +env_str = os.path.dirname(os.path.abspath(sys.argv[0])) os.environ['PROJ_LIB'] = env_str @@ -60,11 +61,11 @@ def resampe_image(aux_dry_wet_unresame_path, mas_dry_wet_unresame_path, temp_dir if __name__ == '__main__': - mas_nc = r'F:\干涉大气延迟校正\大气延迟检验\大气延迟检验\ERA5_N25_N35_E115_E125_20220910_10.nc' - aux_nc = r'F:\干涉大气延迟校正\大气延迟检验\大气延迟检验\ERA5_N25_N35_E115_E125_20220922_10.nc' - dem_file = r'' - temp_dir = 'F://干涉大气延迟校正//大气延迟检验//大气延迟检验//nc_file//test//' - out_path = 'F://干涉大气延迟校正//大气延迟检验//大气延迟检验//nc_file//' + mas_nc = r'D:\micro\WorkSpace\AtmosphericDelay\ERA5\ERA5_N42.0_N46.0_E114.0_E118.0_20230615_08.nc' + aux_nc = r'D:\micro\WorkSpace\AtmosphericDelay\ERA5\ERA5_N42.0_N46.0_E114.0_E118.0_20230910_08.nc' + dem_file = r'D:\micro\WorkSpace\AtmosphericDelay\ERA5\cut_dem.tif' + temp_dir = r'D:\micro\WorkSpace\AtmosphericDelay\test_ztd\test' + out_path = r'D:\micro\WorkSpace\AtmosphericDelay\test_ztd' + '\\' # 读取气象数据 ncHandle = NcHandle() @@ -76,23 +77,23 @@ if __name__ == '__main__': base_file = out_path + "MasterNC_geo_h.tif" # 用来获取裁剪后气象数据的经纬度、分辨率等信息 # - # # 1.2 计算主、辅影像垂直分层湿干延迟值,并保存干湿延迟图 - # m_cdstack_dry_wet = Ady().aps_wrf_sar(base_file, m_temp, m_re_hum, m_geo, dem_file) # 主影像垂直分层干湿延迟值数组 - # m_dry_wet_path = out_path + "m_dry_wet.tif" # 主影像干湿延迟图保存路径 - # Ady().write_dry_wet_tif(dem_file, base_file, m_cdstack_dry_wet, m_dry_wet_path) - # - # a_cdstack_dry_wet = Ady().aps_wrf_sar(base_file, a_temp, a_re_hum, a_geo, dem_file) # 辅影像垂直分层干湿延迟值数组 - # a_dry_wet_path = out_path + "a_dry_wet.tif" # 辅影像干湿延迟图保存路径 - # Ady().write_dry_wet_tif(dem_file, base_file, a_cdstack_dry_wet, a_dry_wet_path) - # # + # 1.2 计算主、辅影像垂直分层湿干延迟值,并保存干湿延迟图 + m_cdstack_dry_wet = Ady().aps_wrf_sar(base_file, m_temp, m_re_hum, m_geo, dem_file) # 主影像垂直分层干湿延迟值数组 + m_dry_wet_path = out_path + "m_dry_wet.tif" # 主影像干湿延迟图保存路径 + Ady().write_dry_wet_tif(dem_file, base_file, m_cdstack_dry_wet, m_dry_wet_path) + + a_cdstack_dry_wet = Ady().aps_wrf_sar(base_file, a_temp, a_re_hum, a_geo, dem_file) # 辅影像垂直分层干湿延迟值数组 + a_dry_wet_path = out_path + "a_dry_wet.tif" # 辅影像干湿延迟图保存路径 + Ady().write_dry_wet_tif(dem_file, base_file, a_cdstack_dry_wet, a_dry_wet_path) # # aux_dry_wet_resamed_path, mas_dry_wet_resamed_path = resampe_image(a_dry_wet_path, m_dry_wet_path, temp_dir) # 参照气象数据分辨率进行重采样 - # - # gc.collect() # 回收内存 - # # 1.4 输出主辅影像ztd数组 - # a_ztd = Ady().calc_ztd(a_dry_wet_path, dem_file) # 辅影像的ztd数组 - # m_ztd = Ady().calc_ztd(m_dry_wet_path, dem_file) # 主影像的ztd数组 - # out_aux_ztd_path = out_path + "aux_ztd.tif" - # out_mas_ztd_path = out_path + "mas_ztd.tif" - # Ady().write_ztd_tif(dem_file, base_file, a_ztd, out_aux_ztd_path) # ztd数组->ztd影像 - # Ady().write_ztd_tif(dem_file, base_file, m_ztd, out_mas_ztd_path) # ztd数组->ztd影像 + + gc.collect() # 回收内存 + # 1.4 输出主辅影像ztd数组 + a_ztd = Ady().calc_ztd(a_dry_wet_path, dem_file) # 辅影像的ztd数组 + m_ztd = Ady().calc_ztd(m_dry_wet_path, dem_file) # 主影像的ztd数组 + out_aux_ztd_path = out_path + "aux_ztd.tif" + out_mas_ztd_path = out_path + "mas_ztd.tif" + Ady().write_ztd_tif(dem_file, base_file, a_ztd, out_aux_ztd_path) # ztd数组->ztd影像 + Ady().write_ztd_tif(dem_file, base_file, m_ztd, out_mas_ztd_path) # ztd数组->ztd影像 + diff --git a/landcover_c_sar/LandCover.xml b/landcover_c_sar/LandCover.xml index 5dbd8561..2cd6023a 100644 --- a/landcover_c_sar/LandCover.xml +++ b/landcover_c_sar/LandCover.xml @@ -87,7 +87,7 @@ Value string Man - 0,1,2,7,8,9,10 + 0,1,2,7,8,9,10,11,12,13 True True UploadInput @@ -135,7 +135,7 @@ File tar.gz Man - D:\micro\WorkSpace\LandCover\Output\GF3B_KSC_QPSI_010328_E86.1_N44.5_20231109_L1A_AHV_L10000262134-ortho-LANDClASS.tar.gz + D:\micro\WorkSpace\LandCover\Output\GF3B_KSC_QPSI_010328_E86.1_N44.5_20231109_L1A_AHV_L10000262134-ortho-LANDCLASS.tar.gz diff --git a/landcover_c_sar/LandCoverAuxData.py b/landcover_c_sar/LandCoverAuxData.py index 4cec7c84..e52ae0b5 100644 --- a/landcover_c_sar/LandCoverAuxData.py +++ b/landcover_c_sar/LandCoverAuxData.py @@ -122,10 +122,15 @@ class LandCoverMeasCsv: # raise Exception('there are empty data!', train_data) if len(train_data_list) <= 1: raise Exception('there is only one label type!', train_data_list) + num_list = [] + for train_data in train_data_list: + if not len(train_data[3]) == 0: + num_list.append(len(train_data[3])) + max_num = np.min(num_list) for train_data in train_data_list: logger.info(str(train_data[0]) + "," + str(train_data[2]) +"," + "num:" + str(len(train_data[3]))) - max_num = self.__max_tran__num_per_class + # max_num = self.__max_tran__num_per_class logger.info("max number =" + str(max_num) + ", random select" + str(max_num) + " point as train data!") if (len(train_data[3]) > max_num): train_data[3] = random.sample(train_data[3], max_num) diff --git a/landcover_c_sar/LandCoverMain.py b/landcover_c_sar/LandCoverMain.py index bdf8f3e6..df60ef01 100644 --- a/landcover_c_sar/LandCoverMain.py +++ b/landcover_c_sar/LandCoverMain.py @@ -116,7 +116,7 @@ class LandCoverMain: checkFlag, self.__parameters_dic = self.__check_handler.check_input_paras(self.__input_paras) self.__workspace_path = self.__alg_xml_handler.get_workspace_path() self.__create_work_space() - self.__processing_paras = InitPara.init_processing_paras(self.__input_paras) + self.__processing_paras = InitPara.init_processing_paras(self.__input_paras, self.__workspace_preprocessed_path) self.__processing_paras.update(self.get_tar_gz_inf(self.__processing_paras["sar_path0"])) SrcImageName = os.path.split(self.__input_paras["AHV"]['ParaValue'])[1].split('.tar.gz')[0] result_name = SrcImageName + tar + ".tar.gz" @@ -498,6 +498,21 @@ class LandCoverMain: out_path = os.path.join(dir, name) self.calInterpolation_bil_Wgs84_rc_sar_sigma(self.__processing_paras['paraMeter'], self.__preprocessed_paras['sim_ori'], file, out_path) + + calOutDir = os.path.join(self.__workspace_processing_path, 'cal\\') # 添加四极化后向散射系数到特征图中 + if not os.path.exists(calOutDir): + os.makedirs(calOutDir) + para_names_l1a = ["HH", "VV", "HV", "VH"] + for key in para_names_l1a: + name = key + '_geo.tif' + out_path = os.path.join(dir, name) + calOut_path = os.path.join(calOutDir, key + '_cal.tif') + AHVToPolsarpro.sar_backscattering_sigma(self.__preprocessed_paras[key], + self.__processing_paras['Origin_META'], calOut_path) + self.calInterpolation_bil_Wgs84_rc_sar_sigma(self.__processing_paras['paraMeter'], + self.__preprocessed_paras['sim_ori'], + calOut_path, out_path) + return dir def process_handle(self, start): @@ -549,7 +564,7 @@ class LandCoverMain: logger.info('progress bar: 50%') # 生成最优特征子集训练集 - X_train, Y_train, optimal_feature = ml.gene_optimal_train_set(train_data_dic, feature_geo, 0.07, 0.85) + X_train, Y_train, optimal_feature = ml.gene_optimal_train_set(train_data_dic, feature_geo, 0.07, 0.85) # 0.07, 0.85 # 训练模型 cost = self.__processing_paras["Cost"] diff --git a/soilSalinity/SoilSalinity.xml b/soilSalinity/SoilSalinity.xml index c2f30a80..3bb6fd9a 100644 --- a/soilSalinity/SoilSalinity.xml +++ b/soilSalinity/SoilSalinity.xml @@ -138,7 +138,7 @@ File tar.gz Man - D:\micro\WorkSpace\SoilSalinity\Output\GF3B_SYC_QPSI_008316_E116.2_N43.7_20230622_L1A_AHV_L10000202891-ortho-salinty.tar.gz + D:\micro\WorkSpace\SoilSalinity\Output\GF3B_SYC_QPSI_008316_E116.2_N43.7_20230622_L1A_AHV_L10000202891-ortho-SSAA.tar.gz DEFAULT DEFAULT DEFAULT diff --git a/surfaceRoughness_oh2004/SurfaceRoughness.xml b/surfaceRoughness_oh2004/SurfaceRoughness.xml index 140f00b9..82250929 100644 --- a/surfaceRoughness_oh2004/SurfaceRoughness.xml +++ b/surfaceRoughness_oh2004/SurfaceRoughness.xml @@ -38,7 +38,7 @@ File tar.gz Man - E:\202306pj\GF3B_MYC_QPSI_008114_E121.6_N40.9_20230608_L1A_AHV_L10000196489-ortho.tar.gz + D:\micro\WorkSpace\Ortho\Output\GF3B_SYC_QPSI_008316_E116.1_N43.3_20230622_L1A_AHV_L10000202892-ortho.tar.gz True False File @@ -68,7 +68,7 @@ File tif Man - E:\202306pj\n51_40_2020lc030.tif + D:\Dict\50T_20220101-20230101.tif True False File @@ -83,7 +83,7 @@ Value string Man - 10;20;30;40;50;70;71;72;83;74;90 + empty True False UploadInput @@ -98,7 +98,7 @@ File tif Man - E:\202306pj\L9NDVI_GF3B_175394.tif + F:\202306hb\NDVI\S2_202306_NDVI.tif True False File @@ -130,7 +130,7 @@ File tar.gz Man - D:\micro\WorkSpace\SurfaceRoughness\Output\GF3B_MYC_QPSI_008114_E121.6_N40.9_20230608_L1A_AHV_L10000196489-ortho-SR.tar.gz + D:\micro\WorkSpace\SurfaceRoughness\Output\GF3B_SYC_QPSI_008316_E116.1_N43.3_20230622_L1A_AHV_L10000202892-ortho-SR.tar.gz diff --git a/surfaceRoughness_oh2004/SurfaceRoughnessMain.py b/surfaceRoughness_oh2004/SurfaceRoughnessMain.py index b57690e1..8a919e41 100644 --- a/surfaceRoughness_oh2004/SurfaceRoughnessMain.py +++ b/surfaceRoughness_oh2004/SurfaceRoughnessMain.py @@ -328,7 +328,7 @@ class MoistureMain: product_path = os.path.join(self.__product_dic, SrcImageName) # 获取影像roi区域 - roi.cal_roi(product_path, product_geo_path, bare_land_mask_path, background_value=0) + roi.cal_roi(product_path, product_geo_path, bare_land_mask_path, background_value=-9999) # 生成快视图 self.imageHandler.write_quick_view(product_path) diff --git a/tool/algorithm/algtools/ROIAlg.py b/tool/algorithm/algtools/ROIAlg.py index 186fb968..b1319dd8 100644 --- a/tool/algorithm/algtools/ROIAlg.py +++ b/tool/algorithm/algtools/ROIAlg.py @@ -228,11 +228,11 @@ class ROIAlg: logger.info("cal_roi success, path: %s", out_tif_path) return True -# if __name__ == '__main__': -# dir = r'G:\MicroWorkspace\C-SAR\SoilMoisture\Temporary\processing/' -# out_tif_path = dir + 'soil_moisture_roi.tif' -# in_tif_path = dir + 'soil_moisture.tif' -# mask_path = dir + 'bare_land_mask.tif' -# background_value = np.nan -# ROIAlg.cal_roi(out_tif_path, in_tif_path, mask_path, background_value) -# pass \ No newline at end of file +if __name__ == '__main__': + dir = r'G:\MicroWorkspace\C-SAR\SoilMoisture\Temporary\processing/' + out_tif_path = r'D:\micro\WorkSpace\SurfaceRoughness\Temporary\SurfaceRoughnessProduct_test.tif' + in_tif_path = r'D:\micro\WorkSpace\SurfaceRoughness\Temporary\SurfaceRoughnessProduct_geo.tif' + mask_path = r'D:\micro\WorkSpace\SurfaceRoughness\Temporary\processing\roi\ndvi_mask.tif' + background_value = 0 + ROIAlg.cal_roi(out_tif_path, in_tif_path, mask_path, background_value) + pass \ No newline at end of file diff --git a/vegetationPhenology/VegetationPhenology.xml b/vegetationPhenology/VegetationPhenology.xml index b87c7cf0..2a76f064 100644 --- a/vegetationPhenology/VegetationPhenology.xml +++ b/vegetationPhenology/VegetationPhenology.xml @@ -37,7 +37,7 @@ File tar.gz Man - E:\VegetationPhenology-likun\rusuoces\GF3C_MYC_QPSI_006270_E100.4_N27.0_20230615_L1A_AHV_L10000158764-ortho.tar.gz + E:\VegetationPhenology-likun\lijiang\GF3B_KSC_QPSI_007906_E100.2_N27.0_20230525_L1A_AHV_L10000190531-ortho.tar.gz DEFAULT DEFAULT DEFAULT @@ -51,7 +51,7 @@ File csv Man - E:\VegetationPhenology-likun\rusuoces\VegetationPhe_samples.csv + E:\VegetationPhenology-likun\lijiang\VegetationPhe_samples.csv DEFAULT DEFAULT DEFAULT @@ -65,7 +65,7 @@ File tif Man - E:\VegetationPhenology-likun\rusuoces\N47_25_2020LC030\n47_25_2020lc030.tif + E:\VegetationPhenology-likun\lijiang\landcover.tif True False File @@ -80,7 +80,7 @@ Value string Man - 10 + 3 True False UploadInput @@ -130,7 +130,7 @@ File tar.gz Man - D:\micro\WorkSpace\VegetationPhenology\Output\GF3C_MYC_QPSI_006270_E100.4_N27.0_20230615_L1A_AHV_L10000158764-ortho-VP.tar.gz + D:\micro\WorkSpace\VegetationPhenology\Output\GF3B_KSC_QPSI_007906_E100.2_N27.0_20230525_L1A_AHV_L10000190531-ortho-VP.tar.gz DEFAULT DEFAULT DEFAULT diff --git a/vegetationPhenology/VegetationPhenologyAuxData.py b/vegetationPhenology/VegetationPhenologyAuxData.py index bb4987b6..832d2a37 100644 --- a/vegetationPhenology/VegetationPhenologyAuxData.py +++ b/vegetationPhenology/VegetationPhenologyAuxData.py @@ -320,9 +320,13 @@ class PhenoloyMeasCsv_geo: if train_data[3] == [] : raise Exception('there are empty data!', train_data) + if len(train_data_list) <= 1: + raise Exception('there is only one label type!', train_data_list) + num_list = [] for train_data in train_data_list: - num_list.append(len(train_data[3])) + if not len(train_data[3]) == 0: + num_list.append(len(train_data[3])) max_num = np.min(num_list) for train_data in train_data_list: logger.info(str(train_data[0]) + "," + str(train_data[2]) +"," + "num:" + str(len(train_data[3]))) @@ -331,8 +335,7 @@ class PhenoloyMeasCsv_geo: if(len(train_data[3]) > max_num): train_data[3] = random.sample(train_data[3], max_num) - if len(train_data_list) <= 1: - raise Exception('there is only one label type!', train_data_list) + return train_data_list @staticmethod