Two libraries support the writing/reading of data "slices" to/from full (and potentially larger) images. libDRMS provides drms_segment_writeslice() and drms_segment_readslice(). drms_segment_writeslice() takes an output data array and two vectors as input. The data array contains the slice that will be written into a region of the full image. The two vectors, each with a rank that matches 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. drms_segment_readslice() also takes two vectors as input that also specify a bounding box the 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.

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 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: