matthew-gaddes / LiCSAlert

Volcano monitoring using Sentinel-1 InSAR data
GNU General Public License v3.0
19 stars 6 forks source link

LICSBAS output example #4

Open mohseniaref-InSAR opened 3 years ago

mohseniaref-InSAR commented 3 years ago

Hi Mathew,

I think my test example is not working. I used LICSBAS output but I don't know why there is an error in the output I used your example to get output. Your example dataset works without any problem. I really appreciate it if you can help me regarding this issue. the same issue has happened with ICASAR example_spatial_02.py with a new dataset from LICSBAS!

best, Mohammad

the code is


import sys
import pickle
from pathlib import Path
import copy
import numpy as np

sys.path.append("./lib")
from LiCSAlert_functions import LiCSAlert_batch_mode
LiCSBAS_out_folder_campi_flegrei = Path('./010D_11455_131313')
sys.path.append(str(ICASAR_path))                                                                       # Add ICASAR to the path so we can use one of its functions.  
from ICASAR_functions import LiCSBAS_to_ICASAR                                                          # which is for importing time series processed by LiCSBAS.  

LiCSAlert_settings = {"n_baseline_end" : 55,                                         # n_ifgs that are used in the baseline stage (i.e. by ICASAR)
                      "out_folder" : "LiCSAlert_03_Campi_Flegrei",    # no spaces, snake or camel case
                      "run_ICASAR" : True,                                           # If False, attempt to load results from previous run.  If True, run (which can be slow)
                      "intermediate_figures" :True,                                # if set to True, a figure is produced for all time steps in the monitoring data, which can be time consuming.  
                      "downsample_run" : 1.,                                        # 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

ICASAR_settings = {"n_comp" : 5,                                         # number of components to recover with ICA (ie the number of PCA sources to keep)
                   "bootstrapping_param" : (200, 0),                    # (number of runs with bootstrapping, number of runs without bootstrapping)                    "hdbscan_param" : (35, 10),                        # (min_cluster_size, min_samples)
                   "tsne_param" : (30, 12),                             # (perplexity, early_exaggeration)
                   "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.  
                   "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,filtered=True, figures=True,return_r3=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)

The output



QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-maref'
Traceback (most recent call last):
  File "./LiCSAlert_batch_mode_examples.py", line 106, in <module>
    displacement_r2, tbaseline_info = LiCSBAS_to_ICASAR(LiCSBAS_out_folder_campi_flegrei,filtered=True, figures=True,return_r3=True)        # open various LiCSBAS products, spatial ones in displacement_r2, temporal ones in tbaseline_info
  File "/raid-manaslu/maref/Software/ICASAR/lib/ICASAR_functions.py", line 581, in LiCSBAS_to_ICASAR
    displacement_r2['incremental'], _ = rank3_ma_to_rank2(displacement_r3['incremental'])                          # also convert incremental, no need to also get mask as should be same as above
  File "/raid-manaslu/maref/Software/ICASAR/lib/ICASAR_functions.py", line 432, in rank3_ma_to_rank2
    ifgs_r3_consistent = ma.array(ifgs_r3, mask = ma.repeat(mask_coh_water_consistent[np.newaxis,], n_ifgs, axis = 0))                       # mask with the new consistent mask
  File "/raid-manaslu/maref/Software/anaconda3/envs/myisceenv/lib/python3.8/site-packages/numpy/ma/core.py", line 6559, in array
    return MaskedArray(data, mask=mask, dtype=dtype, copy=copy,
  File "/raid-manaslu/maref/Software/anaconda3/envs/myisceenv/lib/python3.8/site-packages/numpy/ma/core.py", line 2909, in __new__
    raise MaskError(msg % (nd, nm))
numpy.ma.core.MaskError: Mask and data not compatible: data size is 2788668, mask si
```ze is 108.
matthew-gaddes commented 3 years ago

Hi Mohammed,

It could be an issue with using a different version of LiCSBAS. This was written for 1.5 I think. Two ideas:

1) If you're happy to share our LiCSBAS folder with me, I will run it myself and work out what is going on and add something to produce a more meaningful error if this is encountered in the future. I think you have my email from Fringe. WeTransfer is good.

2) If you want to debug it yourself, I would add a break or something in the lines above the error:

mask_coh_water = np.isnan(cumulative)                                                                       # get where masked
displacement_r3["cumulative"] = ma.array(cumulative, mask=mask_coh_water)                                   # rank 3 masked array of the cumulative displacement
displacement_r3["incremental"] = np.diff(displacement_r3['cumulative'], axis = 0)                           # displacement between each acquisition - ie incremental
n_im, length, width = displacement_r3["cumulative"].shape                                   

and have a look at that. Do the ifgs in displacement_r3 make sense? Are n_im, length, and width all what they should be? The function that is giving an error takes the interferograms in rank 3 format and requires that the same pixels are used in each interferogram. My outputs from LiCSBAS always do this (ie consistent mask of which pixels are used through time), but a difference here could cause the error.

Regards, Matt

mohseniaref-InSAR commented 3 years ago

Hi Matt,

Thanks so much, I sent you the data.

Best regards, Mohammad