LALSimulation  5.4.0.1-fe68b98
LALSimReadData.h File Reference

Prototypes

LALFILE * XLALSimReadDataFileOpen (const char *fname)
 Opens a specified data file, searching default path if necessary. More...
 
size_t XLALSimReadDataFile2Col (double **xdat, double **ydat, LALFILE *fp)
 Read a two-column data file. More...
 
size_t XLALSimReadDataFileNCol (double **data, size_t *ncol, LALFILE *fp)
 Read a multi-column data file. More...
 

Go to the source code of this file.

Function Documentation

◆ XLALSimReadDataFileOpen()

LALFILE* XLALSimReadDataFileOpen ( const char fname)

Opens a specified data file, searching default path if necessary.

Opens a data file for input with a specified path name. If the path name is an absolute path then this specific file is opened; otherwise, search for the file in paths given in the environment variable LAL_DATA_PATH, and finally search in the installed PKG_DATA_DIR path.

Parameters
[in]fnameThe path of the file to open.
Returns
A pointer to a LALFILE structure or NULL on failure.

Definition at line 59 of file LALSimReadData.c.

◆ XLALSimReadDataFile2Col()

size_t XLALSimReadDataFile2Col ( double **  xdat,
double **  ydat,
LALFILE *  fp 
)

Read a two-column data file.

Read a data file containing two whitespace separated columns of data and create two arrays containing the data in each column. If any line begins with the character '#' then it is ignored.

Parameters
[out]xdatThe x-data stored in the first column.
[out]ydatThe y-data stored in the second column.
fpPointer to a LALFILE structure opened for input.
Returns
The number of data points read or <0 if an error occurs.

Definition at line 84 of file LALSimReadData.c.

◆ XLALSimReadDataFileNCol()

size_t XLALSimReadDataFileNCol ( double **  data,
size_t *  ncol,
LALFILE *  fp 
)

Read a multi-column data file.

Read a data file containing multiple whitespace separated columns of data and create an array containing the data. If any line begins with the character '#' then it is ignored. The data is stored in the array in row-major format so that the data sample on row i (beginning with zero) and column j (beginning with zero) is found as the element [i * ncol + j] where ncol is the number of columns.

Parameters
[out]dataThe data stored in row-major order.
[out]ncolThe number of columns in the data file.
fpPointer to a LALFILE structure opened for input.
Returns
The number of rows read or (size_t)(-1) if an error occurs.

Definition at line 133 of file LALSimReadData.c.