opihiexarata.astrometry.webclient module
- class opihiexarata.astrometry.webclient.AstrometryNetHostAPIEngine(url=None, apikey: str = None, silent: bool = True)[source]
Bases:
AstrometryNetWebAPIEngine
This class is the same as the AstrometryNetWebAPIEngine, but the default URL point is directed somewhere else to the self-hosted version.
For all documentation, please refer to the parent function.
- class opihiexarata.astrometry.webclient.AstrometryNetWebAPIEngine(url=None, apikey: str = None, silent: bool = True)[source]
Bases:
AstrometryEngine
A python-based wrapper around the web API for astrometry.net.
This API does not have the full functionality of the default Python client seen at https://github.com/dstndstn/astrometry.net/blob/master/net/client/client.py. The point of this class is to be simple enough to be understood by others and be specialized for OpihiExarata.
- _ASTROMETRY_NET_API_BASE_URL
The base URL for the API which all other service URLs are derived from.
- Type:
string
- _apikey
The API key used to log in.
- Type:
string
- original_upload_filename
The original filename that was used to upload the data.
- Type:
string
- session
The session ID of this API connection to astrometry.net
- Type:
string
- __del_job_id() None
Remove the current job ID association.
- __del_submission_id() None
Remove the current submission ID association.
- __doc_job_id = 'When file upload or table upload is sent to the API, the job ID of the submission is saved here.'
- __doc_submission_id = 'When file upload or table upload is sent to the API, the submission ID is saved here.'
- __get_job_id() str
Extract the job ID from the image upload results. It may be the case that there is not job yet associated with this submission.
- __get_submission_id() str
Extract the submission ID from the image upload results.
- __init__(url=None, apikey: str = None, silent: bool = True) None [source]
The instantiation, connecting to the web API using the API key.
- Parameters:
url (string, default = None) – The base url which all other API URL links are derived from. This should be used if the API is a self-hosted install or has a different web source than nova.astrometry.net. Defaults to the nova.astrometry.net api service.
apikey (string) – The API key of the user.
silent (bool, default = True) – Should there be printed messages as the processes are executed. This is helpful for debugging or similar processes.
- Return type:
None
- __job_id = None
- __login(apikey: str) str
The method to log into the API system.
- Parameters:
apikey (string) – The API key for the web API service.
- Returns:
session_key – The session key for this login session.
- Return type:
string
- __set_job_id(job_id) None
Assign the job ID, it should only be done once when the image is obtained.
- __set_submission_id(sub_id) None
Assign the submission ID, it should only be done once when the image is obtained.
- __submission_id = None
- _generate_service_url(service: str) str [source]
Generate the correct URL for the desired service. Because astrometry.net uses a convention, we can follow it to obtain the desired service URL.
- Parameters:
service (str) – The service which the API URL for should be generated from.
- Returns:
url – The URL for the service.
- Return type:
str
- _generate_upload_args(**kwargs) dict [source]
Generate the arguments for sending a request. This constructs the needed arguments, replacing the defaults with user provided arguments where desired.
- Parameters:
**kwargs (dict) – Arguments which would override the defaults.
- Returns:
args – The arguments which can be used to send the request.
- Return type:
dict
- _send_web_request(service: str, args: dict = {}, file_args: dict = None) dict [source]
A wrapper function for sending a web request to the astrometry.net API service. Returns the results as well.
- Parameters:
service (string) – The service which is being requested. The web URL is constructed from this string.
args (dictionary, default = {}) – The arguments being sent over the web request.
file_args (dictionary, default = None) – If a file is being uploaded instead, special care must be taken to sure it matches the upload specifications.
- Returns:
results – The results of the web request if it did not fail.
- Return type:
dictionary
- download_result_file(filename: str, file_type: str, job_id: str = None) None [source]
Downloads fits data table files which correspond to the job id.
- Parameters:
filename (str) – The filename of the file when it is downloaded and saved to disk.
file_type (str) –
The type of file to be downloaded from astrometry.net. It should one of the following:
wcs: The world coordinate data table file.
new_fits, new_image: A new fits file, containing the original image, annotations, and WCS header information.
rdls: A table of reference stars nearby.
axy: A table in of the location of stars detected in the provided image.
corr: A table of the correspondences between reference stars location in the sky and in pixel space.
job_id (str, default = None) – The ID of the job that the results should be obtained from. If not provided, the ID determined by the file upload is used.
- Return type:
None
- get_job_results(job_id: str = None) dict [source]
Get the results of a job sent to the API service.
- Parameters:
job_id (str, default = None) – The ID of the job that the results should be obtained from. If not provided, the ID determined by the file upload is used.
- Returns:
results – The results of the astrometry.net job. They are, in general: (If the job has not finished yet, None is returned.)
Status : The status of the job.
Calibration : Calibration of the image uploaded.
Tags : Known tagged objects in the image, people inputted.
Machine Tags : Ditto for tags, but only via machine inputs.
Objects in field : Known objects in the image field.
Annotations : Known objects in the field, with annotations.
Info : A collection of most everything above.
- Return type:
dict
- get_job_status(job_id: str = None) str [source]
Get the status of a job specified by its ID.
- Parameters:
job_id (str, default = None) – The ID of the job that the results should be obtained from. If not provided, the ID determined by the file upload is used.
- Returns:
status – The status of the submission. If the job has not run yet, None is returned instead.
- Return type:
string
- get_reference_star_pixel_correlation(job_id: str = None, temp_filename: str = None, delete_after: bool = True) Table [source]
This obtains the table that correlates the location of reference stars and their pixel locations. It is obtained from the fits corr file that is downloaded into a temporary directory.
- Parameters:
job_id (string, default = None) – The ID of the job that the results should be obtained from. If not provided, the ID determined by the file upload is used.
temp_filename (string, default = None) – The filename that the downloaded correlation file will be downloaded as. The path is going to still be in the temporary directory.
delete_after (bool, default = True) – Delete the file after downloading it to extract its information.
- Returns:
correlation_table – The table which details the correlation between the coordinates of the stars and their pixel locations.
- Return type:
Table
- get_submission_results(submission_id: str = None) dict [source]
Get the results of a submission specified by its ID.
- Parameters:
submission_id (str) – The ID of the submission. If it is not passed, the ID determined by the file upload is used.
- Returns:
result – The result of the submission.
- Return type:
dict
- get_submission_status(submission_id: str = None) str [source]
Get the status of a submission specified by its ID.
- Parameters:
submission_id (str, default = None) – The ID of the submission. If it is not passed, the ID determined by the file upload is used.
- Returns:
status – The status of the submission.
- Return type:
string
- get_wcs(job_id: str = None, temp_filename: str = None, delete_after: bool = True) WCS [source]
This obtains the wcs header file and then computes World Coordinate System solution from it. Because astrometry.net computes it for us, we just extract it from the header file using Astropy.
- Parameters:
job_id (string, default = None) – The ID of the job that the results should be obtained from. If not provided, the ID determined by the file upload is used.
temp_filename (string, default = None) – The filename that the downloaded wcs file will be downloaded as. The path is going to still be in the temporary directory.
delete_after (bool, default = True) – Delete the file after downloading it to extract its information.
- Returns:
wcs – The world coordinate solution class for the image provided.
- Return type:
Astropy WCS
- property job_id: str
When file upload or table upload is sent to the API, the job ID of the submission is saved here.
- property submission_id: str
When file upload or table upload is sent to the API, the submission ID is saved here.
- upload_file(pathname: str, **kwargs) dict [source]
A wrapper to allow for the uploading of files or images to the API.
This also determines the submission ID and the job ID for the uploaded image and saves it.
- Parameters:
pathname (str) – The pathname of the file to open. The filename is extracted and used as well.
- Returns:
results – The results of the API call to upload the image.
- Return type:
dict