loading data from Vizier tables

an upfront apology - this is a very specific problem, that is only in part related to observable - however it’s a window to a bunch of cool data that people here might like to play with so i hope you won’t mind.

Most astronomical data is publically accessible with some great tools for accessing it - but most of these tools are built with languages like Python, Matlab and IDL in mind - javascript is an unknown beast to most of the Astro community.

One fantastic repository is the Vizier catalog search - which is a window to thousands of published datasets about any object in the sky - a lovely example is the Gaia catalog which gives the position and velocity of millions of stars. Vizier allows simple queries, for example, a small patch of sky, or a specific named object, as well as deciding which fields of the data to load.

However, after a few hours of struggling with it I cannot work out how we would go about accessing this data in observable/javascript more generally - it seems like it could be as simple as 'data=d3.tsv('http://vizier.u-strasbg.fr/viz-bin/asu-tsv?-source=I/239/hip_main’)’ - but this returns ‘data = TypeError: Failed to fetch’

There is LOADS of documentation on this service (here’s a good central repository) but it reads like it’s designed for very different kinds of tasks - plus there’s a ton of astronomy specific tools and langauges that get mixed in.

I thought i’d throw this out to the observable community to see if anyone could help me unpick how to formulate a functional url to read the data.

(p.s. as an example of what I’m hoping for this command works great for accessing the list of confirmed exoplanets: 'planetdata=d3.csv('https://exoplanetarchive.ipac.caltech.edu/cgi-bin/nstedAPI/nph-nstedAPI?table=exoplanets&select=pl_bmassj,pl_radj,pl_bmassn,pl_bmassjerr1,pl_bmassjerr2,pl_eqt&order=dec’)’)

This probably only takes you a small way, but this particular error derives from a lack of CORS support on the dataset. Try this instead:

data = d3.tsv(‘https://cors-anywhere.herokuapp.com/http://vizier.u-strasbg.fr/viz-bin/asu-tsv?-source=I/239/hip_main’)

[using `cors-anywhere.herokuapp.com`]

Note that it will take several seconds to load. For me, for now, it returned an array of 50039 objects

2 Likes

If those data sets are static, then you could alternatively add them as file attachments to your notebook (for up to 15MB).

Whatever solution you choose, please also keep in mind that VizieR asks you to cite the authors.

3 Likes

that’s great - thank you.

just to check my understanding - this wasn’t working before Vizier is not allowing cross-origin requests? Is that a normal/sensible thing to disallow? I’m wondering whether there’s an argument for trying to persuade the team behind it to change that setting.

Hi @zpenoyre. I am no expert on CORS, so I cannot respond about the incentives for allowing or disallowing it. I suspect the ease of enabling it might depend on the hosting platform.