NOAA-Buoy / orig_downloads /download_data.sh
lukawskikacper's picture
First version of the dataset
8be024f
raw
history blame contribute delete
No virus
950 Bytes
#!/bin/bash
buoy_number="42002"
curl_command="https://www.ndbc.noaa.gov/view_text_file.php?filename=42002hXXXX.txt.gz&dir=data/historical/stdmet/"
output_file="42002_XXXX.txt"
# get historical data
#for value in {1983..2022}
#do
#echo "${url//XXXX/"$value"}"
# curl ${curl_command//XXXX/"$value"} > ${output_file/XXXX/$value}
#done
#now get 2023 data
months=("junk" "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep")
month_curl="https://www.ndbc.noaa.gov/view_text_file.php?filename=42002X2023.txt.gz&dir=data/stdmet/YYY/"
month_output_file="42002_YYY.txt"
for i in {1..8}
do
temo_month_curl=${month_curl/X/"$i"}
#echo $temo_month_curl
temo_month_curl=${temo_month_curl/YYY/"${months[i]}"}
curl ${temo_month_curl} > ${month_output_file/YYY/"${months[i]}"}
done
# For some reason Sept URL is a totally different format
curl "https://www.ndbc.noaa.gov/data/stdmet/Sep/42002.txt" > "42002_Sep.txt"
echo "done"