20. Collect Spectra finished

The rest is almost standard SAMP fare to get the spectra retrieved to SPLAT as they come in:

  try:
    target_id = vohelper.find_client(conn, "splat")
  except KeyError:
    sys.exit("Start Splat and try again")
  ...
  for ds_name, access_url in specs:
    try:
      vohelper.send_spectrum_to(
        conn, target_id, access_url, ds_name)
    except vohelper.SAMPProxyError:
      print("  (Failed)")

[See get_spectra.py]

As for images, spectra are usually passed around by their URLs in SAMP.

What’s new here is that we’re catching exceptions. Catching the KeyError when trying to find Splat is probably helpful when you run the program after a couple of months, have forgotten about splat being a part of this analysis chain, and would wonder otherwise why you see a KeyError of all things.

The second exception catching, around send_spectrum_to, is a lot more subtle. Here, and exception is raised if Splat fails to open a spectrum and sends back a notice to this effect. So, what we’re catching here, in effect, is an exception raised within Splat. In general, there’s no telling if the target client has already informed the user that something is wrong – it’s probably better to assume it has in generic code most of the time, and so sending code should avoid modal error messages (“Click here to continue”). Our very terse notification might not be optimal either, though.

Problems

(1)

Can you change our program such that only spectra of resolving power 10000 or greater are retrieved?

Hint: Use TOPCAT or the tables property of your TAPService to inspect the metadata of the ivoa.obscore table to figure out which column to query against. Just in case: It’s almost always better to filter on the remote side rather than the local side, and that’s always true if the constraint can be expressed as a single condition in a WHERE clause.

Files


Markus Demleitner, Hendrik Heinl