为方便各位GNSS初学者能够对观测数据批量下载,笔者分享自己在Linux系统下编写的脚本,运行该脚本需要额外的脚本支持,需要在Linux系统中安装wget与CRX2RNX并能够成功使用该命令。
wget具体安装方式网上有很多教程在此不再赘述,此处分享一下CRX2RNX的脚本文件。链接:https://pan.baidu.com/s/1hV2CmYNLRUpN-8seE3YXxQ 提取码:zhao
一切准备就绪后就可以运行批量下载的脚本了,具体代码如下:
#!/bin/bash
# function: Download the observations of MGEX and EUREF
# Usage : wgetbs YYYY DOY SITE outDir
# Examp : Download to current dir: wgetObs 2017 012 JFNG ./
###########################################################################################
if [ $# != 4 ]; then #判断输入格式是否正确
echo "Usage: wgetObs YYYY DOY SITE outDir"
echo "Usage: wgetObs 2019 001 ABMF /date/gnss/"
exit
fi
yyyy=$1
day=$2
SITE=$3 #大写测站名
ObsPath=$4 #输出路径
doy=`echo ${day} | awk '{printf("%03d",$0)}'`; #年积日
yy=`echo ${yyyy} | awk '{printf("%2.2d",$1-int($1/100)*100)}'`; #年份
site=${SITE}
site0=`echo ${site} | tr 'A-Z' 'a-z'` #小写测站名
#Check the file existence #判断o文件是否存在
if [ -f ${ObsPath}${site0}${doy}0.${yy}o ] ; then
echo "Obsfile : ${ObsPath}${site0}${doy}0.${yy}o exist"
exit
fi
#define the data center 观测数据下载地址
URL_CDDIS="https://cddis.nasa.gov/archive/gnss/data/daily/${yyyy}/${doy}/${yy}d/"
URL_WHU="ftp://igs.gnsswhu.cn/pub/gps/data/daily/${yyyy}/${doy}/${yy}d/"
RINEX3L="${site}*${yyyy}${doy}*.crx.gz" #Rinex3 LONG NAME 用于匹配ABMF00GLP_R_20203570000_01D_30S_MO.crx.gz
RINEX3S="${site}*d.Z" #Rinex3 SHORT NAME 用于匹配abpo3570.20o
# Download the RINEX 3.X format
if [ ! -f ${ObsPath}${RINEX3L} ]; then
wget -t 10 -T 120 -q ${URL_WHU}${RINEX3L} -P ${ObsPath}
fi
# Rename the 3.X observations
if [ -f ${ObsPath}${RINEX3L} ]; then
gzip -d ${ObsPath}${site}*${yyyy}${doy}*.gz
file=`ls ${ObsPath}${site}*${yyyy}${doy}*.crx`
mv ${file} ${ObsPath}${site0}${doy}0.${yy}d #将文件改名为.d
CRX2RNX -f ${ObsPath}${site0}${doy}0.${yy}d #利用crn2rnx将文件文件格式转化
rm ${ObsPath}${site0}${doy}0.${yy}d
fi
# If the 3.x file donoe exit, download the 2.x file
if [ -f ${ObsPath}${site0}${doy}0.${yy}o ] ; then
echo "Download completed: ${site0}${doy}0.${yy}o"
else
echo "***WARNING***:Download failed: ${site0}${doy}0.${yy}o"
fi
运行方式如下:
wgetobs 2021 001 ABPO /home/zh/gnss/
wgetobs为脚本名, 2021 为年份 ,001为年积日,ABPO为测站名,/home/zh/gnss/为所下载文件输出路径。
成功下载后会有如下提示:
Download completed: abpo0010.21o