Skip to content

Commit

Permalink
Fix noise xml processing for bursts downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyPechnikov committed Nov 30, 2024
1 parent 7ad2d85 commit 3dbf03e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
52 changes: 31 additions & 21 deletions pygmtsar/pygmtsar/ASF.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,27 +537,37 @@ def download_burst(result, basedir, session):
adsHeader['imageNumber'] = '001'
noise = noise | {'adsHeader': adsHeader}

noiseRangeVector = annotation['noiseRangeVectorList']
items = filter_azimuth_time(noiseRangeVector['noiseRangeVector'], start_utc_dt, stop_utc_dt)
# re-numerate line numbers for the burst
for item in items: item['line'] = str(int(item['line']) - (length * burstIndex))
noiseRangeVector = {'@count': len(items), 'noiseRangeVector': items}
noise = noise | {'noiseRangeVectorList': noiseRangeVector}

noiseAzimuthVector = annotation['noiseAzimuthVectorList']
items = noiseAzimuthVector['noiseAzimuthVector']['line']['#text'].split(' ')
items = [int(item) for item in items]
lowers = [item for item in items if item <= burstIndex * length] or items[0]
uppers = [item for item in items if item >= (burstIndex + 1) * length - 1] or items[-1]
mask = [True if item>=lowers[-1] and item<=uppers[0] else False for item in items]
items = [item - burstIndex * length for item, m in zip(items, mask) if m]
noiseAzimuthVector['noiseAzimuthVector']['firstAzimuthLine'] = lowers[-1] - burstIndex * length
noiseAzimuthVector['noiseAzimuthVector']['lastAzimuthLine'] = uppers[0] - burstIndex * length
noiseAzimuthVector['noiseAzimuthVector']['line'] = {'@count': len(items), '#text': ' '.join([str(item) for item in items])}
items = noiseAzimuthVector['noiseAzimuthVector']['noiseAzimuthLut']['#text'].split(' ')
items = [item for item, m in zip(items, mask) if m]
noiseAzimuthVector['noiseAzimuthVector']['noiseAzimuthLut'] = {'@count': len(items), '#text': ' '.join(items)}
noise = noise | {'noiseAzimuthVectorList': noiseAzimuthVector}
if 'noiseVectorList' in annotation:
noiseRangeVector = annotation['noiseVectorList']
items = filter_azimuth_time(noiseRangeVector['noiseVector'], start_utc_dt, stop_utc_dt)
# re-numerate line numbers for the burst
for item in items: item['line'] = str(int(item['line']) - (length * burstIndex))
noiseRangeVector = {'@count': len(items), 'noiseVector': items}
noise = noise | {'noiseVectorList': noiseRangeVector}

if 'noiseRangeVectorList' in annotation:
noiseRangeVector = annotation['noiseRangeVectorList']
items = filter_azimuth_time(noiseRangeVector['noiseRangeVector'], start_utc_dt, stop_utc_dt)
# re-numerate line numbers for the burst
for item in items: item['line'] = str(int(item['line']) - (length * burstIndex))
noiseRangeVector = {'@count': len(items), 'noiseRangeVector': items}
noise = noise | {'noiseRangeVectorList': noiseRangeVector}

if 'noiseAzimuthVectorList' in annotation:
noiseAzimuthVector = annotation['noiseAzimuthVectorList']
items = noiseAzimuthVector['noiseAzimuthVector']['line']['#text'].split(' ')
items = [int(item) for item in items]
lowers = [item for item in items if item <= burstIndex * length] or items[0]
uppers = [item for item in items if item >= (burstIndex + 1) * length - 1] or items[-1]
mask = [True if item>=lowers[-1] and item<=uppers[0] else False for item in items]
items = [item - burstIndex * length for item, m in zip(items, mask) if m]
noiseAzimuthVector['noiseAzimuthVector']['firstAzimuthLine'] = lowers[-1] - burstIndex * length
noiseAzimuthVector['noiseAzimuthVector']['lastAzimuthLine'] = uppers[0] - burstIndex * length
noiseAzimuthVector['noiseAzimuthVector']['line'] = {'@count': len(items), '#text': ' '.join([str(item) for item in items])}
items = noiseAzimuthVector['noiseAzimuthVector']['noiseAzimuthLut']['#text'].split(' ')
items = [item for item, m in zip(items, mask) if m]
noiseAzimuthVector['noiseAzimuthVector']['noiseAzimuthLut'] = {'@count': len(items), '#text': ' '.join(items)}
noise = noise | {'noiseAzimuthVectorList': noiseAzimuthVector}

with open(xml_noise_file, 'w') as file:
file.write(xmltodict.unparse({'noise': noise}, pretty=True, indent=' '))
Expand Down
2 changes: 1 addition & 1 deletion pygmtsar/pygmtsar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# Licensed under the BSD 3-Clause License (see LICENSE for details)
# ----------------------------------------------------------------------------
__version__ = '2024.8.30.post4'
__version__ = '2024.8.30.post5'

# unified progress indicators
from .tqdm_joblib import tqdm_joblib
Expand Down

0 comments on commit 3dbf03e

Please sign in to comment.