To download data from inside the SAAO network, follow these steps:
Perform your search on SAAO Data Search.
Once you have located the data you want to download, repeat the search and select "FileName" under "Format Output" and redo the search.
Copy and paste the list of filenames into a file on your local machine. Name it filelist.txt
.
On your local machine, create a directory into which you want to download your data. Place both filelist.txt
and download_files.py
in this directory.
Run the download script with the following command:
python download_files.py <your_username>
Replace <your_username>
with your SAAO username. Enter your password when prompted, and the download will begin.
import os
import sys
def main(username):
# Read filenames from filelist.txt
with open('filelist.txt', 'r') as file:
filenames = file.read().splitlines()
# Create the scp command string
scp_command = f"scp -OT {username}@astro2015.cape.saao.ac.za:'{' '.join(filenames)}' ."
# Execute the command on the command line
os.system(scp_command)
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python download_files.py ")
sys.exit(1)
username = sys.argv[1]
main(username)