=Telescope(config='~/.config/telescope.ini') scope
core
Telescope
class which provides state tracking and low level methods - forming a basic API layer. The higher level functions are implemented as separate functions construced with the Telescope class API.
Telescope
Telescope (user='', passwd='', config=None, cache='.cache/jobs')
Main telescope website API class.
Preliminary steps
All interactions with the telescope site must start with the creation of the session which is handled by the login
method. The credentials used for the connection are initialised in the Telescope
class constructor. The constructor calls login
method as well. After creation the class should be ready for use.
Good practice suggests that no credentials should ever be stored inside the code. Here we are using the config file stored in the user directory, outside of the code tree.
Calls to internal API of the telescope.org page
These are used internally and are not intended for general use. They may and will change when the telescope.org internal functioning change.
- User-API
- Request Manager
- Request Constructor
Telescope.get_user_requests
Get all user requests from folder (Inbox=1 by default), sorted by sort column (‘rid’ by default). Possible sort columns are: ‘rid’, ‘object’, ‘completion’ The data is returned as a list of dictionaries.
= scope.get_user_requests(sort='completion')
reqs print(f'User {scope.user} has {len(reqs)} requests. Recent few:')
for rq in reqs[:10]:
print(f'{rq["id"]}: {rq["objectname"]:15}'
f' ({Telescope.REQUESTSTATUS_TEXTS[int(rq["status"])]})')
User jochym has 1849 requests. Recent few:
767380: EQ Lyr (Complete)
767374: SS Cyg (Complete)
767376: V686 Cyg (Complete)
767375: IP Cyg (Complete)
767373: CH Cyg (Complete)
766438: DX Vul (Complete)
766436: CH Cyg (Complete)
766435: T CrB (Complete)
766437: SS Cyg (Complete)
766264: T CrB_M (Complete)
Telescope.get_jid_for_req
Telescope.get_jid_for_req (req=None)
*Find and output jobID for the request. If request is not yet done returns False.
Input
req : request dictionary or requestid
Output
JobID if the request is completed, otherwise False*
for rq in reqs[:10]:
= scope.get_jid_for_req(rq)
jid print(f'{rq["id"]}: {rq["objectname"]:15}'
f' ({Telescope.REQUESTSTATUS_TEXTS[int(rq["status"])]})'
f' jid: {jid if jid else ""}')
767380: EQ Lyr (Complete) jid: 419547
767374: SS Cyg (Complete) jid: 419541
767376: V686 Cyg (Complete) jid: 419543
767375: IP Cyg (Complete) jid: 419542
767373: CH Cyg (Complete) jid: 419540
766438: DX Vul (Complete) jid: 418739
766436: CH Cyg (Complete) jid: 418737
766435: T CrB (Complete) jid: 418736
766437: SS Cyg (Complete) jid: 418738
766264: T CrB_M (Complete) jid: 418581
Telescope.get_user_folders
Telescope.get_user_folders ()
Get all user folders. Returns list of dictionaries.
scope.get_user_folders()
[{'id': '1', 'creationtime': '0', 'name': 'Inbox', 'count': '1849'},
{'id': '2', 'creationtime': '0', 'name': 'Favourites', 'count': None},
{'id': '3', 'creationtime': '0', 'name': 'Archive', 'count': '447'},
{'id': '4', 'creationtime': '0', 'name': 'Trash', 'count': '63'},
{'id': '461',
'creationtime': '1407254495',
'name': 'Complete',
'count': '13'}]
Telescope.get_obs_list
Telescope.get_obs_list (t=None, dt=1, filtertype='', camera='', hour=16, minute=0, verb=False)
*Get the dt days of observations taken no later then time in t.
Input
t - end time in seconds from the epoch (as returned by time.time()) dt - number of days, default to 1 filtertype - filter by type of filter used camera - filter by the camera/telescope used
Output
Returns a list of JobIDs (int) for the observations.*
= 1
dt while True:
= scope.get_obs_list(dt=dt, verb=False)
jobs if jobs :
break
else :
+= 1
dt = scope.get_obs_list(dt=dt, verb=True)
jobs assert jobs
print(jobs[0], f'... ({len(jobs)-2} jobs) ...', jobs[-1])
Params:
Earliest completion time: 17/11/24 16:00:00
Latest completion time: 18/11/24 16:00:59
Job status values of:
  - Success
