dplR (version 1.7.6)

write.tucson: Write Tucson Format Chronology File

Description

This function writes a chronology to a Tucson (decadal) format file.

Usage

write.tucson(rwl.df, fname, header = NULL, append = FALSE,
             prec = 0.01, mapping.fname = "", mapping.append = FALSE,
             long.names = FALSE, ...)

Value

fname

Arguments

rwl.df

a data.frame containing tree-ring ring widths with the series in columns and the years as rows. The series IDs are the column names and the years are the row names. This type of data.frame is produced by read.rwl and read.compact.

fname

a character vector giving the file name of the rwl file.

header

a list giving information for the header of the file. If NULL then no header information will be written.

append

logical flag indicating whether to append this chronology to an existing file. The default is to create a new file.

prec

numeric indicating the precision of the output file. This must be equal to either 0.01 or 0.001 (units are in mm).

mapping.fname

a character vector of length one giving the file name of an optional output file showing the mapping between input and output series IDs. The mapping is only printed for those IDs that are transformed. An empty name (the default) disables output.

mapping.append

logical flag indicating whether to append the description of the altered series IDs to an existing file. The default is to create a new file.

long.names

logical flag indicating whether to allow long series IDs (7 or 8 characters) to be written to the output. The default is to only allow 6 characters.

...

Unknown arguments are accepted but not used.

Author

Andy Bunn. Patched and improved by Mikko Korpela.

Details

This writes a standard rwl file as defined according to the standards of the ITRDB at https://www1.ncdc.noaa.gov/pub/data/paleo/treering/treeinfo.txt. This is the decadal or Tucson format. It is an ASCII file and machine readable by the standard dendrochronology programs. Header information for the rwl can be written according to the International Tree Ring Data Bank (ITRDB) standard. The header standard is not very reliable however and should be thought of as experimental here. Do not try to write headers using dplR to submit to the ITRDB. When submitting to the ITRDB, you can enter the metadata via their website. If you insist however, the header information is given as a list and must be formatted with the following:

DescriptionNameClassMax Width
Site IDsite.idcharacter5
Site Namesite.namecharacter52
Species Codespp.codecharacter4
State or Countrystate.countrycharacter13
Speciessppcharacter18
Elevationelevcharacter5
Latitudelatcharacter or numeric5
Longitudelongcharacter or numeric5
First Yearfirst.yrcharacter or numeric4
Last Yearlast.yrcharacter or numeric4
Lead Investigatorlead.invscharacter63
Completion Datecomp.datecharacter8

See examples for a correctly formatted header list. If the width of the fields is less than the max width, then the fields will be padded to the right length when written. Note that lat and long are really lat * 100 or long * 100 and given as integral values. E.g., 37 degrees 30 minutes would be given as 3750.

Series can be appended to the bottom of an existing file with a second call to write.tucson. The output from this file is suitable for publication on the ITRDB.

The function is capable of altering excessively long and/or duplicate series IDs to fit the Tucson specification. Additionally, characters other than numbers or English letters will be removed. If series IDs are changed, one or more warnings are shown. In that case, the user may wish to print a list of the renamings (see Arguments).

Setting long.names = TRUE allows series IDs to be 8 characters long, or 7 in case there are year numbers using 5 characters. Note that in the latter case the limit of 7 characters applies to all IDs, not just the one corresponding to the series with long year numbers. The default (long.names = FALSE) is to allow 6 characters. Long IDs may cause incompatibility with other software.

See Also

write.crn, read.tucson, write.rwl, write.compact, write.tridas

Examples

Run this code
library(utils)
data(co021)
co021.hdr <- list(site.id = "CO021",
                  site.name = "SCHULMAN OLD TREE NO. 1, MESA VERDE",
                  spp.code = "PSME", state.country = "COLORADO",
                  spp = "DOUGLAS FIR", elev = "2103M", lat = 3712,
                  long = -10830, first.yr = 1400, last.yr = 1963,
                  lead.invs = "E. SCHULMAN", comp.date = "")
fname <- write.tucson(rwl.df = co021, fname = tempfile(fileext=".rwl"),
                      header = co021.hdr, append = FALSE, prec = 0.001)
print(fname) # tempfile used for output

unlink(fname) # remove the file

Run the code above in your browser using DataLab