write_Spectrum: Write spectrum files to disk

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/write_Spectrum.R

Description

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

Usage

1
2
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.

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.

Value

Write files to the disk, no further output provided.

Author(s)

Christoph Burow, University of Cologne (Germany)

See Also

writeBin, write.table

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## 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 = ",")

## End(Not run)

tzerk/ESR documentation built on May 20, 2019, 1:12 p.m.