Writing and Reading Data "Slices

Two libraries support the writing/reading of data "slices" into/from full images. libDRMS provides drms_segment_writeslice(), drms_segment_readslice(), drms_fitsrw_writeslice(), drms_fitsrw_readslice(), drms_fitstas_writeslice(), and drms_fitstas_readslice(). drms_segment_writeslice() takes a data array and two vectors as input. The data array contains the slice of data that will be written into a region, identified by the vectors, of the full image. The region to be so written must lie completely within the dimensions of the full image - an error message is generated otherwise and the the function returns an error code. drms_segment_readslice() also takes two vectors as input that also specify a bounding box that lies within the full image. The function reads the data from the bounding box and returns a data array containing that data to the caller. The caller may specify a data type when calling drms_segment_readslice() - the data slice extracted from the full image will be converted to this data type before the data array is returned to the caller. Both API functions support the FITS, TAS, and FITZ data segment protocols, and drms_segment_readslice() additionally supports the BINARY and BINZIP protocols. All other protocols are currently unsupported.

drms_fitsrw_writeslice() is similar to drms_segment_writeslice(). It writes a data slice to a file containing a full image. It differs, in that it operates only on FITS files. It takes a FITS file path, a slice of data, and information that describes the dimensions of the full image as input. If the FITS file already exists, it simply writes the slice into that FITS file. If the file does not exist, it creates it (using the input dimension information) and writes the first slice into it. Similarly, drms_fitsrw_readslice() reads a slice of data from a FITS file into a data array, using input vectors to identify the location and size of the desired slice in the FITS-file image.

drms_segment_writeslice() - The data array contains the slice that will be written into a region of the full image. The two vectors, each with a number of elements equivalent to the number of dimensions of the full image, specify the location in the full image to where the slice should be written. One vector, the "start" vector, specifies the "lower-left corner" of a bounding box that resides within the full image. The other vector, the "end" vector, specifies the "upper-right corner" of the bounding box. The bounding box thus described is exactly the same size as the slice to be written - drms_segment_writeslice() will write the slice into the bounding box with the data in the slice completely "filling" the bounding box. This implies that the number of axes of the data array (slice) to be written must also be equivalent to the number of axes of the full image.

When the image to be written/read is compressed, only certain slice sizes are permitted. This restriction prevents inefficient writes and reads. The slice to be written/read must fully overlap an integral number of compression tiles. Otherwise image data that reside outside of the slice would need to be compressed/uncompressed. The restriction on slice dimensions ensures that the amount of data to be compressed/uncompressed is minimized.

When writing the first slice of a new, non-existent FITS file, a decision needs to be made about the dimensions of the final image in the new file being created. libDRMS always uses the dimension lengths in the segment's description (the segment's specification line in the series' jsd) when possible. For all non-VARDIM segment protocols, this is always the case; the segment's description must specify positive values for all dimension lengths, otherwise a failure will result. If a valid set of dimension lengths is specified, then the resulting FITS file will contain an image with those valid dimension lengths. If the segment protocol is VARDIM, however, then it is a combination of parameters in the segment's description and the output array being written that controls the dimensions of this final image:

JsocWiki: DataSlices (last edited 2013-05-01 04:35:24 by localhost)