read_spectra_from_config_file - Reads spectra from a config file


#include "s/s_io.h"

Example compile flags (system dependent):
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 

int read_spectra_from_config_file
	Spectra **result_sp_ptr,
	const char *env_var,
	const char *directory,
	const char *file_name,
	const char *message_name,
	char *config_file_name,
	size_t config_file_name_size


This routine reads spectra from a configuration file, checking several possible locations for the file. If the parameter "env_var" is not NULL, then it first tries using this string as the configuration file name. Next it looks for "file_name" in the current directory, then the user's home directory, and, depending on how the library was built, then the "shared" home directory and/or the programmer's home directory. If "directory" is not NULL, then it is used as a sub-directory in all paths starting from a home directory (i.e., all paths except the current directory). The parameter message_name can be used to specify a name for the configuration file to be used in error and verbose output messages. If message_name is NULL, then "configuration" is used. If the buffer config_file_name is not NULL, then the file name actually used is copied into it. If it is used, then its size must be passed in via config_file_name_size;


Either NO_ERROR, or ERROR, with an appropriate error message being set.


Suppose directory is "x" and file_name is "y". Also supposed that the shared directory is "~iis" (compiled in constant) and the programmer's directory is "~kobus" (another compiled in constant). Then the following files are tried in the order listed.
The file name actually used is put into the buffer config_file_name whose size must be passed in via max_len; The spectra *result_sp_ptr is created or resized as necessary. If file_name is the special name "off" (or "none" or "0"), then the above does not apply. In this case, *result_sp_ptr is freed and set to NULL.


Spectra is plural! This routine will read as many spectra from the file as there are. Normally the file is in Kobus's spectra file format which has a line including the number for intervals, the interval size, and the first interval wavelength in nano-meterst. If no such line is present, then the values for the PhotoResearch PR-650 are used which is equivalent to having the following header:
            #! t=s n=101 o=380 s=4
(Note that the "#" is resettable by the user option "comment-char", and the "!" is resettable by the user option "header-char").


This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.


Kobus Barnard


Kobus Barnard


read_reflectance_spectra , read_illuminant_spectra , read_sensor_spectra , read_spectra , read_spectra_file_header , fp_read_spectra_file_header , write_spectra_full_precision , fp_write_spectra_full_precision , write_spectra , fp_write_spectra , fp_write_spectra_file_header