-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixwcs_api_C5_M67.py
59 lines (48 loc) · 1.68 KB
/
fixwcs_api_C5_M67.py
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
import os
import myclient
import time
files = open('filenames_M67.txt', 'r')
for line in files:
line = line.strip()
end = line.find('.fits')
start = line.find('M67_')
print line
cli = myclient.MyClient()
### Put your API key below in places of xxxxxxx
cli.login('xxxxxxxxxxxxxx')
#Set some solving options
opts=dict()
opts['allow_commercial_use'] = 'n'
opts['allow_modifications'] = 'n'
opts['publicly_visible'] = 'n'
opts['scale_units'] = "arcsecperpix"
opts['scale_lower'] = 3.9
opts['scale_upper'] = 4.1
opts['tweak_order'] = 1
#Upload an image
cli.upload(line, **opts)
#Save state in case of problems. This uses python shelves underneath
#so it's not portable between machines. To restore a client in
#a new session, use cli.load()
cli.save('cli.sav')
data = cli.getFilenames()
job = data[0][0]
# See if job is done; if not, sleep a bit:
status = cli.check_status_single_job(job)
check = (status['processing_finished'] != 'None') and ('success' in (status['jobStatus']).values())
failed = ('failure' in (status['jobStatus']).values())
while (check == False and failed == False):
time.sleep(5)
print 'Not done yet'
try:
status = cli.check_status_single_job(job)
check = (status['processing_finished'] != 'None') and ('success' in (status['jobStatus']).values())
failed = ('failure' in (status['jobStatus']).values())
print check
except:
print 'Error- trying again'
if (failed != True):
newfile = line[start:end]+'_wcs.fits'
print newfile
cli.getNewImage(job,newfile)
files.close()