Skip to content

Instantly share code, notes, and snippets.

@christopherlovell
Created June 13, 2018 16:47
Show Gist options
  • Save christopherlovell/aa60ea6477594953892f28e51b56729f to your computer and use it in GitHub Desktop.
Save christopherlovell/aa60ea6477594953892f28e51b56729f to your computer and use it in GitHub Desktop.
Create list of URLs for wget from SDSS DR7 spec info
#!/bin/bash
# Clear output file
> out.csv
while read f; do
# read in line to array, comma delimited
arrIn=(${f//,/ })
printf -v plate "%04d" ${arrIn[0]}
printf -v mjd "%05d" ${arrIn[1]}
printf -v fiber "%03d" ${arrIn[2]}
# Example: http://das.sdss.org/raw/spectro/1d_26/0308/1d/spSpec-51662-0308-640.fit
out="http://das.sdss.org/raw/spectro/1d_26/$plate/1d/spSpec-"
out="$out$mjd-$plate-$fiber.fit"
echo $out >> out.csv
done < <(tail -n+2 result.csv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment