From d219448d5878cfbc9ab9464c069e47fb586a71ec Mon Sep 17 00:00:00 2001 From: Oliver Stephenson Date: Thu, 27 Jan 2022 21:55:28 -0800 Subject: [PATCH] bugfix for `timeseries2velocity.py --bootstrap --save-res` (#733) When running `timeseries2velocity.py` with bootstrapping, we use the function `time_func.estimate_time_func` to repeatedly fit the time series data. This function returns the design matrix, `G`, however when bootstrapping we don't assign the design matrix to a variable, meaning that if we try to save the residual file we get the error `UnboundLocalError: local variable 'G' referenced before assignment` at line 702. If we want to output the residual when bootstrapping, we need to get the full design matrix. I've added a line of code to do this. --- mintpy/timeseries2velocity.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mintpy/timeseries2velocity.py b/mintpy/timeseries2velocity.py index 2cfce357f..4abe68e40 100755 --- a/mintpy/timeseries2velocity.py +++ b/mintpy/timeseries2velocity.py @@ -316,11 +316,9 @@ def read_exclude_date(inps, dateListAll): def read_date_info(inps): - """Get inps.excludeDate full list - Inputs: - inps - Namespace, - Output: - inps.excludeDate - list of string for exclude date in YYYYMMDD format + """Read dates used in the estimation and its related info. + Parameters: inps - Namespace + Returns: inps - Namespace """ if inps.key == 'timeseries': tsobj = timeseries(inps.timeseries_file) @@ -613,6 +611,9 @@ def run_timeseries2time_func(inps): m_std[:, mask] = m_boot.std(axis=0).reshape(num_param, -1) del m_boot + # get design matrix to calculate the residual time series + G = time_func.get_design_matrix4time_func(inps.dateList, model=model, ref_date=inps.ref_date, seconds=seconds) + else: ## option 2 - least squares with uncertainty propagation