trident-project / trident

A Synthetic Spectral Generation Suite
Other
21 stars 25 forks source link

Save ray start & end as HDF5 attributes #173

Closed clairekope closed 3 years ago

clairekope commented 3 years ago

It'd be nice for rays to store their start and end coordinates as HDF5 attributes. In the past I have randomly generated sets of starts and ends but not saved them, so I'd have to try to recreate the start and end coordinates from the ray's position fields. I've run into weird bugs with this, and it'd be easier to just store this kind of metadata as attributes. There's probably more metadata associated with compound rays, but I've not ever worked with those. This should be easy to do through the extra_attrs argument in yt's save_as_dataset.

chummels commented 3 years ago

Hi @clairekope . These data are already stored in the ray object. You can access them by looking at ds.light_ray_solution:

In [1]: ds.light_ray_solution
Out[1]:
[{'end': unyt_array([1., 1., 1.], 'unitary'),
  'filename': 'snapshot_600.hdf5',
  'redshift': 0.05,
  'start': unyt_array([0.48810148, 0.51748806, 0.54316002], 'unitary'),
  'traversal_box_fraction': unyt_quantity(0.83878521, 'unitary'),
  'unique_identifier': '1436307563512020127'}]

I'll try to make this easier to find in the docs, though.

chummels commented 3 years ago

I'll leave this PR open until I've updated the docs sufficiently.

chummels commented 3 years ago

Fixed in PR #175 .

clairekope commented 3 years ago

Awesome! I didn't see this metadata with h5ls so I thought it didn't exist. Thanks for updating the docs!

chummels commented 3 years ago

No worries! It was sneaky in there. I actually started to implement your request and then realized it was already there, so I even fooled myself!