后向散射系数增加处理DH极化数据
parent
b94755f574
commit
040d228ca6
|
@ -1,7 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<Root>
|
||||
<TaskID>CSAR_202107275419_0001-0</TaskID>
|
||||
<WorkSpace>F:\C-SAR\</WorkSpace>
|
||||
<WorkSpace>D:\micro\WorkSpace\</WorkSpace>
|
||||
<AlgCompt>
|
||||
<DataTransModel>File</DataTransModel>
|
||||
<Artificial>ElementAlg</Artificial>
|
||||
|
@ -45,7 +45,7 @@
|
|||
<ParaType>File</ParaType>
|
||||
<DataType>tar.gz</DataType>
|
||||
<ParaSource>Cal</ParaSource>
|
||||
<ParaValue>F:\C-SAR\GF3C_MYC_FSI_005874_E100.0_N26.5_20230519_L1A_HHHV_L10000148115.tar.gz</ParaValue>
|
||||
<ParaValue>E:\2023xibei\GF3B_KSC_QPSI_010364_E86.0_N44.9_20231112_L1A_AHV_L10000263358.tar.gz</ParaValue>
|
||||
<EnModification>True</EnModification>
|
||||
<EnMultipleChoice>False</EnMultipleChoice>
|
||||
<Control>File</Control>
|
||||
|
@ -60,7 +60,7 @@
|
|||
<ParaType>File</ParaType>
|
||||
<DataType>File</DataType>
|
||||
<ParaSource>Cal</ParaSource>
|
||||
<ParaValue>F:\C-SAR\ns_dem</ParaValue>
|
||||
<ParaValue>E:\2023xibei\dem</ParaValue>
|
||||
<EnModification>True</EnModification>
|
||||
<EnMultipleChoice>True</EnMultipleChoice>
|
||||
<Control>File</Control>
|
||||
|
@ -92,7 +92,7 @@
|
|||
<ParaType>File</ParaType>
|
||||
<DataType>tar.gz</DataType>
|
||||
<ParaSource>Cal</ParaSource>
|
||||
<ParaValue>F:\C-SAR\Ortho\Output\GF3C_MYC_FSI_005874_E100.0_N26.5_20230519_L1A_HHHV_L10000148115-ortho.tar.gz</ParaValue>
|
||||
<ParaValue>D:\micro\WorkSpace\Ortho\Output\GF3B_KSC_QPSI_010364_E86.0_N44.9_20231112_L1A_AHV_L10000263358-ortho.tar.gz</ParaValue>
|
||||
<MaxValue>DEFAULT</MaxValue>
|
||||
<MinValue>DEFAULT</MinValue>
|
||||
<OptionValue>DEFAULT</OptionValue>
|
||||
|
|
|
@ -86,6 +86,8 @@ class ScatteringAlg:
|
|||
polarization = 'VV'
|
||||
if replece_VV:
|
||||
polarization = 'HV' #土壤水分算法中可能会用HV替换VV
|
||||
elif 'DH' in os.path.basename(in_sar_tif):
|
||||
polarization = 'HH'
|
||||
else:
|
||||
raise Exception ('there are not HH、HV、VH、VV in path:',in_sar_tif)
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ from tool.algorithm.xml.AlgXmlHandle import ManageAlgXML, CheckSource
|
|||
from tool.algorithm.xml.CreateMetaDict import CreateMetaDict, CreateProductXml, OrthoAzimuth
|
||||
from tool.algorithm.image.ImageHandle import ImageHandler
|
||||
from tool.algorithm.algtools.PreProcess import PreProcess as pp
|
||||
from BackScatteringAlg import IndirectOrthorectification, DEMProcess,rpc_correction,getRCImageRC,get_RPC_lon_lat,getRCImageRC2
|
||||
from BackScatteringAlg import IndirectOrthorectification, DEMProcess, rpc_correction, getRCImageRC, get_RPC_lon_lat, \
|
||||
getRCImageRC2
|
||||
from BackScatteringAlg import ScatteringAlg as alg
|
||||
from tool.config.ConfigeHandle import Config as cf
|
||||
import os
|
||||
|
@ -25,7 +26,6 @@ import shutil
|
|||
import tarfile
|
||||
import sys
|
||||
|
||||
|
||||
if cf.get('debug') == 'True':
|
||||
DEBUG = True
|
||||
else:
|
||||
|
@ -35,13 +35,15 @@ tager = cf.get('tager')
|
|||
LogHandler.init_log_handler('run_log\\' + EXE_NAME)
|
||||
logger = logging.getLogger("mylog")
|
||||
# env_str = os.path.split(os.path.realpath(__file__))[0]
|
||||
env_str =os.path.dirname(os.path.abspath(sys.argv[0]))
|
||||
env_str = os.path.dirname(os.path.abspath(sys.argv[0]))
|
||||
os.environ['PROJ_LIB'] = env_str
|
||||
|
||||
|
||||
class ScatteringMain:
|
||||
"""
|
||||
后向散射系数主函数
|
||||
"""
|
||||
|
||||
def __init__(self, alg_xml_path):
|
||||
self.alg_xml_path = alg_xml_path
|
||||
self.imageHandler = ImageHandler()
|
||||
|
@ -71,7 +73,7 @@ class ScatteringMain:
|
|||
if self.__check_handler.check_run_env() is False:
|
||||
return False
|
||||
|
||||
input_para_names = ["SLC","DEM"]
|
||||
input_para_names = ["SLC", "DEM"]
|
||||
if self.__check_handler.check_input_paras(input_para_names) is False:
|
||||
return False
|
||||
|
||||
|
@ -79,7 +81,8 @@ class ScatteringMain:
|
|||
self.__create_work_space()
|
||||
self.__task_id = self.__alg_xml_handler.get_task_id()
|
||||
self.__input_paras = self.__alg_xml_handler.get_input_paras()
|
||||
self.__in_processing_paras = self.__init_processing_paras(self.__input_paras, self.__workspace_preprocessing_path)
|
||||
self.__in_processing_paras = self.__init_processing_paras(self.__input_paras,
|
||||
self.__workspace_preprocessing_path)
|
||||
SrcImageName = os.path.split(self.__input_paras["SLC"]['ParaValue'])[1].split('.tar.gz')[0]
|
||||
AlgorithmName = self.__alg_xml_handler.get_algorithm_name()
|
||||
TaskId = self.__alg_xml_handler.get_task_id()
|
||||
|
@ -87,13 +90,13 @@ class ScatteringMain:
|
|||
# out_name = os.path.splitext(os.path.splitext(os.path.basename(self.__input_paras['SLC']['ParaValue']))[0])[0]
|
||||
# self.__out_para = os.path.join(self.__workspace_path, EXE_NAME, 'Output', "BackScatteringProduct.tar.gz")
|
||||
self.__out_para = os.path.join(self.__workspace_path, EXE_NAME, 'Output', result_name)
|
||||
self.__alg_xml_handler.write_out_para("BackScatteringProduct", self.__out_para) # 写入输出参数
|
||||
self.__alg_xml_handler.write_out_para("BackScatteringProduct", self.__out_para) # 写入输出参数
|
||||
|
||||
logger.info('check_source success!')
|
||||
logger.info('progress bar: 30%')
|
||||
return True
|
||||
|
||||
def __init_processing_paras(self, names,out_path):
|
||||
def __init_processing_paras(self, names, out_path):
|
||||
"""
|
||||
:param names:字典列表,每个字典为一个输入产品的配置信息
|
||||
"""
|
||||
|
@ -107,14 +110,14 @@ class ScatteringMain:
|
|||
if para['DataType'] == 'File':
|
||||
processing_paras.update({name: para['ParaValue']})
|
||||
# if para['DataType'] == 'csv':
|
||||
# para_value_list = para['ParaValue'].split(";")
|
||||
# if len(para_value_list) == 1:
|
||||
# para_path = para['ParaValue']
|
||||
# processing_paras.update({name: para_path})
|
||||
# else:
|
||||
# for n, para_value in zip(range(len(para_value_list)), para_value_list):
|
||||
# processing_paras.update({'feature'+str(n): para_value})
|
||||
# self.__feature_name_list.append('feature'+str(n))
|
||||
# para_value_list = para['ParaValue'].split(";")
|
||||
# if len(para_value_list) == 1:
|
||||
# para_path = para['ParaValue']
|
||||
# processing_paras.update({name: para_path})
|
||||
# else:
|
||||
# for n, para_value in zip(range(len(para_value_list)), para_value_list):
|
||||
# processing_paras.update({'feature'+str(n): para_value})
|
||||
# self.__feature_name_list.append('feature'+str(n))
|
||||
elif para['DataType'] == 'tar.gz':
|
||||
paths = para['ParaValue'].split(';')
|
||||
for path in paths:
|
||||
|
@ -131,7 +134,7 @@ class ScatteringMain:
|
|||
else:
|
||||
file_path = DEMProcess.unzip_file(para['ParaValue'], out_path)
|
||||
processing_paras.update({name: file_path})
|
||||
elif para['DataType'] == 'tif' or para['DataType'] == 'tiff': # 新增修改dem数据为文件绝对路径
|
||||
elif para['DataType'] == 'tif' or para['DataType'] == 'tiff': # 新增修改dem数据为文件绝对路径
|
||||
if para['ParaValue'] != 'empty' and para['ParaValue'] != 'Empty' and para['ParaValue'] != '':
|
||||
para_path_list = para['ParaValue'].split(";")
|
||||
if len(para_path_list) != 0:
|
||||
|
@ -191,21 +194,24 @@ class ScatteringMain:
|
|||
"""
|
||||
删除原有工作区文件夹,创建新工作区文件夹
|
||||
"""
|
||||
self.__workspace_preprocessing_path = os.path.join(self.__workspace_path, EXE_NAME, "Temporary", "preprocessing") # self.__workspace_path + EXE_NAME + r"\Temporary\preprocessing""\\"
|
||||
self.__workspace_preprocessed_path = os.path.join(self.__workspace_path, EXE_NAME, "Temporary", "preprocessed") # self.__workspace_path + EXE_NAME + r"\Temporary\preprocessed""\\"
|
||||
self.__workspace_processing_path = os.path.join(self.__workspace_path, EXE_NAME, "Temporary","processing\\") #self.__workspace_path + EXE_NAME + r"\Temporary\processing""\\"
|
||||
self.__workspace_preprocessing_path = os.path.join(self.__workspace_path, EXE_NAME, "Temporary",
|
||||
"preprocessing") # self.__workspace_path + EXE_NAME + r"\Temporary\preprocessing""\\"
|
||||
self.__workspace_preprocessed_path = os.path.join(self.__workspace_path, EXE_NAME, "Temporary",
|
||||
"preprocessed") # self.__workspace_path + EXE_NAME + r"\Temporary\preprocessed""\\"
|
||||
self.__workspace_processing_path = os.path.join(self.__workspace_path, EXE_NAME, "Temporary",
|
||||
"processing\\") # self.__workspace_path + EXE_NAME + r"\Temporary\processing""\\"
|
||||
self.__workspace_origin_path = os.path.join(self.__workspace_path, EXE_NAME, "Temporary", "origin")
|
||||
path_list = [self.__workspace_preprocessing_path, self.__workspace_preprocessed_path,
|
||||
self.__workspace_processing_path, self.__workspace_origin_path]
|
||||
|
||||
for path in path_list:
|
||||
if os.path.exists(path):
|
||||
if DEBUG is True:
|
||||
continue
|
||||
self.del_floder(path)
|
||||
os.makedirs(path)
|
||||
else:
|
||||
os.makedirs(path)
|
||||
if os.path.exists(path):
|
||||
if DEBUG is True:
|
||||
continue
|
||||
self.del_floder(path)
|
||||
os.makedirs(path)
|
||||
else:
|
||||
os.makedirs(path)
|
||||
logger.info('create new workspace success!')
|
||||
|
||||
def del_file(self, path_data):
|
||||
|
@ -220,6 +226,7 @@ class ScatteringMain:
|
|||
os.remove(file_data)
|
||||
else:
|
||||
self.del_file(file_data)
|
||||
|
||||
@staticmethod
|
||||
def del_floder(dic):
|
||||
"""
|
||||
|
@ -250,7 +257,8 @@ class ScatteringMain:
|
|||
"""
|
||||
if DEBUG is True:
|
||||
return
|
||||
path = os.path.join(self.__workspace_path, EXE_NAME, "Temporary") # self.__workspace_path + EXE_NAME + r"\Temporary"
|
||||
path = os.path.join(self.__workspace_path, EXE_NAME,
|
||||
"Temporary") # self.__workspace_path + EXE_NAME + r"\Temporary"
|
||||
if os.path.exists(path):
|
||||
self.del_floder(path)
|
||||
|
||||
|
@ -269,7 +277,7 @@ class ScatteringMain:
|
|||
pp().cut_img(sim_ori_process, sim_ori, shp_path)
|
||||
return sim_ori_process
|
||||
|
||||
def process_handle(self,start):
|
||||
def process_handle(self, start):
|
||||
in_tif_paths = list(glob.glob(os.path.join(self.__in_processing_paras['SLC'], '*.tif')))
|
||||
if in_tif_paths == []:
|
||||
in_tif_paths = list(glob.glob(os.path.join(self.__in_processing_paras['SLC'], '*.tiff')))
|
||||
|
@ -284,11 +292,11 @@ class ScatteringMain:
|
|||
vh_flag = 1
|
||||
elif 'VV' in os.path.basename(in_tif_path):
|
||||
vv_flag = 1
|
||||
self.processinfo=[hh_flag, hv_flag, vh_flag, vv_flag]
|
||||
self.processinfo = [hh_flag, hv_flag, vh_flag, vv_flag]
|
||||
|
||||
ref_tif_path = ""
|
||||
meta_file_path = self.__in_processing_paras['META']
|
||||
rpc_path=None
|
||||
rpc_path = None
|
||||
|
||||
#######################
|
||||
# RD
|
||||
|
@ -296,28 +304,32 @@ class ScatteringMain:
|
|||
# 2.2 生成局地入射角
|
||||
path2 = env_str
|
||||
print("path2:" + path2)
|
||||
Orthorectification = IndirectOrthorectification(os.path.join(path2,"config.yaml"))
|
||||
Orthorectification.IndirectOrthorectification(self.__in_processing_paras["SLC"], self.__workspace_processing_path) # 改动1
|
||||
Orthorectification = IndirectOrthorectification(os.path.join(path2, "config.yaml"))
|
||||
Orthorectification.IndirectOrthorectification(self.__in_processing_paras["SLC"],
|
||||
self.__workspace_processing_path) # 改动1
|
||||
# 2.3 输出结果
|
||||
|
||||
# 3 处理RD
|
||||
# 合并DEM
|
||||
Orth_Slc=[]
|
||||
Orth_Slc = []
|
||||
in_dem_path = self.__in_processing_paras['DEM']
|
||||
meta_file_path = self.__in_processing_paras['META'] # .meta文件路径
|
||||
meta_file_path = self.__in_processing_paras['META'] # .meta文件路径
|
||||
out_dem_path = self.__workspace_preprocessing_path
|
||||
# unzipped_folder_path = DEMProcess.unzip_file(in_dem_path, self.__workspace_origin_path) # 解压DEM.zip
|
||||
|
||||
dem_merged_path=DEMProcess.dem_merged(in_dem_path, meta_file_path, out_dem_path) # 生成TestDEM\mergedDEM_VRT.tif
|
||||
dem_merged_path = DEMProcess.dem_merged(in_dem_path, meta_file_path,
|
||||
out_dem_path) # 生成TestDEM\mergedDEM_VRT.tif
|
||||
|
||||
in_slc_path=None
|
||||
in_slc_path = None
|
||||
for slc_path in in_tif_paths:
|
||||
if slc_path.find(".tiff")>0 and (slc_path.find("_HH_")>0 or slc_path.find("_VV_")>0):
|
||||
in_slc_path=slc_path
|
||||
if slc_path.find(".tiff") > 0 and (
|
||||
slc_path.find("_HH_") > 0 or slc_path.find("_VV_") > 0 or slc_path.find("_DH_") > 0):
|
||||
in_slc_path = slc_path
|
||||
break
|
||||
|
||||
# 获取校正模型后
|
||||
Orthorectification.preCaldem_sar_rc(dem_merged_path,in_slc_path,self.__workspace_preprocessing_path,self.__workspace_processing_path.replace("\\","\\\\")) # 初步筛选坐标范围
|
||||
Orthorectification.preCaldem_sar_rc(dem_merged_path, in_slc_path, self.__workspace_preprocessing_path,
|
||||
self.__workspace_processing_path.replace("\\", "\\\\")) # 初步筛选坐标范围
|
||||
logger.info('progress bar: 40%')
|
||||
# clip_dem_reample_path=os.path.join(self.__workspace_preprocessing_path, "SAR_dem.tiff")
|
||||
# infooption=gdal.InfoOptions("-json")
|
||||
|
@ -325,20 +337,22 @@ class ScatteringMain:
|
|||
# dem_merged_info=gdal.Info(dem_merged_path,options=infooption)
|
||||
# sampling_f=clip_dem_tif_info['size'][0]/dem_merged_info['size'][0]
|
||||
# 处理RD 的结果
|
||||
out_dir_path=self.__workspace_processing_path.replace("\\","\\\\")
|
||||
out_dir_path = self.__workspace_processing_path.replace("\\", "\\\\")
|
||||
this_outSpace_path = out_dir_path
|
||||
this_out_dem_slantRange_path = os.path.join(out_dir_path, "dem_slantRange.tiff") # out_dir_path + "\\" + "dem_slantRange.tiff"#// 地形斜距
|
||||
this_out_plant_slantRange_path = os.path.join(out_dir_path, "flat_slantRange.tiff") # out_dir_path + "\\" + "flat_slantRange.tiff"#// 平地斜距
|
||||
this_out_dem_slantRange_path = os.path.join(out_dir_path,
|
||||
"dem_slantRange.tiff") # out_dir_path + "\\" + "dem_slantRange.tiff"#// 地形斜距
|
||||
this_out_plant_slantRange_path = os.path.join(out_dir_path,
|
||||
"flat_slantRange.tiff") # out_dir_path + "\\" + "flat_slantRange.tiff"#// 平地斜距
|
||||
# 保留结果
|
||||
if(os.path.exists(this_out_dem_slantRange_path)):
|
||||
if (os.path.exists(this_out_dem_slantRange_path)):
|
||||
os.remove(this_out_dem_slantRange_path)
|
||||
|
||||
if(os.path.exists(this_out_plant_slantRange_path)):
|
||||
if (os.path.exists(this_out_plant_slantRange_path)):
|
||||
os.remove(this_out_plant_slantRange_path)
|
||||
|
||||
|
||||
this_out_dem_rc_path = os.path.join(out_dir_path, "WGS_SAR_map.tiff") # out_dir_path + "\\" + "WGS_SAR_map.tiff"#// 经纬度与行列号映射
|
||||
if(os.path.exists(this_out_dem_rc_path)):
|
||||
this_out_dem_rc_path = os.path.join(out_dir_path,
|
||||
"WGS_SAR_map.tiff") # out_dir_path + "\\" + "WGS_SAR_map.tiff"#// 经纬度与行列号映射
|
||||
if (os.path.exists(this_out_dem_rc_path)):
|
||||
os.remove(this_out_dem_rc_path)
|
||||
|
||||
this_out_sar_sim_path = out_dir_path + "\\" + "sar_sim.tiff"
|
||||
|
@ -349,21 +363,28 @@ class ScatteringMain:
|
|||
if (os.path.exists(this_out_sar_sim_wgs_path)):
|
||||
os.remove(this_out_sar_sim_wgs_path)
|
||||
|
||||
this_out_incidence_path = os.path.join(out_dir_path, "incidentAngle.tiff") # out_dir_path + "\\" + "incidentAngle.tiff"#// 入射角
|
||||
this_out_localIncidenct_path = os.path.join(out_dir_path, "localIncidentAngle.tiff") # out_dir_path + "\\" + "localIncidentAngle.tiff"#// 局地入射角
|
||||
if(os.path.exists(this_out_incidence_path)):
|
||||
shutil.move(this_out_incidence_path,os.path.join(out_dir_path, "inc_angle.tif")) # out_dir_path + "\\" + "inc_angle.tif")
|
||||
if(os.path.exists(this_out_localIncidenct_path)):
|
||||
shutil.move(this_out_localIncidenct_path, os.path.join(out_dir_path, "LocalIncidenceAngle.tif")) # out_dir_path + "\\" + "LocalIncidenceAngle.tif")
|
||||
this_out_incidence_path = os.path.join(out_dir_path,
|
||||
"incidentAngle.tiff") # out_dir_path + "\\" + "incidentAngle.tiff"#// 入射角
|
||||
this_out_localIncidenct_path = os.path.join(out_dir_path,
|
||||
"localIncidentAngle.tiff") # out_dir_path + "\\" + "localIncidentAngle.tiff"#// 局地入射角
|
||||
if (os.path.exists(this_out_incidence_path)):
|
||||
shutil.move(this_out_incidence_path,
|
||||
os.path.join(out_dir_path, "inc_angle.tif")) # out_dir_path + "\\" + "inc_angle.tif")
|
||||
if (os.path.exists(this_out_localIncidenct_path)):
|
||||
shutil.move(this_out_localIncidenct_path, os.path.join(out_dir_path,
|
||||
"LocalIncidenceAngle.tif")) # out_dir_path + "\\" + "LocalIncidenceAngle.tif")
|
||||
|
||||
this_out_inc_angle_rpc_path = os.path.join(out_dir_path, "RD_incidentAngle.tiff") # out_dir_path + "\\" + "RD_incidentAngle.tiff"#// 局地入射角
|
||||
this_out_local_inc_angle_rpc_path = os.path.join(out_dir_path, "RD_localIncidentAngle.tiff") # out_dir_path + "\\" + "RD_localIncidentAngle.tiff"#// 局地入射角
|
||||
if(os.path.exists(this_out_inc_angle_rpc_path)):
|
||||
this_out_inc_angle_rpc_path = os.path.join(out_dir_path,
|
||||
"RD_incidentAngle.tiff") # out_dir_path + "\\" + "RD_incidentAngle.tiff"#// 局地入射角
|
||||
this_out_local_inc_angle_rpc_path = os.path.join(out_dir_path,
|
||||
"RD_localIncidentAngle.tiff") # out_dir_path + "\\" + "RD_localIncidentAngle.tiff"#// 局地入射角
|
||||
if (os.path.exists(this_out_inc_angle_rpc_path)):
|
||||
os.remove(this_out_inc_angle_rpc_path)
|
||||
if(os.path.exists(this_out_local_inc_angle_rpc_path)):
|
||||
if (os.path.exists(this_out_local_inc_angle_rpc_path)):
|
||||
os.remove(this_out_local_inc_angle_rpc_path)
|
||||
|
||||
this_out_ori_sim_tiff = os.path.join(out_dir_path, "RD_ori_sim.tif") # out_dir_path + "\\" + "RD_ori_sim.tif"#// 局地入射角
|
||||
this_out_ori_sim_tiff = os.path.join(out_dir_path,
|
||||
"RD_ori_sim.tif") # out_dir_path + "\\" + "RD_ori_sim.tif"#// 局地入射角
|
||||
this_in_rpc_lon_lat_path = this_out_ori_sim_tiff
|
||||
|
||||
this_out_sim_ori_tiff = os.path.join(out_dir_path, "RD_sim_ori.tif")
|
||||
|
@ -373,15 +394,18 @@ class ScatteringMain:
|
|||
|
||||
parameter_path = os.path.join(self.__workspace_processing_path, "orth_para.txt")
|
||||
|
||||
|
||||
for in_tif_path in in_tif_paths:
|
||||
# out_tif_path = os.path.join(self.__workspace_preprocessing_path,os.path.splitext(os.path.basename(in_tif_path))[0]) + r"_lin.tif"
|
||||
out_tif_path = os.path.join(self.__workspace_preprocessing_path,os.path.splitext(os.path.basename(in_tif_path))[0]) + r"_lin.tif"
|
||||
if ('HH' in os.path.basename(in_tif_path)) or ('HV' in os.path.basename(in_tif_path)) or ('VH' in os.path.basename(in_tif_path)) or ('VV' in os.path.basename(in_tif_path)):
|
||||
out_tif_path = os.path.join(self.__workspace_preprocessing_path,
|
||||
os.path.splitext(os.path.basename(in_tif_path))[0]) + r"_lin.tif"
|
||||
if ('HH' in os.path.basename(in_tif_path)) or ('HV' in os.path.basename(in_tif_path)) or (
|
||||
'VH' in os.path.basename(in_tif_path)) or ('VV' in os.path.basename(in_tif_path)) or (
|
||||
'DH' in os.path.basename(in_tif_path)):
|
||||
alg.sar_backscattering_coef(in_tif_path, meta_file_path, out_tif_path)
|
||||
# 构建RPC
|
||||
# 查找RPC
|
||||
rpc_path=in_tif_path.replace(".tiff",".rpc") if os.path.exists(in_tif_path.replace(".tiff",".rpc")) else in_tif_path.replace(".tiff",".rpb")
|
||||
rpc_path = in_tif_path.replace(".tiff", ".rpc") if os.path.exists(
|
||||
in_tif_path.replace(".tiff", ".rpc")) else in_tif_path.replace(".tiff", ".rpb")
|
||||
if not os.path.exists(rpc_path):
|
||||
logger.error('rpc not found!')
|
||||
|
||||
|
@ -392,7 +416,8 @@ class ScatteringMain:
|
|||
# out_tif_path,
|
||||
# lin_tif_path)
|
||||
# 线性->地理编码->db
|
||||
lin_tif_path=os.path.join(self.__workspace_preprocessing_path,os.path.splitext(os.path.basename(in_tif_path))[0]) + r"-lin_geo.tif"
|
||||
lin_tif_path = os.path.join(self.__workspace_preprocessing_path,
|
||||
os.path.splitext(os.path.basename(in_tif_path))[0]) + r"-lin_geo.tif"
|
||||
# Orthorectification.calInterpolation_cubic_Wgs84_rc_sar_sigma(parameter_path, this_in_rpc_x_y_path_pro,
|
||||
# out_tif_path,
|
||||
# lin_tif_path)
|
||||
|
@ -402,29 +427,28 @@ class ScatteringMain:
|
|||
lin_tif_path)
|
||||
tempout_tif_path = os.path.join(self.__workspace_processing_path,
|
||||
os.path.splitext(os.path.basename(in_tif_path))[0]) + tager + r".tif"
|
||||
alg.lin_to_db(lin_tif_path, tempout_tif_path) #线性值转回DB值
|
||||
|
||||
alg.lin_to_db(lin_tif_path, tempout_tif_path) # 线性值转回DB值
|
||||
|
||||
# 移动RPC
|
||||
#rpc_correction(in_tif_path,rpc_path,out_tif_path,dem_tif_file = None)
|
||||
# rpc_correction(in_tif_path,rpc_path,out_tif_path,dem_tif_file = None)
|
||||
# Orthorectification.inter_Range2Geo(this_in_rpc_lon_lat_path,out_tif_path,tempout_tif_path,Orthorectification.heightspace)
|
||||
|
||||
self.imageHandler.write_quick_view(tempout_tif_path, color_img=False)
|
||||
# self.imageHandler.write_quick_view(lin_tif_path, color_img=False)
|
||||
else:
|
||||
shutil.copy(in_tif_path,self.__workspace_processing_path)
|
||||
shutil.copy(in_tif_path, self.__workspace_processing_path)
|
||||
ref_tif_path = tempout_tif_path
|
||||
# ref_tif_path = lin_tif_path
|
||||
# 构建行列号映射表
|
||||
#out_rpc_rc_path = os.path.join(self.__workspace_processing_path,"RPC_ori_sim.tif")
|
||||
#getRCImageRC(in_tif_path,out_rpc_rc_path,rpc_path)
|
||||
# out_rpc_rc_path = os.path.join(self.__workspace_processing_path,"RPC_ori_sim.tif")
|
||||
# getRCImageRC(in_tif_path,out_rpc_rc_path,rpc_path)
|
||||
logger.info('progress bar: 90%')
|
||||
if(os.path.exists(this_in_rpc_lon_lat_path)):
|
||||
if (os.path.exists(this_in_rpc_lon_lat_path)):
|
||||
os.remove(this_in_rpc_lon_lat_path)
|
||||
if (os.path.exists(this_in_rpc_x_y_path)):
|
||||
os.remove(this_in_rpc_x_y_path)
|
||||
# out_mate_file_path = os.path.join(self.__workspace_processing_path,os.path.split(meta_file_path)[1].rstrip('.meta.xml') + '_DB.meta.xml')
|
||||
out_mate_file_path = os.path.join(self.__workspace_processing_path,os.path.basename(meta_file_path))
|
||||
# out_mate_file_path = os.path.join(self.__workspace_processing_path,os.path.split(meta_file_path)[1].rstrip('.meta.xml') + '_DB.meta.xml')
|
||||
out_mate_file_path = os.path.join(self.__workspace_processing_path, os.path.basename(meta_file_path))
|
||||
shutil.copy(meta_file_path, out_mate_file_path)
|
||||
|
||||
if ref_tif_path != "":
|
||||
|
@ -480,8 +504,8 @@ class ScatteringMain:
|
|||
if __name__ == '__main__':
|
||||
start = datetime.datetime.now()
|
||||
try:
|
||||
if len(sys.argv)<2:
|
||||
xml_path = 'BackScattering.xml'
|
||||
if len(sys.argv) < 2:
|
||||
xml_path = 'BackScattering_C_SAR_V3.xml'
|
||||
else:
|
||||
xml_path = sys.argv[1]
|
||||
ScatteringMain = ScatteringMain(xml_path)
|
||||
|
|
Binary file not shown.
|
@ -53,7 +53,7 @@
|
|||
<ParaType>File</ParaType>
|
||||
<DataType>csv</DataType>
|
||||
<ParaSource>Man</ParaSource>
|
||||
<ParaValue>E:\isce_yuan\lancover-yuan\output_wkt.csv</ParaValue>
|
||||
<ParaValue>E:\isce_yuan\lancover-yuan\train_landConver1.csv</ParaValue>
|
||||
<EnModification>True</EnModification>
|
||||
<EnMultipleChoice>True</EnMultipleChoice>
|
||||
<Control>UploadInput</Control>
|
||||
|
@ -94,37 +94,6 @@
|
|||
<InputType>Aux</InputType>
|
||||
<InputNum>0</InputNum>
|
||||
<DateFrom>Aux</DateFrom>
|
||||
</Parameter>
|
||||
<Parameter>
|
||||
<ParaName>Kernel</ParaName>
|
||||
<ParaChsName>核函数</ParaChsName>
|
||||
<Description>SVM模型核函数(Kernel):rbf、poly、linear</Description>
|
||||
<ParaType>Value</ParaType>
|
||||
<DataType>string</DataType>
|
||||
<ParaSource>Man</ParaSource>
|
||||
<ParaValue>rbf</ParaValue>
|
||||
<EnModification>True</EnModification>
|
||||
<EnMultipleChoice>True</EnMultipleChoice>
|
||||
<Control>UploadInput</Control>
|
||||
<InputType>Aux</InputType>
|
||||
<InputNum>0</InputNum>
|
||||
<DateFrom>Aux</DateFrom>
|
||||
</Parameter>
|
||||
<Parameter>
|
||||
<ParaName>Cost</ParaName>
|
||||
<ParaChsName>惩戒参数</ParaChsName>
|
||||
<Description>默认值为1.0。错误项的惩罚系数。C越大,即对分错样本的惩罚程度越大,因此在训练样本中准确率越高,但是泛化能力降低,也就是对测试数据的分类准确率降低。
|
||||
相反,减小C的话,容许训练样本中有一些误分类错误样本,泛化能力强。对于训练样本带有噪声的情况,一般采用后者,把训练样本集中错误分类的样本作为噪声。</Description>
|
||||
<ParaType>Value</ParaType>
|
||||
<DataType>int</DataType>
|
||||
<ParaSource>Man</ParaSource>
|
||||
<ParaValue>1</ParaValue>
|
||||
<EnModification>True</EnModification>
|
||||
<EnMultipleChoice>True</EnMultipleChoice>
|
||||
<Control>UploadInput</Control>
|
||||
<InputType>Aux</InputType>
|
||||
<InputNum>0</InputNum>
|
||||
<DateFrom>Aux</DateFrom>
|
||||
</Parameter>
|
||||
</Inputs>
|
||||
<Outputs ParameterNum="1">
|
||||
|
|
|
@ -567,12 +567,12 @@ class LandCoverMain:
|
|||
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"]
|
||||
kernel = self.__processing_paras["Kernel"]
|
||||
if cost < 0:
|
||||
cost = 1
|
||||
if kernel != 'rbf' and kernel != 'poly' and kernel != 'linear' and kernel != 'sigmoid':
|
||||
kernel = 'rbf'
|
||||
# cost = self.__processing_paras["Cost"]
|
||||
# kernel = self.__processing_paras["Kernel"]
|
||||
# if cost < 0:
|
||||
# cost = 1
|
||||
# if kernel != 'rbf' and kernel != 'poly' and kernel != 'linear' and kernel != 'sigmoid':
|
||||
# kernel = 'rbf'
|
||||
|
||||
# RF
|
||||
clf = ml.trainRF(X_train, Y_train)
|
||||
|
|
|
@ -392,6 +392,20 @@ class MachineLeaning:
|
|||
logger.info('total:%s,num:%s create train set success!', len(measured_data_img), n)
|
||||
return np.array(X_train), np.array(Y_train)
|
||||
|
||||
@staticmethod
|
||||
def get_train_data(features_array, measured_data):
|
||||
X_train = []
|
||||
Y_train = []
|
||||
for data in measured_data:
|
||||
row = data[0]
|
||||
col = data[1]
|
||||
feature = features_array[:, row, col]
|
||||
if not np.isnan(feature).any() or np.isinf(feature).any():
|
||||
X_train.append(list(feature))
|
||||
Y_train.append([data[2]])
|
||||
|
||||
return np.array(X_train), np.array(Y_train)
|
||||
|
||||
@staticmethod
|
||||
def trainRF(X_train, Y_train):
|
||||
#随机森林
|
||||
|
|
|
@ -165,14 +165,14 @@ class ManageAlgXML:
|
|||
env_note = self.__alg_compt.find("Environment")
|
||||
|
||||
is_cluster = int(env_note.find("IsCluster").text.replace("\n", "").replace(' ', ''))
|
||||
is_legal = is_cluster in [0, 1]
|
||||
if not is_legal:
|
||||
raise Exception("IsCluster is not 0 or 1")
|
||||
# is_legal = is_cluster in [0, 1]
|
||||
# if not is_legal:
|
||||
# raise Exception("IsCluster is not 0 or 1")
|
||||
|
||||
cluster_num = int(env_note.find("ClusterNum").text)
|
||||
is_legal = cluster_num in [0, 1, 2, 3, 4, 5, 6, 7]
|
||||
if not is_legal:
|
||||
raise Exception("cluster_num is beyond [0,1,2,3,4,5,6,7]")
|
||||
# if not is_legal:
|
||||
# raise Exception("cluster_num is beyond [0,1,2,3,4,5,6,7]")
|
||||
|
||||
operating_system = env_note.find("OperatingSystem").text.replace("\n", "").replace(' ', '') #去除空格和回车
|
||||
# is_legal = operating_system in ["Windows10", "Windows7", "WindowsXP"]
|
||||
|
@ -186,8 +186,8 @@ class ManageAlgXML:
|
|||
|
||||
memory = env_note.find("Memory").text.replace("\n", "").replace(' ', '') #去除空格和回车
|
||||
is_legal = memory in ["1GB", "2GB", "4GB", "6GB", "8GB", "10GB", "12GB", "16GB"]
|
||||
if not is_legal:
|
||||
raise Exception("OperatingSystem is beyond [1GB, 2GB, 4GB, 6GB, 8GB, 10GB, 12GB, 16GB]")
|
||||
# if not is_legal:
|
||||
# raise Exception("OperatingSystem is beyond [1GB, 2GB, 4GB, 6GB, 8GB, 10GB, 12GB, 16GB]")
|
||||
|
||||
storage = env_note.find("Storage").text.replace("\n", "").replace(' ', '') #去除空格和回车
|
||||
is_legal = int(storage[:-2]) > 0
|
||||
|
@ -543,7 +543,7 @@ class InitPara:
|
|||
processing_paras.update({name+str(n): para_value})
|
||||
elif para['DataType'] == 'zip':
|
||||
# temp_para = para['ParaValue'].split(".")[0]
|
||||
para_value_list = out_path.split(";")
|
||||
para_value_list = para['ParaValue'].split(";")
|
||||
if len(para_value_list) == 1:
|
||||
para_path = para['ParaValue']
|
||||
if para_path != 'empty' and para_path != '':
|
||||
|
@ -716,8 +716,7 @@ class InitPara:
|
|||
para_dic.update({'name': name})
|
||||
|
||||
file_dir = os.path.join(workspace_preprocessing_path, name + '\\')
|
||||
if self._debug == False:
|
||||
fileHandle().de_targz(tar_gz_path, file_dir)
|
||||
fileHandle().de_targz(tar_gz_path, file_dir)
|
||||
# 元文件字典
|
||||
para_dic.update(InitPara.get_meta_dic_VP(InitPara.get_meta_paths(file_dir, name), name))
|
||||
# tif路径字典
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
import os
|
||||
import tarfile
|
||||
import shutil
|
||||
import zipfile
|
||||
|
||||
class fileHandle:
|
||||
def __init__(self, debug_mode=False):
|
||||
|
@ -63,6 +64,20 @@ class fileHandle:
|
|||
with tarfile.open(output_filename, "w:gz") as tar:
|
||||
tar.add(source_dir, arcname=os.path.basename(source_dir))
|
||||
|
||||
@staticmethod
|
||||
def make_zip(output_filename, source_file):
|
||||
"""
|
||||
一次性打包整个根目录。空子目录会被打包。
|
||||
如果只打包不压缩,将"w:gz"参数改为"w:"或"w"即可。
|
||||
:param output_filename:输出压缩包的完整路径,eg:'E:\test.tar.gz'
|
||||
:param source_dir:需要打包的跟目录,eg: 'E:\testFfile\'打包文件夹里面的所有文件,'E:\testFfile'打包文件夹
|
||||
"""
|
||||
dir = os.path.split(output_filename)[0]
|
||||
if os.path.exists(dir) is False:
|
||||
os.makedirs(dir)
|
||||
with zipfile.ZipFile(output_filename, "w") as zipf:
|
||||
zipf.write(source_file, os.path.basename(source_file))
|
||||
|
||||
@staticmethod
|
||||
def de_targz(tar_gz_path, file_dir):
|
||||
name = os.path.split(tar_gz_path)[1].rstrip('.tar.gz')
|
||||
|
@ -82,7 +97,9 @@ class fileHandle:
|
|||
os.makedirs(dir) # 创建路径
|
||||
shutil.copy(srcfile, dir + fname) # 复制文件
|
||||
|
||||
# if __name__ == '__main__':
|
||||
# file = fileHandle()
|
||||
# file.del_floder("I:\preprocessed")
|
||||
# pass
|
||||
if __name__ == '__main__':
|
||||
file = fileHandle()
|
||||
out_zip = r'D:\micro\WorkSpace\SoilSalinityTrain\Output\model.zip'
|
||||
source = r'D:\micro\WorkSpace\SoilSalinityTrain\Temporary\processing\product\model.pkl'
|
||||
file.make_zip(out_zip, source)
|
||||
pass
|
Loading…
Reference in New Issue