后向散射系数文件替换

Mn
mnCompanyPC1 2023-10-17 14:03:36 +08:00
parent 9218816d96
commit 031081d268
3 changed files with 52 additions and 16 deletions

View File

@ -329,10 +329,14 @@ class ScatteringMain:
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")
this_in_rpc_x_y_path = this_out_sim_ori_tiff
parameter_path = os.path.join(self.__workspace_processing_path, "orth_para.txt")
dem_rc = os.path.join(self.__workspace_preprocessing_path, "dem_rc.tiff")
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"_DB.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)):
alg.sar_backscattering_coef(in_tif_path, meta_file_path, out_tif_path)
@ -342,25 +346,36 @@ class ScatteringMain:
if not os.path.exists(rpc_path):
logger.error('rpc not found!')
# tempout_tif_path=os.path.join(self.__workspace_processing_path,os.path.splitext(os.path.basename(in_tif_path))[0]).replace("_L1A_","_L4_")+ r".tif"
tempout_tif_path=os.path.join(self.__workspace_processing_path,os.path.splitext(os.path.basename(in_tif_path))[0]) + r"-cal.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"
# lin_tif_path=os.path.join(self.__workspace_processing_path,os.path.splitext(os.path.basename(in_tif_path))[0]) + r"-cal.tif"
# 移动RPC
#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)
Orthorectification.calInterpolation_cubic_Wgs84_rc_sar_sigma(parameter_path, dem_rc, out_tif_path,
tempout_tif_path)
Orthorectification.calInterpolation_cubic_Wgs84_rc_sar_sigma(parameter_path, this_in_rpc_x_y_path, out_tif_path,
lin_tif_path)
# tempout_tif_path = os.path.join(self.__workspace_processing_path,
# os.path.splitext(os.path.basename(in_tif_path))[0]) + r"-cal.tif"
# alg.lin_to_db(lin_tif_path, tempout_tif_path) #线性值转回DB值
#shutil.move(rpc_path,out_tif_path.replace(".tiff",".rpc"))
self.imageHandler.write_quick_view(tempout_tif_path, color_img=False)
# 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)
ref_tif_path = tempout_tif_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)
logger.info('progress bar: 90%')
if(os.path.exists(this_in_rpc_lon_lat_path)):
os.remove(this_in_rpc_lon_lat_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')
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))
shutil.copy(meta_file_path, out_mate_file_path)

View File

@ -94,15 +94,30 @@ class ScatteringAlg:
# 计算后向散射系数
#对数形式
coef_arr = 10 * (np.log10(intensity_arr * ((QualifyValue/32767)**2))) - Kdb
coef_arr[np.isnan(coef_arr)] = -9999
coef_arr[np.isinf(coef_arr)] = -9999
coef_arr[where_9999_0] = -9999
coef_arr[where_9999_1] = -9999
tif_array = np.power(10.0, coef_arr / 10.0) # dB --> 线性值 后向散射系数
tif_array[np.isnan(tif_array)] = 0
tif_array[np.isinf(tif_array)] = 0
tif_array[where_9999_0] = 0
tif_array[where_9999_1] = 0
# coef_arr[np.isnan(coef_arr)] = -9999
# coef_arr[np.isinf(coef_arr)] = -9999
# coef_arr[where_9999_0] = -9999
# coef_arr[where_9999_1] = -9999
# 输出的SAR后向散射系数产品
ImageHandler.write_img(out_sar_tif, proj, geotrans, coef_arr, -9999)
# ImageHandler.write_img(out_sar_tif, proj, geotrans, coef_arr, 0)
ImageHandler.write_img(out_sar_tif, proj, geotrans, tif_array, 0)
return True
@staticmethod
def lin_to_db(lin_path, db_path):
proj, geotrans, in_data = ImageHandler.read_img(lin_path)
db_arr = 10 * np.log10(in_data)
# db_arr[np.isnan(db_arr)] = -9999
# db_arr[np.isinf(db_arr)] = -9999
ImageHandler.write_img(db_path, proj, geotrans, db_arr, -9999)
def FindInfomationFromJson(HeaderFile_dom_json, node_path_list):
@ -1154,6 +1169,8 @@ class Orthorectification(object):
# 12、PRF
HeaderInformation_json['PRF'] = float(
FindInfomationFromJson(HeaderFile_dom_json, self.config['sensor']['PRF']['NodePath']))
HeaderInformation_json['Fs'] = float(
FindInfomationFromJson(HeaderFile_dom_json, self.config['sensor']['Fs']['NodePath']))
# 13、中心时间
HeaderInformation_json['ImageInformation']['CenterTime'] = datetime.datetime.strptime(
FindInfomationFromJson(HeaderFile_dom_json, self.config['imageinfo']['CenterImageTime']['NodePath']),
@ -1176,6 +1193,7 @@ class Orthorectification(object):
self.heightspace=HeaderInformation_json['ImageInformation']['ImageHeightSpace']
self.refrange=HeaderInformation_json['ImageInformation']['refRange']
self.nearrange=HeaderInformation_json['ImageInformation']['NearRange']
self.Fs=HeaderInformation_json['Fs']*1e6 # Mhz
return HeaderInformation_json
pass
@ -1438,7 +1456,8 @@ class IndirectOrthorectification(Orthorectification):
fp.write("{}\n".format(self.header_info['ImageInformation']['StartTime']))
fp.write("{}\n".format(self.header_info['PRF']))
fp.write("{}\n".format(self.refrange))
fp.write("{}\n".format(self.widthspace))
fp.write("{}\n".format(self.Fs))
# fp.write("{}\n".format(self.widthspace))
# 多普勒系数
fp.write("{}\n".format(len(self.header_info['ImageInformation']['DopplerCentroidCoefficients'])))

View File

@ -91,6 +91,8 @@ sensor:
lambda: # 波长
NodePath:
['product','sensor','lamda']
Fs: # 等效采样频率 eqvFs
NodePath:
['product','imageinfo','eqvFs']
LightSpeed:
299792458