Skip to content

Commit cc18d1d

Browse files
authored
Add handy properties (#29)
* add/changed sensing mid and stop from methods to properties added length and width properties * use length instead of indexing a tuple * fix sensing mid computation
1 parent 13fb7dd commit cc18d1d

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

src/s1reader/s1_burst_slc.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,6 @@ def slc_to_vrt_file(self, out_path):
302302
with open(out_path, 'w') as fid:
303303
fid.write(tmpl)
304304

305-
def get_sensing_mid(self):
306-
'''Returns sensing mid as datetime.datetime object.
307-
308-
Returns:
309-
--------
310-
_ : datetime.datetime
311-
Sensing mid as datetime.datetime object.
312-
'''
313-
d_seconds = 0.5 * (self.shape[0] - 1) * self.azimuth_time_interval
314-
return self.sensing_start + datetime.timedelta(seconds=d_seconds)
315-
316305
def get_az_carrier_poly(self, offset=0.0, xstep=500, ystep=50,
317306
az_order=5, rg_order=3, index_as_coord=False):
318307
"""
@@ -431,3 +420,35 @@ def as_dict(self):
431420
val = temp
432421
self_as_dict[key] = val
433422
return self_as_dict
423+
424+
@property
425+
def sensing_mid(self):
426+
'''Returns sensing mid as datetime.datetime object.
427+
428+
Returns:
429+
--------
430+
_ : datetime.datetime
431+
Sensing mid as datetime.datetime object.
432+
'''
433+
d_seconds = 0.5 * self.length * self.azimuth_time_interval
434+
return self.sensing_start + datetime.timedelta(seconds=d_seconds)
435+
436+
@property
437+
def sensing_stop(self):
438+
'''Returns sensing end as datetime.datetime object.
439+
440+
Returns:
441+
--------
442+
_ : datetime.datetime
443+
Sensing end as datetime.datetime object.
444+
'''
445+
d_seconds = (self.length - 1) * self.azimuth_time_interval
446+
return self.sensing_start + datetime.timedelta(seconds=d_seconds)
447+
448+
@property
449+
def length(self):
450+
return self.shape[0]
451+
452+
@property
453+
def width(self):
454+
return self.shape[1]

0 commit comments

Comments
 (0)