Skip to content

Commit

Permalink
Updated downloader script to check for already-existing files
Browse files Browse the repository at this point in the history
  • Loading branch information
nichollsh committed Jul 19, 2024
1 parent 1479cad commit 81d0863
Showing 1 changed file with 67 additions and 51 deletions.
118 changes: 67 additions & 51 deletions get_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Download and unpack required and/or optional data
# All files can be found on OSF at https://osf.io/8dumn/

# Exit script if any of the commands fail
set -e

# Check that curl is installed
if ! [ -x "$(command -v curl)" ]; then
echo 'ERROR: curl is not installed.' >&2
Expand Down Expand Up @@ -47,64 +50,77 @@ function osf {

# target file path
tgt="$2/$3"
rm -f $tgt
echo " $1 > $tgt"

# exists?
if [[ -f "$tgt" ]]; then
echo " $1 > file already exists"
return 0
fi

# get data
echo " $1 > $tgt"
mkdir -p $2
curl -LsS "https://osf.io/download/$1/" > $tgt
}

# Handle user input
case $1 in
"basic")
echo $help_basic

osf qmp4e $res/spectral_files/Oak/318/ Oak.sf
osf 5fxr7 $res/spectral_files/Oak/318/ Oak.sf_k

osf heuza $res/spectral_files/Dayspring/48/ Dayspring.sf
osf c5jv3 $res/spectral_files/Dayspring/48/ Dayspring.sf_k

osf b5gsh $res/spectral_files/Dayspring/256/ Dayspring.sf
osf dn6wh $res/spectral_files/Dayspring/256/ Dayspring.sf_k

osf 2qdu8 $res/stellar_spectra sun.txt
;;

"highres")
echo $help_highres

osf p672d $res/spectral_files/Honeyside/4096/ Honeyside.sf
osf ujb4z $res/spectral_files/Honeyside/4096/ Honeyside.sf_k
;;

"steam")
echo $help_steam

osf 6rvfe $res/spectral_files/Frostflow/16/ Frostflow.sf
osf kxve8 $res/spectral_files/Frostflow/16/ Frostflow.sf_k

osf 9n6mw $res/spectral_files/Frostflow/48/ Frostflow.sf
osf xfap8 $res/spectral_files/Frostflow/48/ Frostflow.sf_k

osf mnvyq $res/spectral_files/Frostflow/256/ Frostflow.sf
osf tzsgc $res/spectral_files/Frostflow/256/ Frostflow.sf_k
;;
return 0
}

"stellar")
echo $help_stellar
osf mabp2 $res/stellar_spectra trappist-1.txt
osf rk7mj $res/stellar_spectra eps-eri.txt
osf agsrq $res/stellar_spectra hd97658.txt
osf ehfsy $res/stellar_spectra gj1214.txt
;;
# Handle request for downloading a group of data
function handle_request {
case $1 in
"basic")
echo $help_basic

osf qmp4e $res/spectral_files/Oak/318/ Oak.sf
osf 5fxr7 $res/spectral_files/Oak/318/ Oak.sf_k

osf heuza $res/spectral_files/Dayspring/48/ Dayspring.sf
osf c5jv3 $res/spectral_files/Dayspring/48/ Dayspring.sf_k

osf b5gsh $res/spectral_files/Dayspring/256/ Dayspring.sf
osf dn6wh $res/spectral_files/Dayspring/256/ Dayspring.sf_k

osf 2qdu8 $res/stellar_spectra sun.txt
;;

"highres")
echo $help_highres

osf p672d $res/spectral_files/Honeyside/4096/ Honeyside.sf
osf ujb4z $res/spectral_files/Honeyside/4096/ Honeyside.sf_k
;;

"steam")
echo $help_steam

osf 6rvfe $res/spectral_files/Frostflow/16/ Frostflow.sf
osf kxve8 $res/spectral_files/Frostflow/16/ Frostflow.sf_k

osf 9n6mw $res/spectral_files/Frostflow/48/ Frostflow.sf
osf xfap8 $res/spectral_files/Frostflow/48/ Frostflow.sf_k

osf mnvyq $res/spectral_files/Frostflow/256/ Frostflow.sf
osf tzsgc $res/spectral_files/Frostflow/256/ Frostflow.sf_k
;;

"stellar")
echo $help_stellar
osf mabp2 $res/stellar_spectra trappist-1.txt
osf rk7mj $res/stellar_spectra eps-eri.txt
osf agsrq $res/stellar_spectra hd97658.txt
osf ehfsy $res/stellar_spectra gj1214.txt
osf 2qdu8 $res/stellar_spectra sun.txt
;;

*)
echo "$help"
return 0
;;
esac
return 0
}

*)
echo "$help"
exit 1
;;
esac
handle_request $1

echo "Done!"

Expand Down

0 comments on commit 81d0863

Please sign in to comment.