diff --git a/CODE/shells/gnss/README.md b/CODE/shells/gnss/README.md new file mode 100644 index 00000000..ae66e90a --- /dev/null +++ b/CODE/shells/gnss/README.md @@ -0,0 +1,2 @@ +The frontend shell programs _gnss_run_gipsyx_ to run GNSS processing with GipsyX have been moved to a stand-alone Github repository called ___gnssposflow___, available here: +[https://github.com/IPGP/gnssposflow/](https://github.com/IPGP/gnssposflow/) diff --git a/CODE/shells/gnss/download_orbit b/CODE/shells/gnss/download_orbit deleted file mode 100755 index 44114d90..00000000 --- a/CODE/shells/gnss/download_orbit +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/bash -# Script: download_orbit -# -# -# Authors: Edgar Lenhof, François Beauducel -# Created: 2019-07-31 at OVPF, La Réunion Island -# Updated: 2023-08-24 -# -# **** Updates -# ** 2023-08-24 Pierre Sakic -# - Download Rapid_GE orbits -# ** 2025-03-20 PS -# - Hotfix to solve JPL's sideshow -# certificate issue with wget - -if [ $# -lt 2 ]; then - echo " Syntax: download_orbit DAYS DEST [options]" - echo "Description: downloads best available orbit for chosen dates from the" - echo " JPL secured web server (see " - echo " https://sideshow.jpl.nasa.gov/pub/JPL_GNSS_Products)" - echo " Arguments:" - echo " DAYS = number of days to process (from start day)" - echo " DEST = root directory where orbits shall be saved" - echo " Options:" - echo " -o ORBIT = type of orbit (Ultra, Rapid, Final, or Rapid_GE)" - echo " -d STARTDAY = days to start retrieving (YYYY/mm/dd)" - echo " -r DAYS = remove orbit files older than DAYS days" - echo " -v = verbose mode" - echo "" - echo "Needs the companion file download_orbit.rc" - exit 0; -fi - -PROGDIR=$( cd "$( dirname "$0" )" && pwd ) - -DAYS=$1 -DEST=$2 -DAYLIST=$(for d in $(seq $DAYS -1 0);do date -d "$d day ago" +%Y/%m/%d;done) -ORBIT=("Final" "Rapid" "Ultra" "Rapid_GE") -delete="FALSE" -verbose="FALSE" -quiet="-q" -xtra_opts="--no-check-certificate" - -# Optionnal parameters -for (( i=1; i<=$#; i++)); do - - case ${!i} in - - -d) - k=$((i+1)) - IFS=',' read -ra arrayDay <<< "${!k}" - STARTDAYS=${arrayDay[@]} - DAYLIST= $() - for start in $STARTDAYS;do - L=$(for d in $(seq $DAYS -1 0);do date -d "$d day ago $start" +%Y/%m/%d;done) - DAYLIST=("${DAYLIST[@]}" "${L[@]}") - done - DAYLIST=($(printf "%s\n" "${DAYLIST[@]}" | sort -u | tr '\n' ' ')) - DAYLIST=${DAYLIST[@]} #converting to proper format - ;; - - -o) - k=$((i+1)) - ORBIT=( "${!k}" ) - # Check correct orbit input - if [[ "$ORBIT" != "Ultra" && "$ORBIT" != "Rapid" && "$ORBIT" != "Final" && "$ORBIT" != "Rapid_GE" ]]; then - echo "Error: Please enter orbit as Ultra, Rapid, Final, or Rapid_GE" - exit 1 - fi - ;; - - -r) - k=$((i+1)) - delete="TRUE" - nb_delete=( "${!k}" ) - ;; - - -v) - verbose="TRUE" - quiet="" - - esac -done - - -# deleting too ancient orbits -if [ $delete == "TRUE" ]; then - files=$(find $DEST -type f -mtime +$nb_delete) - for f in $files; do - rm $f - if [ $verbose == "TRUE" ]; then - echo "removed $f" - fi - done -fi - -for day in $DAYLIST; do - - year=${day:0:4} - month=${day:5:2} - day=${day:8:2} - - for orbit in "${ORBIT[@]}"; do - LOCAL="$DEST/$orbit/$year/$year-$month-$day.eo.gz" - - if [[ ! -e $LOCAL || "$orbit" == "Ultra" ]]; then - - echo -n " Downloading orbit $orbit for $year-$month-$day..." - URL="https://sideshow.jpl.nasa.gov/pub/JPL_GNSS_Products/$orbit/$year/" - - if [ -e "$0.rc" ]; then - for f in $(cat "$0.rc"); do - wget $xtra_opts $quiet -N -P $DEST/$orbit/$year -r -l1 -nd "$URL/$year-$month-$day$f" - if [ $? -ne 0 ]; then - break - fi - done - else - wget $xtra_opts $quiet -N -P $DEST/$orbit/$year -r -l1 -nd $URL -A "$year-$month-$day*" - fi - - if [ -e $LOCAL ]; then # if download succeed - echo " OK." - break - else - echo " not yet available!" - fi - - else - echo " Orbit $orbit for $day-$month-$year is locally available." - fi - - done - -done diff --git a/CODE/shells/gnss/download_orbit.rc b/CODE/shells/gnss/download_orbit.rc deleted file mode 100644 index 38d121f8..00000000 --- a/CODE/shells/gnss/download_orbit.rc +++ /dev/null @@ -1,23 +0,0 @@ -.eo.gz -.meta.gz -.pcm.gz -.pos.gz -.shadhist.gz -.tdp.gz -.wlpb.gz -.quat.gz -.x.gz -_hr.tdp.gz -_nf.eo.gz -_nf.pos.gz -_nf.quat.gz -_nf.tdp.gz -_nf.wlpb.gz -_nf_hr.tdp.gz -_nnr.eo.gz -_nnr.pos.gz -_nnr.quat.gz -_nnr.tdp.gz -_nnr.wlpb.gz -_nnr.x.gz -_nnr_hr.tdp.gz diff --git a/CODE/shells/gnss/gnss_make_rinex b/CODE/shells/gnss/gnss_make_rinex deleted file mode 100755 index dea16be0..00000000 --- a/CODE/shells/gnss/gnss_make_rinex +++ /dev/null @@ -1,221 +0,0 @@ -#!/bin/bash -# Script: gnss_make_rinex -# -# Dependencies: -# - teqc (3rd party binary www.unavco.org, must be in $PATH) -# - raw2rinex (WebObs script located in the same directory) -# - the list of stations to process is default set in the .rc using NODES -# variable, or, using a local WebObs proc for node's list with FID -# parameter as station/marker code name for each node. -# - a directory of sitelogs can be added to overwrite Rinex headers with -# receiver/antenna/approx. position metadata (set SITELOG variable in -# .rc); needs sitelog2json (WebObs script) and jq (JSON processor). -# - a station.info Gamit file can be added to overwrite Rinex headers -# with receiver/antenna codes (set STATION_INFO variable in .rc); -# needs stationinfo2json (WebObs script) and jq (JSON processor). -# -# For all other parameters see the gnss_make_rinex.rc template. -# -# Authors: Baptiste Camus -# -# Created: 2022-03-20 at IRD,ISTERRE Chambéry (France) -# inspired by gnss_run_gipsyx by François BEAUDUCEL, Edgar LENHOF, Patrice BOISSIER (IPGP) -# Domerapi/WebObs Project, 2014. -# Updated: - -# Helper -if [ $# -lt 2 ]; then - echo " Syntax: gnss_make_rinex CONF DAYS [options]" - echo " Description: genrate gnss rinex file from rawdata and some site information if needed" - echo " Arguments:" - echo " CONF = configuration filename, e.g., /etc/webobs.d/gnss_make_rinex.rc" - echo " DAYS = number of days to process (from today)" - echo " Options:" - echo " -s \"STA1 STA2...\"" - echo " station code or station list with double quotes" - echo " default is a list of nodes $NODES defined in .rc" - echo " and it can be also all nodes associated with local WebObs $GRID proc name defined in .rc to" - echo " -d \"yyyy/mm/dd,yyyy/mm/dd\"" - echo " choose days to start process; the DAYS argument can still be used to" - echo " process previous days from the selected ones, for instance:" - echo " gnss_make_rinex CONF 1 -d 2017/03/17,2018/08/05" - echo " will compute 2017/03/17, 2017/03/16, 2018/08/05 and 2018/08/04" - echo " -i GRID/SITELOG/STATION_INFO" - echo " choose the site information source to overwrite missing headers " - echo " data during the rinex creation" - echo " -debug" - echo " verbose mode" - echo "" - exit 0; -fi - -# reads parameters from bash configuration script -# variables that must be set: $GRID $FROM $DEST $TEQCOPTIONS -source "$1" || { - echo "cannot read configuration file $1. Abort". - exit 1 -} - -PWD=$(pwd) -PROGDIR=$( cd "$( dirname "$0" )" && pwd ) - - if [[ "$GRID" != "" && -z $NODES ]]; then - # PROC is local directory containing nodes .cnf - if [ -d "$NODEROOT" ]; then - PROC="$NODEROOT/" - else - PROC="/etc/webobs.d/GRIDS2NODES/$GRID." - fi - # node's list defined from the FID parameter in .cnf - NODES=$(grep -h "^$GRID\.FID|" $PROC*/*.cnf|sed -E "s/.*FID\|//") - NODESTABLE=$(grep -H "^$GRID\.FID|" $PROC*/*.cnf|sed -E "s/.*\///"|sed -E "s/\.cnf:.*FID\|/\ /") -fi - -if [ -z "$FMT" ]; then - FMT='$FROM/$FID/$yyyy/$mm/$dd' -fi - -TODAY=$(date -u +"%Y/%m/%d") -DAYS=$2 -DAYLIST=$(for d in $(seq $DAYS -1 0);do date -u -d "$d day ago" +"%Y/%m/%d";done) - -echo "*** Rinex maker / WebObs $GRID GNSS File Processing ***" - -# Optional parameters -for (( i=1; i<=$#; i++)); do - case ${!i} in - -debug) - VERBOSE=1 - echo "Debug mode : processing with verbose log" - ;; - -d) - k=$((i+1)) - IFS=',' read -ra arrayDay <<< "${!k}" - STARTDAYS=${arrayDay[@]} - DAYLIST= $() - for start in $STARTDAYS;do - L=$(for d in $(seq $DAYS -1 0);do date -d "$d day ago $start" +%Y/%m/%d;done) - DAYLIST=("${DAYLIST[@]}" "${L[@]}") - done - DAYLIST=($(printf "%s\n" "${DAYLIST[@]}" | sort -u | tr '\n' ' ')) - DAYLIST=${DAYLIST[@]} #converting to proper format - ;; - -i) - l=$((i+1)) - INFOSRC=${!l} - echo " Generating rinex with headers informations based on "$INFOSRC" files" - ;; - -s) - j=$((i+1)) - IFS=' ' read -ra arrayStation <<< "${!j}" - NODES=${arrayStation[@]} - esac -done - -for station in $NODES; do - # cleans the string ! - FID=${station//[$'\t\r\n ']} - echo "" - echo "*** Processing files from station $FID for the last $DAYS days" - - - for ymd in $DAYLIST; do - - doy=$(date -d "$ymd" +"%j") - sta=$(echo $FID | tr '[:upper:]' '[:lower:]') - yyyy=${ymd:0:4} - year=$yyyy - mm=${ymd:5:2} - dd=${ymd:8:2} - - DAYLYMSG="$FID $ymd -" - - # setting results paths - RINEX="$DEST/GNSS/rinex/30s/$FID/$yyyy" - - # path of raw data: eval() will replace any variables in $FMT (from .rc) - RAW=$(eval "echo $FMT") - - if [[ ! -z "$(ls -Ad $RAW 2>/dev/null)" && ! -z "$(find $RAW -type f)" ]]; then - - if [ ! -z $INFOSRC ]; then - - case $INFOSRC in - WEBOBS) - # use node's parameters to overwrite rinex header - if [[ "$GRID" != "" && "$NODEROOT" != "" ]]; then - ID=$(echo "$NODESTABLE" | awk "/$FID/ {print \$1}") - receiver=$(grep -h "^$GRID\.FID_RECEIVER|" $PROC$ID/$ID.cnf|sed -E "s/.*FID_RECEIVER\|//"|tr -d '\r') - anttype=$(grep -h "^$GRID\.FID_ANTENNA|" $PROC$ID/$ID.cnf|sed -E "s/.*FID_ANTENNA\|//"|tr -d '\r') - alertheader=" $DAYLYMSG WO ID = $ID - receiver = '$receiver' - antenna = '$anttype' (will use rinex header if empty)" - else - echo " $DAYLYMSG - Warning - Webobs site information : GRID or NODEROOT is empty in .rc file." - fi - ;; - STATION_INFO) - # uses station.info to overwrite rinex header - if [[ "$STATION_INFO" != "" && -s "$STATION_INFO" ]]; then - receiver=$($PROGDIR/stationinfo2json "$STATION_INFO" $FID $yyyy-$doy|jq '.rt' | tr -d '"') - anttype=$($PROGDIR/stationinfo2json "$STATION_INFO" $FID $yyyy-$doy|jq '.at' | tr -d '"') - alertheader=" $DAYLYMSG station.info: $doy - receiver = '$receiver' - antenna = '$anttype' (will use rinex header if empty)" - else - echo " $DAYLYMSG - Warning - station.info : STATION_INFO is empty in .rc file. " - fi - ;; - SITELOG) - # uses sitelogs to overwrite rinex header - if [[ "$SITELOG" != "" ]]; then - receiver=$($PROGDIR/sitelog2json "$SITELOG" $FID $ymd|jq '.rt' | tr -d '"') - anttype=$($PROGDIR/sitelog2json "$SITELOG" $FID $ymd|jq '.at' | tr -d '"') - antnum=$($PROGDIR/sitelog2json "$SITELOG" $FID $ymd|jq '.an' | tr -d '"') - posxyz=$($PROGDIR/sitelog2json "$SITELOG" $FID $ymd|jq '.px' | tr -d '"') - observer=$($PROGDIR/sitelog2json "$SITELOG" $FID $ymd|jq '.op' | tr -d '"') - agency=$($PROGDIR/sitelog2json "$SITELOG" $FID $ymd|jq '.ag' | tr -d '"') - alertheader=" $DAYLYMSG sitelog: receiver='$receiver' - antenna type='$anttype' - antenna s/n='$antnum' - observer='$observer' - agency='$agency' (will use rinex header if empty)" - else - echo " $DAYLYMSG - Warning - sitelog : SITELOG is empty in .rc file !!!" - fi - ;; - *) - echo " $DAYLYMSG - Warning - bad site information source " - esac - fi - if [[ ! -z "$receiver$anttype$antnum$posxyz$observer$agency" ]]; then - echo "$alertheader" - # transform site imformation in teqc option - if [ ! -z "$receiver" ]; then - receiver=" -O.rt \"$receiver\"" - fi - if [ ! -z "$anttype" ]; then - anttype=" -O.at \"$anttype\"" - fi - if [ ! -z "$antnum" ]; then - antnum=" -O.an \"$antnum\"" - fi - if [ ! -z "$posxyz" ]; then - posxyz=" -O.px $posxyz" - fi - if [ ! -z "$observer" ]; then - observer=" -O.op $observer" - fi - if [ ! -z "$agency" ]; then - agency=" -O.ag $agency" - fi - else - echo " $DAYLYMSG - Warning - No site information fond in $INFOSRC, Rinex will be generated whithout overwriting headers if empty" - fi - - - # makes Rinex daily file from raw data (see raw2rinex script) - mkdir -p $RINEX - $PROGDIR/raw2rinex "$RAW" $RINEX $TEQCOPTIONS -O.mn \"$FID\" -O.mo \"$FID\" $receiver $anttype $antnum $posxyz $observer $agency - if [[ ! -z $VERBOSE || $? != 0 ]]; then - echo " $PROGDIR/raw2rinex \"$RAW\" $RINEX $TEQCOPTIONS -O.mn \"$FID\" -O.mo \"$FID\" $receiver $anttype $antnum $posxyz $observer $agency" - fi - else - echo " $DAYLYMSG no data to process in $RAW." - fi - done -done - -echo "*************************************" diff --git a/CODE/shells/gnss/gnss_make_rinex.rc b/CODE/shells/gnss/gnss_make_rinex.rc deleted file mode 100644 index 77fef5f8..00000000 --- a/CODE/shells/gnss/gnss_make_rinex.rc +++ /dev/null @@ -1,41 +0,0 @@ -############################################################################### -# Template configuration file for script gnss_make_rinex (must be in the same -# directory). Please copy, rename and edit it for each "network". -# -# Created: 2022-03-25 -# Updated: - -# default list of station codes (space separated) -NODES= -# ... or empty $NODES and grid of a local WebObs that contains the station list (nodes). -GRID=PROC.GIPSYX -NODEROOT=/etc/webobs.d/GRID2NODES/$GRID. - -# site information source used to overwrite rinex headers if empty (antenna type, receiver codes, etc. ) -# it can be a site_log file, a station.info file (Gamit), or the webobs node informations -# this option can be also pass in parameters with "-i" -# valid variables are : SITELOG (recommended) / WEBOBS / STATION_INFO -INFOSRC=SITELOG - -# site information source parameters : -# - sitelog directory, must be filled to use SITELOG as INFOSRC -SITELOG=/opt/webobs/rawdata/GNSS/site_log -# - station.info file (Gamit), must be filled to use STATION_INFO as INFOSRC -STATION_INFO= -# - webobs node informations, GRID and NODEROOT must be filled to use WEBOBS as INFOSRC -# on another hand FID_ANTENNA and FID_RECEIVER have to be completed in the node configuration page - -# base directory that contains the raw data -FROM=/opt/webobs/rawdata/GNSS/rawdata - -# directory structure of the raw data (will be evaluated using eval...) -# valid variables are: $FID, $sta (lowercase FID), $yyyy, $yy, $mm, $dd, $doy -FMT='$FROM/$FID/$yyyy/$mm/$dd' - -# base directory for output results -# output path format will be $DEST/GNSS/rinex/30s/$FID/$yyyy -DEST=/opt/webobs/rawdata - -# teqc options: Please take a deep look at www.unavco.org TEQC tutorial! -TEQCOPTIONS='+quiet -O.pe 0 0 0 -C2 -O.-obs C2 -O.-obs C5 -O.dec 30s -max_rx_SVs 50 -n_GLONASS 27' - diff --git a/CODE/shells/gnss/gnss_run_gipsyx b/CODE/shells/gnss/gnss_run_gipsyx deleted file mode 100755 index be9fcaac..00000000 --- a/CODE/shells/gnss/gnss_run_gipsyx +++ /dev/null @@ -1,516 +0,0 @@ -#!/bin/bash -# Script: gnss_run_gipsyx -# -# Dependencies: -# - teqc (3rd party binary www.unavco.org, must be in $PATH) -# - raw2rinex (WebObs script located in the same directory) -# - download_orbit (WebObs script located in the same directory) -# - the list of stations to process can be set in the .rc using NODES -# variable, or, using a local WebObs proc for node's list with FID -# parameter as station/marker code name for each node. Optionally, -# each node might contain the parameters (will overwrite Rinex header): -# FID_RECEIVER: receiver code name -# FID_ANTENNA: antenna code name -# - a station.info Gamit file can be added to overwrite Rinex headers -# with receiver/antenna codes (set STATION_INFO variable in .rc); -# needs stationinfo2json (WebObs script) and jq (JSON processor). -# - a directory of sitelogs can be added to overwrite Rinex headers with -# receiver/antenna/approx. position metadata (set SITELOG variable in -# .rc); needs sitelog2json (WebObs script) and jq (JSON processor). -# -# For all other parameters see the gnss_run_gipsyx.rc template. -# -# Authors: François BEAUDUCEL, Edgar LENHOF, Patrice BOISSIER, Pierre SAKIC -# -# Created: 2019-02-11 at PVMBG, Bandung (Indonesia) -# Based on Gipsy-Oasis version by Francois BEAUDUCEL (IPGP) and Ahmad Ali FAHMI (IRD), -# Domerapi/WebObs Project, 2014. -# Updated: 2024-07-22 -# -# **** Updates -# ** 2023-06-xx Pierre Sakic -# - Handles Non Fiducial Orbits + associated Helmert transfo. with NFORB=1 -# -# ** 2023-08-07 Pierre Sakic -# - Handles RINEX3 -# - custom temp. directory possible with $TMPDIRMAIN -# - Trivia note: flinn stands for -# Fiducial Laboratories for an International Natural sciences Network (FLINN) -# JPL's GPS analysis was initially its contribution to the FLINN -# (Zumberge et al. 1994, https://hdl.handle.net/hdl:2014/32449) -# -# ** 2024-09-12 Pierre Sakic -# - implement full logs -# -# ** 2025-03-10 Pierre Sakic -# - store full log in 7zip (easier to extract stuffs from it) -# - add CM2CF option - - -#Check lock file -LOCKFILE=/tmp/gnss_run_gipsyx.txt -if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then - echo "already running" - exit -fi - -# Helper -if [ $# -lt 2 ]; then - echo " Syntax: gnss_run_gipsyx CONF DAYS [options]" - echo " Description: runs the automatic GNSS process from raw files to position solution" - echo " Arguments:" - echo " CONF = configuration filename, e.g., /etc/webobs.d/gnss_run_gipsyx.rc" - echo " DAYS = number of days to process (from today)" - echo " Options:" - echo " -s \"STA1 STA2...\"" - echo " station code or station list with double quotes" - echo " default is all nodes associated with local WebObs $GRID proc name" - echo " or a list of nodes $NODES defined in .rc" - echo " -d \"yyyy/mm/dd,yyyy/mm/dd\"" - echo " choose days to start process; the DAYS argument can still be used to" - echo " process previous days from the selected ones, for instance:" - echo " gnss_run_gipsyx CONF 1 -d 2017/03/17,2018/08/05" - echo " will compute 2017/03/17, 2017/03/16, 2018/08/05 and 2018/08/04" - echo " -final, -rapid, -ultra" - echo " use only final, rapid or ultra orbit" - echo " -force" - echo " forces the process despite existence of final results" - echo " -lock" - echo " creates a lock file to prevent multiple process of gnss_run_gipsyx" - echo " -debug" - echo " verbose mode & temporary folders will not be deleted" - echo " -fullog" - echo " Full log record. Temporary folders are stored in a .fullog.7z file (7-zip needed)" - echo "" - exit 0; -fi - -# reads parameters from bash configuration script -# variables that must be set: $GRID $FROM $DEST $GIPSYOPTIONS $TEQCOPTIONS -source "$1" || { - echo "cannot read configuration file $1. Abort". - exit 1 -} - -### ------- temporary directory -# the main tmp dir can be customized, -# working in the default /tmp can be tricky especially for big repro -if [ -z $TMPDIRMAIN ] || [ ! -d $TMPDIRMAIN ]; then - if [ ! -d $TMPDIRMAIN ]; then - echo "WARN: given main temp dir $TMPDIRMAIN does not exists, defaut /tmp will be used" - fi - TMPDIRMAIN="/tmp/" -fi - -# TMPDIRMAIN must be an environnement var because raw2rinex needs it too -export TMPDIRMAIN=$TMPDIRMAIN - -tmpdir=$(mktemp -d $TMPDIRMAIN/gipsyx.XXXXXXXXXX) -rinex="$tmpdir/rinex" - -PWD=$(pwd) -PROGDIR=$( cd "$( dirname "$0" )" && pwd ) - -ORBITS=( "flinn" "ql" "ultra" ) - -# gets the nodes list from WebObs (will erase $NODES) -if [ "$GRID" != "" ]; then - # PROC is local directory containing nodes .cnf - if [ -d "$NODEROOT" ]; then - PROC="$NODEROOT/" - else - PROC="/etc/webobs.d/GRIDS2NODES/$GRID." - fi - # node's list defined from the FID parameter in .cnf - NODES=$(grep -h "^$GRID\.FID|" $PROC*/*.cnf|sed -E "s/.*FID\|//") - NODESTABLE=$(grep -H "^$GRID\.FID|" $PROC*/*.cnf|sed -E "s/.*\///"|sed -E "s/\.cnf:.*FID\|/\ /") -fi - -if [ -z "$FMT" ]; then - FMT='$FROM/$FID/$yyyy/$mm/$dd' -fi - -TODAY=$(date -u +"%Y/%m/%d") -DAYS=$2 -DAYLIST=$(for d in $(seq $DAYS -1 0);do date -u -d "$d day ago" +"%Y/%m/%d";done) - -LOG=gd2e.log - - - -if [ -z "$ERROR_REGEX_RINEX" ]; then - ERROR_REGEX_RINEX="REC #|ANT #|# / TYPES OF OBSERV|MARKER NAME" -fi - -# boolean for forcing process (default value doesn't force) -if [ -z "$FORCE" ]; then - FORCE=0 -fi -# boolean for enabling debug mode (default value doesn't) -if [ -z "$DEBUG" ]; then - DEBUG=0 - -fi -# boolean for enabling full log mode (default value doesn't) -if [ -z "$FULLOG" ]; then - FULLOG=0 -fi - -# do not use non fiducial (NF) orbits per default -# -# NFORB is the "frontend" boolean set by the user -# NFORBLOOP is modified for each day/site loop step -# because non fiducial is only possible for Final -if [ -z "$NFORB" ]; then - NFORB=0 -fi - -# boolean for enabling Center-of-Mass > Center-of-Figure -# transformation (default value doesn't) -if [ -z "$CM2CF" ]; then - echo "WARN: CM2CF option is not set, but Center-of-Mass > Center-of-Figure" - echo " transformation is recommended since IGS20 switch (2024-08)" - CM2CF=0 -fi - -echo "*** GipsyX / WebObs $GRID GNSS File Processing ***" - -# Optional parameters -for (( i=1; i<=$#; i++)); do - case ${!i} in - -final) - ORBITS=( "flinn" ) - echo "Will use only final orbit" - ;; - -rapid) - ORBITS=( "ql" ) - echo "Will use only rapid orbit" - ;; - -ultra) - ORBITS=( "ultra" ) - echo "Will use only ultra orbit" - ;; - -force) - FORCE=1 - echo "Force computation despites final orbits already exist" - ;; - -debug) - DEBUG=1 - export VERBOSE=1 ## make raw2rinex VERBOSE - echo "Debug mode: temporary folders will NOT be deleted!" - ;; - -fullog) - FULLOG=1 - echo "Full log record: temporary folders will be stored in zip files" - ;; - -s) - j=$((i+1)) - IFS=' ' read -ra arrayStation <<< "${!j}" - NODES=${arrayStation[@]} - ;; - -d) - k=$((i+1)) - IFS=',' read -ra arrayDay <<< "${!k}" - STARTDAYS=${arrayDay[@]} - DAYLIST= $() - for start in $STARTDAYS;do - L=$(for d in $(seq $DAYS -1 0);do date -d "$d day ago $start" +%Y/%m/%d;done) - DAYLIST=("${DAYLIST[@]}" "${L[@]}") - done - DAYLIST=($(printf "%s\n" "${DAYLIST[@]}" | sort -u | tr '\n' ' ')) - DAYLIST=${DAYLIST[@]} #converting to proper format - ;; - -lock) - # make sure the lockfile is removed when we exit and then claim it - trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT - echo $$ > ${LOCKFILE} - esac -done - - -for station in $NODES; do - # cleans the string ! - FID=${station//[$'\t\r\n ']} - echo "" - echo "*** Processing files from station $FID for the last $DAYS days" - - # looks in node's parameters for possible antenna and receiver (will overwrite rinex header) - if [ "$GRID" != "" ]; then - ID=$(echo "$NODESTABLE" | awk "/$FID/ {print \$1}") - receiver=$(grep -h "^$GRID\.FID_RECEIVER|" $PROC$ID/$ID.cnf|sed -E "s/.*FID_RECEIVER\|//"|tr -d '\r') - antenna=$(grep -h "^$GRID\.FID_ANTENNA|" $PROC$ID/$ID.cnf|sed -E "s/.*FID_ANTENNA\|//"|tr -d '\r') - echo " WO ID = $ID - receiver = '$receiver' - antenna = '$antenna' (will use rinex header if empty)" - if [ ! -z "$receiver" ]; then - receiver=" -O.rt \"$receiver\"" - fi - if [ ! -z "$antenna" ]; then - antenna=" -O.at \"$antenna\"" - fi - fi - - for ymd in $DAYLIST; do - - doy=$(date -d "$ymd" +"%j") - sta=$(echo $FID | tr '[:upper:]' '[:lower:]') - yyyy=${ymd:0:4} - year=$yyyy - yy=${ymd:2:2} - mm=${ymd:5:2} - dd=${ymd:8:2} - bb=$(date -d "$ymd" +"%b") - #rinex="$tmpdir/${sta}${doy}0.${yy}o" - rinex="$tmpdir/${sta}${yyyy}${doy}.rnx" # non-conventionnal RNX name, can be 2 or 3 without confusion... - label="" # used in the tdp file to custom the parameter labels - - # uses station.info to overwrite rinex header - if [[ "$STATION_INFO" != "" && -s "$STATION_INFO" ]]; then - receiver=$($PROGDIR/stationinfo2json "$STATION_INFO" $FID $yyyy-$doy|jq '.rt' | tr -d '"') - antenna=$($PROGDIR/stationinfo2json "$STATION_INFO" $FID $yyyy-$doy|jq '.at' | tr -d '"') - alertheader=" station.info: $FID @ $yyyy-$doy - receiver = '$receiver' - antenna = '$antenna' (will use rinex header if empty)" - if [ ! -z "$receiver" ]; then - receiver=" -O.rt \"$receiver\"" - fi - if [ ! -z "$antenna" ]; then - antenna=" -O.at \"$antenna\"" - fi - else - alertheader='' - fi - - # uses sitelogs to overwrite rinex header - if [[ "$SITELOG" != "" ]]; then - receiver=$($PROGDIR/sitelog2json "$SITELOG" $FID $ymd|jq '.rt' | tr -d '"') - antenna=$($PROGDIR/sitelog2json "$SITELOG" $FID $ymd|jq '.at' | tr -d '"') - posxyz=$($PROGDIR/sitelog2json "$SITELOG" $FID $ymd|jq '.px' | tr -d '"') - alertheader=" sitelog: $FID @ $ymd - receiver = '$receiver' - antenna = '$antenna' (will use rinex header if empty)" - if [ ! -z "$receiver" ]; then - receiver=" -O.rt \"$receiver\"" - fi - if [ ! -z "$antenna" ]; then - antenna=" -O.at \"$antenna\"" - fi - if [ ! -z "$posxyz" ]; then - posxyz=" -O.px $posxyz" - fi - else - alertheader='' - fi - - # setting paths - res="$DEST/$FID/$yyyy/$yyyy-$mm-$dd.$FID" - gipsyres="$res.tdp" - gipsycov="$res.gdcov" - gipsylog="$res.log" - gipsyfullog_targz="$res.fullog.7z" # will be used only if $FULLOG is activated - - if [[ $FORCE == 0 && -s "$gipsyres" ]]; then - echo " file $gipsyres [flinn] already exists..." - else - # path of raw data: eval() will replace any variables in $FMT (from .rc) - RAW=$(eval "echo $FMT") - if [ ! -z "$(ls -Ad $RAW 2>/dev/null)" ]; then - echo "$alertheader" - rm -rf $tmpdir/* - # makes Rinex daily file from raw data (see raw2rinex script) - $PROGDIR/raw2rinex "$RAW" $rinex $TEQCOPTIONS -O.mn \"$FID\" -O.mo \"$FID\" $receiver $antenna $posxyz - if [[ ! -z $VERBOSE || $? != 0 ]]; then - echo " $PROGDIR/raw2rinex \"$RAW\" $rinex $TEQCOPTIONS -O.mn \"$FID\" -O.mo \"$FID\" $receiver $antenna $posxyz" - fi - - # real-time case: makes a 24h window from yesterday+today data - if [[ "$REALTIME" == "Y" && "$ymd" == "$TODAY" ]]; then - - rinex1=$tmpdir/rinex1 # 2 days ago - rinex2=$tmpdir/rinex2 # yesterday - rinex3=$tmpdir/rinex3 # today - - ORBITS=( "ultra" ) #reaffect orbit value because only ultra can be used for realtime - - yesterday=$(date -u -d "1 day ago" +"%Y/%m/%d") - two_days_ago=$(date -u -d "2 day ago" +"%Y/%m/%d") - echo " Real-time case: Appending $two_days_ago, $yesterday and $TODAY to process 30h of data." - - # converting yesterday rinex - doy=$(date -d "$yesterday" +"%j") - yyyy=${yesterday:0:4} - mm=${yesterday:5:2} - dd=${yesterday:8:2} - RAW2=$(eval "echo $FMT") - echo "$RAW2" - $PROGDIR/raw2rinex "$RAW2" $rinex2 $TEQCOPTIONS -O.mn \"$FID\" -O.mo \"$FID\" $receiver $antenna $posxyz - if [[ ! -z $VERBOSE || $? != 0 ]]; then - echo "$PROGDIR/raw2rinex \"$RAW2\" $rinex2 $TEQCOPTIONS -O.mn \"$FID\" -O.mo \"$FID\" $receiver $antenna $posxyz" - fi - - #converting 2 days ago rinex - doy=$(date -d "$two_days_ago" +"%j") - yyyy=${two_days_ago:0:4} - mm=${two_days_ago:5:2} - dd=${two_days_ago:8:2} - RAW1=$(eval "echo $FMT") - echo "$RAW1" - $PROGDIR/raw2rinex "$RAW1" $rinex1 $TEQCOPTIONS -O.mn \"$FID\" -O.mo \"$FID\" $receiver $antenna $posxyz - if [[ ! -z $VERBOSE || $? != 0 ]]; then - echo "$PROGDIR/raw2rinex \"$RAW1\" $TEQCOPTIONS -O.mn \"$FID\" -O.mo \"$FID\" $receiver $antenna $posxyz" - fi - - mv $rinex $rinex3 #already converted rinex for today - if [[ ! -z $VERBOSE || $? != 0 ]]; then - echo " mv $rinex $rinex2" - fi - - endwindow=$(date -u -d "$DATA_DELAY ago" +"%Y%m%d%H%M%S") - teqc -phc +quiet -e $endwindow -dh 30 $rinex1 $rinex2 $rinex3 > $rinex - if [[ ! -z $VERBOSE || $? != 0 ]]; then - echo " teqc -phc +quiet -e $endwindow -dh 30 $rinex1 $rinex2 $rinex3 > $rinex" - fi - fi - - # makes GipsyX processing - tdp="$tmpdir/smoothFinal.tdp" - cov="$tmpdir/smoothFinal.gdcov" - cd $tmpdir - - # makes a loop for different orbits precision: from Final to Ultra - for orbit in "${ORBITS[@]}" ; do - if [[ $orbit == "ql" && -s $gipsyres.$orbit && $FORCE == 0 ]]; then - echo " file $gipsyres [$orbit] already exists..." - break - else - NFORBLOOP=0 ### we force the standard case here (fiducial orbits) - if [ "$ORBITSDIR" != "" ]; then #running Gipsy from local orbit - case $orbit in - flinn) - product="Final" - NFORBLOOP=$NFORB - ;; - ql) - product="Rapid";; - #product="Rapid_GE";; - ultra) - product="Ultra";; - esac - - # calling download_orbit - $PROGDIR/download_orbit 0 $ORBITSDIR -o $product -d $ymd $DOWNLOAD_OPTIONS - - if [ -e "$ORBITSDIR/$product/$yyyy/$yyyy-$mm-$dd.eo.gz" ]; then - ORBITOK=1 - else - ORBITOK="" - continue # if download not successfull go to next orbit - fi - ORBITOPT="$ORBITSDIR/$product" - - else #running Gipsy from direct download - ORBITOPT=$orbit - fi - - # if we use NF orbits, add the necessary options -prodTypeGNSS nf -gdCov - [ $NFORBLOOP -eq 1 ] && NFORBOPTS="-prodTypeGNSS nf -gdCov" || NFORBOPTS="" - - # if we use CM2CF transformation, add the necessary option -gdCov - [[ $CM2CF -eq 1 && $NFORBLOOP -eq 0 ]] && CM2CFOPTS="-gdCov" || CM2CFOPTS="" - - # vvvvvvvvvv RUN GIPSYX HERE vvvvvvvvvv - cmd="gd2e.py -rnxFile $rinex -GNSSproducts $ORBITOPT $GIPSYOPTIONS $NFORBOPTS $CM2CFOPTS" - echo " $cmd" - [ $DEBUG -eq 0 ] && eval "$cmd > $LOG 2>&1" || eval "$cmd" - # ^^^^^^^^^^ RUN GIPSYX HERE ^^^^^^^^^^ - rc=$? - if [[ $rc == 0 && -s $tdp ]]; then - mkdir -p "$DEST/$FID/$year" - rm -f $gipsyres.* - ### Apply Center-of-Mass > Center-of-Figure transformation - if [ $CM2CF -eq 1 ]; then - echo " Apply Center-of-Mass > Center-of-Figure transformation" - cp ${cov} ${cov}_cm - cmdcm2cf="netApplyNonLinear.py ${cov} -cmFile $GOA_VAR/sta_info/IGS20.cm -reverse" - [ $DEBUG -eq 0 ] && eval "$cmdcm2cf >> $LOG 2>&1" || eval "$cmdcm2cf" - cp ${cov} ${cov}_cf - label="${label}.CF" - fi - - ### handle non-fiducial orbits: a further transformation has to be applied - if [ $NFORBLOOP -eq 1 ]; then - echo " Apply Non-Fiducial > Fiducial Helmert transformation" - #cp -v $cov $gipsycov #### copy the gdcov from temp > final dir, for debug only - trsprm="$ORBITSDIR/$product/$yyyy/$yyyy-$mm-$dd.x.gz" - cmdtrans="netApply.py -t -r -s -i $cov -o ${cov}_trs -x $trsprm" - echo " $cmdtrans" - [ $DEBUG -eq 0 ] && eval "$cmdtrans >> $LOG 2>&1" || eval "$cmdtrans" - # save nf anf transformed versions, but regular cov is now the transformed - mv ${cov} ${cov}_nf - cp ${cov}_trs ${cov} - label="${label}.NFtrs" - fi - - if [[ $NFORBLOOP -eq 0 && $CM2CF -eq 0 ]]; then - ### Simple case: No Fiducial orbit nor CM2CF - grep "\.State\.Pos\.[XYZ]" $tdp | tail -n3 > $gipsyres - else - ### Non Fiducial orbit, a conversion gdcov > tdp must be done - # this one-liner - # 1) get the coordinates - # 2) 1st awk to reorder the fields - # 3) 2nd awk to format the fields (issue when trying to merge both awk) - # 4) Substitute the label field - # 5) Customize it with WebObs internal custom code - # NFtrs => Non Fiducial transformed - # CF => Center-of-Figure - grep ".STA.[XYZ]" ${cov} | awk '{print $3,0,$4,$5,".Station."$2}' | awk '{printf "%9d %+22.15e %+22.15e %+22.15e %s\n",$1,$2,$3,$4,$5}' | sed "s/.STA./.State.Pos./g" | sed "s/$/${label}/" > $gipsyres - fi - - if [ ! -z $TROP_TDP ]; then - grep "\.Trop\." $tdp >> $gipsyres - fi - echo "==> $gipsyres [$orbit] written." - if [[ "$orbit" != "flinn" ]]; then - mv $gipsyres $gipsyres.$orbit - fi - break - else - echo " $cmd" - if [[ -z $ORBITOK && "$orbit" != "ultra" ]]; then - echo " ** WARNING: Problem to process gd2e... May be orbit $orbit not yet available?" - else - echo " ** ERROR: Problem to process gd2e... Please check logs." - grep -E "$ERROR_REGEX_RINEX" $rinex - ERROR=1 - break - fi - fi - fi - done - if [[ -z $ERROR && -e $LOG ]]; then - mv -f $LOG $gipsylog - gzip -f $gipsylog - fi - - if [[ $FULLOG -eq 1 ]]; then - ntmpfil=`ls $tmpdir | wc -l` - if [[ $ntmpfil -le 1 ]]; then - echo " full log not saved (tmp folder contains only the input RINEX)" - else - curdir=`pwd` - cd $tmpdir - #tar -zcf $gipsyfullog_targz * - 7za a $gipsyfullog_targz * > /dev/null 2>&1 - cd $curdir - echo " full log saved in $gipsyfullog_targz" - fi - fi - else - echo " no data to process in $RAW." - fi - fi - done -done - -echo "*************************************" - -if [ $DEBUG -eq 0 ]; then - rm -rf $tmpdir -fi - -rm -f ${LOCKFILE} diff --git a/CODE/shells/gnss/gnss_run_gipsyx_template.rc b/CODE/shells/gnss/gnss_run_gipsyx_template.rc deleted file mode 100644 index 62a0262d..00000000 --- a/CODE/shells/gnss/gnss_run_gipsyx_template.rc +++ /dev/null @@ -1,110 +0,0 @@ -############################################################################### -# Template configuration file for script gnss_run_gipsyx (must be in the same -# directory). Please copy, rename and edit it for each "network". -# -# Created: 2019-02-25 -# Updated: 2025-01-17 - -# main temporary directory (/tmp per default, change is recommended) -TMPDIRMAIN=/tmp - -# prepares GIPSYX processing (this is GipsyX's rc file, in the GipsyX folder) -source /home/wo/GipsyX-1.2/rc_GipsyX.sh - -# grid of a local WebObs that contains the station list (nodes) -#GRID=PROC.GIPSYX -#NODEROOT=/opt/webobs.d/GRID2NODES/$GRID. -# ... or empty $GRID and default list of station codes (space separated) -NODES= - -# optional site logs to overwrite rinex headers (antenna and receiver codes) -# - option 1: station.info file (Gamit) -STATION_INFO= -# - option 2: site log directory (recommended) -SITELOG= - -# base directory that contains the raw data -FROM=/home/wo/rawdata/GNSS - -# directory structure of the raw data (will be evaluated using eval...) -# valid variables are: $FID, $sta (lowercase FID), $yyyy, $yy, $mm, $dd, $doy, -# $bb. Example for station BABA on September 07, 2022: -# $FID: BABA -# $sta: baba -# $yyyy: 2022 -# $yy: 22 -# $mm: 09 -# $dd: 07 -# $doy: 250 -# $bb: Sep -FMT='$FROM/$FID/$yyyy/$mm/$dd' - -# base directory for output results -DEST=/home/wo/GNSS/gipsyx - -# base directory to store local orbits (optional) -ORBITSDIR=/home/wo/GNSS/JPL_Local_Orbits - -# download_orbit options (see download_orbit) -DOWNLOAD_OPTIONS="-r 30" -# "-r 30": orbits older than 30 day are removed - -# gd2e.py options -GIPSYOPTIONS="-runType PPP" - -# teqc options: Please take a deep look at www.unavco.org TEQC tutorial! -TEQCOPTIONS="+quiet -O.pe 0 0 0 -C2 -O.-obs C2 -O.-obs C5 -O.dec 30s -max_rx_SVs 50 -n_GLONASS 27" - -# not empty value will add troposphere results in .tdp files (.Trop.*) -TROP_TDP= - -# display some rinex header in case of error -ERROR_REGEX_RINEX="REC #|ANT #|# / TYPES OF OBSERV|MARKER NAME|APPROX POSITION XYZ" - -# realtime processing (put "Y" if wanted) -REALTIME="" - -# data delay for realtime processing -DATA_DELAY="5 min" - -###### Processing details management -### activate debug mode -# verbose mode & temporary folders will not be deleted -DEBUG=0 - -### Full log record -# Temporary folders are stored in a -# .fullog.7z file (7zip needed) -FULLOG=0 - -###### Advanced geodetic modes - -### use fiducial (regular) or non-fiducial (NF) orbits. -# NFORB option will add '-prodTypeGNSS nf -gdCov' in the GIPSYOPTIONS -# and will perform the post-processing re-alignement -# leave NFORB=0 if you are not sure of what you are doing -NFORB=0 -# *** Detailed Note: -# JPL's Fiducial orbits are directly aligned to ITRF. -# But the usage of Non-fiducial orbits are recommended by -# the JPL and the geodetic community -# Coordinates computed with non Fiducial orbits requiries -# a re-alignement to the ITRF with external Helmert parameters - -### Apply Center-of-Mass > Center-of-Figure transformation -# CM2CF option will add '-gdCov' in the GIPSYOPTIONS -# and will perform a post-processing CM > CF transformation -# Activate CM2CF is recommended, but stays OFF per default -CM2CF=0 -# *** Detailled Note: -# Since August 2024, JPL provides its orbits in -# IGS20 (~ITRF2020) w.r.t. Earth's Center of Mass (CM) -# For volcanological studies, Earth's Center of Figure (CF) -# is a better origin point (no seasonal signal visible) -# Thus, a CM > CF transformation is needed - - - - - - diff --git a/CODE/shells/gnss/raw2rinex b/CODE/shells/gnss/raw2rinex deleted file mode 100755 index d32e48a5..00000000 --- a/CODE/shells/gnss/raw2rinex +++ /dev/null @@ -1,243 +0,0 @@ -#!/bin/bash -# Syntax: raw2rinex input output [teqcoptions] -# Description: GNSS raw data files convertion to daily RINEX 2.11 -# Arguments: -# input Directory or filename of raw data (Leica, Trimble, Rinex) -# compressed of not -# output Either output directory to write rinex (must exist), or any -# output rinex filename -# teqcoptions Any options to add to teqc (example: -O.dec 30 -O.rt "receiver" -# -O.at "antenna") -# -# Dependencies: -# teqc for all data preprocessing, binary available at unavco -# https://www.unavco.org/software/data-processing/teqc/teqc.html -# gunzip with .gz files -# unzip with .zip files -# CRX2RNX with Hatanaka files -# runpkr00 with some Trimble .T02 files (MUST be version ≥ 6.03) -# cnvrnx3-rnx2-v3 with Rinex v.3 files, source available at -# http://acc.igs.org/misc/cnvrnx3-rnx2-v3.f -# -# -# Author: F. Beauducel / DOMERAPI -# Created: 2014-01-12 -# Updated: 2023-08-21 -# -# **** Updates -# ** 2023-08-07 Pierre Sakic -# - Handle the RINEX3 as it is -# (no downgrade to RNX2, but no modification of the header either) -# ** 2024-05-05 Pierre Sakic -# - Handle gzip compression for RINEX2 -# (NB: RINEX3 are always gzipped by design) -# - -### comment the variable to disable the verbose mode -#VERBOSE=1 - -if [ $# -lt 2 ]; then - echo "raw2rinex input output [teqc options]" - exit 0; -fi - -### ------- temporary directory -# the main tmp dir can be customized, -# working in the default /tmp can be tricky especially for big repro -if [ -z $TMPDIRMAIN ] || [ ! -d $TMPDIRMAIN ]; then - if [ ! -d $TMPDIRMAIN ]; then - echo "WARN: given main temp dir $TMPDIRMAIN does not exists, defaut /tmp will be used" - fi - TMPDIRMAIN="/tmp/" -fi - -tmpdir=$(mktemp -d $TMPDIRMAIN/raw2rinex.XXXXXXXXXX) -cd $tmpdir - -rawdir=$1 -if [ -d "$rawdir" ]; then - files=$(find $rawdir -type f) -else - files=$(ls $rawdir 2>/dev/null) -fi - -#echo "** files = $files" - -outdir=$2 - -if [ "$#" -ge 3 ] -then - shift - shift - teqcopt=$@ -fi - -# --- copy and uncompress files in a temporary directory -for f in $files -do - # unzip (-o option is mandatory to avoid prompting in some circumstances !) - if [[ $f == *".zip" ]]; then - unzip -oq $f -d $tmpdir - else - cp -L $f $tmpdir/ - fi - - # gunzip (must copy first before unzip) - if [[ $f == *".gz" ]]; then - gunzip -f $tmpdir/*.gz - fi -done - -# ------ RINEX2 -------------------------------------------------------- -# --- try RINEX2 uncompressed files -rf=$(find $tmpdir -iname "*.??o" | sort ) -if [ ! -z "$rf" ]; then - echo " Found some RINEX2 files in $rawdir: proceeding..." - # must convert Rinex 3 files - for f in $rf; do - if [[ $(head -n1 $f | awk '{print $1}') == '3.01' ]]; then - cnvrnx3-rnx2-v3 $f +0 g - if [ -s $f.gps.rnx2 ]; then - # must remove these specific header lines for teqc... - grep -v "PHASE SHIFTS" $f.gps.rnx2 > $f - fi - fi - done - rawfiles=$rf - obsfiles=$(find $tmpdir -iname "*.??o" | sort ) - navfiles=$(find $tmpdir -iname "*.??n" | sort ) - teqcfmt="" - skipteqc=0 -fi - -# --- try RINEX2 Hatanaka files -rf=$(find $tmpdir -name "*.??d.Z" -o -name "*.??d.gz" -o -name "*.??d" | sort ) -if [ ! -z "$rf" ]; then - echo " Found some RINEX2 Hatanaka files in $rawdir: proceeding..." - # must convert ??d to ??o - for f in $rf; do - if [[ $f == *".Z" ]] || [[ $f == *".gz" ]]; then - gunzip -f $f - f=${f%.*} - fi - CRX2RNX $f -f - done - rawfiles=$(find $tmpdir -iname "*.??o" | sort ) - obsfiles=$rawfiles - navfiles="" - teqcfmt="" - skipteqc=0 -fi - -# ------ RINEX3 -------------------------------------------------------- -# --- try RINEX3 uncompressed files -rf=$(find $tmpdir -iname "*.rnx" | sort ) -if [ ! -z "$rf" ]; then - echo " Found some RINEX3 files in $rawdir: proceeding..." - rawfiles=$rf - obsfiles=$rf - #navfiles=$(find $tmpdir -iname "*.??n" | sort ) - teqcfmt="" - skipteqc=1 -fi - -# --- try RINEX3 Hatanaka files -rf=$(find $tmpdir -name "*.crx.gz" -o -name "*.crx" | sort ) -if [ ! -z "$rf" ]; then - echo " Found some RINEX3 Hatanaka files in $rawdir: proceeding..." - # must convert ??d to ??o - for f in $rf; do - if [[ $f == *".gz" ]]; then - gunzip -f $f - f=${f%.*} - fi - f2=${f%.*}'.rnx' - cat $f | CRX2RNX > $f2 - done - rawfiles=$(find $tmpdir -iname "*.crx" | sort ) - obsfiles=$(find $tmpdir -iname "*.rnx" | sort ) - navfiles="" - teqcfmt="" - skipteqc=1 -fi - -# try Leica mdb... -rf=$(find $tmpdir -name "*.m??" | sort ) -if [ ! -z "$rf" ]; then - echo " Found some Leica files in $rawdir: proceeding..." - rawfiles=$rf - obsfiles=$(find $tmpdir -iname "*.m??" | sort ) - navfiles=$rawfiles - teqcfmt="-lei mdb" - skipteqc=0 -fi - -# try Trimble T02... -rf=$(find $tmpdir -name "*.T02" | sort ) -if [ ! -z "$rf" ]; then - echo " Found some Trimble files in $rawdir: proceeding..." - # must convert T02 to tgd (dat without -g option) - for f in $rf; do - runpkr00 -g -d $f - done - rawfiles=$(find $tmpdir -iname "*.tgd" | sort ) - obsfiles=$rawfiles - navfiles=$rawfiles - teqcfmt="-tr d" - skipteqc=0 -fi - -if [ -z "$rawfiles" ]; then - echo "No valid GNSS file found in $rawdir... abort." - exit -fi - -tmprnx=$tmpdir/rinex -tmpnav=$tmpdir/nav - -# --- converts rawfiles to single daily Rinex -if [ $skipteqc -eq 0 ]; then - if [ ! -z $VERBOSE ]; then - echo "teqc $teqcfmt $teqcopt $obsfiles > $tmprnx" - fi - teqc $teqcfmt $teqcopt $obsfiles > $tmprnx -else - if [ ! -z $VERBOSE ]; then - echo " teqc concatenation/modding skipped (RNX3). Header's ant/rec assumed correct!" - fi - obsfiles_1st=`echo $obsfiles | head -1` - cp $obsfiles_1st $tmprnx #### XXXXX Unicity problem -fi - -# case A: output **directory** specified => archiving rinex with proper names (obs and nav) -if [ -d $outdir ]; then - # gets the station code from the filename - for f in $rawfiles; do - #echo $f - mdbfile=$(basename $f) - code=${mdbfile:0:4} - rinex=$outdir/${mdbfile:0:8} - done - code=$(echo $code | tr '[:lower:]' '[:upper:]') - starttime=$(teqc +meta $tmprnx | grep "start date" | sed -e 's/.*: //' | sed -e 's/[ \t]*//') - yy=${starttime:2:2} - echo " cp -f $tmprnx ${rinex}.${yy}o" - cp -f $tmprnx ${rinex}.${yy}o - if [ ! -z "$navfiles" ]; then - teqc ${teqcfmt}n $teqcopt $navfiles > $tmpnav - if [ ! -z $VERBOSE ]; then - echo " cp -f $tmpnav ${rinex}.${yy}n" - fi - cp -f $tmpnav ${rinex}.${yy}n - fi -# case B: output **file** specified => write the rinex using given filename -else - if [ ! -z $VERBOSE ]; then - echo " cp -f $tmprnx $outdir" - fi - cp -f $tmprnx $outdir -fi - -if [ -z $VERBOSE ]; then - rm -rf $tmpdir -fi diff --git a/CODE/shells/gnss/sitelog2json b/CODE/shells/gnss/sitelog2json deleted file mode 100755 index 5109a0e6..00000000 --- a/CODE/shells/gnss/sitelog2json +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# sitelog2json -# -# Author: F. Beauducel -# Created: 2021-03-15 in Yogyakarta -# Updated: 2021-03-17 - -# Helper -if [ $# -lt 2 ]; then - echo " Syntax: sitelog2json FILE SITE [DATE]" - echo " Description: reads sitelog file(s) and returns data as JSON" - echo " Arguments: FILE = path or filename(s) of sitelog(s)" - echo " SITE = site code (4 characters)" - echo " DATE = date as YYYY-MM-DD[Thh:mm] (default is current time)" - echo " Outputs: JSON string with following fields:" - echo " mo = monument site code (4 characters)" - echo " sn = site name" - echo " px = approximate position (WGS84xyz,m)" - echo " rt = receiver type" - echo " rv = receiver version" - echo " rn = receiver S/N" - echo " at = antenna type" - echo " an = antenna S/N" - echo " pe = antenna Marker->ARP (hEN,m)" - echo " op = operator" - echo " ag = agency" - echo "" - exit 0; -fi - -if [ -z "$3" ]; then - DATE=$(date -u +"%Y-%m-%d %H:%M") # current date and time, UT -else - DATE="$3" -fi - -# upper and lower case site code -site=$(echo $2 | tr '[:upper:]' '[:lower:]') -SITE=$(echo $2 | tr '[:lower:]' '[:upper:]') - -# selects the last sitelog file for the site -if [ -d "$1" ]; then - FILE=$(ls $1/${site}*_????????.log 2>/dev/null | sort -t '_' -k 2 | tail -n1) -else - FILE=$(ls $1 | sort -t '_' -k 2 | tail -n1) -fi -if [[ -z "${FILE}" || -z "$(grep "Four Character ID.*: ${SITE}" ${FILE})" ]]; then - exit -fi - -# makes the JSON string -if [ ! -z "$FILE" ]; then - #******************* site ******************* - JSON={\"mo\":\"${SITE}\" - #******************* Serial number ******************* - JSON=$JSON,\"sn\":\"$(sed -n "/^1\. /,/Site Name/p" ${FILE} | tail -n1 | sed -e 's/^.*: //g')\" - #******************* Approximative position ******************* - JSON=$JSON,\"px\":\"$(sed -n "/^2\. /,/Z coordinate/p" ${FILE} | tail -n3 | sed -e 's/^.*: //g')\" - #******************* receiver ******************* - JSON=$JSON$(sed -n "/^3\.[1-9]. /,/Date Removed/p" ${FILE} |\ - sed -e 's/^.*: //g' | paste -d '\t' - - - - - - - |\ - awk -F '\t' -v date="${DATE}" '{ if (date >= $6 && date <= $7) \ - printf ",\"rt\":\"%s\",\"rv\":\"%s\",\"rn\":\"%s\"", $1, $2, $3 }' - ) - #******************* Antenna ******************* - JSON=$JSON$(sed -n "/^4\.[1-9]. /,/Date Removed/p" ${FILE} |\ - sed -e 's/^.*: //g' | sed -e 's/\s*NONE//g'| paste -d '\t' - - - - - - - - - - - - - |\ - awk -F '\t' -v date="${DATE}" '{ if (date >= $12 && date <= $13) \ - printf ",\"at\":\"%s\",\"an\":\"%s\",\"pe\":\"%1.4f %1.4f %1.4f\"", $1, $2, $4, $5, $6 }' - ) - #******************* Observer ******************* - JSON=$JSON,\"op\":\"$(sed -n "/^11\. /,/Abbreviation/p" ${FILE} | tail -n1 | sed -e 's/^.*: //g')\" - #******************* Agency ****************** - JSON=$JSON,\"ag\":\"$(sed -n "/^12\. /,/Abbreviation/p" ${FILE} | tail -n1 | sed -e 's/^.*: //g')\"} - echo $JSON -fi diff --git a/CODE/shells/gnss/stationinfo2json b/CODE/shells/gnss/stationinfo2json deleted file mode 100755 index a911e53e..00000000 --- a/CODE/shells/gnss/stationinfo2json +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# stationinfo2json -# uses gawk and date -# -# Author: F. Beauducel -# Created: 2021-03-08 in Yogyakarta -# Updated: 2021-03-16 - -# Helper -if [ $# -lt 2 ]; then - echo " Syntax: stationinfo2json FILE SITE [DATE]" - echo " Description: reads station.info file and returns data as JSON" - echo " Arguments: FILE = filename of station.info" - echo " SITE = site code" - echo " DATE = date as YYYY-DDD [HH:MM:SS] (default is current time)" - echo "" - exit 0; -fi - -if [ -z "$3" ]; then - DATE=$(date -u +"%Y-%j %H:%M:%S") # current date and time, UT -else - DATE="$3" -fi - -JSON=$(gawk -v site="$2" -v date="$DATE" ' - function trim(s) { gsub(/^[ ]+/, "", s); gsub(/[ ]+$/, "", s); return s } - BEGIN { FIELDWIDTHS = "6 18 5 4 3 3 4 5 4 3 3 4 9 7 9 9 21 22 7 22 24 21" } - { - start = sprintf("%4d-%03d %02d:%02d:%02d",$3, $4, $5, $6, $7); - stop = sprintf("%4d-%03d %02d:%02d:%02d",$8, $9, $10, $11, $12); - if (trim($1) == site && date >= start && date <= stop) - print "{\"mo\":\"" site \ - "\",\"sn\":\"" trim($2)\ - "\",\"tw\":\"" start,stop\ - "\",\"pe\":\"" trim($13),trim($15),trim($16)\ - "\",\"hc\":\"" trim($14)\ - "\",\"rt\":\"" trim($17)\ - "\",\"rs\":\"" trim($18)\ - "\",\"rv\":\"" trim($19)\ - "\",\"rn\":\"" trim($20)\ - "\",\"at\":\"" trim($21)\ - "\",\"an\":\"" trim($22) "\"}" - }' $1) - -echo $JSON