Skip to content

Instantly share code, notes, and snippets.

@troyhill
Created December 20, 2018 14:22
Show Gist options
  • Save troyhill/df05cadae47b0953218f9dcb1a81786b to your computer and use it in GitHub Desktop.
Save troyhill/df05cadae47b0953218f9dcb1a81786b to your computer and use it in GitHub Desktop.
tests for Jed
###
discharge_section_join.sh L67_L30 > /home/thill/RDATA/dataForEver/data_L67_L30_flow.csv
###
#!/bin/bash
# Script pulls coordinates for all stations in DataForEver database
# Usage: ./bash/dataForEver_getCoords.sh
if [ $# -ne 1 ]; then
echo ""
echo "Usage: $0"
echo ""
exit 1
fi
outputDir=/home/thill/RDATA/dataForEver/WQdata/station_coordinates
stationList=$1
echo "select station, longitude, latitude from station \
where latitude is not NULL" \
| sql ' ' > $outputDir/coords.dat;
##################################################
#!/bin/bash
# Pull flow data from DataForEver Hydrology database and deposit in a specified folder
# Usage: ./bash/extractDataForEver_flow.sh ~/RDATA/dataForEver/WQdata/20180801 /home/thill/RDATA/dataForEver/station_lists/test.lst stage
# [script name] [directory for data] [station list] [parameter]
if [ $# -ne 3 ]; then
echo ""
echo "Usage: $0 target_directory target_stations parameter"
echo ""
exit 1
fi
param=${3:-flow}
# pull flow data
#hydro_data.sh np205 stage 2010-01-01 2018-04-20 real_time aggregate_statistic validation_level units_converted > data.dat
. set_project hydrology
while read station; do
echo "reading hydro data from $station"
echo "redirecting stdout to: ${station}_${param}.dat"
hydro_data.sh $station $param 1960-01-01 $(date +%Y-%m-%d) \
daily aggregate_statistic validation_level units_converted \
| gawk -F "|" '{printf"%s\t%s\t%s\t%s\n", $1, $2, $3, $4}' \
> $1/"$station"_"$param".dat;
done < $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment