I/O

Read and write spin configurations, chains or eigenmodes. Vectorfields are generally written in the OOMMF vector field (OVF) file format.

Note that, when reading an image or chain from file, the file will automatically be tested for an OVF header. If it cannot be identified as OVF, it will be tried to be read as three plain text columns (Sx Sy Sz).

Note also, IO is still being re-written and only OVF will be supported as output format.

spirit.io.FILEFORMAT_OVF_BIN = 0

OVF binary format corresponding to the precision with which the code was compiled

spirit.io.FILEFORMAT_OVF_BIN4 = 1

OVF binary format with precision 4

spirit.io.FILEFORMAT_OVF_BIN8 = 2

OVF binary format with precision 8

spirit.io.FILEFORMAT_OVF_CSV = 4

OVF text format with comma-separated columns

spirit.io.FILEFORMAT_OVF_TEXT = 3

OVF text format

spirit.io.chain_append(p_state, filename, fileformat=3, comment='', idx_chain=-1)

Append a chain of images to a given file.

If the file does not exist, it is created.

Arguments:

  • p_state: state pointer
  • filename: the name of the file to append to

Keyword arguments:

  • fileformat: the format in which to write the data (default: OVF text)
  • comment: a comment string to be inserted in the header (default: empty)
spirit.io.chain_read(p_state, filename, starting_image=0, ending_image=-1, insert_idx=-1, idx_chain=-1)

Attempt to read a chain of images from a given file.

Arguments:

  • p_state: state pointer
  • filename: the name of the file to read

Keyword arguments:

  • starting_image: the index within the file at which to start reading (default: 0)
  • ending_image: the index within the file at which to stop reading (default: -1, meaning the entire file)
  • insert_idx: the index within the chain at which to start placing the images (default: active image)

Images of the chain will be overwritten with what is read from the file. If the chain is not long enough for the number of images to be read, it is automatically set to the right length.

spirit.io.chain_write(p_state, filename, fileformat=3, comment='', idx_chain=-1)

Write a chain of images to a file.

Arguments:

  • p_state: state pointer
  • filename: the name of the file to write

Keyword arguments:

  • fileformat: the format in which to write the data (default: OVF text)
  • comment: a comment string to be inserted in the header (default: empty)
spirit.io.eigenmodes_read(p_state, filename, fileformat=3, idx_image_inchain=-1, idx_chain=-1)

Read the vector fields from a file as a set of eigenmodes for the spin system.

spirit.io.eigenmodes_write(p_state, filename, fileformat=3, comment='', idx_image=-1, idx_chain=-1)

Write the eigenmodes of a spin system to file, if they have been already calculated.

spirit.io.image_append(p_state, filename, fileformat=3, comment='', idx_image=-1, idx_chain=-1)

Append an image of the chain to a file, incrementing the segment count.

If the file does not exist, it is created.

Arguments:

  • p_state: state pointer
  • filename: the name of the file to append to

Keyword arguments:

  • fileformat: the format in which to write the data (default: OVF text)
  • comment: a comment string to be inserted in the header (default: empty)
  • idx_image: the index of the image to be written to the file (default: active image)
spirit.io.image_read(p_state, filename, idx_image_infile=0, idx_image_inchain=-1, idx_chain=-1)

Attempt to read a spin configuration from a file into an image of the chain.

Arguments:

  • p_state: state pointer
  • filename: the name of the file to read

Keyword arguments:

  • idx_image_infile: the index of the image in the file which should be read in (default: 0)
  • idx_image_inchain: the index of the image in the chain into which the data should be read (default: active image)
spirit.io.image_write(p_state, filename, fileformat=3, comment='', idx_image=-1, idx_chain=-1)

Write an image of the chain to a file.

Arguments:

  • p_state: state pointer
  • filename: the name of the file to write

Keyword arguments:

  • fileformat: the format in which to write the data (default: OVF text)
  • comment: a comment string to be inserted in the header (default: empty)
  • idx_image: the index of the image to be written to the file (default: active image)
spirit.io.image_write_energy_per_spin(p_state, filename, fileformat=3, idx_image=-1, idx_chain=-1)

Write the energies per spin to a file.

Arguments:

  • p_state: state pointer
  • filename: the name of the file to append to

Keyword arguments

  • fileformat: the format in which to write the data (default: OVF text)
spirit.io.n_images_in_file(p_state, filename, idx_image_inchain=-1, idx_chain=-1)

Returns the number of segments or images in a given file.

Arguments:

  • p_state: state pointer
  • filename: the name of the file to check