Statusables¶
- class astrometry_net_client.statusables.Job(job_id)¶
Represents a single job from Astrometry.net. It can either still be running, or be finished. When finished, results can be queried using the appropriate methods.
- id¶
Identifier for the Astrometry.net Job.
- Type:
int
- resp_status¶
The status of the Job (as it was last queried). Can be:
"success"
,"failure"
or"solving"
.- Type:
str
- objects_in_field¶
Detected objects in the field. Result of the
info()
query.- Type:
list(str)
- machine_tags¶
Tags made by the API (machine). Result of the
info()
query.- Type:
list(str)
- tags¶
All tags of the Job. Can be made by users or by the API. Result of the
info()
query.- Type:
list(str)
- original_filename¶
Filename of the uploaded file. Will not include the path. Result of the
info()
query.- Type:
str
- calibration¶
Dictionary containing information about the solved image, example:
>>> job.calibration {"parity": 1.0, "orientation": 105.74942079091929, "pixscale": 1.0906710701159739, "radius": 0.8106715896625917, "ra": 169.96633791366915, "dec": 13.221011585315143}
- Type:
dict
See also
Statusable
For available functions on getting the status & waiting
- annotated_display()¶
JPEG image as a binary string
- Return type:
bytes
- extraction_image_display()¶
PNG image as a binary string
- Return type:
bytes
- new_fits_file()¶
Get the new fits file (original file + new header).
- Return type:
astropy.io.fits.HDUList
- red_green_image_display()¶
PNG image as a binary string
- Return type:
bytes
- wcs_file()¶
Get the resulting wcs file as an astropy.io.fits.Header.
- Return type:
astropy.io.fits.Header
- class astrometry_net_client.statusables.Statusable¶
- done()¶
Evaluates if the last
status()
result is the final result.- Returns:
True
, when the last response from status is the final status (e.g. it does not change anymore).False
otherwise- Return type:
bool
- status(force=False)¶
Method which queries the status if it is needed.
status
is a method which queries the status of the statusable if the current / last retrieved status is notdone()
(or no status is known). If an earlier queried status signals that the statusable is finished, no further request is made.- Parameters:
force (bool) – Can be set to true to make a status request regardless of the result of
done()
.- Returns:
dict – attribute
stat_response
.- Return type:
Dictionary with the status response (content). Same as
- success()¶
Evaluates if the statusable was successful.
Will always be
False
ifdone()
isFalse
.- Return type:
bool
- until_done(start=4, end=300, timeout=None)¶
Blocking method which waits for the Statusable to be finished.
This method will keep querying the
status()
until the statusable isdone()
. Will sleep in increasing intervals between each status query, to avoid overloading the API server (and give room for possible threading). The sleeping behaviour is determined bystart
andend
.It is possible to specify a timeout, in seconds, after which a
TimeoutError
is raised.- Parameters:
start (int) – Determines the intitial sleep time, which is doubled after each query. Defaults to 4s.
end (int or None) – If specified, gives a maximal value for the sleep time. Otherwise the sleep time will be doubled forever.
timeout (int or None) – If specified will raise a
TimeoutError
when the method has been running for the given time.
- Returns:
Dictionary with the status response (content). Same as attribute
stat_response
.- Return type:
dict
- Raises:
TimeoutError – When parameter timeout is set and the waited time exceeds this value.
Examples
Will wait forever and doubles the sleep time until it reaches 300.
>>> stat.until_done()
Will wait forever, and doubles the sleep time until it is equal to 60s
>>> stat.until_done(end=60)
Will wait forever and doubles the sleep time indefinitely
>>> stat.until_done(end=None)
Waits until 120s have passed (default sleep behaviour)
>>> stat.until_done(timeout=120s) TimeoutError
- class astrometry_net_client.statusables.Submission(submission_id)¶
Represents a single submission from Astrometry.net. A submission is the result of any of the
astrometry_net_client.UploadFile
orastrometry_net_client.UploadURL
uploaders.When
status()
is called and jobs are available, the status of the jobs will also be queried. To see the response of these jobs, see theirresponse
attribute.Note that some of the attributes listed below are only available when
status()
is queried.- id¶
Identifier for the submission. Used in the request URL.
- Type:
int
- user¶
Identifier for the user which made the Submission.
- Type:
int
- images¶
List of references to the uploaded images.
- Type:
list(int)
- job_calibrations¶
Identifier to the references used to solve the images.
- Type:
list(int)
- jobs¶
The list of jobs which the Submission spawned. Will typically be one Job per uploaded image. When no job was spawned yet, the list will be:
[None]
.- Type:
list(Jobs)
- processing_started¶
If available, a string containing the date when the Submission process started.
- Type:
str
- processing_finished¶
If available, a string containing the date when the Submission process finished.
- Type:
str
See also
Statusable
For available function on getting the status & waiting
- astrometry_net_client.statusables.cache_response(func)¶
Wrapper around a function to cache its result in an attribute of the object. Name of the attribute is: _<funcname>_result
- Parameters:
func – function to be wrapped
- Return type:
wrapped function
- astrometry_net_client.statusables.ensure_status(func)¶
Decorator for a method to enforce it only being called when the statusable is finished.
- Parameters:
func – function to be wrapped
- Return type:
wrapped function
- Raises:
StillProcessingException – when
done()
isFalse
- astrometry_net_client.statusables.ensure_status_success(func)¶
Decorator for a method to enforce it only being called when the statusable is successful (and therefore also finished).
- Parameters:
func – function to be wrapped
- Return type:
wrapped function
- Raises:
StatusFailedException – When the
success()
evaluates toFalse
butdone()
toTrue
.StillProcessingException – When
done()
isFalse