yt.utilities.grid_data_format.writer module

Writing yt data to a GDF file.

yt.utilities.grid_data_format.writer.save_field(ds, fields, field_parameters=None)[source]

Write a single field associated with the dataset ds to the backup file.

  • ds (Dataset object) – The yt dataset that the field is associated with.
  • fields (field of list of fields) – The name(s) of the field(s) to save.
  • field_parameters (dictionary) – A dictionary of field parameters to set.
yt.utilities.grid_data_format.writer.write_to_gdf(ds, gdf_path, fields=None, data_author=None, data_comment=None, dataset_units=None, particle_type_name='dark_matter', overwrite=False, **kwargs)[source]

Write a dataset to the given path in the Grid Data Format.

  • ds (Dataset object) – The yt data to write out.
  • gdf_path (string) – The path of the file to output.
  • fields – The field or list of fields to write out. If None, defaults to ds.field_list.
  • data_author (string, optional) – The name of the author who wrote the data. Default: None.
  • data_comment (string, optional) – A descriptive comment. Default: None.
  • dataset_units (dictionary, optional) –

    A dictionary of (value, unit) tuples to set the default units of the dataset. Keys can be:

    • “length_unit”
    • “time_unit”
    • “mass_unit”
    • “velocity_unit”
    • “magnetic_unit”

    If not specified, these will carry over from the parent dataset.

  • particle_type_name (string, optional) – The particle type of the particles in the dataset. Default: “dark_matter”
  • overwrite (boolean, optional) – Whether or not to overwrite an already existing file. If False, attempting to overwrite an existing file will result in an exception.


>>> dataset_units = {"length_unit":(1.0,"Mpc"),
...                  "time_unit":(1.0,"Myr")}
>>> write_to_gdf(ds, "clumps.h5", data_author="John ZuHone",
...              dataset_units=dataset_units,
...              data_comment="My Really Cool Dataset", overwrite=True)