Python examples
Observe an explicit CSV target list
The complete source is included below.
python -m nextastro_obs_client.examples.target_list nextastro_obs_client/examples/targets.csv
Reads target_name,ra_hours,dec_deg,filter,seconds,count and executes the rows in order. The supplied CSV has illustrative coordinates; edit it for the observing session. A real failure stops the run and preserves the completed commands in OBS history.
Student extension: Add a results CSV linking each target row to returned exposure IDs and files.
Python source
"""Run explicit coordinates and exposure settings from a CSV."""
import csv
from nextastro_obs_client.examples._common import parser, execute
def run(obs, camera, args):
with open(args.targets, newline="", encoding="utf-8-sig") as handle:
for row in csv.DictReader(handle):
obs.mount.slew(ra_hours=float(row["ra_hours"]), dec_deg=float(row["dec_deg"]))
for image in camera.expose(seconds=float(row["seconds"]), filter=row["filter"],
count=int(row["count"]), target_name=row["target_name"]):
print(row["target_name"], image.path)
def main(argv=None):
p = parser("CSV target list")
p.add_argument("targets", help="CSV: target_name,ra_hours,dec_deg,filter,seconds,count")
return execute(p, run, argv)
if __name__ == "__main__":
main()
Shared argument and session helpers: Example support code.