How to prepare Sentinel-1 images stack for PSI/SBAS in SNAP 5


use a Linux machine. Was the same for me with cygwin. It doesn’t call the scripts correctly.


ok thanks @ABraun :confused:


@Fikretjfm @ABraun if you use csh shell in Cygwin you will be able to run the scripts on windows (just type ‘csh’ in Cygiwin command line to change from bash (used by default) to csh).

Additionally, I added a few lines to the modified mt_prep_gamma script by @FeiLiu to avoid problems when matlab tries to access the folder where the data is (Cygwin executes unix scripts “virtually” and the absolute path that uses is different from the real one in windows, which is used by Matlab). The script works if you run StaMPS from your C: drive, otherwise you will have to modify drive name to run them correctly. Change_log.txt explains how to modify it.

After running this script you will only need to run matlab and change ‘insar_processor’ to ‘gamma’ and hopefully all will run flawlessly.

Change_log.txt (1.1 KB)
mt_prep_gamma (6.6 KB)


thanks for the hint! I remember using csh but there were problems calling the matlab scripts in Windows. But I will give it a try!


You are right! The problems calling the matlab scripts are due to the different path that I mention on the previous post. After changing this I had no problems to complete the analysis with StaMPS in windows


That would be fantastic, thanks for sharing!


@alvegavaleri Thanks for help. I modified mt_prep_gamma_snap and I am working under :F directory due to memory. I changed c: to f: under mt_prep_gamma and changed cygwin to csh but still program gives following errors:

[Asus@fdogru …StaMPS_v3.3b1/bin]$ /cygdrive/f/Sentinel/PSI/StaMPS_v3.3b1/bin/mt_prep_gamma_snap 20090530 /cygdrive/f/Sentinel/PSI/INSAR_20090530 0.4 2 2 50 200
mt_prep_gamma_snap Andy Hooper, December 2012

Amplitude Dispersion Threshold: 0.4
Processing 2 patch(es) in range and 2 in azimuth

STAMPS: Undefined variable.
calamp: Command not found.
cat: /cygdrive/f/Sentinel/PSI/StaMPS_v3.3b1/bin/calamp.out: No such file or directory
mt_extract_cands: Command not found.
Unmatched ‘’’.

Also I wonder when you changed cygwin to csh @bayzidul did your installation progress of StaMPS change???
Nothing changed for me in the installation progress.


Different things. You have to run mt_prep_gamma from the directory where you store the data exported from SNAP, not the directory where StaMPS is installed, otherwise mt_prep_gamma would not find the files that requires (what the error says about calmp.out: No such file or directory).

It also seems that the system cannot find the installed StaMPS scripts. Make sure that you installed it correctly and that the folder containing StaMPS installation is in your PATH variable. I hope that this helps you!


I guess my installation isn’t correct and gives following results. I deleted StaMPS files and tried again but now before typing initially csh. But gives same results. Also I adjust path variables StaMPS installed directory and also bin directory. As you said it does not work under exported files. I am typing under exported .dem .rslc … files
mt_prep_gamma_snap and its says “no command”. Could you show me the directory which includes exported files? Which files in it and what are you typing on command line without giving directory as me?


Hello @Fikretjfm, My installation result is same as yours. The problem is also same for me. I am also getting the same error as yours,

STAMPS: Undefined variable.
calamp: Command not found.
cat: /cygdrive/f/Sentinel/PSI/StaMPS_v3.3b1/bin/calamp.out: No such file or directory
mt_extract_cands: Command not found.

Maybe @alvegavaleri could help us a little more…


if the commands are not found, you need to add the directories with the scripts in your PATH variable.


I did (I added all directories in PATH variable) but still does not work. I guess it is all about StaMPS installation. It did not install correctly then program doesn’t work. I tried under Ubuntu and Windows same as @bayzidul but there is something wrong in the installation progress. In windows system, mt_prep_gamma_snap is a file not a program after installing StaMPS (wrongly I guess). But I recognized it should be kind of program as @bayzidul 's before post.

