Skip to content

Commit 42d5be4

Browse files
committed
update download_all_MFS
1 parent c17cad1 commit 42d5be4

1 file changed

Lines changed: 31 additions & 6 deletions

File tree

cirada_software/download_all_MFS_images.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
"""
2+
Handy file to pre-download all available MFS images from CASDA to CANFAR.
3+
4+
Meant to be run manually in a CANFAR notebook sessions, since CASDA will prompt for your password.
5+
"""
6+
7+
18
#!/usr/bin/env python
29
import numpy as np
310
from astroquery.utils.tap.core import Tap
411
from astroquery.casda import Casda
512
import argparse
613
import os
7-
import getpass # noqa: F401
14+
from pathlib import Path
815
import re
916
import gspread
1017
import astropy.table as at
@@ -108,10 +115,28 @@ def getEvalURLs(casda_tap, sb):
108115
return tar_urls
109116

110117

118+
def get_casda_username_password(path: str =None) -> tuple[str,str]:
119+
"""
120+
Docstring for get_casda_username_password
121+
122+
:param path: Path to file that stores CASDA username as password
123+
124+
first line is assumed to be username
125+
second line is assumed to be password
126+
127+
returns: username, password
128+
"""
129+
130+
path = path or os.path.expanduser("~/.ssh/casdapass")
131+
with open(path, 'r') as f:
132+
username, passw = f.read().strip().splitlines()
133+
134+
return username, passw
135+
111136
if __name__ == "__main__":
112-
# POSSUM Status Monitor
113-
# on CANFAR
114-
Google_API_token = "/arc/home/ErikOsinga/.ssh/psm_gspread_token.json"
137+
# default location for PSM token on CANFAR
138+
homedir = Path.home()
139+
Google_API_token = homedir / ".ssh/psm_gspread_token.json"
115140

116141
parser = argparse.ArgumentParser(description="Download all EMU MFS images")
117142
parser.add_argument(
@@ -126,10 +151,10 @@ def getEvalURLs(casda_tap, sb):
126151

127152
band = "943MHz" # hardcode for now
128153

129-
username = "erik.osinga@utoronto.ca"
154+
username, _ = get_casda_username_password()
130155

156+
# Meant to be run in notebook, where user will be prompted for their password
131157
casda_tap = Tap(url="https://casda.csiro.au/casda_vo_tools/tap")
132-
# passw = getpass.getpass(str("Enter password for user "+username+": "))
133158
casda = Casda()
134159
casda.login(username=username)
135160

0 commit comments

Comments
 (0)