-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCHANGES-UPSTREAM-78.diff
97 lines (88 loc) · 4.19 KB
/
CHANGES-UPSTREAM-78.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
diff --git testGeogrid_ISCE.py testGeogrid_ISCE.py
--- testGeogrid_ISCE.py
+++ testGeogrid_ISCE.py
@@ -67,6 +67,10 @@ def cmdLineParse():
help='Input stable surface mask')
parser.add_argument('-fo', '--flag_optical', dest='optical_flag', type=bool, required=False, default=0,
help='flag for reading optical data (e.g. Landsat): use 1 for on and 0 (default) for off')
+ parser.add_argument('-b', '--buffer', dest='buffer', type=bool, required=False, default=0,
+ help='buffer to add to the starting/end range accounting for all passes from the same relative orbit')
+ parser.add_argument('-p', '--parse', dest='parse', action='store_true',
+ default=False, help='Parse the SAFE zip file to get radar image and orbit metadata; no need to run ISCE')
return parser.parse_args()
@@ -113,7 +117,7 @@ def getMergedOrbit(product):
return orb
-def loadMetadata(indir):
+def loadMetadata(indir,buffer=0):
'''
Input file.
'''
@@ -135,12 +139,57 @@ def loadMetadata(indir):
info.prf = 1.0 / frames[0].bursts[0].azimuthTimeInterval
info.rangePixelSize = frames[0].bursts[0].rangePixelSize
info.lookSide = -1
+
+ info.startingRange -= buffer * info.rangePixelSize
+ info.farRange += buffer * info.rangePixelSize
+
info.numberOfLines = int( np.round( (info.sensingStop - info.sensingStart).total_seconds() * info.prf)) + 1
- info.numberOfSamples = int( np.round( (info.farRange - info.startingRange)/info.rangePixelSize)) + 1
+ info.numberOfSamples = int( np.round( (info.farRange - info.startingRange)/info.rangePixelSize)) + 1 + 2 * buffer
info.orbit = getMergedOrbit(frames)
return info
+def loadParsedata(indir,buffer=0):
+ '''
+ Input file.
+ '''
+ import os
+ import numpy as np
+ import isce
+ from isceobj.Sensor.TOPS.Sentinel1 import Sentinel1
+
+
+ frames = []
+ for swath in range(1,4):
+ rdr=Sentinel1()
+ rdr.configure()
+# rdr.safe=['./S1A_IW_SLC__1SDH_20180401T100057_20180401T100124_021272_024972_8CAF.zip']
+ rdr.safe=[indir]
+ rdr.output='reference'
+ rdr.orbitDir='/Users/yanglei/orbit/S1A/precise'
+ rdr.auxDir='/Users/yanglei/orbit/S1A/aux'
+ rdr.swathNumber=swath
+ rdr.polarization='hh'
+ rdr.parse()
+ frames.append(rdr.product)
+
+ info = Dummy()
+ info.sensingStart = min([x.sensingStart for x in frames])
+ info.sensingStop = max([x.sensingStop for x in frames])
+ info.startingRange = min([x.startingRange for x in frames])
+ info.farRange = max([x.farRange for x in frames])
+ info.prf = 1.0 / frames[0].bursts[0].azimuthTimeInterval
+ info.rangePixelSize = frames[0].bursts[0].rangePixelSize
+ info.lookSide = -1
+
+ info.startingRange -= buffer * info.rangePixelSize
+ info.farRange += buffer * info.rangePixelSize
+
+ info.numberOfLines = int( np.round( (info.sensingStop - info.sensingStart).total_seconds() * info.prf)) + 1
+ info.numberOfSamples = int( np.round( (info.farRange - info.startingRange)/info.rangePixelSize)) + 1 + 2 * buffer
+ info.orbit = getMergedOrbit(frames)
+
+ return info
def coregisterLoadMetadataOptical(indir_m, indir_s):
'''
@@ -383,8 +432,12 @@ def main():
metadata_m, metadata_s = coregisterLoadMetadataOptical(inps.indir_m, inps.indir_s)
runGeogridOptical(metadata_m, metadata_s, inps.demfile, inps.dhdxfile, inps.dhdyfile, inps.vxfile, inps.vyfile, inps.srxfile, inps.sryfile, inps.csminxfile, inps.csminyfile, inps.csmaxxfile, inps.csmaxyfile, inps.ssmfile)
else:
- metadata_m = loadMetadata(inps.indir_m)
- metadata_s = loadMetadata(inps.indir_s)
+ if inps.parse:
+ metadata_m = loadParsedata(inps.indir_m,inps.buffer)
+ metadata_s = loadParsedata(inps.indir_s,inps.buffer)
+ else:
+ metadata_m = loadMetadata(inps.indir_m,inps.buffer)
+ metadata_s = loadMetadata(inps.indir_s,inps.buffer)
runGeogrid(metadata_m, metadata_s, inps.demfile, inps.dhdxfile, inps.dhdyfile, inps.vxfile, inps.vyfile, inps.srxfile, inps.sryfile, inps.csminxfile, inps.csminyfile, inps.csmaxxfile, inps.csmaxyfile, inps.ssmfile)