Skip to content

Instantly share code, notes, and snippets.

@braingram
Created November 10, 2022 16:11
Show Gist options
  • Save braingram/b369a6326e299088fb98bcef38a01c7d to your computer and use it in GitHub Desktop.
Save braingram/b369a6326e299088fb98bcef38a01c7d to your computer and use it in GitHub Desktop.
import io
import asdf
b = io.BytesIO(b"""#ASDF 1.0.0
#ASDF_STANDARD 1.5.0
%YAML 1.1
%TAG ! tag:stsci.edu:asdf/
--- !core/asdf-1.1.0
asdf_library: !core/software-1.0.0 {author: The ASDF Developers, homepage: 'http://github.com/asdf-format/asdf',
name: asdf, version: 2.8.1}
history:
extensions:
- !core/extension_metadata-1.0.0
extension_class: asdf.extension.BuiltinExtension
software: !core/software-1.0.0 {name: asdf, version: 2.8.1}
- !core/extension_metadata-1.0.0
extension_class: astropy.io.misc.asdf.extension.AstropyAsdfExtension
software: !core/software-1.0.0 {name: astropy, version: 4.3.1}
end_time: !time/time-1.1.0 2021-03-01T00:02:53.320
...""")
af = asdf.open(b)
print(af['end_time'])
ob = io.BytesIO()
af.write_to(ob)
ob.seek(0)
print(ob.read().decode('ascii'))
@braingram
Copy link
Author

When run without asdf-astropy output is:

WARNING: AstropyDeprecationWarning: ASDF functionality for astropy is being moved out of the astropy package to the new asdf-astropy package. Please use this package instead. astropy.io.misc.asdf is deprecated since astropy 5.1 and will be removed in a future release. [astropy.io.misc.asdf.types]
2021-03-01T00:02:53.320
WARNING: AstropyDeprecationWarning: ASDF functionality for astropy is being moved out of the astropy package to the new asdf-astropy package. Please use this package instead. astropy.io.misc.asdf is deprecated since astropy 5.1 and will be removed in a future release. [astropy.io.misc.asdf.types]
#ASDF 1.0.0
#ASDF_STANDARD 1.5.0
%YAML 1.1
%TAG ! tag:stsci.edu:asdf/
--- !core/asdf-1.1.0
asdf_library: !core/software-1.0.0 {author: The ASDF Developers, homepage: 'http://github.com/asdf-format/asdf',
  name: asdf, version: 2.13.1.dev152+g7a64cb5.d20221109}
history:
  extensions:
  - !core/extension_metadata-1.0.0
    extension_class: asdf.extension.BuiltinExtension
    software: !core/software-1.0.0 {name: asdf, version: 2.13.1.dev152+g7a64cb5.d20221109}
  - !core/extension_metadata-1.0.0
    extension_class: astropy.io.misc.asdf.extension.AstropyAsdfExtension
    software: !core/software-1.0.0 {name: astropy, version: 5.1.1}
end_time: !time/time-1.1.0 2021-03-01T00:02:53.320
...

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