Main Page   Data Structures   File List   Data Fields   Globals  

umtzlib.h File Reference

The micro-mtz low-level library. More...

#include <math.h>
#include "library.h"

Go to the source code of this file.

Data Structures

struct  umtz_bat_
struct  umtz_hdr_
struct  umtz_list_
struct  umtzfile_

Defines

#define MTZRECLEN   80
#define MTZBATCHR   (3*MTZRECLEN)
#define MTZBATINT   29
#define MTZBATFLT   156
#define MTZBATLEN   ( MTZBATCHR + 4*(MTZBATINT+MTZBATFLT) )
#define MTZDATAOFF   20

Typedefs

typedef struct umtz_hdr_  umtz_hdr
typedef struct umtz_bat_  umtz_bat
typedef struct umtz_list_  umtz_list
typedef struct umtzfile_  umtzfile

Functions

umtzfileumtz_open (const char *filename, const char *mode)
void umtz_close (umtzfile *file)
int umtz_num_cols (const umtzfile *file)
int umtz_num_rows (const umtzfile *file)
int umtz_num_head (const umtzfile *file)
int umtz_num_hist (const umtzfile *file)
float umtz_mnf (const umtzfile *file)
int umtz_ismnf (const umtzfile *file, float f)
umtz_hdrumtz_first_head (const umtzfile *file)
umtz_hdrumtz_first_hist (const umtzfile *file)
umtz_batumtz_first_bats (const umtzfile *file)
umtz_hdrumtz_last_head (const umtzfile *file)
umtz_hdrumtz_last_hist (const umtzfile *file)
umtz_batumtz_last_bats (const umtzfile *file)
int umtz_keymatch (const char *hdr, const char *key)
void umtz_add_head (umtzfile *file, const char *hdr)
void umtz_add_hist (umtzfile *file, const char *hdr)
void umtz_add_bats (umtzfile *file, const char *cdata, const int *idata, const float *fdata)
void umtz_seek_row (const umtzfile *file, const int n)
void umtz_get_row (const umtzfile *file, float *fdata)
void umtz_add_row (umtzfile *file, const float *fdata)
void umtz_get_cell (const umtzfile *file, const int ixtl, float *cell)
void umtz_cell_metric (const float *cell, float *metric)
int umtz_num_head_type (const umtzfile *file, char *head)
void umtz_make_rec (umtz_list *l, const int rec_len)
void umtz_copy_pad (char *d, const char *s, const int rec_len)
void umtz_rewrite_headers_ranges (umtzfile *file)
void umtz_rewrite_headers_legacy (umtzfile *file)


Detailed Description

The micro-mtz low-level library.

This is a low-level library for accessing the MTZ file format. It is not generally called by applications, but rather provides a basis for higher level libraries such as mmtzlib.


Define Documentation

#define MTZBATCHR   (3*MTZRECLEN)
 

chars in MTZ batch record.

#define MTZBATFLT   156
 

floats in MTZ batch record.

#define MTZBATINT   29
 

ints in MTZ batch record.

#define MTZBATLEN   ( MTZBATCHR + 4*(MTZBATINT+MTZBATFLT) )
 

Length of MTZ batch record.

#define MTZDATAOFF   20
 

Offset to start of binary data

#define MTZRECLEN   80
 

Length of an MTZ header record.


Typedef Documentation

typedef struct umtz_bat_ umtz_bat
 

typedef struct umtz_hdr_ umtz_hdr
 

typedef struct umtz_list_ umtz_list
 

typedef struct umtzfile_ umtzfile
 


Function Documentation

void umtz_add_bats ( umtzfile * file,
const char * cdata,
const int * idata,
const float * fdata )
 

Add a batch record.

The MTZBATS header is supplied automatically.

Parameters:
file   The file to be operated upon.
cdata   The character data array. This contains 120 characters and must be padded with space. THe first 80 characters contain the HD
idata   The integer data array.
fdata   The floating point data array.

void umtz_add_head ( umtzfile * file,
const char * hdr )
 

Add a header to the list of header records.

This is only possible before any reflections have been written to the file, since a header may change the number of solumns in the file. Only the headers 'COLUMN' and 'VALM' are actually understood by this function, incrementing the number of columns and seting the missing number flag respectively. Terminal headers ( END, MTZENDOFHEADERS ) are generated automatically and should not be added.

Parameters:
file   The file to be operated upon.
hdr   The header to be added. Only the first 80 characters will be used. Shorter strings will be padded with spaces.

void umtz_add_hist ( umtzfile * file,
const char * hdr )
 

Add a history entry.

The MTZHIST header is supplied automatically.

Parameters:
file   The file to be operated upon.
hdr   The history entry to be added. Only the first 80 characters will be used. Shorter strings will be padded with spaces.

void umtz_add_row ( umtzfile * file,
const float * fdata )
 

Add a row to the file.

The data contains raw floats, missing values should already be set to umtz_mnf().

Parameters:
file   The file to be operated upon.

void umtz_cell_metric ( const float * cell,
float * metric )
 

Get the reciprocal space matric tensor for a given cell.

This is used to calculate 1/resol^2 from the Miller indices using:

 s = h*h*metric[0] + k*k*metric[1] + l*l*metric[2]
   + h*k*metric[3] + h*l*metric[4] + k*l*metric[5];
Parameters:
cell   The unit cell, float[6]
metric   The metric tensor, float[6]

void umtz_close ( umtzfile * file )
 

Close an MTZ file and write the headers.

An MTZ file which is opened for writing but not closed will be corrupted.

Parameters:
file   The file to be operated upon.

void umtz_copy_pad ( char * d,
const char * s,
const int rec_len )
 

For internal use only.

umtz_bat * umtz_first_bats ( const umtzfile * file )
 

Return a pointer to the first batch record.

Parameters:
file   The file to be operated upon.

umtz_hdr * umtz_first_head ( const umtzfile * file )
 

Return a pointer to the first header.

To access the n'th header, use umtz_first_head(file)[n].

Parameters:
file   The file to be operated upon.

umtz_hdr * umtz_first_hist ( const umtzfile * file )
 

Return a pointer to the first history entry.

To access the n'th history entry, use umtz_first_head(file)[n].

Parameters:
file   The file to be operated upon.

void umtz_get_cell ( const umtzfile * file,
const int ixtl,
float * cell )
 

Get the cell for dataset i, or if no datasets are present, the base cell.

If i is zero, the base cell is returned.

Parameters:
file   The file to be operated upon.
ixtl   The dataset number, or zero.
cell   The unit cell, float[6]

void umtz_get_row ( const umtzfile * file,
float * fdata )
 

Get a row from the file.

The result contains raw floats, missing number flags are not processed at this stage.

Parameters:
file   The file to be operated upon.

int umtz_ismnf ( const umtzfile * file,
float f )
 

Test whether f is a missing number flag, according to the file.

Parameters:
file   The file to be operated upon.
f   The float to be tested.

int umtz_keymatch ( const char * hdr,
const char * key )
 

Test if the string hdr starts with the keyword key.

Parameters:
hdr   The string to be tested.
key   The keyword to be matched.

umtz_bat * umtz_last_bats ( const umtzfile * file )
 

Return a pointer to the space after the last batch record.

See umtz_last_head().

Parameters:
file   The file to be operated upon.

umtz_hdr * umtz_last_head ( const umtzfile * file )
 

Return a pointer to the space after the last header.

To loop over headers use

umtz_hdr* ptr;
for ( ptr = umtz_first_head(file); ptr != umtz_last_head(file); ptr++ )
Parameters:
file   The file to be operated upon.

umtz_hdr * umtz_last_hist ( const umtzfile * file )
 

Return a pointer to the space after the last history entry.

See umtz_last_head().

Parameters:
file   The file to be operated upon.

void umtz_make_rec ( umtz_list * l,
const int rec_len )
 

For internal use only.

float umtz_mnf ( const umtzfile * file )
 

Return the value of the missing number flag for this file.

If ccp4_isnan(umtz_mnf(file)), then the missing number flag for this file is NaN. Note however that comparing a value from the file to umtz_mnf() is not valid in such a case. Use umtz_ismnf() instead.

Parameters:
file   The file to be operated upon.

int umtz_num_cols ( const umtzfile * file )
 

Return the number of data columns in the file.

Parameters:
file   The file to be operated upon.

int umtz_num_head ( const umtzfile * file )
 

Return the number of headers in the file.

Parameters:
file   The file to be operated upon.

int umtz_num_head_type ( const umtzfile * file,
char * head )
 

Count the number of headers beginning with a particular keyword.

Parameters:
file   The file to be operated upon.

int umtz_num_hist ( const umtzfile * file )
 

Return the number of history entries in the file.

Parameters:
file   The file to be operated upon.

int umtz_num_rows ( const umtzfile * file )
 

Return the number of reflections in the file.

Parameters:
file   The file to be operated upon.

umtzfile * umtz_open ( const char * filename,
const char * mode )
 

Open an mtz file for reading or writing.

Parameters:
filaname   The filename (pathname) of the file to be opened.
mode   The mode. If the frist character is 'r', then the file will be read. If it is 'w' the file will be written.

void umtz_rewrite_headers_legacy ( umtzfile * file )
 

For internal use only.

void umtz_rewrite_headers_ranges ( umtzfile * file )
 

For internal use only.

void umtz_seek_row ( const umtzfile * file,
const int n )
 

Skip to the (n-1)'th reflection in the file.

The first record is zero.

Parameters:
file   The file to be operated upon.
n   The record to seek.


Generated at Fri Dec 14 11:37:56 2001 by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001