Export ESR spectrum objects as .SPC/.PAR or .TXT files.

write_Spectrum(x, file, type = c("SPC", "TXT")[1], sep = "\t",
  gvalue = FALSE, ...)

Arguments

x

ESR.Spectrum-class (required): An object of class ESR.Spectrum that is written to the disk.

file

character (required): A character string naming a file for writing.

type

character (with default): Indicates the file type the data is exported as:

  • "SPC": (default) Binary data format as produced by the ESP300-E spectrometer. Parameters are written to a seperate .PAR file. See details about encoding.

  • "TXT": Plain text file of the spectrum's x,y-values

sep

character (with default): The field separator string. Values within each row of x are separated by this string. Only used if type = 'TXT'.

gvalue

logical (with default): Export the spectrum with g-values instead of magnetic field values. Requires all necessary information in the ESR.Spectrum object (microwave frequency, magnetic field values, center field, sweep width). Only used if type = 'TXT'.

...

currently not used.

Value

Write files to the disk, no further output provided.

Details

SPC file format

If type = 'SPC' this function will write a binary file as is produced by a Bruker ESP300-E spectrometer. These files use a big-endian byte order with 4 bytes per element in the byte stream. This format only stores integer values, so exporting a floating-point number spectrum might introduce more or less severe rounding errors. To counteract this, the function multiplies all intensity values by 1000 before exporting. This preserves relative differences in spectra, but absolute intensity values may no longer be interpreted at face value.

The measurement parameters are written to a separate <file>.PAR file with two whitespaces as field seperator and macintosh style carriage return line breaks.

See also

Examples

# NOT RUN { ## Load example data set file <- system.file("inst/extdata/quartz.DTA", package = "ESR") ## Import the file x <- read_Spectrum(file, verbose = FALSE) ## Export as ESP300-E .SPC/.PAR file set write_Spectrum(x = x, file = "~/exported.SPC", type = "SPC") ## Export as plain text write_Spectrum(x = x, file = "~/exported.txt", type = "TXT", gvalue = TRUE, sep = ",") # }