Skip to content

Commit

Permalink
New residual method ("window" instead of "cumulative"). This calcault…
Browse files Browse the repository at this point in the history
…es the residual as the ratio of the maximum RMS for all windows / mean RMS for all windows of the cumulative residual.

Because of this, it doesn't grow in the same way the cumulative residual does.  Note also that this could be changed to be as above but for the residual, rather than the cumulative residual.
  • Loading branch information
matthew-gaddes committed Dec 1, 2021
1 parent a083644 commit 59142d3
Show file tree
Hide file tree
Showing 34 changed files with 123 additions and 27 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified LiCSAlert_03_Campi_Flegrei/ICASAR_outputs/01_pca_variance_line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file modified LiCSAlert_03_Campi_Flegrei/ICASAR_outputs/ICASAR_results.pkl
Binary file not shown.
Binary file modified LiCSAlert_03_Campi_Flegrei/ICASAR_outputs/ICs.kmz
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified LiCSAlert_03_Campi_Flegrei/LiCSAlert_results.pkl
Binary file not shown.
18 changes: 11 additions & 7 deletions LiCSAlert_batch_mode_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import licsalert
from licsalert.licsalert import LiCSAlert_batch_mode

ICASAR_path = Path("/home/matthew/university_work/15_my_software_releases/ICASAR-2.7.2/") # location of ICASAR functions
#ICASAR_path = Path("/home/matthew/university_work/01_blind_signal_separation_python/13_ICASAR/ICASAR_GitHub") # development version
#ICASAR_path = Path("/home/matthew/university_work/15_my_software_releases/ICASAR-2.7.2/") # location of ICASAR functions
ICASAR_path = Path("/home/matthew/university_work/01_blind_signal_separation_python/13_ICASAR/ICASAR_GitHub") # development version


#%% Load Sentinel-1 data for Sierra Negra, note that this wasn't processed with LiCSBAS, and doesn't include the DEM.
Expand Down Expand Up @@ -49,7 +49,8 @@
"run_ICASAR" : True, # If False, attempt to load results from previous run. If True, run (which can be slow)
"intermediate_figures" : False, # if set to True, a figure is produced for all time steps in the monitoring data, which can be time consuming.
"downsample_run" : 0.5, # data can be downsampled to speed things up
"downsample_plot" : 0.5} # and a 2nd time for fast plotting. Note this is applied to the restuls of the first downsampling, so is compound
"downsample_plot" : 0.5, # and a 2nd time for fast plotting. Note this is applied to the restuls of the first downsampling, so is compound,
"residual_type" : 'cumulative'} # this is the default from the 2019 paper, but it could be switched to "window", but this hasn't been tested widely.


ICASAR_settings = {"n_comp" : 6, # number of components to recover with ICA (ie the number of PCA sources to keep)
Expand All @@ -59,7 +60,7 @@
"ica_param" : (1e-2, 150), # (tolerance, max iterations)
"figures" : "png", # if png, saved in a folder as .png. If window, open as interactive matplotlib figures, if window+png then both.
"create_all_ifgs_flag" : False, # Creates all possible pairs of ifgs between all acquisitions. Results can be more complex with this set to True, but also better at recovering small magnitude signals
"load_fastICA_results" : False} # If True, ICASAR will try to load the results of FastICA from previous runs. This is useful if you wish to fine tune the hdbscan or tsne settings quickly.
"load_fastICA_results" : True} # If True, ICASAR will try to load the results of FastICA from previous runs. This is useful if you wish to fine tune the hdbscan or tsne settings quickly.



Expand All @@ -74,6 +75,8 @@
LiCSAlert_batch_mode(displacement_r2_copy, ICASAR_settings = ICASAR_settings, **LiCSAlert_settings,ICASAR_path = ICASAR_path)




#%% Example 3, Running LiCSAlert with a smaller signal (Campi Flegrei, processed with LiCSBAS)

LiCSBAS_out_folder_campi_flegrei = Path('./022D_04826_121209')
Expand All @@ -86,7 +89,8 @@
"run_ICASAR" : True, # If False, attempt to load results from previous run. If True, run (which can be slow)
"intermediate_figures" : False, # if set to True, a figure is produced for all time steps in the monitoring data, which can be time consuming.
"downsample_run" : 0.5, # data can be downsampled to speed things up
"downsample_plot" : 0.5} # and a 2nd time for fast plotting. Note this is applied to the restuls of the first downsampling, so is compound
"downsample_plot" : 0.5, # and a 2nd time for fast plotting. Note this is applied to the restuls of the first downsampling, so is compound
"residual_type" : 'cumulative'} # controls the type of residual used in the lower plot. Either cumulative or window


