Remove use of deprecated XML ElementTree getchildren method

LT1AB
Ryan Burns 2021-05-13 10:59:16 -07:00
parent 19b754dd1a
commit a540c0116e
13 changed files with 211 additions and 213 deletions

View File

@ -246,7 +246,7 @@ from collections import UserDict
def dict_to_xml(adict,file,nodeTag=None,elementTag=None):
a = ET.Element(nodeTag) # something to hang nodes on
a = dict_to_et(a,adict,nodeTag,elementTag)
et = a.getchildren()[0]
et = list(a)[0]
indent(et)
tree = ET.ElementTree(et)
tree.write(file)

View File

@ -44,7 +44,7 @@ class CEOSDB(object):
self.metadata = {}
if not xml == None:
self.xmlFP = open(self.xml, 'r')
self.rootChildren = ET(file=self.xmlFP).getroot().getchildren()
self.rootChildren = list(ET(file=self.xmlFP).getroot())
else:
self.xmlFP = None
self.rootChildren = []
@ -81,7 +81,7 @@ class CEOSDB(object):
self.metadata[key] = [None]*loopCount
for i in range(loopCount):
struct = {}
for node in z.getchildren():
for node in z:
(subkey,data) = self.decodeNode(node)
struct[subkey] = data
self.metadata[key][i] = struct
@ -98,7 +98,7 @@ class CEOSDB(object):
xmlFP = open(self.xml, 'r')
self.root = ET(file=xmlFP).getroot()
for z in self.root.getchildren():
for z in self.root:
# If the tag name is 'rec', this is a plain old record
if z.tag == 'rec':
(key,data) = self.decodeNode(z)
@ -116,7 +116,7 @@ class CEOSDB(object):
self.metadata[key] = [None]*loopCount
for i in range(loopCount):
struct = {}
for node in z.getchildren():
for node in z:
(subkey,data) = self.decodeNode(node)
struct[subkey] = data
self.metadata[key][i] = struct

View File

@ -276,8 +276,8 @@ class Radarsat2_GRD(Component):
glist = (self.getxmlelement('imageAttributes/geographicInformation/geolocationGrid'))
lat = []
lon = []
for child in glist.getchildren():
for grandchild in child.getchildren():
for child in glist:
for grandchild in child:
string = ElementTree.tostring(grandchild, encoding = 'unicode', method = 'xml')
string = string.split("<")[1]
string = string.split(">")[0]
@ -303,7 +303,7 @@ class Radarsat2_GRD(Component):
if node.tag == 'stateVector':
sv = StateVector()
sv.configure()
for z in node.getchildren():
for z in node:
if z.tag == 'timeStamp':
timeStamp = self.convertToDateTime(z.text)
elif z.tag == 'xPosition':
@ -346,16 +346,16 @@ class Radarsat2_GRD(Component):
if not node.tag == 'imageTiePoint':
continue
for z in node.getchildren():
for z in node:
if z.tag == 'imageCoordinate':
for zz in z.getchildren():
for zz in z:
if zz.tag == 'line':
line = float(zz.text)
elif zz.tag == 'pixel':
pixel = float(zz.text)
if z.tag == 'geodeticCoordinate':
for zz in z.getchildren():
for zz in z:
if zz.tag == 'latitude':
lat = float(zz.text)
elif zz.tag == 'longitude':
@ -424,8 +424,8 @@ class Radarsat2_GRD(Component):
lines = []
data = []
for child in node.getchildren():
for child in node.getchildren():
for child in node:
for child in node:
string = ElementTree.tostring(child, encoding = 'unicode', method = 'xml')
string = string.split("<")[1]
string = string.split(">")[0]

View File

@ -406,7 +406,7 @@ class Sentinel1(Component):
lat = []
lon = []
for child in glist.getchildren():
for child in glist:
lat.append( float(child.find('latitude').text))
lon.append( float(child.find('longitude').text))
@ -502,7 +502,7 @@ class Sentinel1(Component):
frameOrbit = Orbit()
frameOrbit.configure()
for child in node.getchildren():
for child in node:
timestamp = self.convertToDateTime(child.find('time').text)
pos = []
vel = []
@ -543,7 +543,7 @@ class Sentinel1(Component):
tstart = self.product.sensingStart - margin
tend = self.product.sensingStop + margin
for child in node.getchildren():
for child in node:
timestamp = self.convertToDateTime(child.find('UTC').text[4:])
if (timestamp >= tstart) and (timestamp < tend):
@ -606,7 +606,7 @@ class Sentinel1(Component):
pixels = []
data = None
for ii, child in enumerate(node.getchildren()):
for ii, child in enumerate(node):
pixnode = child.find('pixel')
nump = int(pixnode.attrib['count'])
@ -685,7 +685,7 @@ class Sentinel1(Component):
noise_range_lut_indices = np.zeros((num_vectors,))
noise_range_lut_values = np.zeros((num_vectors, self.product.numberOfSamples))
for ii, child in enumerate(node.getchildren()):
for ii, child in enumerate(node):
print("Processing range noise vector {}/{}".format(ii + 1, num_vectors))
pixnode = child.find('pixel')
@ -711,7 +711,7 @@ class Sentinel1(Component):
noise_azimuth_lut_indices = defaultdict(list)
noise_azimuth_lut_values = defaultdict(list)
for block_i, child in enumerate(node.getchildren()):
for block_i, child in enumerate(node):
print("Processing azimuth noise vector {}/{}".format(block_i + 1, num_vectors))
linenode = child.find('line')
signode = child.find("noiseAzimuthLut")
@ -861,7 +861,7 @@ class Sentinel1(Component):
data = []
for ii, child in enumerate(node.getchildren()):
for ii, child in enumerate(node):
t0 = self.convertToDateTime(child.find('azimuthTime').text)
lines.append( (t0-self.product.sensingStart).total_seconds()/self.product.azimuthTimeInterval)