Also I tried snaphu program under cygwin and it worked correctly. Why StaMPS does not install correctly I do not see. I hope @alvegavaleri will help us about this issue. Thanks all.


Most of the scripts used in StaMPS are NOT executables after installation (.exe files), only a few of them (calamp.exe, cpxsum.exe, pscdem.exe, psclonlat.exe, pscphase.exe, selpsc_patch.exe,selsbc_patch.exe, selsbc_patch_new.exe and showme.exe). mt_prep_gamma is not an executable but a script and it is necessary to change the file by the one provided by @FeiLiu or myself. Just download it and copy/paste in installation directory, erase the old one and change the name of the new one to mt_prep_gamma. Here there is a screenshot of the folder where I have StaMPS installed.

If the installation worked properly and you have added the path to your system variable, when you type “mt_prep_gamma” on cygwin shell (from any directory) the header of the script with instructions should be printed on the console. If this does not happen it means that the script is not placed where you indicated or the directory is not added properly to the system path variable.

Once you get this to work, the program is installed correctly. Then you should change directory to the folder where you exported SNAP data (a folder with 4 subdirectories: dem,diff0,geo,rslc) and execute mt_prep_gamma from there. Take care using the correct syntaxis to call mt_prep_gamma. It should be something like:

mt_prep_gamma [masterdate in format yyyymmdd] [data directory] [amp_threshold] [rg_patches] [az_patches] [az_overlap] [rg_overlap]

for example for a master 15 october 2016 and data placed in C:/Insardata/Stamps_export. Amplitude threshold 0.4, 5 patches in each direction and 200 pixels of overlapping:

mt_prep_gamma 20161015 /cygdrive/c/Insardata/Stamps_export 0.4 5 5 200 200

I hope you find your problems!


Hi @Fikretjfm … Here we go…
I think the problem is about bash and csh/tcsh (

Set your PATH like this in Cygwin…

nano ~/.bash_profile
add… setenv PATH $PATH:/dir_to_your_StaMPS

Then open Cigwin and write…


Then >> mt_prep_gamma_snap [masterdate in format yyyymmdd] [data directory] [amp_threshold] [rg_patches] [az_patches] [az_overlap] [rg_overlap] {for instance… mt_prep_gamma_snap 20161015 /cygdrive/c/Insardata/Stamps_export 0.4 2 2 50 200}

It should work perfectly, at least worked for me…

  1. Please carefully read previous comments to process your data
  2. Please carefully read to select right script

I will try to solve the issue for Linux.

Have fun…!!


Hi @alvegavaleri and @bayzidul ,
I found my error. I was doing the PATH issue wrongly. I found the following instructions from website and now progressing started. I hope I won’t get any error :). Thanks for your effort.

"Create a new environment variable with name “CYGWIN_HOME” and value “C:\cygwin” (or wherever you installed cygwin. The default location is “C:\cygwin” so this should probably work for you).

Then edit the environment variable named “PATH”, and tack on the following to the end:



this is for Windows to be able to find the cygwin drivers and installations. But within cygwin the path definition is different, as @bayzidul explained.


I found this might be it is helpfull,


I achieved to run mt_prep_gamma_snap via your helps. I have some errors when running stamps under export directory same as @ABraun 's faced errors before. I am trying to work under Linux due to get out of this error. If you solve the following error, could you give me an advice? Thanks. I searched all of the forum and I couldn’t find any solution. I changed also the last ps_load_initial_gamma_snap file with old one.

"Loading data into matlab…
Error using load
Unable to read file ‘…/’. No such file or directory.

Error in ps_load_initila (line 52)

Error in stamps (line 141)


Can i Export backscatter values to Excel or CSV format by SNAP toolbox?
Thanks all…


You should use ps_load_initial_snap and remember to change the paramater ‘insar_processor’ from ‘doris’ to ‘gamma’ before running stamps.

After calling matlab from cygwin, enter in matlab console: