Skip to content

Instantly share code, notes, and snippets.

@braingram
Last active November 15, 2022 20:03
Show Gist options
  • Save braingram/1e7505fd98f66fc6e0c5b8852bdda2eb to your computer and use it in GitHub Desktop.
Save braingram/1e7505fd98f66fc6e0c5b8852bdda2eb to your computer and use it in GitHub Desktop.
import asdf
import jwst.datamodels
import numpy
af = asdf.AsdfFile({'data': numpy.zeros((10, 10), dtype='f4')})
af.write_to('tmp.asdf')
with asdf.open('tmp.asdf', mode='r') as af:
m = jwst.datamodels.MultiExposureModel()
data = af['data']
assert data.__class__.__name__ == 'NDArrayType'
im = jwst.datamodels.ImageModel()
im.data = data
im.err = data.copy()
im.dq = data.copy()
m.exposures.append(im)
m.save('foo.asdf')
m.save('foo.fits')
@braingram
Copy link
Author

Using NDArrayType from asdf produces the same result, a fits file with embedded asdf with no blocks in the asdf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment