2020-01-03 15:23:12 -07:00
|
|
|
#!/bin/bash
|
|
|
|
# wut-dl-sort-tx
|
|
|
|
# transmitter_uuid
|
|
|
|
#
|
|
|
|
# Populates the data/ directory from the download/dir.
|
|
|
|
# Does it just for a specific transmitter UUID (e.g. a particular
|
|
|
|
# satellites' transmitter).
|
|
|
|
#
|
|
|
|
# XXX This script removes directories in data/ !!! XXX
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# wut-dl-sort-tx [Transmitter UUID] [Minimum Observation ID] [Maximum Observation ID]
|
|
|
|
# Example:
|
2020-01-03 18:13:37 -07:00
|
|
|
# wut-dl-sort-tx KgazZMKEa74VnquqXLwAvD 1467000 1470000
|
2020-01-03 15:23:12 -07:00
|
|
|
#
|
|
|
|
# * Takes the files in the download/ dir.
|
|
|
|
# * Looks at the JSON files to see if it is :good", "bad", or "failed".
|
|
|
|
# * Hard link it in the appropriate data/ directory.
|
|
|
|
# * File is randomly copied to either data/train or data/val directory.
|
|
|
|
#
|
|
|
|
# Possible vetted_status: bad, failed, good, null, unknown.
|
|
|
|
|
2020-01-26 17:27:12 -07:00
|
|
|
cd /srv/satnogs
|
|
|
|
|
2020-01-03 15:23:12 -07:00
|
|
|
OBSTX="$1"
|
|
|
|
OBSIDMIN="$2"
|
|
|
|
OBSIDMAX="$3"
|
|
|
|
OBSID=$OBSIDMIN
|
|
|
|
|
|
|
|
# Enable the following if you want to download waterfalls in this range:
|
|
|
|
#echo "Downloading Waterfalls"
|
|
|
|
#./wut-water-range $OBSIDMIN $OBSIDMAX
|
|
|
|
|
|
|
|
# XXX remove data/train and data/val directories XXX
|
|
|
|
echo "Removing data/ subdirectories"
|
|
|
|
rm -rf data/train data/val
|
|
|
|
# Create new empty dirs
|
|
|
|
mkdir -p data/train/good data/train/bad data/train/failed
|
|
|
|
mkdir -p data/val/good data/val/bad data/val/failed
|
|
|
|
|
|
|
|
# Then parse each file and link appropriately
|
|
|
|
echo "Parsing download/ directory for observation IDs $OBSIDMIN to $OBSIDMAX"
|
|
|
|
cd download/ || exit
|
|
|
|
|
|
|
|
while [ $OBSID -lt $OBSIDMAX ]
|
2020-01-03 18:13:37 -07:00
|
|
|
do cd $OBSID
|
2020-01-03 15:23:12 -07:00
|
|
|
VET=`cat $OBSID.json | jq --compact-output '.[0] | {vetted_status}' | cut -f 2 -d ":" | sed -e 's/}//g' -e 's/"//g'`
|
|
|
|
TX=`cat $OBSID.json | jq --compact-output '.[0] | {transmitter_uuid}' | cut -f 2 -d ":" | sed -e 's/}//g' -e 's/"//g'`
|
2020-01-21 16:06:47 -07:00
|
|
|
if [ "$OBSTX" = "$TX" ] ; then
|
2020-01-03 15:23:12 -07:00
|
|
|
RAND_DIR=`echo $((0 + RANDOM % 2))`
|
|
|
|
if [ $RAND_DIR = 1 ] ; then
|
|
|
|
CLASS_DIR="train"
|
|
|
|
else
|
|
|
|
CLASS_DIR="val"
|
|
|
|
fi
|
|
|
|
case "$VET" in
|
|
|
|
bad) ln waterfall_$OBSID_*.png ../../data/$CLASS_DIR/$VET/
|
|
|
|
;;
|
|
|
|
good) ln waterfall_$OBSID_*.png ../../data/$CLASS_DIR/$VET/
|
|
|
|
;;
|
|
|
|
failed) ln waterfall_$OBSID_*.png ../../data/$CLASS_DIR/$VET/
|
|
|
|
;;
|
|
|
|
null) echo "null, not copying"
|
|
|
|
;;
|
|
|
|
unknown) echo "unknown, not copying"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
let OBSID=$OBSID+1
|
|
|
|
cd ..
|
|
|
|
done
|