ShowImageRequest

class wwt_api_client.ShowImageRequest(client)[source]

Bases: APIRequest

Request a WTML XML document suitable for showing an image in a client.

This request connects to the ShowImage endpoint. Perhaps counterintuitively, this API returns a WTML collection XML document that points to a single web-accessible image no larger than 2048×2048 pixels. The XML document is a fairly straightforward transcription of the URL parameters that are passed to the API call. Therefore this API is most useful when you are using some other web API that requires a URL to a WTML file — by passing it a URL involving this endpoint, you can point at a “virtual” WTML file that tells WWT how to show an image.

Only the name and image_url parameters are essential:

>>> from wwt_api_client import Client
>>> req = Client().show_image('http://example.com/space.jpg', 'My Image')
>>> print(req.send()[:10])  # prints start of a WTML XML document
<?xml vers

The image to be shown must be less than 2048×2048 in size and should use a tangential projection.

For details, see the documentation of the ShowImage endpoint.

Attributes Summary

credits

Free text describing where the image came from.

credits_url

Absolute URL of a webpage with more information about the image.

dec_deg

The declination at which to center the view, in degrees.

image_url

Absolute URL of the image to show.

name

A name to give the image an its enclosing <Place>.

ra_deg

The right ascension at which to center the view, in degrees.

reverse_parity

If true, the image will be flipped left-right before display.

rotation_deg

How much to rotate the image in an east-from-north sense, in degrees.

scale_arcsec

The angular size of each image pixel, in arcseconds.

thumbnail_url

Absolute URL of a 96×45 pixel image thumbnail used to represent the <Place>.

x_offset_pixels

The horizontal offset of the image’s lower-left corner from the view center, in pixels.

y_offset_pixels

The vertical offset of the image’s lower-left corner from the view center, in pixels.

Methods Summary

invalidity_reason()

Check whether the parameters of this request are valid.

make_request()

Generate a requests.Request from the current parameters.

Attributes Documentation

credits = None

Free text describing where the image came from.

credits_url = None

Absolute URL of a webpage with more information about the image.

dec_deg = 0.0

The declination at which to center the view, in degrees.

image_url = None

Absolute URL of the image to show.

name = None

A name to give the image an its enclosing <Place>. Commas will be stripped by the server.

ra_deg = 0.0

The right ascension at which to center the view, in degrees.

reverse_parity = False

If true, the image will be flipped left-right before display.

rotation_deg = 0.0

How much to rotate the image in an east-from-north sense, in degrees.

scale_arcsec = 1.0

The angular size of each image pixel, in arcseconds. Pixels must be square.

thumbnail_url = None

Absolute URL of a 96×45 pixel image thumbnail used to represent the <Place>.

x_offset_pixels = 0.0

The horizontal offset of the image’s lower-left corner from the view center, in pixels.

y_offset_pixels = 0.0

The vertical offset of the image’s lower-left corner from the view center, in pixels.

Methods Documentation

invalidity_reason()[source]

Check whether the parameters of this request are valid.

Returns:
reasonstring or None

If None, indicates that this request is valid. Otherwise, the returned string explains what about the request’ parameters is invalid.

Examples

You can manually check if a request is correctly set up:

>>> from wwt_api_client import Client
>>> req = Client().show_image('http://example.com/space.jpg', 'My Image')
>>> assert req.invalidity_reason() is None
make_request()[source]

Generate a requests.Request from the current parameters.

This method returns a requests.Request object ready for sending to the API server.

Returns:
requestrequests.Request object

The HTTP request.

Examples

Get the URL that will be accessed for a request:

>>> from urllib.parse import urlparse
>>> from wwt_api_client import Client
>>> req = Client().show_image('http://example.com/space.jpg', 'My Image')
>>> parsed_url = urlparse(req.make_request().prepare().url)
>>> print(parsed_url.path)
/WWTWeb/ShowImage.aspx