Skip to content

Commit

Permalink
bugfix for timeseries2velocity.py --bootstrap --save-res (#733)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
olliestephenson committed Jan 28, 2022
1 parent cfa7991 commit d219448
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mintpy/timeseries2velocity.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d219448

Please sign in to comment.