1919signals.
2020"""
2121# pylint: disable=invalid-name, too-many-locals, too-many-arguments
22- import logging
2322import os
2423from copy import deepcopy
2524from collections import OrderedDict
2625import numpy as np
2726from numpy import isnan
2827from scipy .fftpack import fft2 , ifft2 , fftshift , ifftshift
2928from scipy .interpolate import griddata
29+ from pyrate .core .logger import pyratelogger as log
3030
3131from pyrate .core import shared , ifgconstants as ifc , mpiops , config as cf
3232from pyrate .core .covariance import cvd_from_phase , RDist
3333from pyrate .core .algorithm import get_epochs
3434from pyrate .core .shared import Ifg
3535from pyrate .core .timeseries import time_series
36- from pyrate .merge import _assemble_tiles
37-
38- log = logging .getLogger (__name__ )
36+ from pyrate .merge import assemble_tiles
3937
4038
4139def wrap_spatio_temporal_filter (ifg_paths , params , tiles , preread_ifgs ):
4240 """
4341 A wrapper for the spatio-temporal filter so it can be tested.
4442 See docstring for spatio_temporal_filter.
4543 """
46- if not params [cf .APSEST ]:
47- log .info ('APS correction not required.' )
44+ if params [cf .APSEST ]:
45+ log .info ('Doing APS spatio-temporal filtering' )
46+ else :
47+ log .info ('APS spatio-temporal filtering not required' )
4848 return
4949
5050 # perform some checks on existing ifgs
@@ -101,16 +101,15 @@ def _calc_svd_time_series(ifg_paths, params, preread_ifgs, tiles):
101101 new_params [cf .TIME_SERIES_METHOD ] = 2 # use SVD method
102102
103103 process_tiles = mpiops .array_split (tiles )
104- output_dir = params [cf .TMPDIR ]
105104
106105 nvels = None
107106 for t in process_tiles :
108107 log .debug ('Calculating time series for tile {} during APS '
109108 'correction' .format (t .index ))
110109 ifg_parts = [shared .IfgPart (p , t , preread_ifgs , params ) for p in ifg_paths ]
111- mst_tile = np .load (os .path .join (output_dir , 'mst_mat_{}.npy' .format (t .index )))
110+ mst_tile = np .load (os .path .join (params [ cf . TMPDIR ] , 'mst_mat_{}.npy' .format (t .index )))
112111 tsincr = time_series (ifg_parts , new_params , vcmt = None , mst = mst_tile )[0 ]
113- np .save (file = os .path .join (output_dir , 'tsincr_aps_{}.npy' .format (t .index )), arr = tsincr )
112+ np .save (file = os .path .join (params [ cf . TMPDIR ] , 'tsincr_aps_{}.npy' .format (t .index )), arr = tsincr )
114113 nvels = tsincr .shape [2 ]
115114
116115 nvels = mpiops .comm .bcast (nvels , root = 0 )
@@ -125,11 +124,14 @@ def _assemble_tsincr(ifg_paths, params, preread_ifgs, tiles, nvels):
125124 """
126125 Helper function to reconstruct time series images from tiles
127126 """
127+ # pre-allocate dest 3D array
128128 shape = preread_ifgs [ifg_paths [0 ]].shape + (nvels ,)
129129 tsincr_g = np .empty (shape = shape , dtype = np .float32 )
130+ # shape of one 2D time-slice array
131+ s = preread_ifgs [ifg_paths [0 ]].shape
132+ # loop over the time slices and assemble dest 3D array
130133 for i in range (nvels ):
131- for n , t in enumerate (tiles ):
132- _assemble_tiles (i , n , t , tsincr_g [:, :, i ], params [cf .TMPDIR ], 'tsincr_aps' )
134+ tsincr_g [:, :, i ] = assemble_tiles (s , params [cf .TMPDIR ], tiles , out_type = 'tsincr_aps' , index = i )
133135
134136 return tsincr_g
135137
@@ -184,7 +186,7 @@ def spatial_low_pass_filter(ts_lp, ifg, params):
184186 :return: ts_hp: filtered time series data of shape (ifg.shape, n_epochs)
185187 :rtype: ndarray
186188 """
187- log .info ('Applying APS spatial low-pass filter' )
189+ log .info ('Applying spatial low-pass filter' )
188190 if params [cf .SLPF_NANFILL ] == 0 :
189191 ts_lp [np .isnan (ts_lp )] = 0 # need it here for cvd and fft
190192 else :
@@ -281,7 +283,7 @@ def temporal_low_pass_filter(tsincr, epochlist, params):
281283 :return: tsfilt_incr: filtered time series data, shape (ifg.shape, nepochs)
282284 :rtype: ndarray
283285 """
284- log .info ('Applying APS temporal low-pass filter' )
286+ log .info ('Applying temporal low-pass filter' )
285287 nanmat = ~ isnan (tsincr )
286288 tsfilt_incr = np .empty_like (tsincr , dtype = np .float32 ) * np .nan
287289 intv = np .diff (epochlist .spans ) # time interval for the neighboring epoch
@@ -298,7 +300,7 @@ def temporal_low_pass_filter(tsincr, epochlist, params):
298300 func = mean_filter
299301
300302 _tlpfilter (cols , cutoff , nanmat , rows , span , threshold , tsfilt_incr , tsincr , func )
301- log .debug ("Finished applying temporal low pass filter" )
303+ log .debug ("Finished applying temporal low- pass filter" )
302304 return tsfilt_incr
303305
304306# Throwaway function to define Gaussian filter weights
0 commit comments