---
# System prepended metadata

title: Fringe insar processing working note
tags: [' fringe', ' timeseries', isce]

---

---
tags: isce, fringe, timeseries
---
# Fringe insar processing working note
## Introduction 

FRInGE is a psds processing code utilizing the sequential MLE algorithm. 
The fringe project is developed by :rocket:NASA JPL. 
[fringe@github](https://github.com/isce-framework/fringe)  

Here, we want to combine **distributed scatter** and **PS algorithm, StaMPS**, and explore more precise timeseries in geodesy . 

## Installation
Follow the github page. 
Notion: you must install the same version gdal as ISCE since it sometimes calls ISCE functions. 

## Fringe workflow for PSI
:::success
1. ISCE SLC stack for input
2. Cropping the slc stack is recommended. 
3. I do some modidication to the code for StaMPS support. Here's my :dog:[github page](https://github.com/sharkbig/fringe2mintpy)
:::

### Standard FRInGE workflow for DS estimation
1. load data 
`tops2vrt.py -i ../crop_merged/ -s coreg_stack -g geometry`
2. calibrate amplitude
`mkdir calamp & calamp.py -i coreg_stack/slcs_base.vrt -o calamp/slcs_base_calamp.vrt`
    - calibrate is optional (?)
    - replace the coreg_stack/slcs_base.vrt in the following step 

3. KS/AD test to find SHP candidates 
`nmap.py -i calamp/slcs_base_calamp.vrt -o KS2/nmap -c KS2/count -x 25 -y 7` 
    - need more tests for window size determination.
    - The code has GPU support.

4. Sequential Estimator 
`sequential.py -i ../crop_merged/SLC -o Sequential -w KS2/nmap -b calamp/slcs_base_calamp.vrt -x 25 -y 7 -s 15`
    - take most time 
    - The window size must be consistent with the previous step. 

6. `adjustMiniStacks.py -s slcs/ -m Sequential/miniStacks/ -d Sequential/Datum_connection/ -o adjusted_wrapped_DS -M 10` 
    - Datum connection process with sequential
6. Amplitude dispersion and PS pixel mask
```bash
ampdispersion.py  -i calamp/slcs_base_calamp.vrt \
          -o calamp/ampdispersion -m calamp/mean
gdal2isce_xml.py -i calamp/ampdispersion
imageMath.py -e="a<0.4" --a=calamp/ampdispersion \
          -o calamp/ps_pixels -t byte
```


## integratePS.py for StaMPS
- The original code makes single master interferograms and utilize mintpy (prep_fringe.py) to **display** the PS-DS result. 
*(I'm not going to introduce in this docs)*
- Since we want to apply the StaMPS algorithm to calculate the timeseries, **the option "--stamps" is added to export SLCs without interference.**
```bash
integratePS.py  -s coreg_stack/slcs_base.vrt \
                -d adjusted_wrapped_DS/ \
                -t Sequential/Datum_connection/EVD/tcorr.bin \
                -p calamp/ps_pixels \
                -o PS_DS --stamps
```
:::info
Also, the modified code has SBAS support.
Check the github page for more info! 
:::


## StaMPS insar timeseries 
### mask_file for coherence
10. `gdal2isce_xml.py -i PS_DS/tcorr_ds_ps.bin`
11. `imageMath.py -e="a<0.85" --a="PS_DS/tcorr_ds_ps.bin" -o PS_DS/TempCohMask -t B`

** temporal cherence value threshold still need more experiment.  (0.85、0.9、0.95?)
** the one-byte (char*) binany file is designated to stamps input (very important!!)
** In StaMPS, the "selpsc_patch.c" code treats "0" for no mask, other value for mask out. 
Here, we let temporal coherence < 0.85 as 1 and greater as 0, which means points whose cohrence higher than 0.85 will be processed.


### "input_file" for StaMPS
**replace "$project" with your project directory**
```
source_data slc_stack
slc_stack_path $project/fringe/PS_DS
slc_stack_reference 20230510
slc_stack_geom_path $project/crop_merged/geom_reference
slc_stack_baseline_path $project/crop_merged/baselines
range_looks 1
azimuth_looks 1
aspect_ratio 1
lambda 0.0555
slc_suffix
geom_suffix .full
maskfile $project/fringe/PS_DS/TempCohMask

```

The same as isce2stamps procedure, which you can refer to [ISCE-stamps/MTI-TomoSAR](/Je0fJkX_TsS1nqCoaW2bwA) note. 

execute command:
`mt_prep_isce 0.45 1 1`

- **da_threshold** for *mt_prep_isce* still needs more test for DS algorithm.
- While using the same value as step 7, the result will be the same as **not doing DS**





## Parameter issues
there are some parameter that is important for estimation
1. xwin/ywin
2. number of connection

I did some experiments, and they can be briefly concluded as: 
1. the window size is according to the sar resolution. And for sentinel-1, I guesss -x 11 -y 6 is good enough. (not too big?)
2. the number of connection will affect the ministack estimation. Thus, I cannot be too small. In some of my experiments, I think larger than 10 is better?