Results

Generic results and snapshots

class astrophysix.simdm.results.generic.GenericResult(**kwargs)

Experiment generic result class

Parameters
  • name (string) – result name (mandatory)

  • description (string) – result description

  • directory_path (string) – result data directory path

__eq__(other)

GenericResult comparison method

other: GenericResult

generic result to compare to

__ne__(other)

Not an implied relationship between “rich comparison” equality methods in Python 2.X but only in Python 3.X see https://docs.python.org/2.7/reference/datamodel.html#object.__ne__

other: other instance to compare to

__unicode__()

String representation of the instance

property datafiles

Result Datafile list (ObjectList)

property description

Result description. Can be set to any string value.

property directory_path

Result directory.path. Can be set to any string value.

galactica_validity_check(**kwargs)

Perform validity checks on this instance and eventually log warning messages.

Parameters

kwargs (dict) – keyword arguments (optional)

property name

Result name. Can be set to a non-empty string value.

property uid
class astrophysix.simdm.results.snapshot.Snapshot(**kwargs)

Experiment snapshot class (Simulation data model)

Parameters
  • name (string) – snapshot name (mandatory)

  • description (string) – snapshot description

  • directory_path (string) – snapshot directory path

  • time ((float, Unit) tuple) – snapshot time info (value, unit) tuple

  • physical_size ((float, Unit) tuple) – snapshot physical size info (value, unit) tuple

  • data_reference (string) – snapshot data reference (e.g. data directory name, snapshot number) string

__eq__(other)

Snapshot comparison method

other: Snapshot

snapshot to compare to

__ne__(other)

Not an implied relationship between “rich comparison” equality methods in Python 2.X but only in Python 3.X see https://docs.python.org/2.7/reference/datamodel.html#object.__ne__

other: other instance to compare to

__unicode__()

String representation of the instance

property data_reference

Snapshot data reference (e.g. data directory name, snapshot number). Can be set to any string value.

property datafiles

Result Datafile list (ObjectList)

property description

Result description. Can be set to any string value.

property directory_path

Result directory.path. Can be set to any string value.

galactica_validity_check(**kwargs)

Perform validity checks on this instance and eventually log warning messages.

Parameters

kwargs (dict) – keyword arguments (optional)

property name

Result name. Can be set to a non-empty string value.

property physical_size

Snapshot physical size info (value, unit) tuple . Can be set to a float value (unitless) or a (float, Unit) tuple.

Example

>>> sn = Snapshot(name="My super snapshot")
>>> sn.physical_size = "0.256"
>>> sn.physical_size = ("0.24", U.pc)
>>> sn.physical_size = ("0.45", "kpc")
>>> sn.physical_size[1] == U.kpc
True
>>> sn.physical_size = 4.46
>>> sn.physical_size = (7.89e2, "Mpc")
>>> sn.physical_size[1] == U.Mpc
True
>>> sn.physical_size = (78.54, U.ly)
property time

Snapshot time info (value, unit) tuple . Can be set to a float value (unitless) or a (float, Unit) tuple.

Example

>>> sn = Snapshot(name="My super snapshot")
>>> sn.time = "0.256"
>>> sn.time[1] == U.none
True
>>> sn.time = ("0.24", U.year)
>>> sn.time = ("0.45", "Myr")
>>> sn.time[1] == U.Myr
True
>>> sn.time = (7.89e2, "Gyr")
>>> sn.time = (78.54, U.min)
property uid

Datafiles

Datafile and AssociatedFile

class astrophysix.simdm.datafiles.Datafile(**kwargs)

Datafile class

Parameters
  • name (string) – datafile name (mandatory)

  • description (string) – datafile description

Example

>>> from astrophysix.utils import FileType
>>> from astrophysix.simdm.datafiles import JpegImageFile
>>> df = Datafile(name="Pre-stellar cores mass spectrum")
>>> df[FileType.PNG_FILE] = "/data/SIMUS/result_spectrum/mass_spectrum.png"
>>> df[FileType.FITS_FILE] = "/data/SIMUS/result_spectrum/pre-stellar-core-mass-hist.fits"
>>> df[FileType.PNG_FILE] = JpegImageFile.load_file("/data/SIMUS/result_spectrum/hist.jpg")
ValueError: Datafile associated file type mismatch : expected PngImageFile object but JpegImageFile was provided.
>>> df[FileType.PNG_FILE] = "/data/SIMUS/result_spectrum/hist.jpg"
AttributeError: Invalid filename for a PNG file (/data/SIMUS/result_spectrum/hist.jpg).
>>> # Removing a file
>>> del df[FileType.FITS_FILE]
__delitem__(ftype)

