write

From DavinciWiki
Jump to: navigation, search


Description

Save data to a file

Arguments and Return Values

Arguments: A data object, a filename and a file type.

Return Value: None. A file is written.

Usage

Syntax: write(object = VAL, filename = STRING, type = TYPE [, force = 1, separator = STRING, header = 0])

The write() function copies data to a file. The value of type specifies the type of file written, and is one of:

  • specpr - SpecPR
  • vicar - Vicar grayscale
  • grd - USGS Grid
  • pgm - Pbmplus 8-bit grayscale
  • ppm - Pbmplus 24-bit true-color
  • isis - PDS/ISIS
  • ascii - Columnar ascii matrix
  • imath - Imath format
  • ers - ER Mapper Raster
  • gif - Compuserve GIF format
  • tiff - Tagged Image File Format
  • jpeg - Joint Photographic Experts Group
  • png - Portable Network Graphics
  • bmp - Microsoft Bitmap
  • raw - Binary output, no header
  • hdf - HDF
  • csv - Comma Separated Value

If the force keyword is included, then any existing file of the same name is overwritten. Without this keyword, the write is aborted if the filename already exists.

Notes:

The standard graphics formats (GIF, TIFF, JPEG, PNG, BMP, PPM), all expect either 1 or 3 band, byte images. A 3-band image is interpreted to be a red band, a green band and a blue band.

The PGM and GRD formats can not handle multiplane data.

The ERS format produces two files, one named "path", containing the raw raster data, and another named "path.ers", containing the ERS header. This is the standard for ERS files.

The CSV format defaults to tab, "\t", as the separator if none is specified. If optional parameter header is 1, a header row will be printed as the first row, using davinci structure field names, if available. Otherwise davinci generates generic column names following the pattern "col_n". This format only supports single plane data in BSQ organization.

save() is an alias for write().

Examples

dv> a
100x100x1 array of float, bsq format [40,000 bytes]

dv> write(a,"test.cub",vicar,force=1)

dv> a = unpack("Iu2i3u4r4x51", "strmulttest.dat", 0, col_names=names)
struct, 5 elements
   name1: 1x10x1 array of short, bsq format [20 bytes]
   name2: 1x10x1 array of int, bsq format [40 bytes]
   name3: 1x10x1 array of int, bsq format [40 bytes]
   name4: 1x10x1 array of double, bsq format [80 bytes]
   name5: 1x10x1 array of float, bsq format [40 bytes]
dv> write(a, "csv_example.csv", csv, force=0, separator="\t", header=1)

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Related Functions

Recent Core Changes

Modified On: 12-23-2010

Personal tools