Skip to content

Distributing simple model by itself - individual yaml file or OrsoDataset? Standardisation is required. #143

@andyfaff

Description

@andyfaff

I'm getting requests for (de-)serialisation of simple models. I am trying to go down the lines of using the simple model language.

Most of the test examples that use the simple model language are individual YAML files (e.g. https://github.com/reflectivity/orsopy/blob/main/examples/sample_model_example_2.yml).

There is no functionality for testing a file to see if they are model language files, and whether they are ORSO compliant or not. In order to do this one has to load the yaml and try to resolve the model. If there's an exception it can't have been ORSO compliant.

  • could we have a function that says if these files are model language files and check for ORSO compliance (schema?)?
  • should we have # # ORSO reflectivity data file | 0.1 standard | YAML encoding | https://www.reflectometry.org/ at the top of those simple YAML files?

More to the point, we need some standardisation as to how we pass around a simple model by itself. Should we be placing the simple model in bare yaml by itself, or should it be placed into an OrsoDataset? My hope is for the latter.

Unfortunately it's not possible to create, or read, an OrsoDataset that only has the model and no data. The following raises an exception:

from orsopy.fileio import Orso, OrsoDataset
header = Orso.empty()
# inject a simple model into `info` at this point.
od = OrsoDataset(info=header, data=None)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[25], line 1
----> 1 od = OrsoDataset(info=header, data=None)

File <string>:5, in __init__(self, info, data)

File [~/miniforge3/envs/dev3/lib/python3.13/site-packages/orsopy/fileio/orso.py:157](http://localhost:8888/lab/tree/refnx-testdata/data/reflect/~/miniforge3/envs/dev3/lib/python3.13/site-packages/orsopy/fileio/orso.py#line=156), in OrsoDataset.__post_init__(self)
    156 def __post_init__(self):
--> 157     if self.data.shape[1] != len(self.info.columns):
    158         raise ValueError("Data has to have the same number of columns as header")

AttributeError: 'NoneType' object has no attribute 'shape'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions