x2sys是GMT软件扩展工具包,主要用于地球物理测线数据的管理和交点差的计算。x2sys软件包有10个计算模块构成,通过建立测线数据库和数据参数规格说明(称之为TAG),用户可以通过添加、抽取等多种操作对整个测线区块或局部区域的测线进行交点差统计。
x2sys模块简介:
- x2sys_init 创建一个新的测线数据库
- x2sys_binlist 创建分区索引(bin index)
- x2sys_put 更新测线数据
- x2sys_get 按参数提取测线数据文件列
- x2sys_cross 计算交点差
- x2sys_report 形成交点差计算结果报告
- x2sys_list 从交点差数据库中抽取子区交点差
- x2sys_solve 计算每一条测线的交点差改正值
- x2sys_datalist 数据导出
- x2sys_merge 多个交点差数据库合并 [/code]
更详细的功能介绍见Paul Wessel关于该扩展模块的论文:Tools for analyzing intersecting tracks: The x2sys package.
计算前,用户必须指定一个可读写的目录作为存放测线参数路径,叫做$HOME_X2SYS,顾名思义,这个目录就是用来存放x2sys各类参数及中间过程的“根目录”。另外,需要根据所处理数据的格式建立一个数据格式说明,称作Definition Files,系统自带了一些简单的数据格式说明文件,存放于GMT软件包的Share/x2sys文件夹中。数据格式说明文件有2部分构成:表头说明和列说明。表头说明用于告诉程序数据格式,比如ASCII,二进制文件等,数据文件有无表头说明,如有则需要跳过(SKIP)几行等;数据列说明有name type NaN NaN-proxy scale offset oformat 7个选项组成。 - name 列名称,对于经纬度列需要注意:lon和lat为地理坐标,x和y为笛卡尔坐标。 - type 数据类型,如果是ascii则为a,其他类型根据文件格式确定,如字符c,整形i等 - NaN 文件中如果需要将特定数值(如-9999)用NaN代替,则填Y,否则填N。 - NaN-proxy 需要用NaN代替的数值 - scale 读入的数值乘以scale值,不需要修改则为1。 - offset 乘以scale值后加该数值 - oformat 输入文件的格式,采用C语言的输入输出格式。
以下是经纬度坐标为例,由lon、lat、z三列数据组成的文本文件数据的数据格式说明,保存为xyz.def。
# Define file for X2SYS processing of ASCII xyz files
# This file applies to a 3-column ASCII files, generated from dumping the nadir beam;
# longitude, latitude, depth
# from mbsbystem using the command;
# mblist -I $input file list -OXYZU -P3 > $output file
#---------------------------------------------------------------------
#ASCII # The input file is ASCII
#SKIP 1 # The number of header records to skip
#---------------------------------------------------------------------
#name intype NaN-proxy? NaN-proxy scale offset oformat
lon a N 0 1 0 %10.7f
lat a N 0 1 0 %9.7f
z a N 0 1 0 %7.3f
下面是利用多波束中央波束计算测线交点差的代码:
# Cruise identifier
fileID="Arctic8"
ROOT_DIR=`pwd`
CRUISE_DIR=$ROOT_DIR"/"$fileID
X2SYS_DIR=$CRUISE_DIR"/X2SYS"
NADIR_DIR=$CRUISE_DIR"/XYZ"
# remove existing x2sys system directories\files for example cruise, make a blank ones
if [ -d "$X2SYS_DIR" ]; then
rm -rf $X2SYS_DIR
fi
mkdir $X2SYS_DIR
# Create xyzt definition file
cat > $X2SYS_DIR"/xyz.def" << EOF
# Define file for X2SYS processing of ASCII xyz files
# This file applies to a 3-column ASCII files, generated from dumping the nadir beam;
# longitude, latitude, depth
# from mbsbystem using the command;
# mblist -I $input file list -OXYZU -P3 > $output file
#---------------------------------------------------------------------
#ASCII # The input file is ASCII
#SKIP 1 # The number of header records to skip
#---------------------------------------------------------------------
#name intype NaN-proxy? NaN-proxy scale offset oformat
lon a N 0 1 0 %10.7f
lat a N 0 1 0 %9.7f
z a N 0 1 0 %7.3f
EOF
# Save the default x2sys home location (if set)
X2SYS_HOME_OLD=$X2SYS_HOME
# Change the default x2sys home directory to the local directory for our example
cd $X2SYS_DIR
export X2SYS_HOME=`pwd`
# Initialize the TAG folder
#x2sys_init $fileID -Gd -Cg -Dxyz -F -V -Wd1
x2sys_init $fileID -V -G -Dxyz -Rg -Ce -Ndk -Nsn -I1/1 -Etxt
cd $fileID
# Copy cruise trackline filenames to datalist.d
ls $NADIR_DIR > datalist.d
# Create path file
# the absolute path to the folder with the extracted nadir beams
echo $NADIR_DIR > $fileID"_paths.txt"
#x2sys_binlist
#x2sys_binlist -V -T$fileID :datalist.d > tracks.tbf
#x2sys_put
#x2sys_put -V -T$fileID tracks.tbf
#x2sys_get -V -T$fileID -R-173.5/-167.5/75.2/76.70 -Fz > tracks.tbf
# Calculate crossovers
# Set speed constraint so that we dont calculate crossings for speeds less that 1.0289 m/s
# e.g. 2 knots......(helps remove self crossings from holding position)
x2sys_cross =datalist.d -T$fileID -Qe -V -Sl1.0289 > $fileID.CROSS
if test -s $fileID.CROSS; then
echo "CROSSOVERS FOUND";
# Output the crossovers from the database
x2sys_list -Cz -T$fileID $fileID.CROSS -FNc -V > tmp
# x2sys_list has a tendency to find "self crossings" along straight line segments (yes,
# even with the speed constraint). We will remove these from the list. It is thereby
# important to make sure your lines are not obscenely long and self-crossing.
awk '{if ($1 != $2) {print $0} else next}' tmp > $fileID.LIST
/bin/rm tmp
# Find corrections (although we dont apply any)
x2sys_solve -Cz -T$fileID $fileID.LIST -V -Ec > $fileID.SOLVE
touch N_`awk 'NR > 3 {print $0}' *.LIST | minmax | awk '{print $4}'`
else
echo "NO CROSSOVERS.....ABORTING...."
fi