# D-InSAR by GMTSAR
:::success
Learning resources and manuals
> https://topex.ucsd.edu/gmtsar/
> https://topex.ucsd.edu/gmtsar/tar/GMTSAR_2ND_TEX.pdf
Notes for procedures of D-InSAR
>[name=Hu Wan-Lin]
>[time=Tue, Jan 23, 2024]
:::
### 1. Installation
[GMT](https://www.generic-mapping-tools.org/download/)
[GMTSAR](https://github.com/gmtsar/gmtsar)
export their PATH
### 2. Collecting files
#### download SAR image files (.zip->unzip->.SAFE)
**ASF data space**
https://search.asf.alaska.edu/
**ESA data spcae**
https://dataspace.copernicus.eu/browser/
**file details**
C-SAR
Level-1 SLC: single look complex
ETAD: Extended Timing Annotation Dataset (infrequently used)
**Auxiliary data files**
POEORB: precise orbit file (recommended)
PREORB: predicted orbit file
#### DEM
> https://boundingbox.klokantech.com/
* The dem file name should be ==dem.grd== and save in /topo folder
download from:
> https://topex.ucsd.edu/gmtsar/demgen/
or
```
make_dem.csh W E S N 2
```
>make_dem.csh W E S N [mode]
> Uses GMT server to download SRTM 1-arcsec data >>(@earth_relief_xxs)
> and removes the EGM96 geoid to make heights relative >to WGS84.
> mode 1:SRTM-1s 2:SRTM-3s
#### Orbit files (EOF)
Script to gather Sentinel-1 orbits
Try this new command:
`organize_files_tops.csh`
or for LINUX
`organize_files_tops_linux.csh`
or download .EOF from ESA website
#### Organize files and folders
./topo/dem.grd
./raw/*.SAFE and *.EOF
./config.txt
### 3. Set up configure file
```txt
pop_config.csh S1_TOPS > config.txt
```
and ==revise config.txt==
Other options:
>pop_config.csh SAT
SAT can be ERS, ENVI, ALOS, ALOS_SLC, ALOS2, ALOS2_SCAN
S1_STRIP, S1_TOPS, CSK_RAW, CSK_SLC, TSX, RS2, GF3
### 4. Process: `p2p_S1_TOPS_Frame.csh`
Usage: `p2p_S1_TOPS_Frame.csh Master.SAFE Master.EOF Aligned.SAFE Aligned.EOF config.s1a.txt polarization parallel`
> Place the .SAFE file in the raw folder, DEM in the topo folder
During processing, F1, F2, F3 and merge folder will be generated
Final results will be placed in the merge folder, with phase
corr [unwrapped phase].
polarization = vv vh hh or hv
parallel = 0-sequential 1-parallel
Example:
```
p2p_S1_TOPS_Frame.csh S1A_IW_SLC__1SSV_20150526T014935_20150526T015002_006086_007E23_679A.SAFE \
S1A_OPER_AUX_POEORB_OPOD_20150615T155109_V20150525T225944_20150527T005944.EOF \
S1A_IW_SLC__1SDV_20150607T014936_20150607T015003_006261_00832E_3626.SAFE \
S1A_OPER_AUX_POEORB_OPOD_20150627T155155_V20150606T225944_20150608T005944.EOF config.txt vv 0
```
#### procedure
**step 4:**
intf.csh
filter.csh
filter_wavelength = 200 (meter)
iono_dsamp = 1 (save ionospheric results in another folder)
#### Offset tracking
`make_a_offset.csh`
>https://github.com/joa-quim/GMT5SAR/blob/master/gmtsar/csh/make_a_offset.csh
### 5. Atmospheric corrections: GACOS for GMTSAR
> download scripts from:
> https://github.com/esrivas17/gacos_correction_for_GMTSAR
download gacos products from:
> http://www.gacos.net/
```
single_GACOS_correction.csh master_ztd master_ztd.rsc slave_ztd slave_ztd.rsc intf_phase.grd reference_point incidence_angle
```
example:
https://www.cnblogs.com/cq-wushaoyu/p/17600736.html
### 6. Output files and directory structures
ra: range and azimuth (radian coordinates)
ll: longitude and latitude (geographic coordinates)
intf: interferograms
filt: filter
amp: amplitudes
`corr_ll.grd` correlation file
`phasefilt_mask_ll.grd` wrapped phase
`unwrap_ll.grd` unwrapped_II.grd
`los_ll.grd` LOS displacement map
```sh
# Convert `unwrap_ll.grd` to `los_ll.grd`:
gmt grdmath corr.grd 0.01 GE 0 NAN mask.grd MUL = mask2.grd
gmt grdmath unwrap.grd mask2.grd MUL = unwrap_mask.grd
proj_ra2ll.csh trans.dat unwrap_mask.grd unwrap_mask_ll.grd
gmt grdmath unwrap_mask_ll.grd $wave MUL -79.58 MUL = los_mask_ll.grd
```
---
#### GMTSAR Timeseries
How to make an InSAR time series from Sentinel-1 TOPS data: Kilauea
https://topex.ucsd.edu/gmtsar/tar/sentinel_time_series_4.pdf