Skip to content

Commit

Permalink
ESA burst map (#47)
Browse files Browse the repository at this point in the history
* adding a text file with esa burst id and max id number of each id

* make the burst IDs consistent with ESA

* move sentinel1_track_burst_id.txt

* add the data file to setup.cfg and MANIFEST.in

* dict to array
  • Loading branch information
hfattahi authored Jul 20, 2022
1 parent 75b30e9 commit 11c01c4
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 1 deletion.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include src/s1reader/data/sentinel1_track_burst_id.txt
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ package_dir =
= src
packages = find:
python_requires = >=3.9
include_package_data = True

[options.packages.find]
where = src
[options.package_data]

175 changes: 175 additions & 0 deletions src/s1reader/data/sentinel1_track_burst_id.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
001 1 2148
002 2149 4296
003 4297 6443
004 6444 8591
005 8592 10739
006 10740 12887
007 12888 15035
008 15036 17183
009 17184 19331
010 19332 21479
011 21480 23627
012 23628 25775
013 25776 27923
014 27924 30071
015 30072 32219
016 32220 34367
017 34368 36514
018 36515 38662
019 38663 40810
020 40811 42958
021 42959 45106
022 45107 47254
023 47255 49402
024 49403 51550
025 51551 53698
026 53699 55846
027 55847 57994
028 57995 60142
029 60143 62290
030 62291 64438
031 64439 66585
032 66586 68733
033 68734 70881
034 70882 73029
035 73030 75177
036 75178 77325
037 77326 79473
038 79474 81621
039 81622 83769
040 83770 85917
041 85918 88065
042 88066 90213
043 90214 92361
044 92362 94508
045 94509 96656
046 96657 98804
047 98805 100952
048 100953 103100
049 103101 105248
050 105249 107396
051 107397 109544
052 109545 111692
053 111693 113840
054 113841 115988
055 115989 118136
056 118137 120284
057 120285 122432
058 122433 124579
059 124580 126727
060 126728 128875
061 128876 131023
062 131024 133171
063 133172 135319
064 135320 137467
065 137468 139615
066 139616 141763
067 141764 143911
068 143912 146059
069 146060 148207
070 148208 150355
071 150356 152503
072 152504 154650
073 154651 156798
074 156799 158946
075 158947 161094
076 161095 163242
077 163243 165390
078 165391 167538
079 167539 169686
080 169687 171834
081 171835 173982
082 173983 176130
083 176131 178278
084 178279 180426
085 180427 182574
086 182575 184721
087 184722 186869
088 186870 189017
089 189018 191165
090 191166 193313
091 193314 195461
092 195462 197609
093 197610 199757
094 199758 201905
095 201906 204053
096 204054 206201
097 206202 208349
098 208350 210497
099 210498 212645
100 212646 214792
101 214793 216940
102 216941 219088
103 219089 221236
104 221237 223384
105 223385 225532
106 225533 227680
107 227681 229828
108 229829 231976
109 231977 234124
110 234125 236272
111 236273 238420
112 238421 240568
113 240569 242716
114 242717 244863
115 244864 247011
116 247012 249159
117 249160 251307
118 251308 253455
119 253456 255603
120 255604 257751
121 257752 259899
122 259900 262047
123 262048 264195
124 264196 266343
125 266344 268491
126 268492 270639
127 270640 272787
128 272788 274934
129 274935 277082
130 277083 279230
131 279231 281378
132 281379 283526
133 283527 285674
134 285675 287822
135 287823 289970
136 289971 292118
137 292119 294266
138 294267 296414
139 296415 298562
140 298563 300710
141 300711 302857
142 302858 305005
143 305006 307153
144 307154 309301
145 309302 311449
146 311450 313597
147 313598 315745
148 315746 317893
149 317894 320041
150 320042 322189
151 322190 324337
152 324338 326485
153 326486 328633
154 328634 330781
155 330782 332928
156 332929 335076
157 335077 337224
158 337225 339372
159 339373 341520
160 341521 343668
161 343669 345816
162 345817 347964
163 347965 350112
164 350113 352260
165 352261 354408
166 354409 356556
167 356557 358704
168 358705 360852
169 360853 362999
170 363000 365147
171 365148 367295
172 367296 369443
173 369444 371591
174 371592 373739
175 373740 375887
23 changes: 22 additions & 1 deletion src/s1reader/s1_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from nisar.workflows.stage_dem import check_dateline
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"

# 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"):
'''Parse given time string to datetime.datetime object.
Expand Down Expand Up @@ -271,6 +274,15 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
bursts : list
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
# 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,
usecols=[2], dtype=int),
0, 0)

_, tail = os.path.split(annotation_path)
platform_id, subswath_id, _, pol = [x.upper() for x in tail.split('-')[:4]]

Expand Down Expand Up @@ -354,6 +366,15 @@ 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
# first track is 1
id_burst += 1

# 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]

# choose nearest azimuth FM rate
d_seconds = 0.5 * (n_lines - 1) * azimuth_time_interval
sensing_mid = sensing_start + datetime.timedelta(seconds=d_seconds)
Expand Down Expand Up @@ -387,7 +408,7 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
last_valid_samples[last_line])


burst_id = f't{track_number}_{subswath_id.lower()}_b{id_burst}'
burst_id = f't{track_number}_{id_burst}_{subswath_id.lower()}'

bursts[i] = Sentinel1BurstSlc(sensing_start, radar_freq, wavelength,
azimuth_steer_rate, azimuth_time_interval,
Expand Down

0 comments on commit 11c01c4

Please sign in to comment.