=Telescope(config='~/.config/telescope.ini') scope
util
Small utility functions for the
ouscope
library.
Telescope.get_object_obs
Telescope.get_object_obs (obj:str)
Find all jobs for a given object.
=scope.get_user_requests(sort='completion')
reqlst= [rq for rq in sorted(reqlst, key=lambda r: int(r['requesttime']), reverse=True)
complete if Telescope.REQUESTSTATUS_TEXTS[int(rq['status'])]=='Complete']
# Get all observations of VS
= 'BI Her'
VS = sorted(list(scope.get_object_obs(VS)))
jlist print(f'Completed observations of {VS}: {len(jlist)}')
for jid, rid in tqdm(jlist):
# print(f"R{rid}:J{jid}")
try :
= scope.get_obs(scope.get_job(jid), cube=True, verbose=False)
data if data :
= f'VS/{"_".join(VS.split())}'
fp =True)
os.makedirs(fp, exist_ok= f'{jid}'
fn try :
# print(os.path.abspath(data.name), f'{fp}/{fn}.fits')
f'{fp}/{fn}.fits')
os.symlink(os.path.abspath(data.name), except FileExistsError:
pass
# with open(f'/home/jochym/Astro/VS/{"_".join(VS.split())}/{jid}.fits', 'wb') as ff:
# ff.write(data.read())
else :
print(f'Download of J{jid} failed (no data)')
except TimeoutError:
print(f'Download of J{jid} failed (timeout)')
continue
Number of users requests: 1849
Completed: 1821
Completed observations of BI Her: 192
# get all completed jobs
for rq in (pbar := tqdm(complete[:25])):
= rq['objectname']
name = int(rq['id'])
rid
pbar.set_postfix_str(name)try:
= int(scope.get_request(rid)['jid'])
jid = scope.get_obs(scope.get_job(jid), cube=True, verbose=False)
data if data :
= f'VS/{"_".join(name.split())}'
fp =True)
os.makedirs(fp, exist_ok= f'{jid}'
fn try :
f'{fp}/{fn}.fits')
os.symlink(os.path.abspath(data.name), except FileExistsError:
pass
else :
print(f'Download of J{jid} failed')
except TimeoutError :
print(f'Download of J{jid} failed, timeout')
pass