Remove associated file given its file type.

Parameters

item (FileType) –

Raises

KeyError – if the search index type is not a FileType instance or if there is no associated file with the required file type.

__eq__(other)

Datafile comparison method

Parameters

other (Datafile) – datafile to compare to:

__getitem__(ftype)

Get an associated file from the data file, given its file type.

Parameters

ftype (FileType) – Associated file type

Returns

f – datafile associated file for the required file type.

Return type

AssociatedFile

Raises

KeyError – if the search index type is not a FileType instance or if there is no associated file with the required file type.

__ne__(other)

Not an implied relationship between “rich comparison” equality methods in Python 2.X but only in Python 3.X see https://docs.python.org/2.7/reference/datamodel.html#object.__ne__

other: other instance to compare to

__setitem__(filetype, ass_file)

Set an associated file with a given file type into the data file.

Parameters
  • filetype (FileType) – Associated file type

  • ass_file (string or AssociatedFile) – Associated file path or instance

__unicode__()

String representation of the data file instance

property description

Datafile description. Can be set to any string value.

display_files()

Show tabulated view of associated files

Example

>>> df.display_files()
[My best datafile] datafile. Attached files :
+-----------+-----------------------------+
| File type |          Filename           |
+-----------+-----------------------------+
| PNG       | CEA.png                     |
+-----------+-----------------------------+
| JPEG      | irfu_simple.jpg             |
+-----------+-----------------------------+
| FITS      | cassiopea_A_0.5-1.5keV.fits |
+-----------+-----------------------------+
| TARGZ     | archive.tar.gz              |
+-----------+-----------------------------+
| JSON      | test_header_249.json        |
+-----------+-----------------------------+
| ASCII     | abstract.txt                |
+-----------+-----------------------------+
| HDF5      | study.h5                    |
+-----------+-----------------------------+
| PICKLE    | dict_saved.pkl              |
+-----------+-----------------------------+
galactica_validity_check(**kwargs)

Perform validity checks on this instance and eventually log warning messages.

Parameters

kwargs (dict) – keyword arguments (optional)

property name

Datafile name. Can be set to a non-empty string value.

property plot_info

Datafile plot information. Can be set to a PlotInfo instance.

property uid
class astrophysix.simdm.datafiles.file.AssociatedFile(**kwargs)
class astrophysix.simdm.datafiles.file.FitsFile(**kwargs)

Bases: astrophysix.simdm.datafiles.file.AssociatedFile

Datafile associated FITS_FILE file class.

property filename

Gets associated file name. Cannot be edited.

property last_modified

Returns file last modification time. Cannot be edited.

classmethod load_file(filepath)

Loads an AssociatedFile object from a filepath

Parameters

filepath (string) – path of the file to load.

Returns

f – Loaded associatedfile

Return type

AssociatedFile instance

property raw_file_data

File binary raw data. Cannot be edited.

save_to_disk(filepath=None)

Save associated file to an external file on the local filesystem

Parameters

filepath (string) – external file path

class astrophysix.simdm.datafiles.file.PickleFile(**kwargs)

Bases: astrophysix.simdm.datafiles.file.AssociatedFile

Datafile associated PICKLE_FILE file class.

property filename

Gets associated file name. Cannot be edited.

property last_modified

Returns file last modification time. Cannot be edited.

classmethod load_file(filepath)

Loads an AssociatedFile object from a filepath

Parameters

filepath (string) – path of the file to load.

Returns

f – Loaded associatedfile

Return type

AssociatedFile instance

property raw_file_data

File binary raw data. Cannot be edited.

save_to_disk(filepath=None)

Save associated file to an external file on the local filesystem

Parameters

filepath (string) – external file path

class astrophysix.simdm.datafiles.file.AsciiFile(**kwargs)

Bases: astrophysix.simdm.datafiles.file.AssociatedFile

Datafile associated ASCII_FILE file class.

property filename

Gets associated file name. Cannot be edited.

property last_modified

Returns file last modification time. Cannot be edited.

classmethod load_file(filepath)

Loads an AssociatedFile object from a filepath