Sorted by Completion time in descending order
Private jobs excluded
1000 results per page
423342 ... (4 jobs) ... 423183
Telescope.get_job
Telescope.get_job (jid=None)
Get a job data for a given JID
= scope.get_job(jobs[-1])
obs for k, v in obs.items():
print(f'{k}: {v}')
jid: 423183
rid: R771716 R771970
type: MESSIER
oid: 109
exp: 120000 ms
filter: BVR
tele: Galaxy
completion: ['18', 'November', '2024', '05:41:09', 'UTC']
status: True
flatid: 31
= scope.get_job(369256)
obs for k, v in obs.items():
print(f'{k}: {v}')
= scope.__do_api_call("image-engine", "0-create-dlzip", {'jid': obs['jid'],})
rsp1 print(rsp1)
= scope.__do_api_call("image-engine", "0-is-job-ready", {'ieid':rsp1['data']['ieID'],})
rsp2 print(rsp2)
jid: 369256
rid: 706248
type: RADEC
oid: 00:42:58.58 +36:28:18.97
exp: 120000 ms
filter: BVR
tele: Galaxy
completion: ['22', 'December', '2020', '23:34:10', 'UTC']
status: True
flatid: 24
{'success': 1, 'status': 'OK_READY', 'data': {'ieID': '1783970', 'flatID': 0}}
{'success': 1, 'status': 'READY', 'data': {'flatID': '0', 'fitsbzsize': '8247874', 'fitssize': '0'}}
Telescope.get_request
Telescope.get_request (rid=None)
Get request data for a given RID
int(obs['rid']))
scope.get_request(= int(scope.get_request(int(rq['id']))['jid'])
last_complete print(f'Last complete jid: {last_complete}')
Last complete jid: 418581
Telescope.download_obs
Telescope.download_obs (obs=None, directory='.', cube=True, pbar=False, verbose=False)
Download the raw observation obs (obtained from get_job) into zip file named job_jid.zip located in the directory (current by default). Alternatively, when the cube=True the file will be a 3D fits file. The name of the file (without directory) is returned.
for cube in (True, False):
= scope.download_obs(scope.get_job(369256), directory='/tmp', cube=cube, pbar=True, verbose=True)
fn if fn is not None:
print(f'Removing downloaded file: {fn}')
'/tmp', fn))
os.unlink(os.path.join(else:
print('Download failed')
OK_WAIT
READY
Removing downloaded file: 369256.fits
OK_WAIT
PROCESSING
READY
Removing downloaded file: 369256.zip
Telescope.get_obs
Telescope.get_obs (obs=None, cube=True, recurse=True, pbar=False, verbose=False)
Get the raw observation obs (obtained from get_job) into zip file-like object. The function returns ZipFile structure of the downloaded data.
=True) scope.get_obs(obs, pbar
<_io.BufferedReader name='.cache/jobs/3/6/369256.fits'>
=False, verbose=True),
(scope.get_obs(scope.get_job(last_complete), cube=True, verbose=True),) scope.get_obs(scope.get_job(last_complete), cube
OK_WAIT
PROCESSING
PROCESSING
READY
OK_WAIT
READY
(<zipfile.ZipFile file=<_io.BufferedReader name='.cache/jobs/4/1/418581.zip'> mode='r'>,
<_io.BufferedReader name='.cache/jobs/4/1/418581.fits'>)
Telescope.download_obs_processed
Telescope.download_obs_processed (obs=None, directory='.', cube=False, pbar=False)
Download the raw observation obs (obtained from get_job) into zip file named job_jid.zip located in the directory (current by default). Alternatively, when the cube=True the file will be a 3D fits file. The name of the file (without directory) is returned.
print(scope.download_obs_processed(obs, directory='OUT', cube=True, pbar=True))
print(scope.download_obs_processed(obs, directory='OUT', cube=False, pbar=True))
art_369256.fits
art_369256.zip
Telescope.get_obs_processed
Telescope.get_obs_processed (obs=None, cube=False)
Get the raw observation obs (obtained from get_job) into zip file-like object. The function returns ZipFile structure of the downloaded data.
=True) scope.get_obs_processed(obs, cube
<_io.BytesIO>
=False) scope.get_obs_processed(obs, cube
<zipfile.ZipFile file=<_io.BytesIO object> mode='r'>
Job submission methods
Submission API
Telescope.submit_job_api
Telescope.submit_job_api (obj, exposure=30000, tele='COAST', filt='BVR', darkframe=True, name='RaDec object', comment='AutoSubmit')
Telescope.submit_RADEC_job
Telescope.submit_RADEC_job (obj, exposure=30000, tele='COAST', filt='BVR', darkframe=True, name='RaDec object', comment='AutoSubmit')
scope.logout()