View File

@ -325,8 +325,8 @@ class Terrasar_GRD(Component):
glist = (self.getxmlelement(self._xml2_root, 'geolocationGrid'))
lat = []
lon = []
for child in glist.getchildren():
for grandchild in child.getchildren():
for child in glist:
for grandchild in child:
string = ElementTree.tostring(child, encoding = 'unicode', method = 'xml')
string = string.split("<")[1]
string = string.split(">")[0]
@ -352,7 +352,7 @@ class Terrasar_GRD(Component):
if node.tag == 'stateVec':
sv = StateVector()
sv.configure()
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
timeStamp = self.convertToDateTime2(z.text)
elif z.tag == 'posX':
@ -396,7 +396,7 @@ class Terrasar_GRD(Component):
if not node.tag == 'gridPoint':
continue
for zz in node.getchildren():
for zz in node:
if zz.tag == 't':
az_time = float(zz.text)
elif zz.tag == 'tau':
@ -429,9 +429,9 @@ class Terrasar_GRD(Component):
if not node.tag == 'antennaPattern':
continue
for z in node.getchildren():
for z in node:
if z.tag == 'elevationPattern':
for zz in z.getchildren():
for zz in z:
if zz.tag == 'gainExt':
node = float(zz.text)
node2.append(node)
@ -467,9 +467,9 @@ class Terrasar_GRD(Component):
for node in self._xml_root.find('productSpecific'):
if not node.tag == 'projectedImageInfo':
continue
for z in node.getchildren():
for z in node:
if z.tag == 'slantToGroundRangeProjection':
for zz in z.getchildren():
for zz in z:
if zz.tag == 'coefficient':
p = float(zz.text)*(SPEED_OF_LIGHT)
pp.append(p)

View File

@ -441,7 +441,7 @@ class _Product(Radarsat2Namespace):
self.imageAttributes = _ImageAttributes()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('productId'):
self.productId = z.text
elif z.tag == self.elementName('documentIdentifier'):
@ -483,7 +483,7 @@ class _SourceAttributes(Radarsat2Namespace):
self.orbitAndAttitude = _OrbitAndAttitude()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('satellite'):
self.satellite = z.text
elif z.tag == self.elementName('sensor'):
@ -548,7 +548,7 @@ class _RadarParameters(Radarsat2Namespace):
def set_from_etnode(self,node):
i = 0
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('acquisitionType'):
self.acquisitionType = z.text
elif z.tag == self.elementName('beams'):
@ -608,7 +608,7 @@ class _ReferenceNoiseLevel(Radarsat2Namespace):
self.noiseLevelValues = []
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('pixelFirstNoiseValue'):
self.pixelFirstNoiseValue = int(z.text)
elif z.tag == self.elementName('stepSize'):
@ -660,7 +660,7 @@ class _OrbitAndAttitude(Radarsat2Namespace):
self.attitudeInformation = _AttitudeInformation()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('orbitInformation'):
self.orbitInformation.set_from_etnode(z)
elif z.tag == self.elementName('attitudeInformation'):
@ -685,7 +685,7 @@ class _OrbitInformation(Radarsat2Namespace):
self.stateVectors = []
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('passDirection'):
self.passDirection = z.text
elif z.tag == self.elementName('orbitDataSource'):
@ -722,7 +722,7 @@ class _StateVector(Radarsat2Namespace):
self.zVelocity = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('timeStamp'):
self.timeStamp = self.convertToDateTime(z.text)
elif z.tag == self.elementName('xPosition'):
@ -766,7 +766,7 @@ class _AttitudeInformation(Radarsat2Namespace):
self.attitudeAngles = []
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('attitudeDataSource'):
self.attitudeDataSource = z.text
elif z.tag == self.elementName('attitudeOffsetApplied'):
@ -797,7 +797,7 @@ class _AttitudeAngles(Radarsat2Namespace):
self.pitch = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('timeStamp'):
self.timeStamp = self.convertToDateTime(z.text)
elif z.tag == self.elementName('yaw'):
@ -833,7 +833,7 @@ class _ImageGenerationParameters(Radarsat2Namespace):
self.payloadCharacteristicsFile = []
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('generalProcessingInformation'):
self.generalProcessingInformation.set_from_etnode(z)
elif z.tag == self.elementName('sarProcessingInformation'):
@ -869,7 +869,7 @@ class _GeneralProcessingInformation(Radarsat2Namespace):
self.softwareVersion = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('productType'):
self.productType = z.text
elif z.tag == self.elementName('_processingFacility'):
@ -925,7 +925,7 @@ class _SarProcessingInformation(Radarsat2Namespace):
self._satelliteHeight = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('lutApplied'):
self.lutApplied = z.text
elif z.tag == self.elementName('numberOfLinesProcessed'):
@ -971,7 +971,7 @@ class _Window(Radarsat2Namespace):
self.windowCoefficient = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('windowName'):
self.windowName = z.text
elif z.tag == self.elementName('windowCoefficient'):
@ -1000,7 +1000,7 @@ class _DopplerCentroid(Radarsat2Namespace):
self.dopplerCentroidConfidence = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('timeOfDopplerCentroidEstimate'):
self.timeOfDopplerCentroidEstimate = self.convertToDateTime(z.text)
elif z.tag == self.elementName('dopplerAmbiguity'):
@ -1027,7 +1027,7 @@ class _DopplerRateValues(Radarsat2Namespace):
self.dopplerRateValuesCoefficients = []
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('dopplerRateReferenceTime'):
self.dopplerRateReferenceTime = float(z.text)
elif z.tag == self.elementName('dopplerRateValuesCoefficients'):
@ -1056,7 +1056,7 @@ class _SlantRangeToGroundRange(Radarsat2Namespace):
self.groundToSlantRangeCoefficients = []
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('zeroDopplerAzimuthTime'):
self.zeroDopplerAzimuthTime = self.convertToDateTime(z.text)
elif z.tag == self.elementName('slantRangeTimeToFirstRangeSample'):
@ -1072,7 +1072,7 @@ class _ImageAttributes(Radarsat2Namespace):
self.fullResolutionImageData = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('productFormat'):
self.productFormat = z.text
elif z.tag == self.elementName('outputMediaInterleaving'):
@ -1097,7 +1097,7 @@ class _RasterAttributes(Radarsat2Namespace):
self.pixelTimeOrdering = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('dataType'):
self.dataType = z.text
elif z.tag == self.elementName('bitsPerSample'):
@ -1123,7 +1123,7 @@ class _GeographicInformation(Radarsat2Namespace):
self.referenceEllipsoidParameters = _ReferenceEllipsoidParameters()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('geolocationGrid'):
self.geolocationGrid.set_from_etnode(z)
@ -1133,7 +1133,7 @@ class _GeolocationGrid(Radarsat2Namespace):
self.imageTiePoint = []
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('imageTiePoint'):
tp = _ImageTiePoint()
tp.set_from_etnode(z)
@ -1147,7 +1147,7 @@ class _ImageTiePoint(Radarsat2Namespace):
self.geodeticCoordinates = _GeodeticCoordinates()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('imageCoordinate'):
self.imageCoordinates.set_from_etnode(z)
elif z.tag == self.elementName('geodeticCoordinate'):
@ -1170,7 +1170,7 @@ class _ImageCoordinates(Radarsat2Namespace):
self.pixel = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('line'):
self.line = float(z.text)
elif z.tag == self.elementName('pixel'):
@ -1194,7 +1194,7 @@ class _GeodeticCoordinates(Radarsat2Namespace):
self.height = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('latitude'):
self.latitude = float(z.text)
elif z.tag == self.elementName('longitude'):
@ -1223,7 +1223,7 @@ class _ReferenceEllipsoidParameters(Radarsat2Namespace):
self.geodeticTerrainHeight = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == self.elementName('ellipsoidName'):
self.ellipsoidName = z.text
elif z.tag == self.elementName('semiMajorAxis'):

View File

@ -370,7 +370,7 @@ class Sentinel1(Sensor):
frameOrbit = Orbit()
frameOrbit.setOrbitSource('Header')
for child in node.getchildren():
for child in node:
timestamp = self.convertToDateTime(child.find('time').text)
pos = []
vel = []
@ -416,7 +416,7 @@ class Sentinel1(Sensor):
tstart = self.frame.getSensingStart() - margin
tend = self.frame.getSensingStop() + margin
for child in node.getchildren():
for child in node:
timestamp = self.convertToDateTime(child.find('UTC').text[4:])
if (timestamp >= tstart) and (timestamp < tend):
@ -487,7 +487,7 @@ class Sentinel1(Sensor):
tdiff = 1.0e9
dpoly = None
for index, burst in enumerate(node.getchildren()):
for index, burst in enumerate(node):
refTime = self.convertToDateTime( burst.find('azimuthTime').text)
delta = abs((refTime - self.frame.sensingMid).total_seconds())

View File

@ -635,7 +635,7 @@ class Sentinel1(Component):
'''
burstList = self.getxmlelement('swathTiming/burstList')
for index, burst in enumerate(burstList.getchildren()):
for index, burst in enumerate(burstList):
bb = self.product.bursts[index]
bb.sensingStart = self.convertToDateTime(burst.find('azimuthTime').text)
deltaT = datetime.timedelta(seconds=(bb.numberOfLines - 1)*bb.azimuthTimeInterval)
@ -670,7 +670,7 @@ class Sentinel1(Component):
####Read in fm rates separately
fmrateList = self.getxmlelement('generalAnnotation/azimuthFmRateList')
fmRates = []
for index, burst in enumerate(fmrateList.getchildren()):
for index, burst in enumerate(fmrateList):
r0 = 0.5 * Const.c * float(burst.find('t0').text)
try:
c0 = float(burst.find('c0').text)
@ -702,7 +702,7 @@ class Sentinel1(Component):
dcList = self.getxmlelement('dopplerCentroid/dcEstimateList')
dops = [ ]
for index, burst in enumerate(dcList.getchildren()):
for index, burst in enumerate(dcList):
r0 = 0.5 * Const.c* float(burst.find('t0').text)
refTime = self.convertToDateTime(burst.find('azimuthTime').text)
@ -729,7 +729,7 @@ class Sentinel1(Component):
eapList = self.getxmlelement('antennaPattern/antennaPatternList')
eaps = []
for index, burst in enumerate(eapList.getchildren()):
for index, burst in enumerate(eapList):
refTime = self.convertToDateTime(burst.find('azimuthTime').text)
taus = [float(val) for val in burst.find('slantRangeTime').text.split()]
angs = [float(val) for val in burst.find('elevationAngle').text.split()]
@ -801,7 +801,7 @@ class Sentinel1(Component):
frameOrbit = Orbit()
frameOrbit.configure()
for child in node.getchildren():
for child in node:
timestamp = self.convertToDateTime(child.find('time').text)
pos = []
vel = []
@ -847,7 +847,7 @@ class Sentinel1(Component):
tstart = self.product.bursts[0].sensingStart - margin
tend = self.product.bursts[-1].sensingStop + margin
for child in node.getchildren():
for child in node:
timestamp = self.convertToDateTime(child.find('UTC').text[4:])
if (timestamp >= tstart) and (timestamp < tend):
@ -889,7 +889,7 @@ class Sentinel1(Component):
xml_root = ET.ElementTree(file=fp).getroot()
res = xml_root.find('calibrationParamsList/calibrationParams')
paramsList = xml_root.find('calibrationParamsList')
for par in (paramsList.getchildren()):
for par in paramsList:
if (par.find('swath').text.strip() == ('IW'+str(burst.swathNumber))) and (par.find('polarisation').text == burst.polarization):
self._delta_theta = float(par.find('elevationAntennaPattern/elevationAngleIncrement').text)
Geap_IQ = [float(val) for val in par.find('elevationAntennaPattern/values').text.split()]

View File

@ -122,8 +122,7 @@ class TanDEMX(Component):
raise IOError(strerr)
self._xml_root = ElementTree(file=fp).getroot()
a = self._xml_root.getchildren()
for z in a:
for z in self._xml_root:
if z.tag == 'generalHeader':
self.generalHeader.set_from_etnode(z)
if z.tag == 'productComponents':
@ -441,7 +440,7 @@ class _GeneralHeader(object):
self.fileName = node.attrib['fileName']
self.fileVersion = node.attrib['fileVersion']
self.status = node.attrib['status']
for z in node.getchildren():
for z in node:
if z.tag == 'itemName':
self.itemName = z.text
if z.tag == 'mission':
@ -512,7 +511,7 @@ class _ProductComponents(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'annotation':
self.annotation.append(_Annotation())
self.annotation[-1].set_from_etnode(z)
@ -554,7 +553,7 @@ class _Annotation(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'type':
self.type = z.text
if z.tag == 'file':
@ -581,7 +580,7 @@ class _ImageData(object):
def set_from_etnode(self,node):
self.layerIndex = int(node.attrib['layerIndex'])
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.type = z.text
if z.tag == 'file':
@ -610,7 +609,7 @@ class _QuickLooks(object):
def set_from_etnode(self,node):
self.layerIndex = int(node.attrib['layerIndex'])
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.type = z.text
if z.tag == 'file':
@ -636,7 +635,7 @@ class _CompositeQuickLook(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'file':
self.file.set_from_etnode(z)
return
@ -656,7 +655,7 @@ class _BrowseImage(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'file':
self.file.set_from_etnode(z)
return
@ -676,7 +675,7 @@ class _MapPlot(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'file':
self.file.set_from_etnode(z)
return
@ -706,7 +705,7 @@ class _ProductInfo(object):
self.sceneInfo = _SceneInfo()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'generationInfo':
self.generationInfo.set_from_etnode(z)
if z.tag == 'missionInfo':
@ -752,7 +751,7 @@ class _GenerationInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'logicalProductID':
self.logicalProductID = z.text
if z.tag == 'receivingStation':
@ -800,7 +799,7 @@ class _QualityInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'qualityInspection':
self.qualityInspection = z.text
if z.tag == 'qualityRemark':
@ -830,7 +829,7 @@ class _MissionInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'mission':
self.mission = z.text
if z.tag == 'orbitPhase':
@ -872,7 +871,7 @@ class _PolarisationList(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.polLayer = z.text
@ -890,7 +889,7 @@ class _ImagingModeStripMap(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'azimuthBeamID':
self.azimuthBeamID = z.text
return
@ -908,7 +907,7 @@ class _ImagingModeSpecificInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'stripMap':
self.stripMap.set_from_etnode(z)
return
@ -933,7 +932,7 @@ class _AcquisitionInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'sensor':
self.sensor = z.text
if z.tag == 'imagingMode':
@ -980,7 +979,7 @@ class _ProductVariantInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'productType':
self.productType = z.text
if z.tag == 'productVariant':
@ -1014,7 +1013,7 @@ class _ImageRaster(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'numberOfRows':
self.numberOfRows = int(z.text)
if z.tag == 'numberOfColumns':
@ -1062,7 +1061,7 @@ class _ImageDataInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'imageRaster':
self.imageRaster.set_from_etnode(z)
return
@ -1084,7 +1083,7 @@ class _SceneInfoTime(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = z.text
if z.tag == 'timeGPS':
@ -1111,7 +1110,7 @@ class _SceneInfoRangeTime(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'firstPixel':
self.firstPixel = float(z.text)
if z.tag == 'lastPixel':
@ -1139,7 +1138,7 @@ class _SceneInfoSceneCornerCoord(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'refRow':
self.refRow = int(z.text)
if z.tag == 'refColumn':
@ -1188,7 +1187,7 @@ class _SceneCenterCoord(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'refRow':
self.refRow = int(z.text)
if z.tag == 'refColumn':
@ -1237,7 +1236,7 @@ class _SceneInfo(object):
def set_from_etnode(self,node):
iCorner = -1
for z in node.getchildren():
for z in node:
if z.tag == 'sceneID':
self.sceneID = z.text
if z.tag == 'start':
@ -1282,7 +1281,7 @@ class _ProductSpecific(object):
self.complexImageInfo = _ComplexImageInfo()
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'complexImageInfo':
self.complexImageInfo.set_from_etnode(z)
return
@ -1302,7 +1301,7 @@ class _ComplexImageInfo(object):
self.quicklookDataStartWith = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'commonPRF':
self.commonPRF = float(z.text)
if z.tag == 'commonRSF':
@ -1348,7 +1347,7 @@ class _ProjectedSpacingRange(object):
self.slantRange = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'groundNear':
self.groundNear = float(z.text)
if z.tag == 'groundFar':
@ -1381,7 +1380,7 @@ class _Platform(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'referenceData':
self.referenceData.set_from_etnode(z)
if z.tag == 'orbit':
@ -1410,7 +1409,7 @@ class _SARAntennaPosition(object):
def set_from_etnode(self,node):
self.DRAoffset = node.attrib['DRAoffset']
for w in node.getchildren():
for w in node:
if w.tag == 'x':
self.x = float(w.text)
if w.tag == 'y':
@ -1438,7 +1437,7 @@ class _GPSAntennaPosition(object):
def set_from_etnode(self,node):
self.GPSreceiver = node.attrib['GPSreceiver']
self.unit = node.attrib['unit']
for w in node.getchildren():
for w in node:
if w.tag == 'x':
self.x = float(w.text)
if w.tag == 'y':
@ -1469,7 +1468,7 @@ class _PlatformReferenceData(object):
def set_from_etnode(self,node):
iGPSAnt = -1
for x in node.getchildren():
for x in node:
if x.tag == 'SARAntennaMechanicalBoresight':
self.SARAntennaMechanicalBoresight = float(x.text)
if x.tag == 'SARAntennaPosition':
@ -1497,7 +1496,7 @@ class _FirstStateTime(object):
self.firstStateTimeGPSFraction = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'firstStateTimeUTC':
self.firstStateTimeUTC = z.text
if z.tag == 'firstStateTimeGPS':
@ -1523,7 +1522,7 @@ class _LastStateTime(object):
self.lastStateTimeGPSFraction = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'lastStateTimeUTC':
self.lastStateTimeUTC = z.text
if z.tag == 'lastStateTimeGPS':
@ -1562,7 +1561,7 @@ class _OrbitHeader(object):
self.dataGapIndicator = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'generationSystem':
self.generationSystem = z.text
self.generationSystemVersion = z.attrib['version']
@ -1652,7 +1651,7 @@ class _StateVec(object):
self.maneuver = node.attrib['maneuver']
self.num = int(node.attrib['num'])
self.qualInd = int(node.attrib['qualInd'])
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = datetime.datetime.strptime(z.text,"%Y-%m-%dT%H:%M:%S.%f")
if z.tag == 'timeGPS':
@ -1700,7 +1699,7 @@ class _Orbit(object):
self.stateVec = ()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'orbitHeader':
self.orbitHeader.set_from_etnode(z)
if z.tag == 'stateVec':
@ -1737,7 +1736,7 @@ class _AttitudeData(object):
self.maneuver = node.attrib['maneuver']
self.num = int(node.attrib['num'])
self.qualInd = int(node.attrib['qualInd'])
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = z.text
if z.tag == 'timeGPS':
@ -1782,7 +1781,7 @@ class _FirstAttitudeTime(object):
self.firstAttitudeTimeGPSFraction = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'firstAttitudeTimeUTC':
self.firstAttitudeTimeUTC = z.text
if z.tag == 'firstAttitudeTimeGPS':
@ -1808,7 +1807,7 @@ class _LastAttitudeTime(object):
self.lastAttitudeTimeGPSFraction = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'lastAttitudeTimeUTC':
self.lastAttitudeTimeUTC = z.text
if z.tag == 'lastAttitudeTimeGPS':
@ -1834,7 +1833,7 @@ class _AttitudeDataRefFrame(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'FromFrame':
self.FromFrame = z.text
if z.tag == 'ToFrame':
@ -1870,7 +1869,7 @@ class _AttitudeHeader(object):
self.steeringLawIndicator = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'generationSystem':
self.generationSystem = z.text
self.generationSystemVersion = z.attrib['version']
@ -1948,7 +1947,7 @@ class _Attitude(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'attitudeHeader':
self.attitudeHeader.set_from_etnode(z)
if z.tag == 'attitudeData':
@ -1977,7 +1976,7 @@ class _Instrument(object):
self.settings = _InstrumentSettings()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'instrumentInfoCoordinateType':
self.instrumentInfoCoordinateType = z.text
if z.tag == 'radarParameters':
@ -2003,7 +2002,7 @@ class _RadarParameters(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'centerFrequency':
self.centerFrequency = float(z.text)
return
@ -2024,7 +2023,7 @@ class _RxGainSetting(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'startTimeUTC':
self.startTimeUTC = z.text
if z.tag == 'stopTimeUTC':
@ -2058,7 +2057,7 @@ class _DataSegment(object):
def set_from_etnode(self,node):
self.segmentID = int(node.attrib['segmentID'])
for z in node.getchildren():
for z in node:
if z.tag == 'startTimeUTC':
self.startTimeUTC = z.text
if z.tag == 'stopTimeUTC':
@ -2095,7 +2094,7 @@ class _SettingRecord(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'dataSegment':
self.dataSegment.set_from_etnode(z)
if z.tag == 'PRF':
@ -2157,7 +2156,7 @@ class _InstrumentSettings(object):
self.settingRecord = ()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.polLayer = z.text
if z.tag == 'DRAoffset':
@ -2245,7 +2244,7 @@ class _Processing(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'geometry':
self.geometry.set_from_etnode(z)
if z.tag == 'doppler':
@ -2279,7 +2278,7 @@ class _ProcessingGeometry(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'geometryCoordinateType':
self.geometryCoordinateType = z.text
if z.tag == 'velocityParameter':
@ -2315,7 +2314,7 @@ class _VelocityParameter(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = z.text
if z.tag == 'velocityParameterPolynomial':
@ -2342,7 +2341,7 @@ class _VelocityParameterPolynomial(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -2385,7 +2384,7 @@ class _ZeroDopplerVelocity(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'velocity':
self.velocity = float(z.text)
return
@ -2405,7 +2404,7 @@ class _DopplerRate(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = z.text
if z.tag == 'dopplerRatePolynomial':
@ -2432,7 +2431,7 @@ class _DopplerRatePolynomial(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -2477,7 +2476,7 @@ class _ProcessingDoppler(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'dopplerBasebandEstimationMethod':
self.dopplerBasebandEstimationMethod = z.text
if z.tag == 'dopplerGeometricEstimationMethod':
@ -2518,7 +2517,7 @@ class _ProcessingDopplerCentroid(object):
def set_from_etnode(self,node):
self.layerIndex = int(node.attrib['layerIndex'])
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.polLayer = z.text
if z.tag == 'DRAoffset':
@ -2581,7 +2580,7 @@ class _DopplerEstimate(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = z.text
if z.tag == 'dopplerAtMidRange':
@ -2636,7 +2635,7 @@ class _BasebandDoppler(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -2681,7 +2680,7 @@ class _GeometricDoppler(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -2727,7 +2726,7 @@ class _CombinedDoppler(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -2779,7 +2778,7 @@ class _ProcessingParameter(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'beamID':
self.beamID = z.text
if z.tag == 'processingInfoCoordinateType':
@ -2844,7 +2843,7 @@ class _RangeCompression(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'segmentInfo':
self.segmentInfo.set_from_etnode(z)
if z.tag == 'chirps':
@ -2869,7 +2868,7 @@ class _RCSegmentInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.polLayer = z.text
if z.tag == 'dataSegment':
@ -2894,7 +2893,7 @@ class _RCDataSegment(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'startTimeUTC':
self.startTimeUTC = z.text
if z.tag == 'stopTimeUTC':
@ -2921,7 +2920,7 @@ class _RCChirps(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'referenceChirp':
self.referenceChirp.set_from_etnode(z)
return
@ -2949,7 +2948,7 @@ class _RCReferenceChirp(object):
def set_from_etnode(self,node):
self.pulseCode = int(node.attrib['pulseCode'])
for z in node.getchildren():
for z in node:
if z.tag == 'pulseType':
self.pulseType = z.text
if z.tag == 'chirpDesignator':
@ -3002,7 +3001,7 @@ class _RCChirpAmplitude(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -3047,7 +3046,7 @@ class _RCChirpPhase(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -3090,7 +3089,7 @@ class _CorrectedInstrumentDelay(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.polLayer = z.text
if z.tag == 'DRAoffset':
@ -3143,7 +3142,7 @@ class _File(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'location':
self.location.set_from_etnode(z)
if z.tag == 'size':
@ -3172,7 +3171,7 @@ class _FileLocation(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'host':
self.host = z.text
if z.tag == 'path':

View File

@ -117,8 +117,7 @@ class TerraSARX(Sensor):
raise IOError(strerr)
self._xml_root = ElementTree(file=fp).getroot()
a = self._xml_root.getchildren()
for z in a:
for z in self._xml_root:
if z.tag == 'generalHeader':
self.generalHeader.set_from_etnode(z)
if z.tag == 'productComponents':
@ -407,7 +406,7 @@ class _GeneralHeader(object):
self.fileName = node.attrib['fileName']
self.fileVersion = node.attrib['fileVersion']
self.status = node.attrib['status']
for z in node.getchildren():
for z in node:
if z.tag == 'itemName':
self.itemName = z.text
if z.tag == 'mission':
@ -478,7 +477,7 @@ class _ProductComponents(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'annotation':
self.annotation.append(_Annotation())
self.annotation[-1].set_from_etnode(z)
@ -520,7 +519,7 @@ class _Annotation(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'type':
self.type = z.text
if z.tag == 'file':
@ -547,7 +546,7 @@ class _ImageData(object):
def set_from_etnode(self,node):
self.layerIndex = int(node.attrib['layerIndex'])
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.type = z.text
if z.tag == 'file':
@ -576,7 +575,7 @@ class _QuickLooks(object):
def set_from_etnode(self,node):
self.layerIndex = int(node.attrib['layerIndex'])
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.type = z.text
if z.tag == 'file':
@ -602,7 +601,7 @@ class _CompositeQuickLook(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'file':
self.file.set_from_etnode(z)
return
@ -622,7 +621,7 @@ class _BrowseImage(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'file':
self.file.set_from_etnode(z)
return
@ -642,7 +641,7 @@ class _MapPlot(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'file':
self.file.set_from_etnode(z)
return
@ -673,7 +672,7 @@ class _ProductInfo(object):
self.sceneInfo = _SceneInfo()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'generationInfo':
self.generationInfo.set_from_etnode(z)
if z.tag == 'missionInfo':
@ -719,7 +718,7 @@ class _GenerationInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'logicalProductID':
self.logicalProductID = z.text
if z.tag == 'receivingStation':
@ -767,7 +766,7 @@ class _QualityInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'qualityInspection':
self.qualityInspection = z.text
if z.tag == 'qualityRemark':
@ -797,7 +796,7 @@ class _MissionInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'mission':
self.mission = z.text
if z.tag == 'orbitPhase':
@ -839,7 +838,7 @@ class _PolarisationList(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.polLayer = z.text
@ -857,7 +856,7 @@ class _ImagingModeStripMap(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'azimuthBeamID':
self.azimuthBeamID = z.text
return
@ -875,7 +874,7 @@ class _ImagingModeSpecificInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'stripMap':
self.stripMap.set_from_etnode(z)
return
@ -900,7 +899,7 @@ class _AcquisitionInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'sensor':
self.sensor = z.text
if z.tag == 'imagingMode':
@ -947,7 +946,7 @@ class _ProductVariantInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'productType':
self.productType = z.text
if z.tag == 'productVariant':
@ -981,7 +980,7 @@ class _ImageRaster(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'numberOfRows':
self.numberOfRows = int(z.text)
if z.tag == 'numberOfColumns':
@ -1029,7 +1028,7 @@ class _ImageDataInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'imageRaster':
self.imageRaster.set_from_etnode(z)
return
@ -1051,7 +1050,7 @@ class _SceneInfoTime(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = z.text
if z.tag == 'timeGPS':
@ -1078,7 +1077,7 @@ class _SceneInfoRangeTime(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'firstPixel':
self.firstPixel = float(z.text)
if z.tag == 'lastPixel':
@ -1106,7 +1105,7 @@ class _SceneInfoSceneCornerCoord(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'refRow':
self.refRow = int(z.text)
if z.tag == 'refColumn':
@ -1155,7 +1154,7 @@ class _SceneCenterCoord(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'refRow':
self.refRow = int(z.text)
if z.tag == 'refColumn':
@ -1204,7 +1203,7 @@ class _SceneInfo(object):
def set_from_etnode(self,node):
iCorner = -1
for z in node.getchildren():
for z in node:
if z.tag == 'sceneID':
self.sceneID = z.text
if z.tag == 'start':
@ -1249,7 +1248,7 @@ class _ProductSpecific(object):
self.complexImageInfo = _ComplexImageInfo()
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'complexImageInfo':
self.complexImageInfo.set_from_etnode(z)
return
@ -1269,7 +1268,7 @@ class _ComplexImageInfo(object):
self.quicklookDataStartWith = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'commonPRF':
self.commonPRF = float(z.text)
if z.tag == 'commonRSF':
@ -1315,7 +1314,7 @@ class _ProjectedSpacingRange(object):
self.slantRange = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'groundNear':
self.groundNear = float(z.text)
if z.tag == 'groundFar':
@ -1348,7 +1347,7 @@ class _Platform(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'referenceData':
self.referenceData.set_from_etnode(z)
if z.tag == 'orbit':
@ -1377,7 +1376,7 @@ class _SARAntennaPosition(object):
def set_from_etnode(self,node):
self.DRAoffset = node.attrib['DRAoffset']
for w in node.getchildren():
for w in node:
if w.tag == 'x':
self.x = float(w.text)
if w.tag == 'y':
@ -1405,7 +1404,7 @@ class _GPSAntennaPosition(object):
def set_from_etnode(self,node):
self.GPSreceiver = node.attrib['GPSreceiver']
self.unit = node.attrib['unit']
for w in node.getchildren():
for w in node:
if w.tag == 'x':
self.x = float(w.text)
if w.tag == 'y':
@ -1436,7 +1435,7 @@ class _PlatformReferenceData(object):
def set_from_etnode(self,node):
iGPSAnt = -1
for x in node.getchildren():
for x in node:
if x.tag == 'SARAntennaMechanicalBoresight':
self.SARAntennaMechanicalBoresight = float(x.text)
if x.tag == 'SARAntennaPosition':
@ -1464,7 +1463,7 @@ class _FirstStateTime(object):
self.firstStateTimeGPSFraction = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'firstStateTimeUTC':
self.firstStateTimeUTC = z.text
if z.tag == 'firstStateTimeGPS':
@ -1490,7 +1489,7 @@ class _LastStateTime(object):
self.lastStateTimeGPSFraction = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'lastStateTimeUTC':
self.lastStateTimeUTC = z.text
if z.tag == 'lastStateTimeGPS':
@ -1529,7 +1528,7 @@ class _OrbitHeader(object):
self.dataGapIndicator = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'generationSystem':
self.generationSystem = z.text
self.generationSystemVersion = z.attrib['version']
@ -1619,7 +1618,7 @@ class _StateVec(object):
self.maneuver = node.attrib['maneuver']
self.num = int(node.attrib['num'])
self.qualInd = int(node.attrib['qualInd'])
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = datetime.datetime.strptime(z.text,"%Y-%m-%dT%H:%M:%S.%f")
if z.tag == 'timeGPS':
@ -1667,7 +1666,7 @@ class _Orbit(object):
self.stateVec = ()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'orbitHeader':
self.orbitHeader.set_from_etnode(z)
if z.tag == 'stateVec':
@ -1704,7 +1703,7 @@ class _AttitudeData(object):
self.maneuver = node.attrib['maneuver']
self.num = int(node.attrib['num'])
self.qualInd = int(node.attrib['qualInd'])
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = z.text
if z.tag == 'timeGPS':
@ -1749,7 +1748,7 @@ class _FirstAttitudeTime(object):
self.firstAttitudeTimeGPSFraction = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'firstAttitudeTimeUTC':
self.firstAttitudeTimeUTC = z.text
if z.tag == 'firstAttitudeTimeGPS':
@ -1775,7 +1774,7 @@ class _LastAttitudeTime(object):
self.lastAttitudeTimeGPSFraction = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'lastAttitudeTimeUTC':
self.lastAttitudeTimeUTC = z.text
if z.tag == 'lastAttitudeTimeGPS':
@ -1801,7 +1800,7 @@ class _AttitudeDataRefFrame(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'FromFrame':
self.FromFrame = z.text
if z.tag == 'ToFrame':
@ -1837,7 +1836,7 @@ class _AttitudeHeader(object):
self.steeringLawIndicator = None
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'generationSystem':
self.generationSystem = z.text
self.generationSystemVersion = z.attrib['version']
@ -1915,7 +1914,7 @@ class _Attitude(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'attitudeHeader':
self.attitudeHeader.set_from_etnode(z)
if z.tag == 'attitudeData':
@ -1944,7 +1943,7 @@ class _Instrument(object):
self.settings = _InstrumentSettings()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'instrumentInfoCoordinateType':
self.instrumentInfoCoordinateType = z.text
if z.tag == 'radarParameters':
@ -1970,7 +1969,7 @@ class _RadarParameters(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'centerFrequency':
self.centerFrequency = float(z.text)
return
@ -1991,7 +1990,7 @@ class _RxGainSetting(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'startTimeUTC':
self.startTimeUTC = z.text
if z.tag == 'stopTimeUTC':
@ -2025,7 +2024,7 @@ class _DataSegment(object):
def set_from_etnode(self,node):
self.segmentID = int(node.attrib['segmentID'])
for z in node.getchildren():
for z in node:
if z.tag == 'startTimeUTC':
self.startTimeUTC = z.text
if z.tag == 'stopTimeUTC':
@ -2062,7 +2061,7 @@ class _SettingRecord(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'dataSegment':
self.dataSegment.set_from_etnode(z)
if z.tag == 'PRF':
@ -2124,7 +2123,7 @@ class _InstrumentSettings(object):
self.settingRecord = ()
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.polLayer = z.text
if z.tag == 'DRAoffset':
@ -2212,7 +2211,7 @@ class _Processing(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'geometry':
self.geometry.set_from_etnode(z)
if z.tag == 'doppler':
@ -2246,7 +2245,7 @@ class _ProcessingGeometry(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'geometryCoordinateType':
self.geometryCoordinateType = z.text
if z.tag == 'velocityParameter':
@ -2282,7 +2281,7 @@ class _VelocityParameter(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = z.text
if z.tag == 'velocityParameterPolynomial':
@ -2309,7 +2308,7 @@ class _VelocityParameterPolynomial(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -2352,7 +2351,7 @@ class _ZeroDopplerVelocity(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'velocity':
self.velocity = float(z.text)
return
@ -2372,7 +2371,7 @@ class _DopplerRate(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = z.text
if z.tag == 'dopplerRatePolynomial':
@ -2399,7 +2398,7 @@ class _DopplerRatePolynomial(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -2444,7 +2443,7 @@ class _ProcessingDoppler(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'dopplerBasebandEstimationMethod':
self.dopplerBasebandEstimationMethod = z.text
if z.tag == 'dopplerGeometricEstimationMethod':
@ -2485,7 +2484,7 @@ class _ProcessingDopplerCentroid(object):
def set_from_etnode(self,node):
self.layerIndex = int(node.attrib['layerIndex'])
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.polLayer = z.text
if z.tag == 'DRAoffset':
@ -2548,7 +2547,7 @@ class _DopplerEstimate(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'timeUTC':
self.timeUTC = z.text
if z.tag == 'dopplerAtMidRange':
@ -2603,7 +2602,7 @@ class _BasebandDoppler(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -2648,7 +2647,7 @@ class _GeometricDoppler(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -2694,7 +2693,7 @@ class _CombinedDoppler(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -2746,7 +2745,7 @@ class _ProcessingParameter(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'beamID':
self.beamID = z.text
if z.tag == 'processingInfoCoordinateType':
@ -2811,7 +2810,7 @@ class _RangeCompression(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'segmentInfo':
self.segmentInfo.set_from_etnode(z)
if z.tag == 'chirps':
@ -2836,7 +2835,7 @@ class _RCSegmentInfo(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.polLayer = z.text
if z.tag == 'dataSegment':
@ -2861,7 +2860,7 @@ class _RCDataSegment(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'startTimeUTC':
self.startTimeUTC = z.text
if z.tag == 'stopTimeUTC':
@ -2888,7 +2887,7 @@ class _RCChirps(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'referenceChirp':
self.referenceChirp.set_from_etnode(z)
return
@ -2916,7 +2915,7 @@ class _RCReferenceChirp(object):
def set_from_etnode(self,node):
self.pulseCode = int(node.attrib['pulseCode'])
for z in node.getchildren():
for z in node:
if z.tag == 'pulseType':
self.pulseType = z.text
if z.tag == 'chirpDesignator':
@ -2969,7 +2968,7 @@ class _RCChirpAmplitude(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -3014,7 +3013,7 @@ class _RCChirpPhase(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'validityRangeMin':
self.validityRangeMin = float(z.text)
if z.tag == 'validityRangeMax':
@ -3057,7 +3056,7 @@ class _CorrectedInstrumentDelay(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'polLayer':
self.polLayer = z.text
if z.tag == 'DRAoffset':
@ -3110,7 +3109,7 @@ class _File(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'location':
self.location.set_from_etnode(z)
if z.tag == 'size':
@ -3135,7 +3134,7 @@ class _FileLocation(object):
return
def set_from_etnode(self,node):
for z in node.getchildren():
for z in node:
if z.tag == 'host':
self.host = z.text
if z.tag == 'path':

View File

@ -154,7 +154,7 @@ class XmlUtil:
else:
keyWord = var.find('name').text
listChildren = var.getchildren()
listChildren = list(var)
tmpDict = {}
for description in listChildren:
if(description.tag == 'name'):

View File

@ -90,7 +90,7 @@ class OrderedDict(UserDict):
def dict_to_xml(adict,file):
a = ET.Element('') # something to hang nodes on
a = dict_to_et(a,adict)
et = a.getchildren()[0]
et = list(a)[0]
indent(et)
tree = ET.ElementTree(et)
tree.write(file)

View File

@ -44,7 +44,7 @@ def get_Date(RSAT2folder):
tree = etree.parse(RSAT2file)
root = tree.getroot()
for attributes in root.iter('{http://www.rsi.ca/rs2/prod/xml/schemas}sourceAttributes'):
attribute_list = attributes.getchildren()
attribute_list = list(attributes)
for attribute in attribute_list:
if attribute.tag=='{http://www.rsi.ca/rs2/prod/xml/schemas}rawDataStartTime':
date = attribute.text