Skip to content
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

SpectralFrame ignoring reference_position #436

Open
braingram opened this issue Jan 12, 2023 · 0 comments
Open

SpectralFrame ignoring reference_position #436

braingram opened this issue Jan 12, 2023 · 0 comments

Comments

@braingram
Copy link
Collaborator

braingram commented Jan 12, 2023

While testing schema with defaults I encountered unexpected behavior when loading an asdf file with a saved spectral frame.

First running:

import asdf
import gwcs

tree = {
    'sf': gwcs.coordinate_frames.SpectralFrame(
        reference_position="GEOCENTER")
}
af = asdf.AsdfFile(tree)
af.write_to('foo.asdf')

Will generate an asdf file with contents:

#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.dev71+gf8efb2a.d20221012}
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.dev71+gf8efb2a.d20221012}
  - !core/extension_metadata-1.0.0
    extension_class: gwcs.extension.GWCSExtension
    software: !core/software-1.0.0 {name: gwcs, version: 0.17.1}
sf: !<tag:stsci.edu:gwcs/spectral_frame-1.0.0>
  axes_names: ['']
  axes_order: [0]
  axis_physical_types: ['custom:dimensionless']
  name: SpectralFrame
  reference_position: geocenter
  unit: [!unit/unit-1.0.0 '']
...

However, loading this file ignores reference_position entirely:

import asdf

af = asdf.open('foo.asdf')
print(af['sf'].reference_position)

Prints None

I believe the cause of the error is that reference_position is not propagated through FrameConverter._from_yaml_tree:

def _from_yaml_tree(self, node, tag, ctx):
kwargs = {'name': node['name']}
if 'axes_type' in node and 'naxes' in node:
kwargs.update({
'axes_type': node['axes_type'],
'naxes': node['naxes']})
if 'axes_names' in node:
kwargs['axes_names'] = node['axes_names']
if 'reference_frame' in node:
kwargs['reference_frame'] = node['reference_frame']
if 'axes_order' in node:
kwargs['axes_order'] = tuple(node['axes_order'])
if 'unit' in node:
kwargs['unit'] = tuple(node['unit'])
if 'axis_physical_types' in node:
kwargs['axis_physical_types'] = tuple(node['axis_physical_types'])
return kwargs

called from SpectralFrameConverter:

node = self._from_yaml_tree(node, tag, ctx)

I looked back several versions and believe this issue might be older than 0.9 (for older versions the issue was with the old asdf types instead of converters).

Cadair added a commit to Cadair/gwcs that referenced this issue Oct 12, 2023
Cadair added a commit to Cadair/gwcs that referenced this issue Oct 12, 2023
Cadair added a commit to Cadair/gwcs that referenced this issue Oct 12, 2023
Cadair added a commit to Cadair/gwcs that referenced this issue Oct 12, 2023
Cadair added a commit to Cadair/gwcs that referenced this issue Sep 26, 2024
Cadair added a commit to Cadair/gwcs that referenced this issue Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant