Client¶
Some example scripts which utulize the Client
class, can be found
under Examples
- class astrometry_net_client.client.Client(session=None, settings=None, **kwargs)¶
Higher level class which makes the interaction with the API easy.
- Parameters:
session (
astrometry_net_client.session.Session
) – Optional argument to provide the session for the API. If not provided, you must either specify the keywordapi_key
orlocation
, or have the key present in your environment. Seeastrometry_net_client.session.Session
settings (
astrometry_net_client.settings.Settings
, dict) – An optional settings object, which will be applied to all uploads. If not specified, the settings object will be created from given keyword arguments which correspond to valid settings. For this seeastrometry_net_client.settings.Settings
.kwargs (arguments) – Used to create a session or settings object, if either is not specified. Will extract the relevant arguments relevant to the object which is created before passing them to the object constructor. See
astrometry_net_client.settings.Settings
andastrometry_net_client.session.Session
- calibrate_file_wcs(filename, settings=None)¶
Uploads a file, returning the wcs header if it succeeds.
- Parameters:
filename (str) – Location + name of the file to upload.
settings (
astrometry_net_client.settings.Settings
) – An optional settings dict which only applies to this specific upload. Will override the default settings with which theClient
was constructed.
- Returns:
Returns the Header if successful, None otherwise.
- Return type:
astropy.io.fits.Header
or None
- filtered_upload_wrapper(filename, filter_func=None, filter_args=None, *args, **kwargs)¶
Wrapper around
upload_file()
which filters the given file based on a specified filter function. Main use for this is a computationally heavy filter function, like counting number of sources locally, and only uploading if not enough are detected.- Parameters:
filename (str) – File to be uploaded. See
upload_file()
.filter_func (Callable) – Predicate filter function which takes in the filename and optionally some argument (filter_args).
filter_args (List) – Arguments which are to be passed to the filter function.
args (other arguments) – Directly passed to
upload_file()
kwargs (keyword arguments) – Directly passed to
upload_file()
- Returns:
Job or None – Will be the job of the resulting upload (see
upload_file()
), or None when filter_func evaluated to False.- Return type:
- upload_file(filename, settings=None)¶
Uploads file and returns completed job when finished solving.
- Parameters:
filename (str) – Location + name of the file to upload.
settings (
astrometry_net_client.settings.Settings
) – An optional settings dict which only applies to this specific upload. Will override the default settings with which theClient
was constructed.
- Returns:
Job – The job of the resulting upload. NOTE: It is possible that the job did not succeed, therefore check with
astrometry_net_client.statusables.Statusable.success()
if it did.- Return type:
- upload_files_gen(files_iter, filter_func=None, filter_args=None, workers=10)¶
Generator which uploads a number of files concurrently, yielding the
astrometry_net_client.statusables.Job
& filename when done.Note that the
files_iter
argument is fully consumed when submitting to the executor is done. This means that the results will only be yielded once the iterator is consumed.- Parameters:
files_iter (iterable) – Some iterable containing paths to the files which will be uploaded. Is fully consumed before any result is yielded.
workers (int, optional) – A positive integer, controlling the amount of workers to use for the processing. Will not exceed the value of
MAX_WORKERS
.filter_func (Callable) – Predicate filter function which takes in the filename and optionally some argument (filter_args).
filter_args (List) – Arguments which are to be passed to the filter function.
- Yields:
(
astrometry_net_client.statusables.Job
,str
) – A tuple containing the finishedastrometry_net_client.statusables.Job
and the corresponding filename. Yields when the Job is finished. NOTE: Order of yielded filenames can (and likely will) be different from the givenfiles_iter