Skip to content

Commit

Permalink
Unit test fixes (#58)
Browse files Browse the repository at this point in the history
* added manifest.safe to test SAFE/zip
* updated burst ID format
* fixed directory structure in zip to match S1 SAFE spec
* documentation fix
  • Loading branch information
LiangJYu authored Aug 4, 2022
1 parent 6a391db commit 3f18705
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/s1reader/s1_burst_slc.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Sentinel1BurstSlc:
doppler: Doppler
range_bandwidth: float
polarization: str # {VV, VH, HH, HV}
burst_id: str # t{track_number}_iw{1,2,3}_b{burst_index}
burst_id: str # t{track_number}_{burst_index}_iw{1,2,3}
platform_id: str # S1{A,B}
center: tuple # {center lon, center lat} in degrees
border: list # list of lon, lat coordinate tuples (in degrees) representing burst border
Expand Down
12 changes: 6 additions & 6 deletions src/s1reader/s1_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from s1reader.s1_burst_slc import Doppler, Sentinel1BurstSlc


esa_track_burst_id_file = f"{os.path.dirname(os.path.realpath(__file__))}/data/sentinel1_track_burst_id.txt"
esa_track_burst_id_file = f"{os.path.dirname(os.path.realpath(__file__))}/data/sentinel1_track_burst_id.txt"

# TODO evaluate if it make sense to combine below into a class
def as_datetime(t_str, fmt = "%Y-%m-%dT%H:%M:%S.%f"):
Expand Down Expand Up @@ -275,8 +275,8 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
List of Sentinel1BurstSlc objects found in annotation XML.
'''

# a 1D array where the indices are the Sentinel-1 track number
# and the data at each row are the corresponding cumulative ID
# a 1D array where the indices are the Sentinel-1 track number
# and the data at each row are the corresponding cumulative ID
# number for the last burst of the given track (i.e., line number)
# get last burst ID number of each track and prepend 0
tracks_burst_id = np.insert(np.loadtxt(esa_track_burst_id_file,
Expand Down Expand Up @@ -366,12 +366,12 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
dt = sensing_times[i] - ascending_node_time
id_burst = int((dt.seconds + dt.microseconds / 1e6) // burst_interval)

# To be consistent with ESA let's start the counter of the ID
# from 1 instead of from 0, i,e, the ID of the first burst of the
# To be consistent with ESA let's start the counter of the ID
# from 1 instead of from 0, i,e, the ID of the first burst of the
# first track is 1
id_burst += 1

# the IDs are currently local to one track. Let's adjust based on
# the IDs are currently local to one track. Let's adjust based on
# the last ID of the previous track
id_burst += tracks_burst_id[track_number-1]

Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_bursts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_burst(bursts):
[-2056.701472691132, 353389.9614836443, -54143009.57327797]]

for i, burst in enumerate(bursts):
expected_burst_id = f't71_iw3_b{844 + i}'
expected_burst_id = f't71_{151200 + i}_iw3'
assert burst.burst_id == expected_burst_id
assert burst.i_burst == i

Expand Down

0 comments on commit 3f18705

Please sign in to comment.