-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetSomePOSSUMdata.py
More file actions
72 lines (55 loc) · 2.42 KB
/
getSomePOSSUMdata.py
File metadata and controls
72 lines (55 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
from astropy.io import ascii
from astroquery.utils.tap.core import Tap
from astroquery.casda import Casda
import numpy as np
import sys
import os
import getpass
import argparse
import re
def download(url_list, sb):
for url in url_list:
if url.find("checksum") != -1:
continue
print("Processing %s" %(url))
#print("wget --content-disposition \"%s\"" %(url))
os.system("wget -P "+sb+" --content-disposition \"%s\"" %(url))
#os.system("wget --content-disposition \"%s\" -O CMPL.tar" %(url))
#os.system("tar -xvf CMPL.tar")
def getResultsForFilenamePart(results, fileNamePart):
regex = re.compile(fileNamePart)
files = results['filename'].tolist()
match = [string for string in files if re.match(regex, string)]
i=files.index(match[0])
return results[i]
def getImageURLs(casda_tap, sb):
images = casda_tap.launch_job_async("SELECT * FROM ivoa.obscore WHERE obs_id='ASKAP-%s'" %(sb))
r_images = images.get_results()
results = []
results.append(getResultsForFilenamePart(r_images, 'image.restored.i.*.contcube.conv.fits'))
results.append(getResultsForFilenamePart(r_images, 'image.restored.v.*.contcube.conv.fits'))
image_urls = casda.stage_data(results, verbose=True)
return image_urls
def getEvalURLs(casda_tap, sb):
evalfiles = casda_tap.launch_job_async("SELECT * FROM casda.observation_evaluation_file oef inner join casda.observation o on oef.observation_id = o.id where o.sbid = '%s'" %(sb))
r_eval = evalfiles.get_results()
evals = []
evals.append(getResultsForFilenamePart(r_eval, 'BeamwiseSourcefinding'))
evals.append(getResultsForFilenamePart(r_eval, 'calibration-metadata-processing'))
tar_urls = casda.stage_data(evals, verbose=True)
return tar_urls
if __name__ == '__main__':
username="jennifer.west@dunlap.utoronto.ca"
casda_tap = Tap("https://casda.csiro.au/casda_vo_tools/tap")
passw = getpass.getpass(str("Enter password for user "+username+": "))
casda = Casda(user=username, password=passw)
sbids = ["60585"]
for sb in sbids:
os.system("mkdir "+sb)
imageURLs = getImageURLs(casda_tap, sb)
evalURLs = getEvalURLs(casda_tap, sb)
print(f'Downloading image files for SBID = {sb}')
download(imageURLs, sb)
print(f'Downloading evaluationa files for SBID = {sb}')
download(evalURLs, sb)