122 lines
4.0 KiB
Python
122 lines
4.0 KiB
Python
|
# -*- coding: UTF-8 -*-
|
|||
|
"""
|
|||
|
@Project :microproduct
|
|||
|
@File :ScatteringAuxData.py
|
|||
|
@Function :后向散射
|
|||
|
@Author :SHJ
|
|||
|
@Contact:
|
|||
|
@Date :2022/6/29
|
|||
|
@Version :1.0.0
|
|||
|
修改历史:
|
|||
|
[修改序列] [修改日期] [修改者] [修改内容]
|
|||
|
1 2022-6-29 石海军 1.兼容GF3元文件和正射校正元文件提取信息
|
|||
|
"""
|
|||
|
import logging
|
|||
|
from xml.etree.ElementTree import ElementTree
|
|||
|
logger = logging.getLogger("mylog")
|
|||
|
|
|||
|
class GF3L1AMetaData:
|
|||
|
def __init__(self):
|
|||
|
pass
|
|||
|
@staticmethod
|
|||
|
def get_QualifyValue(meta_file_path, polarization):
|
|||
|
tree = ElementTree()
|
|||
|
tree.parse(meta_file_path)
|
|||
|
root = tree.getroot()
|
|||
|
QualifyValue = float(root.find('imageinfo').find('QualifyValue').find(polarization).text)
|
|||
|
return QualifyValue
|
|||
|
|
|||
|
|
|||
|
@staticmethod
|
|||
|
def get_Kdb(meta_file_path, polarization):
|
|||
|
tree = ElementTree()
|
|||
|
tree.parse(meta_file_path)
|
|||
|
root = tree.getroot()
|
|||
|
Kdb = float(root.find('processinfo').find('CalibrationConst').find(polarization).text)
|
|||
|
return Kdb
|
|||
|
|
|||
|
class OrthoMetaData:
|
|||
|
def __init__(self):
|
|||
|
pass
|
|||
|
@staticmethod
|
|||
|
def get_QualifyValue(meta_file_path, polarization):
|
|||
|
tree = ElementTree()
|
|||
|
tree.parse(meta_file_path)
|
|||
|
root = tree.getroot()
|
|||
|
QualifyValue = float(root.find('l1aInfo').find('imageinfo').find('QualifyValue').find(polarization).text)
|
|||
|
return QualifyValue
|
|||
|
|
|||
|
@staticmethod
|
|||
|
def get_Kdb(meta_file_path, polarization):
|
|||
|
tree = ElementTree()
|
|||
|
tree.parse(meta_file_path)
|
|||
|
root = tree.getroot()
|
|||
|
Kdb = float(root.find('l1aInfo').find('processinfo').find('CalibrationConst').find(polarization).text)
|
|||
|
return Kdb
|
|||
|
|
|||
|
|
|||
|
@staticmethod
|
|||
|
def get_RadarCenterFrequency(meta_file_path):
|
|||
|
# 获取微波中心频率
|
|||
|
tree = ElementTree()
|
|||
|
tree.parse(meta_file_path)
|
|||
|
root = tree.getroot()
|
|||
|
RadarCenterFrequency = float(root.find('sensor').find('RadarCenterFrequency').text)
|
|||
|
return RadarCenterFrequency
|
|||
|
|
|||
|
|
|||
|
@staticmethod
|
|||
|
def get_lamda(meta_file_path):
|
|||
|
# 获取微波波长,单位:m
|
|||
|
tree = ElementTree()
|
|||
|
tree.parse(meta_file_path)
|
|||
|
root = tree.getroot()
|
|||
|
lamda = float(root.find('sensor').find('lamda').text)
|
|||
|
return lamda
|
|||
|
|
|||
|
class ScatteringAuxData:
|
|||
|
def __init__(self):
|
|||
|
pass
|
|||
|
|
|||
|
@staticmethod
|
|||
|
def get_QualifyValue(meta_file_path, polarization):
|
|||
|
try:
|
|||
|
QualifyValue = OrthoMetaData.get_QualifyValue(meta_file_path, polarization)
|
|||
|
except Exception:
|
|||
|
logger.warning('OrthoMetaData.get_QualifyValue() error!')
|
|||
|
QualifyValue = GF3L1AMetaData.get_QualifyValue(meta_file_path, polarization)
|
|||
|
logger.info('GF3L1AMetaData.get_QualifyValue() success!')
|
|||
|
return QualifyValue
|
|||
|
|
|||
|
@staticmethod
|
|||
|
def get_Kdb(meta_file_path, polarization):
|
|||
|
try:
|
|||
|
Kdb = OrthoMetaData.get_Kdb(meta_file_path, polarization)
|
|||
|
except Exception:
|
|||
|
logger.warning('OrthoMetaData.get_Kdb() error!')
|
|||
|
Kdb = GF3L1AMetaData.get_Kdb(meta_file_path, polarization)
|
|||
|
logger.info('GF3L1AMetaData.get_Kdb() success!')
|
|||
|
return Kdb
|
|||
|
|
|||
|
@staticmethod
|
|||
|
def get_RadarCenterFrequency(meta_file_path):
|
|||
|
# 获取微波中心频率,单位GHz
|
|||
|
RadarCenterFrequency = OrthoMetaData.get_RadarCenterFrequency(meta_file_path)
|
|||
|
return RadarCenterFrequency
|
|||
|
|
|||
|
@staticmethod
|
|||
|
def get_lamda(meta_file_path):
|
|||
|
# 获取微波波长,单位:m
|
|||
|
lamda = OrthoMetaData.get_lamda(meta_file_path)
|
|||
|
return lamda
|
|||
|
|
|||
|
# if __name__ == '__main__':
|
|||
|
# A = ScatteringAuxData()
|
|||
|
# dir = 'G:\MicroWorkspace\C-SAR\AuxSAR\GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HHHV_L10004829485_geo/'
|
|||
|
# path = dir + 'GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HHHV_L10004829485.meta.xml'
|
|||
|
# path1 = dir + 'OrthoProduct.meta.xml'
|
|||
|
# t1 = A.get_QualifyValue(path, 'HH')
|
|||
|
# t2 = A.get_Kdb(path, 'HH')
|
|||
|
# t3 = A.get_RadarCenterFrequency(path)
|
|||
|
# t4 = A.get_lamda(path)
|
|||
|
# pass
|