Parameters

filepath (string) – path of the file to load.

Returns

f – Loaded associatedfile

Return type

AssociatedFile instance

property raw_file_data

File binary raw data. Cannot be edited.

save_to_disk(filepath=None)

Save associated file to an external file on the local filesystem

Parameters

filepath (string) – external file path

class astrophysix.simdm.datafiles.file.HDF5File(**kwargs)

Bases: astrophysix.simdm.datafiles.file.AssociatedFile

Datafile associated HDF5_FILE file class.

property filename

Gets associated file name. Cannot be edited.

property last_modified

Returns file last modification time. Cannot be edited.

classmethod load_file(filepath)

Loads an AssociatedFile object from a filepath

Parameters

filepath (string) – path of the file to load.

Returns

f – Loaded associatedfile

Return type

AssociatedFile instance

property raw_file_data

File binary raw data. Cannot be edited.

save_to_disk(filepath=None)

Save associated file to an external file on the local filesystem

Parameters

filepath (string) – external file path

class astrophysix.simdm.datafiles.file.JsonFile(**kwargs)

Bases: astrophysix.simdm.datafiles.file.AssociatedFile

Datafile associated JSON_FILE file class.

property filename

Gets associated file name. Cannot be edited.

property last_modified

Returns file last modification time. Cannot be edited.

classmethod load_file(filepath)

Loads an AssociatedFile object from a filepath

Parameters

filepath (string) – path of the file to load.

Returns

f – Loaded associatedfile

Return type

AssociatedFile instance

property raw_file_data

File binary raw data. Cannot be edited.

save_to_disk(filepath=None)

Save associated file to an external file on the local filesystem

Parameters

filepath (string) – external file path

class astrophysix.simdm.datafiles.file.CSVFile(**kwargs)

Bases: astrophysix.simdm.datafiles.file.AssociatedFile

Datafile associated CSV_FILE file class.

property filename

Gets associated file name. Cannot be edited.

property last_modified

Returns file last modification time. Cannot be edited.

classmethod load_file(filepath)

Loads an AssociatedFile object from a filepath

Parameters

filepath (string) – path of the file to load.

Returns

f – Loaded associatedfile

Return type

AssociatedFile instance

property raw_file_data

File binary raw data. Cannot be edited.

save_to_disk(filepath=None)

Save associated file to an external file on the local filesystem

Parameters

filepath (string) – external file path

class astrophysix.simdm.datafiles.file.TarGzFile(**kwargs)

Bases: astrophysix.simdm.datafiles.file.AssociatedFile

Datafile associated TARGZ_FILE file class.

property filename

Gets associated file name. Cannot be edited.

property last_modified

Returns file last modification time. Cannot be edited.

classmethod load_file(filepath)

Loads an AssociatedFile object from a filepath

Parameters

filepath (string) – path of the file to load.

Returns

f – Loaded associatedfile

Return type

AssociatedFile instance

property raw_file_data

File binary raw data. Cannot be edited.

save_to_disk(filepath=None)

Save associated file to an external file on the local filesystem

Parameters

filepath (string) – external file path

class astrophysix.simdm.datafiles.image.PngImageFile(**kwargs)

Bases: astrophysix.simdm.datafiles.image.ImageFile

Datafile associated PNG_FILE image file class.

property filename

Gets associated file name. Cannot be edited.

property last_modified

Returns file last modification time. Cannot be edited.

classmethod load_file(filepath)

Loads an AssociatedFile object from a filepath

Parameters

filepath (string) – path of the file to load.

Returns

f – Loaded associatedfile

Return type

AssociatedFile instance

property pil_image

Pillow image (JPEG/PNG) image property getter. Implements lazy I/O.

property raw_file_data

File binary raw data. Cannot be edited.

save_to_disk(filepath=None)

Save associated file to an external file on the local filesystem

Parameters

filepath (string) – external file path

class astrophysix.simdm.datafiles.image.JpegImageFile(**kwargs)

Bases: astrophysix.simdm.datafiles.image.ImageFile

Datafile associated JPEG_FILE image file class.

property filename

Gets associated file name. Cannot be edited.

property last_modified

Returns file last modification time. Cannot be edited.

classmethod load_file(filepath)

Loads an AssociatedFile object from a filepath

Parameters

filepath (string) – path of the file to load.

Returns

f – Loaded associatedfile

Return type

AssociatedFile instance

property pil_image

Pillow image (JPEG/PNG) image property getter. Implements lazy I/O.

property raw_file_data

File binary raw data. Cannot be edited.

save_to_disk(filepath=None)

Save associated file to an external file on the local filesystem

Parameters

filepath (string) – external file path

Plot information

class astrophysix.simdm.datafiles.plot.PlotType(value)

Plot type enum

Example

>>> pt = PlotType.HISTOGRAM_2D
>>> pt.alias
"2d_hist"
>>> pt.display_name
"2D histogram"
>>> pt.ndimensions
2
HISTOGRAM = ('hist', 'Histogram', 1, 1)
HISTOGRAM_2D = ('2d_hist', '2D histogram', 2, 1)
IMAGE = ('img', 'Image', 2, 1)
LINE_PLOT = ('line', 'Line plot', 1, 0)
MAP_2D = ('2d_map', '2D map', 2, 1)
SCATTER_PLOT = ('scatter', 'Scatter plot', 1, 0)
property alias

Plot type alias

property axis_size_offset
property display_name

Plot type verbose name

classmethod from_alias(alias)

Find a PlotType according to its alias

Parameters

alias (string) – required plot type alias

Returns

ft – Plot type matching the requested alias.

Return type

PlotType

Raises

ValueError – if requested alias does not match any plot type.

Example

>>> pt = PlotType.from_alias("hist")
>>> pt.display_name
"Histogram"
>>> pt2 = PlotType.from_alias("MY_UNKNOWN_PLOT_YPE")
ValuerError: No PlotType defined with the alias 'MY_UNKNOWN_PLOT_YPE'.
property ndimensions

Plot type number of dimensions

class astrophysix.simdm.datafiles.plot.PlotInfo(**kwargs)

Datafile class (Simulation data model)

Parameters
  • plot_type (PlotType or string) – Plot type or plot type alias (mandatory)

  • xaxis_values (numpy.ndarray) – x-axis coordinate values numpy 1D array (mandatory).

  • yaxis_values (numpy.ndarray) – y-axis coordinate numpy 1D array (mandatory).

  • values (numpy.ndarray) – plot data values numpy array (mandatory for 2D plots).

  • xlabel (string) – x-axis label

  • ylabel (string) – y-axis label

  • values_label (string) – plot values label

  • xaxis_unit – TODO

  • yaxis_unit – TODO

  • values_unit – TODO

  • xaxis_log_scale (bool) – TODO

  • yaxis_log_scale (bool) – TODO

  • values_log_scale (bool) – TODO

  • plot_title (string) – Plot title.

__eq__(other_plot_info)

PlotInfo comparison method

Parameters

other_plot_info (PlotInfo) – plot info object to compare to:

__unicode__()

String representation of the instance

galactica_validity_check(**kwargs)

Perform validity checks on this instance and eventually log warning messages.

Parameters

kwargs (dict) – keyword arguments (optional)

property plot_type

Returns the plot type (PlotType). Cannot be edited.

set_data(xaxis_values, yaxis_values, values=None)

Set plot data arrays.

Parameters
  • xaxis_values (numpy.ndarray) – x-axis coordinate array

  • yaxis_values (numpy.ndarray) – TODO

  • values (numpy.ndarray) – TODO

property title

Plot title. Can be set to any string value.

property values

Plot values array. Cannot be edited. Implements lazy I/O.

Note

To edit plot values, see PlotInfo.set_data() method.

property values_label

plot values label. Can be set to any string value.

property values_log_scale

value log scale boolean flag. Can be edited to any bool value.

property values_unit

TODO

property xaxis_log_scale

x-axis log scale boolean flag. Can be edited to any bool value.

property xaxis_unit

TODO

property xaxis_values

Plot x-axis coordinate array (numpy.ndarray). Cannot be edited. Implements lazy I/O.

Note

To edit plot values, see PlotInfo.set_data() method.

property xlabel

x-axis label. Can be set to any string value.

property yaxis_log_scale

y-axis log scale boolean flag. Can be edited to any bool value.

property yaxis_unit

TODO

property yaxis_values

Plot y-axis coordinate array (numpy.ndarray). Cannot be edited. Implements lazy I/O.

Note

To edit plot values, see PlotInfo.set_data() method.

property ylabel

y-axis label. Can be set to any string value.