ICASAR_settings = {"n_comp" : 5, # number of components to recover with ICA (ie the number of PCA sources to keep)
Expand All @@ -95,11 +99,11 @@
"ica_param" : (1e-2, 150), # (tolerance, max iterations)
"hdbscan_param" : (100,10), # (min_cluster_size, min_samples) Discussed in more detail in Mcinnes et al. (2017). min_cluster_size sets the smallest collection of points that can be considered a cluster. min_samples sets how conservative the clustering is. With larger values, more points will be considered noise.
"create_all_ifgs_flag" : True, # small signals are hard for ICA to extact from time series, so make it easier by creating all possible long temporal baseline ifgs from the incremental data.
"load_fastICA_results" : False, # If all the FastICA runs already exisit, setting this to True speeds up ICASAR as they don't need to be recomputed.
"load_fastICA_results" : True, # If all the FastICA runs already exisit, setting this to True speeds up ICASAR as they don't need to be recomputed.
"figures" : "png+window"} # if png, saved in a folder as .png. If window, open as interactive matplotlib figures,


displacement_r2, tbaseline_info = LiCSBAS_to_ICASAR(LiCSBAS_out_folder_campi_flegrei, figures=True) # open various LiCSBAS products, spatial ones in displacement_r2, temporal ones in tbaseline_info
displacement_r2, tbaseline_info, _ = LiCSBAS_to_ICASAR(LiCSBAS_out_folder_campi_flegrei, figures=True) # open various LiCSBAS products, spatial ones in displacement_r2, temporal ones in tbaseline_info
displacement_r2['ifg_dates'] = tbaseline_info['ifg_dates'] # Unlike ICASAR, LiCSAlert always needs the ifg_dates too.

LiCSAlert_batch_mode(displacement_r2, ICASAR_settings = ICASAR_settings, **LiCSAlert_settings, ICASAR_path = ICASAR_path)
Expand Down
Binary file modified licsalert/__pycache__/aux.cpython-37.pyc
Binary file not shown.
Binary file modified licsalert/__pycache__/licsalert.cpython-37.pyc
Binary file not shown.
Binary file modified licsalert/__pycache__/monitoring_functions.cpython-37.pyc
Binary file not shown.
30 changes: 30 additions & 0 deletions licsalert/aux.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@

#%%



def r2_to_r3(ifgs_r2, mask):
""" Given a rank2 of ifgs as row vectors, convert it to a rank3. Copied from insar_tools.general to avoid making insar_tools a dependency.
Inputs:
ifgs_r2 | rank 2 array | ifgs as row vectors
mask | rank 2 array | to convert a row vector ifg into a rank 2 masked array
returns:
phUnw | rank 3 array | n_ifgs x height x width
History:
2020/06/10 | MEG | Written
"""
import numpy as np
import numpy.ma as ma
from small_plot_functions import col_to_ma

n_ifgs = ifgs_r2.shape[0]
ny, nx = col_to_ma(ifgs_r2[0,], mask).shape # determine the size of an ifg when it is converter from being a row vector

ifgs_r3 = np.zeros((n_ifgs, ny, nx)) # initate to store new ifgs
for ifg_n, ifg_row in enumerate(ifgs_r2): # loop through all ifgs
ifgs_r3[ifg_n,] = col_to_ma(ifg_row, mask)

mask_r3 = np.repeat(mask[np.newaxis,], n_ifgs, axis = 0) # expand the mask from r2 to r3
ifgs_r3_ma = ma.array(ifgs_r3, mask = mask_r3) # and make a masked array
return ifgs_r3_ma


#%%

def get_baseline_end_ifg_n(LiCSBAS_imdates, baseline_end):
""" Given a list of the dates that there are steps in the LICSBAS time series for (i.e. when there was a Sentinel-1 acquisition),
find which number is the last before the baseline stage ends. Note the baseline stage can end on any date (i.e. not one when there's an acquisition)
Expand Down
Loading

0 comments on commit 59142d3

Please sign in to comment.