API access for the Southern African Large elescope (SALT).
Project description
pyastrosalt
PyAstroSALT is a wrapper around the RESTful API for observations with the South African Astronomical Observatory (SALT).
It can be used for
- validating proposals
- submitting proposals
- making any API request
Installation
PyAstroSALT can be installed from PyPI:
pip install pyastrosalt
Validating a proposal
SALT proposals are stored as zip files. If you want to see what such a zip file looks like, you can create a proposal in the Principal Investigator Proposal Tool (PIPT) and export it using the menu item File | Export as Zip File.
The following assumes that you have a proposal proposal.zip in the working directory and that the proposal code is 2026-1-SCI-042.
You start by creating a session and authenticating with your SALT user credentials. For testing, you can use the playground instead of the production server:
from getpass import getpass
from pyastrosalt.session import Session
username = input("Your SALT username: ")
password = getpass("Your SALT password: ")
session = Session()
session.use_playground()
session.login(username=username, password=password)
You can now validate the proposal:
from pyastrosalt.submission import validate
valid, errors = validate(session, "proposal.zip", "2026-1-SCI-042")
if valid:
print("The proposal is valid.")
else:
print("Validation failed with the following error(s):")
for error in errors:
print(f"- {error}")
Submitting a proposal
As in the previous section, the following example assumes that you have a proposal proposal.zip in the working directory and that the proposal code is 2026-1-SCI-042.
If you want to submit the proposal, you start by creating a session and authenticating. For testing, you can use the playground instead of the production server:
from getpass import getpass
from time import sleep
from pyastrosalt.session import Session
username = input("Your SALT username: ")
password = getpass("Your SALT password: ")
session = Session()
session.use_playground()
session.login(username=username, password=password)
You can now call the submit function. This function returns a Submission instance, which yiu can poll for the submission status, proposal code and (if applicable) submission error:
from time import sleep
from pyastrosalt.submission import submit, SubmissionStatus
submission = submit(
session, "proposal.zip", "2026-1-SCI-042"
)
while submission.status == SubmissionStatus.IN_PROGRESS:
print("Waiting for submission to finish...")
sleep(10)
if submission.status == SubmissionStatus.SUCCESS:
print(f"Success! The proposal code is {submission.proposal_code}.")
else:
print(f"The validation failed with the following error:\n{submission.error}")
Using the SALT API
To make a request to the SALT API, you can create a session, authenticate and issue an HTTP request. Refer to the Requests documentation for details on the available request methods (get, post, put, patch, delete and request).
The following example shows how you can get details about your SALT propoals:
from getpass import getpass
from pyastrosalt.session import Session
# Get a session and authenticate
username = input("Your SALT username: ")
password = getpass("Your SALT password: ")
session = Session()
session.use_playground()
session.login(username=username, password=password)
# Make the API request
response = session.get("/proposals/")
if not response.ok:
raise Exception("The API request failed.")
# Use the response from the API
proposals = response.json()
for proposal in proposals:
print(f"{proposal['proposal_code']}: {proposal['title']}")
You can find the available API endpoints on the SALT API documentation page.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyastrosalt-0.2.1.tar.gz.
File metadata
- Download URL: pyastrosalt-0.2.1.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fca18a4917432b76027556e9796e51144a11eaeca2d1a974e0625e84ed8d3699
|
|
| MD5 |
e5be8f45ed47bee3c1e007bb4d3d3fd1
|
|
| BLAKE2b-256 |
8979fee35e0b4ae20729caf841605973a0bbc82703ec7494aa3a306729e5844e
|
File details
Details for the file pyastrosalt-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pyastrosalt-0.2.1-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
372c930e02f430b01afcae6e3044a2b4142e28257a57c1e8a3639bdfcfcd3cce
|
|
| MD5 |
a2215a86950a588c4a93940e7ebfa748
|
|
| BLAKE2b-256 |
5c054c17fa38c7dd8c229915551b25857b790b5067207a7e5588f28a8a8e0759
|