asdf-format / asdf

ASDF (Advanced Scientific Data Format) is a next generation interchange format for scientific data
http://asdf.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
530 stars 58 forks source link

How to read astropy tables with `asdftool`? #1051

Open ketozhang opened 2 years ago

ketozhang commented 2 years ago

Given an astropy table, how do I use asdftool to read the tabular data (i.e., under the key data).

from astropy.table import Table

table = Table({"colname": list(range(10))})
table.write("data.asdf", format="asdf")

I thought it be asdftool info --show-value data.asdf, but the flag makes no difference.

ketozhang commented 2 years ago

This seems to just be the limitation and intention of info and that asdftool is missing a CLI command that prints AsdfFile::tree.

perrygreenfield commented 2 years ago

It wasn't the intent of info to look at the data, whether image or table. It does suggest that a utility like that would be useful (probably separate ones for simple arrays and tables). Info was more intended to examine the structure of the file (meta data and the location within the tree of any data). So it is a good suggestion that such utilities would be useful, mainly for the shell command line.

ketozhang commented 2 years ago

Sorry, I did not write clearly. I completely agree info is for a structural preview of the tree.

Anyways, adding a full printout command (e.g., asdftool tree FILE returns pretty print JSON) is something I can take a stab at contributing (checking if @drdavella @mdboom have considered this).