-
Notifications
You must be signed in to change notification settings - Fork 15
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
Asdf read speed #514
base: main
Are you sure you want to change the base?
Asdf read speed #514
Conversation
for i, (fm, wcs, headers) in enumerate(zip(file_managers, wcses, header_tables)): | ||
all_headers = vstack(header_tables) | ||
for i, (fm, wcs) in enumerate(zip(file_managers, wcses)): | ||
headers = all_headers[i*len(fm):(i+1)*len(fm)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's some promises about ordering I was not intending to make.
I just did a quick experiment locally and if we convert the Table to a numpy recarray before we save it ( Full codeimport dkist; from dkist.data.sample import VBI_AJQWW
tds = dkist.load_dataset(VBI_AJQWW)
whole_table = tds.combined_headers
import asdf
small1 = whole_table[0:10]
small2 = whole_table[10:20]
new_tree = {"whole": whole_table, "small1":small1, "small2": small2}
with asdf.AsdfFile(tree=new_tree) as af:
af.write_to("test.asdf")
<duplicates the data>
whole_array = whole_table.as_array()
array_tree = {"whole": whole_array, "small1":whole_array[0:10], "small2": whole_array[10:20]}
with asdf.AsdfFile(tree=array_tree) as af:
af.write_to("array.asdf")
<does not duplicate the data> For a small example: whole_table2 = whole_table[["INSTRUME", "DATE-AVG"]]
whole_array2 = whole_table2.as_array()
array_tree2 = {"whole": whole_array2, "small1":whole_array2[0:10], "small2": whole_array2[10:20]}
with asdf.AsdfFile(tree=array_tree2) as af:
af.write_to("array2.asdf") yields this asdf:
notice the I think this might be a good idea. My main worry is that it severely limits how rich we can make the metadata table, i.e. #265 becomes something custom we have to glue on the side rather than being able to use built-in features of astropy Table. However I think this approach has many advantages:
|
|
||
def to_yaml_tree(cls, tiled_dataset, tag, ctx): | ||
tree = {} | ||
tree["inventory"] = tiled_dataset._inventory | ||
tree["datasets"] = tiled_dataset._data.tolist() | ||
tree["headers"] = tiled_dataset.combined_headers.as_array() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do this for dataset too.
Fixes #500