SNAP 9.0 + StaMPS 4.1 集成处理:Ubuntu 18.04 下 30 幅 Sentinel-1 数据 PS-InSAR 全流程

SNAP 9.0 + StaMPS 4.1 集成处理:Ubuntu 18.04 下 30 幅 Sentinel-1 数据 PS-InSAR 全流程

SNAP 9.0 与 StaMPS 4.1 集成处理:30 幅 Sentinel-1 数据的 PS-InSAR 全流程实战指南

1. 环境准备与软件配置

在开始处理 Sentinel-1 数据之前,需要确保系统环境正确配置。以下是 Ubuntu 18.04 下的详细配置步骤:

1.1 系统依赖安装

首先更新系统并安装基础依赖:

sudo apt update && sudo apt upgrade -y sudo apt install -y build-essential gfortran libgdal-dev \ libhdf5-dev libfftw3-dev libxml2-dev libproj-dev \ python3-dev git cmake

注意:StaMPS 需要 GCC 7 版本进行编译,Ubuntu 18.04 默认可能安装的是更高版本。可通过以下命令安装 GCC 7:

sudo apt install -y gcc-7 g++-7 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 70

1.2 MATLAB 安装与配置

StaMPS 需要 MATLAB 环境支持,建议安装 R2018b 或更高版本。安装完成后,需要设置环境变量:

export MATLAB_HOME=/usr/local/MATLAB/R2021b export PATH=$MATLAB_HOME/bin:$PATH

验证 MATLAB 是否能正常启动:

matlab -nodesktop -nodisplay -r "version; exit"

1.3 SNAP 9.0 安装

下载并安装 SNAP 9.0:

wget https://step.esa.int/downloads/9.0/installers/esa-snap_sentinel_unix_9_0.sh chmod +x esa-snap_sentinel_unix_9_0.sh ./esa-snap_sentinel_unix_9_0.sh

安装完成后,配置 SNAP 的 GPT 工具路径:

export SNAP_HOME=/opt/snap export PATH=$SNAP_HOME/bin:$PATH

1.4 StaMPS 4.1 安装

从 GitHub 克隆 StaMPS 仓库并编译:

git clone https://github.com/dbekaert/StaMPS.git cd StaMPS/src make && make install

配置 StaMPS 环境变量:

export STAMPS_HOME=/path/to/StaMPS export PATH=$STAMPS_HOME/bin:$PATH source $STAMPS_HOME/StaMPS-v4.1_CONFIG.bash

在 MATLAB 中添加 StaMPS 路径:

addpath(genpath('/path/to/StaMPS')); savepath;

2. 数据获取与预处理

2.1 Sentinel-1 数据下载

推荐使用 Alaska Satellite Facility (ASF) 或 Copernicus Open Access Hub 下载 Sentinel-1 SLC 数据。以下是通过 ASF 下载的示例命令:

wget --user=your_username --password=your_password \ "https://datapool.asf.alaska.edu/SLC/SA/S1A_IW_SLC__1SDV_20210825T102900_20210825T102927_039430_04A8B2_7A5D.zip"

提示:建议选择同一轨道(relative orbit number相同)的30幅影像,时间跨度建议1-2年,以确保足够的时空基线。

2.2 SNAP 预处理流程

SNAP 预处理包括以下关键步骤,可通过 Graph Processing Framework (GPF) 批量处理:

  1. Split:分离各子条带(IW1/IW2/IW3)

    <node id="Split"> <operator>Split</operator> <parameters> <subswath>IW1</subswath> <selectedPolarisations>VV</selectedPolarisations> </parameters> </node>
  2. Apply Orbit:应用精密轨道文件

    <node id="ApplyOrbit"> <operator>Apply-Orbit-File</operator> <parameters> <orbitType>Sentinel Precise (Auto Download)</orbitType> </parameters> </node>
  3. Back-Geocoding:配准影像

    <node id="BackGeocoding"> <operator>Back-Geocoding</operator> <parameters> <demName>SRTM 1Sec HGT</demName> <demResamplingMethod>BILINEAR_INTERPOLATION</demResamplingMethod> </parameters> </node>
  4. Interferogram:生成干涉图

    <node id="Interferogram"> <operator>Interferogram</operator> <parameters> <subtractFlatEarthPhase>true</subtractFlatEarthPhase> <degreeOfFlatEarth>5</degreeOfFlatEarth> </parameters> </node>
  5. TOPSAR Deburst:去除条带效应

    <node id="Deburst"> <operator>TOPSAR-Deburst</operator> </node>
  6. Export to StaMPS:导出为 StaMPS 格式

    <node id="Export"> <operator>StaMPS-Export</operator> <parameters> <outputFolder>./Export</outputFolder> </parameters> </node>

3. StaMPS 处理流程

3.1 数据准备与参数设置

在 MATLAB 中初始化 StaMPS 处理:

% 设置主影像日期 masterdate = '20210825'; % PS点选择参数 ADD_PS = 0.4; % 振幅离差阈值 NPatchesRange = 5; % 距离向分块数 NPatchesAzimuth = 5; % 方位向分块数 % 准备数据 cmd = ['mt_prep_snap ' masterdate ' ' pwd '/Export ' num2str(ADD_PS) ' ' ... num2str(NPatchesRange) ' ' num2str(NPatchesAzimuth) ' 50 50']; system(cmd); % 初始化处理 stamps(1,1);

3.2 关键参数配置

设置 StaMPS 处理参数:

setparm('density_rand', 1); % 随机点密度 setparm('weed_standard_dev', 1); % 剔除标准差阈值 setparm('weed_time_win', 365); % 时间窗口(天) setparm('merge_resample_size', 100); % 合并重采样尺寸 setparm('unwrap_grid_size', 100); % 解缠网格尺寸 setparm('unwrap_time_win', 365); % 解缠时间窗口 setparm('insar_processor', 'snap'); % 指定InSAR处理器

3.3 分块处理与合并

对于大型数据集,分块处理可提高效率:

% 进入每个patch目录处理 for i = 1:NPatchesRange*NPatchesAzimuth cd(['PATCH_' num2str(i)]); stamps(1,5); % 执行步骤1-5 cd .. end % 合并结果 stamps(5,5);

3.4 相位解缠与时间序列分析

% 相位解缠 setparm('unwrap_method', '3D'); % 使用3D解缠方法 stamps(6,6); % 时间序列分析 stamps(7,7); % 可选:重新解缠(调整参数后) unwrap_grid_size = getparm('unwrap_grid_size'); setparm('unwrap_grid_size', unwrap_grid_size + 10); stamps(6,6);

4. 大气校正与结果可视化

4.1 GACOS 大气校正

  1. 从 GACOS 网站获取大气延迟数据
  2. 将数据整理到 APS 文件夹
  3. 在 MATLAB 中应用校正:
% 配置GACOS参数 setparm_aps('gacos_datapath', './APS'); setparm_aps('UTC_sat', '10:29'); % 卫星过境时间(UTC) % 执行大气校正 aps_weather_model('gacos', 1, 3); % 更新处理流程 setparm('tropo', 'a_gacos'); setparm('subtr_tropo', 'y'); stamps(6,7);

4.2 结果可视化

生成形变时间序列图:

% 绘制LOS向形变速率 ps_plot('V-do'); % 绘制时间序列形变 ps_plot('V-do', 'ts', 1, 0, 0, 'ts'); % 导出结果为CSV格式 load ps2; load ps_plot_V-do.mat; A0 = [lonlat ph_disp]; fid = fopen('deformation_results.csv', 'w'); fprintf(fid, 'Lon,Lat,Deformation(mm)\n'); fprintf(fid, '%f,%f,%f\n', A0'); fclose(fid);

5. 常见问题排查与优化建议

5.1 常见错误与解决方案

错误类型可能原因解决方案
无PS点区域反射特性差降低ADD_PS阈值或更换研究区
配准失败轨道差异大确保所有影像来自同一轨道
解缠错误相位梯度大增大unwrap_grid_size参数
MATLAB崩溃内存不足增加分块数或使用更高配置机器

5.2 性能优化技巧

  • 并行处理:对不同分块使用不同的MATLAB会话并行处理
  • 内存管理:在StaMPS-v4.1_CONFIG.bash中增加MATLAB内存限制:
    export MATLAB_MEMORY_LIMIT=16G
  • 数据精简:处理前使用subset操作减小研究区范围

5.3 结果验证方法

  1. 交叉验证:选择稳定区域检查形变速率是否接近0
  2. GPS对比:如有地面测量数据,进行相关性分析
  3. 多轨道分析:结合升轨和降轨数据提高结果可靠性

在实际项目中,发现将unwrap_grid_size设置为100-150、ADD_PS在0.35-0.45之间通常能获得平衡的点密度和可靠性。对于城市区域,可以尝试更高的density_rand值以增加PS点数量。