diff --git a/pygmtsar/pygmtsar/ASF.py b/pygmtsar/pygmtsar/ASF.py index 10dd9af..a1c99e0 100644 --- a/pygmtsar/pygmtsar/ASF.py +++ b/pygmtsar/pygmtsar/ASF.py @@ -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=' ')) diff --git a/pygmtsar/pygmtsar/__init__.py b/pygmtsar/pygmtsar/__init__.py index 7b00854..5ed9d65 100644 --- a/pygmtsar/pygmtsar/__init__.py +++ b/pygmtsar/pygmtsar/__init__.py @@ -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