swiftemulator.backend.model_values module

Object describing the model values, i.e. this uniquely describes the set of scaling relations present.

class swiftemulator.backend.model_values.ModelValues(model_values: Dict[Hashable, Dict[str, Optional[array]]])[source]

Bases: object

Set of model values for a given scaling relation.

Parameters:
  • model_values – Model values for this given scaling relation. Must have the following structure: {unique_identifier: {"independent": np.array, "dependent": np.array, "dependent_errors": Optional[ np.array]}}, with the unique_identifiers the same as those that were specified within the ModelParameters object. The dependent errors are optional, but if present must be of the same length as the dependent variables. Both independent and dependent are required for every model value that is present. If a unique identifier is present in the model parameters, but not in the values, it is simply left out of the emulation step.

  • Dict[Hashable – Model values for this given scaling relation. Must have the following structure: {unique_identifier: {"independent": np.array, "dependent": np.array, "dependent_errors": Optional[ np.array]}}, with the unique_identifiers the same as those that were specified within the ModelParameters object. The dependent errors are optional, but if present must be of the same length as the dependent variables. Both independent and dependent are required for every model value that is present. If a unique identifier is present in the model parameters, but not in the values, it is simply left out of the emulation step.

  • Dict[str – Model values for this given scaling relation. Must have the following structure: {unique_identifier: {"independent": np.array, "dependent": np.array, "dependent_errors": Optional[ np.array]}}, with the unique_identifiers the same as those that were specified within the ModelParameters object. The dependent errors are optional, but if present must be of the same length as the dependent variables. Both independent and dependent are required for every model value that is present. If a unique identifier is present in the model parameters, but not in the values, it is simply left out of the emulation step.

  • Optional[np.array]]] – Model values for this given scaling relation. Must have the following structure: {unique_identifier: {"independent": np.array, "dependent": np.array, "dependent_errors": Optional[ np.array]}}, with the unique_identifiers the same as those that were specified within the ModelParameters object. The dependent errors are optional, but if present must be of the same length as the dependent variables. Both independent and dependent are required for every model value that is present. If a unique identifier is present in the model parameters, but not in the values, it is simply left out of the emulation step.

Raises:

AttributeError – If the model values do not conform to the required specification.

model_values: Dict[Hashable, Dict[str, Optional[array]]]
items()[source]
keys()[source]
values()[source]
property number_of_variables: int

Total number of variables present in all models.

to_yaml(filename: Path)[source]

Write the model values to a YAML file.

Parameters:

filename (Path) – The path to write the file to. This should be a Path object, but if it is a string it will be automatically converted.

classmethod from_yaml(filename: Path) ModelValues[source]

Generate an instance of ModelValues from a YAML file, written to disk using to_yaml.

Parameters:

filename (Path) – The path to read the file from. This should be a Path object, but if it is a string it will be automatically converted.

Returns:

model_values – Instance of ModelValues restored from disk.

Return type:

ModelValues

to_json(filename: Path)[source]

Write the model values to a JSON file. Preferred to YAML as this is much faster for large datsets.

Parameters:

filename (Path) – The path to write the file to. This should be a Path object, but if it is a string it will be automatically converted.

classmethod from_json(filename: Path) ModelValues[source]

Generate an instance of ModelValues from a JSON file, written to disk using to_json.

Parameters:

filename (Path) – The path to read the file from. This should be a Path object, but if it is a string it will be automatically converted.

Returns:

model_values – Instance of ModelValues restored from disk.

Return type:

ModelValues