1
+ # This Python module is part of the PyRate software package.
2
+ #
3
+ # Copyright 2017 Geoscience Australia
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ """
17
+ This is the aps/spatio-temporal filter main module.
18
+ """
19
+
1
20
import logging
2
21
import os
3
22
from copy import deepcopy
@@ -36,10 +55,10 @@ def wrap_spatio_temporal_filter(ifg_paths, params, tiles, preread_ifgs):
36
55
def spatio_temporal_filter (tsincr , ifg , params , preread_ifgs ):
37
56
"""
38
57
Applies spatio-temportal (aps) filter and save the interferograms.
39
-
58
+
40
59
A first step is to compute the time series using the non-smooth SVD method.
41
60
This is followed by temporal and spatial filters respectively.
42
-
61
+
43
62
Parameters
44
63
----------
45
64
tsincr: ndarray
@@ -60,13 +79,13 @@ def spatio_temporal_filter(tsincr, ifg, params, preread_ifgs):
60
79
tsincr -= ts_aps
61
80
62
81
mpiops .run_once (ts_to_ifgs , tsincr , preread_ifgs )
63
-
82
+
64
83
65
84
def calc_svd_time_series (ifg_paths , params , preread_ifgs , tiles ):
66
85
"""
67
86
Time series inversion with no smoothing (svd method)
68
87
This is the matlab tsinvnosm.m equivalent.
69
-
88
+
70
89
Parameters
71
90
----------
72
91
ifg_paths: list
@@ -77,12 +96,12 @@ def calc_svd_time_series(ifg_paths, params, preread_ifgs, tiles):
77
96
prepread ifgs dict
78
97
tiles: list
79
98
list of shared.Tile class instances
80
-
99
+
81
100
Returns
82
101
-------
83
102
tsincr_g: ndarray
84
103
non smooth (svd method) time series of shape (ifg.shape, nvels)
85
-
104
+
86
105
"""
87
106
log .info ('Calculating time series without smoothing for '
88
107
'spatio-temporal filter' )
@@ -95,11 +114,11 @@ def calc_svd_time_series(ifg_paths, params, preread_ifgs, tiles):
95
114
96
115
nvels = None
97
116
for t in process_tiles :
98
- log .info ('Calculating time series for tile {}' .format (t .index ))
117
+ log .info ('Calculating time series for tile {} during aps '
118
+ 'correction' .format (t .index ))
99
119
ifg_parts = [shared .IfgPart (p , t , preread_ifgs ) for p in ifg_paths ]
100
120
mst_tile = np .load (os .path .join (output_dir ,
101
121
'mst_mat_{}.npy' .format (t .index )))
102
- # don't save this time_series calc, this is done as part of aps filter
103
122
tsincr = time_series (ifg_parts , new_params , vcmt = None , mst = mst_tile )[0 ]
104
123
np .save (file = os .path .join (output_dir , 'tsincr_aps_{}.npy' .format (
105
124
t .index )), arr = tsincr )
@@ -132,16 +151,16 @@ def ts_to_ifgs(ts, preread_ifgs):
132
151
time series nd array (ifg.shape, nvels)
133
152
preread_ifgs: dict
134
153
dict with ifg basic informations
135
-
154
+
136
155
Saves ifgs on disc after conversion.
137
156
"""
138
157
log .info ('Converting time series to ifgs' )
139
158
ifgs = list (OrderedDict (sorted (preread_ifgs .items ())).values ())
140
- epochlist , n = get_epochs (ifgs )
159
+ _ , n = get_epochs (ifgs )
141
160
index_master , index_slave = n [:len (ifgs )], n [len (ifgs ):]
142
- for i in range ( len ( ifgs ) ):
161
+ for i , ifg in enumerate ( ifgs ):
143
162
phase = np .sum (ts [:, :, index_master [i ]: index_slave [i ]], axis = 2 )
144
- _save_aps_corrected_phase (ifgs [ i ] .path , phase )
163
+ _save_aps_corrected_phase (ifg .path , phase )
145
164
146
165
147
166
def _save_aps_corrected_phase (ifg_path , phase ):
0 commit comments