Skip to content

Inconsistent validation on save for fits vs asdf #750

@braingram

Description

@braingram

Using the following to produce a cubemodel with an invalid shaped data.

import stdatamodels.jwst.datamodels as dm, numpy as np
image = dm.ImageModel((5, 5))
cube = dm.CubeModel(image)

Saving to fits (cube.save("foo.fits")) fails with:

ValidationError: Wrong number of dimensions: Expected 3, got 2

Failed validating 'ndim' in schema['properties']['data']:
    {'datatype': 'float32',
     'default': 0.0,
     'fits_hdu': 'SCI',
     'ndim': 3,
     'title': 'The science data'}

On instance['data']:
    ('array([[0., 0., 0., 0., 0.],\n'
     '       [0., 0., 0., 0., 0.],\n'
     '       [0., 0., 0., 0., 0.],\n'
     '       [0., 0., 0., 0., 0.],\n'
     '       [0., 0., 0., 0., 0.]], dtype=float32)')

Saving to asdf (cube.save("foo.asdf")) succeeds with no warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions