Skip to content

Commit 3379f7d

Browse files
Merge branch 'main' of https://github.com/johntruckenbrodt/pyroSAR into feature/ers_envisat
2 parents 40d74fb + dda175b commit 3379f7d

File tree

3 files changed

+42
-38
lines changed

3 files changed

+42
-38
lines changed

pyroSAR/drivers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,14 +2213,23 @@ def scanMetadata(self):
22132213
sp_rg = [float(x.find('.//rangePixelSpacing').text) for x in ann_trees]
22142214
sp_az = [float(x.find('.//azimuthPixelSpacing').text) for x in ann_trees]
22152215
meta['spacing'] = (median(sp_rg), median(sp_az))
2216+
2217+
looks_rg = [float(x.find('.//rangeProcessing/numberOfLooks').text) for x in ann_trees]
2218+
looks_az = [float(x.find('.//azimuthProcessing/numberOfLooks').text) for x in ann_trees]
2219+
meta['looks'] = (median(looks_rg), median(looks_az))
2220+
22162221
samples = [x.find('.//imageAnnotation/imageInformation/numberOfSamples').text for x in ann_trees]
22172222
meta['samples'] = sum([int(x) for x in samples])
2223+
22182224
lines = [x.find('.//imageAnnotation/imageInformation/numberOfLines').text for x in ann_trees]
22192225
meta['lines'] = sum([int(x) for x in lines])
2226+
22202227
heading = median(float(x.find('.//platformHeading').text) for x in ann_trees)
22212228
meta['heading'] = heading if heading > 0 else heading + 360
2229+
22222230
incidence = [float(x.find('.//incidenceAngleMidSwath').text) for x in ann_trees]
22232231
meta['incidence'] = median(incidence)
2232+
22242233
meta['image_geometry'] = ann_trees[0].find('.//projection').text.replace(' ', '_').upper()
22252234

22262235
return meta

pyroSAR/gamma/util.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
pass
4848

4949

50-
def calibrate(id, directory, return_fnames=False, logpath=None, outdir=None, shellscript=None):
50+
def calibrate(id, directory, return_fnames=False,
51+
logpath=None, outdir=None, shellscript=None):
5152
"""
5253
radiometric calibration of SAR scenes
5354
@@ -68,7 +69,7 @@ def calibrate(id, directory, return_fnames=False, logpath=None, outdir=None, she
6869
6970
Returns
7071
-------
71-
72+
List[str] or None
7273
"""
7374
cname = type(id).__name__
7475
new = []
@@ -112,7 +113,8 @@ def calibrate(id, directory, return_fnames=False, logpath=None, outdir=None, she
112113
elif cname == 'ESA':
113114
k_db = {'ASAR': 55., 'ERS1': 58.24, 'ERS2': 59.75}[id.sensor]
114115
inc_ref = 90. if id.sensor == 'ASAR' else 23.
115-
candidates = [x for x in id.getGammaImages(directory) if re.search('_pri$', x)]
116+
imgs = id.getGammaImages(directory)
117+
candidates = [x for x in imgs if re.search('_pri$', x)]
116118
for image in candidates:
117119
out = image.replace('pri', 'grd')
118120
isp.radcal_PRI(PRI=image,
@@ -131,7 +133,8 @@ def calibrate(id, directory, return_fnames=False, logpath=None, outdir=None, she
131133
log.info('calibration already performed during import')
132134

133135
else:
134-
raise NotImplementedError('calibration for class {} is not implemented yet'.format(cname))
136+
msg = f'calibration for class {cname} is not implemented yet'
137+
raise NotImplementedError(msg)
135138

136139
if return_fnames and len(new) > 0:
137140
return new
@@ -888,11 +891,11 @@ def geocode(scene, dem, tmpdir, outdir, spacing, scaling='linear', func_geoback=
888891
all_exist = all([os.path.isfile(x) for x in [out, out_par]])
889892
if not all_exist:
890893
log.info('mosaicing scenes')
891-
isp.MLI_cat(MLI_1=group[0],
894+
isp.MLI_cat(MLI1=group[0],
892895
MLI1_par=group[0] + '.par',
893-
MLI_2=group[1],
896+
MLI2=group[1],
894897
MLI2_par=group[1] + '.par',
895-
MLI_3=out,
898+
MLI3=out,
896899
MLI3_par=out_par,
897900
logpath=path_log, outdir=tmpdir, shellscript=shellscript)
898901
par2hdr(out_par, out + '.hdr')

tests/test_gamma_args.py

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,48 +47,40 @@ def test_args_disp():
4747
def test_args_isp():
4848
from pyroSAR.gamma.api import isp
4949
lookup = {
50+
'MLI_cat': ['degree', 'dtype', 'extrapol', 'interp_mode', 'mflg',
51+
'MLI1', 'MLI1_par', 'MLI2', 'MLI2_par', 'MLI3', 'MLI3_par',
52+
'overlap'],
5053
'multi_look': ['MLI', 'MLI_par', 'SLC', 'SLC_par', 'azlks', 'exp',
51-
'loff', 'logpath', 'nlines', 'outdir', 'rlks', 'scale',
52-
'shellscript'],
54+
'loff', 'nlines', 'rlks', 'scale'],
5355
'multi_look_MLI': ['MLI_in', 'MLI_in_par', 'MLI_out', 'MLI_out_par',
54-
'azlks', 'loff', 'logpath', 'nlines', 'outdir',
55-
'rlks', 'scale', 'shellscript'],
56-
'par_ASAR': ['ASAR_ERS_file', 'K_dB', 'logpath', 'outdir', 'output_name',
57-
'shellscript'],
56+
'azlks', 'loff', 'nlines', 'rlks', 'scale'],
57+
'par_ASAR': ['ASAR_ERS_file', 'K_dB', 'output_name'],
5858
'par_EORC_PALSAR': ['CEOS_data', 'CEOS_leader', 'SLC', 'SLC_par', 'dtype',
59-
'logpath', 'outdir', 'sc_dB', 'shellscript'],
60-
'par_ESA_ERS': ['CEOS_DAT', 'CEOS_SAR_leader', 'SLC', 'SLC_par', 'inlist',
61-
'logpath', 'outdir', 'shellscript'],
59+
'sc_dB'],
60+
'par_ESA_ERS': ['CEOS_DAT', 'CEOS_SAR_leader', 'SLC', 'SLC_par', 'inlist'],
6261
'par_S1_GRD': ['GRD', 'GRD_par', 'GeoTIFF', 'MLI', 'MLI_par', 'annotation_XML',
63-
'calibration_XML', 'eflg', 'logpath', 'noise_XML', 'noise_pwr',
64-
'outdir', 'rps', 'shellscript'],
62+
'calibration_XML', 'eflg', 'noise_XML', 'noise_pwr', 'rps'],
6563
'par_S1_SLC': ['GeoTIFF', 'SLC', 'SLC_par', 'TOPS_par', 'annotation_XML',
66-
'calibration_XML', 'dtype', 'logpath', 'noise_XML',
67-
'noise_pwr', 'outdir', 'sc_dB', 'shellscript'],
68-
'par_TX_GRD': ['GRD', 'GRD_par', 'GeoTIFF', 'annotation_XML',
69-
'logpath', 'outdir', 'pol', 'shellscript'],
70-
'par_TX_SLC': ['COSAR', 'SLC', 'SLC_par', 'annotation_XML', 'dtype',
71-
'logpath', 'outdir', 'pol', 'shellscript'],
64+
'calibration_XML', 'dtype', 'noise_XML',
65+
'noise_pwr', 'sc_dB'],
66+
'par_TX_GRD': ['GRD', 'GRD_par', 'GeoTIFF', 'annotation_XML', 'pol'],
67+
'par_TX_SLC': ['COSAR', 'SLC', 'SLC_par', 'annotation_XML', 'dtype', 'pol'],
7268
'radcal_MLI': ['CMLI', 'K_dB', 'MLI', 'MLI_par', 'OFF_par', 'ant_flag',
73-
'antenna', 'logpath', 'outdir', 'pix_area', 'refarea_flag',
74-
'rloss_flag', 'sc_dB', 'shellscript'],
69+
'antenna', 'pix_area', 'refarea_flag',
70+
'rloss_flag', 'sc_dB'],
7571
'radcal_PRI': ['GRD', 'GRD_par', 'K_dB', 'PRI', 'PRI_par',
76-
'inc_ref', 'loff', 'logpath', 'nl', 'nr',
77-
'outdir', 'roff', 'shellscript'],
72+
'inc_ref', 'loff', 'nl', 'nr', 'roff'],
7873
'radcal_SLC': ['CSLC', 'CSLC_par', 'K_dB', 'SLC', 'SLC_par',
79-
'ant_flag', 'antenna', 'fcase', 'logpath', 'outdir',
80-
'pix_area', 'refarea_flag', 'rloss_flag', 'sc_dB',
81-
'shellscript'],
82-
'S1_OPOD_vec': ['OPOD', 'SLC_par', 'logpath', 'nstate', 'outdir',
83-
'shellscript'],
84-
'SLC_deramp_ScanSAR': ['SLC1_tab', 'SLC2_tab', 'logpath', 'mode',
85-
'outdir', 'phflg', 'shellscript'],
74+
'ant_flag', 'antenna', 'fcase',
75+
'pix_area', 'refarea_flag', 'rloss_flag', 'sc_dB'],
76+
'S1_OPOD_vec': ['OPOD', 'SLC_par', 'nstate'],
77+
'SLC_deramp_ScanSAR': ['SLC1_tab', 'SLC2_tab', 'mode', 'phflg'],
8678
'SLC_mosaic_ScanSAR': ['SLC', 'SLCR_tab', 'SLC_par', 'SLC_tab',
87-
'azlks', 'logpath', 'outdir', 'rlks',
88-
'shellscript', 'bflg']
79+
'azlks', 'rlks', 'bflg']
8980
}
9081
for command, args in lookup.items():
91-
assert set(args).issubset(getargs(getattr(isp, command)))
82+
default = ['logpath', 'outdir', 'shellscript']
83+
assert set(args + default).issubset(getargs(getattr(isp, command)))
9284

9385

9486
@pytest.mark.skipif('lat' not in dir(api), reason='requires GAMMA installation with module LAT')

0 commit comments

Comments
 (0)