Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatalinkRecord should have a backlink to the originating record #542

Open
msdemlei opened this issue Apr 29, 2024 · 0 comments
Open

DatalinkRecord should have a backlink to the originating record #542

msdemlei opened this issue Apr 29, 2024 · 0 comments

Comments

@msdemlei
Copy link
Contributor

When using datalink, one sometimes wants to go back to the table row the datalink originally came from. As an example, assume you want to make Hα maps from spectral cubes; you will need the redshift of the source object for that, and that you can presumably only get from the original record.

Here's some code illustrating the problem:

import pyvo

l0 = 6.5625e-7

svc = pyvo.dal.TAPService("http://dc.g-vo.org/tap")
results = svc.run_sync("select top 5 * from califa.cubes
  natural join califa.objects")

for dl in results.iter_datalinks():
  redshift = *** dl.original["redshift"] ***
  lobs = l0*(1+redshift)
  map = next(dl.bysemantics("#this")).processed(band=(lobs, lobs))

The trouble: This doesn't work at the moment, because there's no "original" attribute on DatalinkRecord-s. To work around this, people would have to figure out the key used by the datalink machinery (which, incidentally, is not pretty in pyVO either, but that's perhaps not a real problem) and then go back to the original table with the datalink.id. That's really not nice.

What I'd suggest instead is that we add an attribute ("original" is perhaps not the best name) or a function ("get_originating_row()") that makes it easy to pull out the record in the original table corresponding to datalink.id.

Opinions? I'd donate an implementation (which shouldn't be hard anyway), but I'd first like to make sure I'm not missing anything -- and whether anyone has ideas for how to make this a pretty and obvious API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant