Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   File Members  

sc Namespace Reference

Declarations of all functions and constants to handle scintillation indices. More...


Enumerations

enum  scwhat {
  HEAD, DSI, DESI, AFLUX,
  MOM
}

Functions

int napcomb (int a)
const char * apername (int nchan, int index)
 Return the name for a given index of entrance aperture or combination of apertures. More...

int ind_seqnum (int nchan, const char *name)
 Return the sequential number of index in storage by its name (ID). More...

void init (int maxndata, int maxnmeas, int nchan)
 Initialize the structures to put the scintillation indices. More...

void chan_init (int chan, double bkgr, double deadtime=-1, double nonpois=-1, count_t *data=0)
 Initialize channel data in static channel array element. More...

void compute (int ndata, int *ncorr, double microexp, bool isgen)
 Compute the normal and differential (aperture and exposure) scintillation indices. More...

int getcurmeas ()
 Get the number of measurements done in a current accumulation time. More...

void again ()
 Reset the counter of accumulated indices in local index storages. More...

void done ()
 Deallocate the memory reserved for module index storages. More...

void writeidx (FILE *f, scwhat what, const char *stamp, const char *suffix=0)
 Write the latest instant indices to the disk. More...

void avgmatrix (double **matrix, int ncol, int nrow, signed char *rowselect, signed char select, double *avg, double *err2, int lag)
 Average a matrix of values along the second dimention with row selection. More...

void average (bool isgen, int lag)
 Average scintillation indices and compute their squared errors. More...

void writeavgidx (FILE *f, scwhat what, bool isgen, const char *stamp)
 Write the average (accumulation-time related) indices on the disk. More...

void writeavgflux (FILE *f, scwhat what, bool isgen, const char *stamp, bool write_nonpois=false)
 Write the average (accumulation-time related) channel fluxes. More...

void writemom (FILE *f, scwhat what, const char *stamp, const char *suffix=0)
 Write the base-time accumulated signal moments on the disk. More...

double getidx (int meas, scwhat what, int i)
 Get the instant index value. More...

double * getidxptr (int meas, scwhat what)
 Get pointer to the array of instant scintillation indices. More...

double getavgidx (scwhat what, bool isgen, int i)
 Get the averaged index value. More...

double * getavgidxptr (scwhat what, bool isgen)
 Get pointer to the array of average scintillation indices. More...

double geter2idx (scwhat what, bool isgen, int i)
 Get the squared error of the averaged index. More...

double * geter2idxptr (scwhat what, bool isgen)
 Get pointer to the array of errors of average scintillation indices. More...

double getmean (bool iscor, int i)
 Get the mean count in the channel in [counts per ms]. More...

double getavgflux (bool isgen, int i)
 Get the average flux in the channel in [counts per ms]. More...

double geter2flux (bool isgen, int i)
 Get the squared error of average flux in channel in [(counts per ms)^2]. More...

double getsig (int lag, int i)
 Get the second moment of counts in channel in [(counts per ms)^2]. More...

void stattest (int ndata, double microexp)
 Compute the expected scintillation indices for the results of the MASS statistical test. More...

void statflux (int ndata, int *ncorr, double microexp, int k, bool isfilt=false, double *nonpois=0, double *avg=0, double *er2=0)
 Recurrence computer of average fluxes and their squared errors from the count series in channels. More...


Variables

const int DESIBIN = 3
const char IDXFMT [] = "%s%7.4f"
const char IDXDLM [] = " "
const char FLXFMT [] = "%s%7.2f"
const char FLXDLM [] = " "
const char MOMFMT [] = "%s%7.0f"
const char MOMDLM [] = "\t"
const int MODENORM = 0
const int MODEGEN = 1
const int MODENO = -1
const int MAXLAG = 0


Detailed Description

Declarations of all functions and constants to handle scintillation indices.

Enumeration Type Documentation

enum sc::scwhat
 

Enumeration of entities to access or write on the disk, to use in get...() and write...() functions.

Enumeration values:
HEAD  Head line writing
DSI  Aperture indices writing (with DESI) or access
DESI  Differential exposure indices access
AFLUX  Average flux in channels access or writing
MOM  Count moments writing


Function Documentation

void again  
 

Reset the counter of accumulated indices in local index storages.

Once the indices in the private module storages are not needed any more (averaged, displayed and saved to disk), the counter of current row in them should be reset to avoid the matrices overfill.

See also:
writeidx() average() init()

const char* apername int    nchan,
int    index
 

Return the name for a given index of entrance aperture or combination of apertures.

Parameters:
nchan  number of apertures
index  sequential number of aperture
Returns:
pointer to name if Ok, or "" if invalid index
Name of an aperture corresponds to the given index according to convention: For index=0..nchan-1: name='A','B',... (for normal indices of scintillation in a single aperture); for index=nchan: name='AB' (first combination of apertures), nchan+1: 'AC',...,'BC','BD' and so on.

This name is copied in the static character string which contains 3 characters (two for the combination and one for trailing zero) and returns the pointer to this string. Thus, if more than one call to this function is done in one statement, the result is unpredictable.

void average bool    isgen,
int    lag
 

Average scintillation indices and compute their squared errors.

Parameters:
isgen  flag that the generalized mode was used
lag  Maximal counts lag to account for the index correlation in the error of mean (MAXLAG may be set)
This utility is called normally after accumulation time span during which rows of the index matrices are computed getcurmeas() times times. It is aimed to obtain some mean value of each index or, in other words, to implement the averaging of the index storage along its time-dimension. Also, the squares of uncertainties of these indices are assessed.

The computed average indices, average shifted indices, and DESIs (both normal and shifted) are put in the global vectors, to be accessed by getavgidx() and geter2idx().

The utility avgmatrix() is used for averaging all the storages.

Note:
To the moment, the average index itself is a simple mean with no rejection; it can in principle be implemented as a mean with rejection or as a median.

void avgmatrix double **    matrix,
int    ncol,
int    nrow,
signed char *    rowselect,
signed char    select,
double *    avg,
double *    err2,
int    lag
 

Average a matrix of values along the second dimention with row selection.

Parameters:
matrix  matrix[nrow][ncol] of values to average along second dimention (i.e. to obtain an average row). Meanwhile, if ncol==1, matrix is interpreted as a vector to be averaged into one number.
ncol  number of columns in matrix[][]
nrow  number of rows in matrix[][]
rowselect  row selection vector[nrow] (set NULL to select all)
select  selection value in rowselect (no matters if rowselect==NULL )
avg  vector[ncol] of resulting average values (one value if ncol==1)
err2  vector[ncol] of resulting squared errors of avg.values (one value if ncol==1)
lag  maximal lag in correction of error for the correlation of values
The rows are selected for averaging from the storage matrix by comparison of respective values in rowselect with select up in a range of the storage row numbers [0..nrow-1]. Average value is thus derived for each column for rows with index row complying the rowselect[row]==select condition.

Errors of average values are computed corrected for correlation of values as given in Korn & Korn "Spravochnik po matematike" 4th edition, section 19.8 with lag of autocovariance up to lag:

where the is the covariance of values x with the lag k and is the dispersion of values

If a given lag is more than nrow, the maximal lag is taken as nrow-1.

See also:
average

void chan_init int    chan,
double    bkgr,
double    deadtime = -1,
double    nonpois = -1,
count_t   data = 0
 

Initialize channel data in static channel array element.

Parameters:
chan  sequential number of the channel (0,1..maxnchan-1) (see init())
bkgr  background level in [counts per units of microexp parameter in compute()]
deadtime  non-linearity parameter (the dead-time of PMT) in the same units as the microexp parameter in compute(), e.g. for [sec] it is about (20-30)*1e-9
nonpois  non-poisson factor (around unity)
data  pointer to the buffer - receiver of channel PMT counts
Returns:
0 if Ok, <0 if error
Function initializes the chan-th channel with the given parameters.
Attention:
This channel data are expected to be allocated by the call to init().
The assignment is made only if the respective parameter has a sense: non-negative for double-type parameters and non-null for the pointer. Thus, a single all-initializing call may be split into a sequence of calls which initialize (or update) some particular members (e.g., changing the non-linearity and background level in the channel) leaving the rest non-sense or default.

Note:
No memory allocation is done here for data[] array, it is only pointed to the buffer already allocated for receiving the channel counts.
See also:
init()

void compute int    ndata,
int *    ncorr,
double    microexp,
bool    isgen
 

Compute the normal and differential (aperture and exposure) scintillation indices.

Parameters:
ndata  Actual number of counts in the channel buffers (equal for all channels)
ncorr  array of numbers of corrected counts in channels (replaced with mean if missing)
microexp  Exposure time of each count (microexposure) to scale the non-linearity parameter and background in calculations (see chan_init())
isgen  Generalized mode flag
This is the main utility in the module SCIND.

The parameter ndata must not exceed the value maxndata with which the init() was called; ncorr[chan] collects the number of counts in respective channel chan which are replaced with the mean value due to the data loss in a line.

This utility computes a set of all instantaneous (i.e. determined using individual PMT counts obtained during the base time) scintillation indices (SI) which can be derived for a given number of channels. Thus, both normal and differential indices (DSI) are calculated.

The implementation of this function depends on the LOGIDX compilation option: if it's set, then the "true" calculations of variations of logarithms of counts is implemented; otherwise - the relative differential approximation is used. Here below we refer to these alternative modes of implementation as "if LOGIDX".

Calculations of scintillation indices go through the following steps:

  • compute the ``raw'' means of counts ;
  • if LOGIDX, compute logarithms of all individual counts and their means;
  • calculate the dispersions and auto-covariances (lag=1,2) of counts (or - if LOGIDX - of their logarithms) x :

    where is a number of pixels in the channel which were replaced with mean due to the loss in the line (see below);

  • calculate the cross-covariances of counts x and y of all combinations of channels with lags 0 and 1:

    Note that the second formula is symmetric;

  • if LOGIDX, denormalize the dispersions and auto-covariances: multiply them by the squared mean count and by the product of mean counts in two channels, respectively ;
  • correct dispersions, covariances and mean counts for non-linearity of PMT L=deadtime/microexp :

  • compute scintillation indices free from photon noise (using non-Poisson factors P for conversion of means into photon noise dispersion) and influence of background B=bkgr*microexp, corrected to zero-exposure: normal and cross-channel (differential):

    Here already the non-linearity corrected means, dispersions and covariances are used ;

  • compute DESI for all channels, using auto-covariances with lags 0 (i.e. dispersion), 1 and 2.

See ``Multi-Aperture Scintillation Sensor. Final design report'', Appx. C (p.87).

Note on ncorr[]:

The counts from channels sometimes miss a certain number of data due to the data loss in the line. In this case, the "data provider" is supposed to replace them with the average count in respective channel. Thus, ncorr[] is used only to correct the dispersion of counts, by decrement of the number of data in calculations.

The order of indices in which they are assigned to the elements of an output array (written to the file or exported by getidx()) is exactly the same as the order of weights in the weight matrix which is computed in the module WEIF: first normal indices, then the covariance of the first channel data with the second, with the third etc..., then the covariances of the second channel with third etc. See sc::apername() and sc::ind_seqnum().

Performance:

The test consists of calculation of scintillation indices for 4 channels including the DESI calculations for all channels. It takes:

  • In relative approximation of indices (normalized dispersion or covariance): 1.7ms at P-III 667 MHz,
  • In true logarithmic form (LOGIDX definition set): 3ms at P-III 667 MHz,
The list of features:

  • the resulting indices in scind are already corrected to zero-exposure;
  • The code assumes the background level and non-linearity parameter to be scaled to the microexposure time used for the count series. E.g. if the count (micro)exposure is 1ms, then the background level of 30 cnt/s should be set as bkrg=30*0.001=0.03; deadtime of PM of 20ns - as nonlin=20ns/0.001s=2e-5.
  • Program currently refuses to process simultaneously the count sets which have different lengths;
  • The pre-allocated arrays mean, cmean, sig are used to store the results of statistical calculations. They contain, respectively: mean counts and means corrected for non-linearity, dispersions and covariances of counts corrected for non-linearity. Note, that, the i-th element of the dispersion/covariance array addresses the same channel or combination of channels as i-th element of the scintillation index array. The global arrays r1 and r2 are also used and are accessible similarly to sig.
The results of index calculations are put in the current measurement's row (see getcurmeas()) of the local index storing matrices.

The calculations are made irrespective of isgen parameter of this function. This parameter is only saved in additional local storage to be able to disentangle the normal and generalized data while averaging the indices.

Before exiting and upon the success of calculations, the counter curmeas of the performed measurements is incremented. If the value of curmeas equals or exceeds the declared in init() maximal number maxnmeas (the length of allocated storages for indices), then the error sc::EROFL is returned and no calculation is done.

void done  
 

Deallocate the memory reserved for module index storages.

This function releases the memory which is allocated for index storages by init().

This function should be called only to end with calculations at all, since the modifications of arrays may be done by the calls to init() with no intermediate done().

Note:
This function must be kept in strict sync with init().

double getavgflux bool    isgen,
int    i
 

Get the average flux in the channel in [counts per ms].

Parameters:
isgen  "false": non-shifted average counts; "true": shifted average counts
i  index of channel [0..Nchan-1]
Returns:
average flux in channel [counts per ms]
Average fluxes are obtained in average().

See notes to getidx().

double getavgidx scwhat    what,
bool    isgen,
int    i
 

Get the averaged index value.

Parameters:
what  DSI: for usual index, DESI: for DESI
isgen  0 for array of non-shifted average indices; 1 for shifted indices
i  index of channel or combination of channels [0..napcomb()-1]
Returns:
averaged index value or some bad numeber on error
The call with isgen==true is only possible if generalized mode was used during the last accumulation time.

See also:
getidx()

double* getavgidxptr scwhat    what,
bool    isgen
 

Get pointer to the array of average scintillation indices.

Parameters:
what  DSI: for usual index, DESI: for DESI
isgen  "false" for array of non-shifted average indices; "true" for shifted indices
Returns:
pointer to the array of the average indices or to some bad number on error
This function is needed for atm::calcn2().
See also:
geter2idx()

int getcurmeas  
 

Get the number of measurements done in a current accumulation time.

Returns:
measurement number
Example: if again() was just used, the function will return "0" since no measurement were done up to now.

double geter2flux bool    isgen,
int    i
 

Get the squared error of average flux in channel in [(counts per ms)^2].

Parameters:
isgen  "false": non-shifted average counts; "true": shifted average counts
i  index of channel [0..Nchan-1]
Returns:
squared error of average flux in channel [counts per ms]
Average fluxes are obtained in average(). The value is quaranteed to be non-negative.

See notes to getidx().

double geter2idx scwhat    what,
bool    isgen,
int    i
 

Get the squared error of the averaged index.

Parameters:
what  DSI: for usual index, DESI: for DESI
isgen  "false" for array of non-shifted average indices; "true" for shifted indices
i  index of channel or combination of channels [0..napcomb()-1]
Returns:
squared error of the average index or some bad number on error
The value is quaranteed to be non-negative.
See also:
getavgidx()

double* geter2idxptr scwhat    what,
bool    isgen
 

Get pointer to the array of errors of average scintillation indices.

Parameters:
what  DSI: for usual index, DESI: for DESI
isgen  "false" for array of non-shifted average indices; "true" for shifted indices
Returns:
pointer to the array of the errors of average indices or to some bad number on error
This function is needed for atm::calcn2().
See also:
geter2idx()

double getidx int    meas,
scwhat    what,
int    i
 

Get the instant index value.

Parameters:
meas  Measurement (row number of the index matrix)
what  0 for usual index, 1 for DESI
i  index of channel or combination of channels [0..napcomb()-1]
Returns:
the index or some bad number on error
One may use getcurmeas()-1 for the parameter meas, to return the last obtained measurement result. Indices are ordered in the returned vector as specified in apername() documentation; the length of vector is napcomb(Nchannel) or Nchannel for what==1 (i.e. DESI).

double* getidxptr int    meas,
scwhat    what
 

Get pointer to the array of instant scintillation indices.

Parameters:
meas  Measurement (row number of the index matrix)
what  DSI: for usual index, DESI: for DESI
Returns:
pointer to the array of indices or to some bad number on error
This function is needed for atm::calcint()
See also:
geter2idx()

double getmean bool    iscor,
int    i
 

Get the mean count in the channel in [counts per ms].

Parameters:
iscor  "false": return the raw mean; "true": return the non-linearity corrected mean
i  index of channel [0..Nchan-1]
Returns:
mean count in channel during the last base time [counts per ms]

double getsig int    lag,
int    i
 

Get the second moment of counts in channel in [(counts per ms)^2].

Parameters:
lag  0: simple dispersion (index<Nchannel) or covariance of counts (for returned array index more or equal to Nchannel); 1,2: the same with lag=1,2 counts
i  index of channel or combination of channels [0..napcomb()-1]
Returns:
the moment value (dispersion or auto/cross-covariance)

int ind_seqnum int    nchan,
const char *    name
 

Return the sequential number of index in storage by its name (ID).

Parameters:
nchan  number of channels
name  ID of an aperture or the combination of apertures (e.g. "B" or "AD")
Returns:
sequential number in range [0..napcomb()-1] or -1 on error (error is set with nr::nrerror() then)
This function is needed to access certain indices with getidx(), getavgidx() and geter2idx() to compute their last parameter by the index "name".

See also:
apername()

void init int    maxndata,
int    maxnmeas,
int    nchan
 

Initialize the structures to put the scintillation indices.

Parameters:
maxndata  Maximal expected number of counts in base time series (one simultaneous measurement of nchan channels)
maxnmeas  Maximal expected number of measurements (accum.time/base.time) to keep in the storage
nchan  Number of channels (entrance apertures)
The module contains the global arrays which keep the normal, differential aperture and differential exposure indices computed for all apertures. These are the matrices in which the rows contain the simultaneously obtained indices for one particular base time.

For the sake of a simple code structure, some intermediate data processing is done in advance to calculation of indices itself. For this and for acceleration of logarithmic indices derivation, some work arrays are also allocated.

The dimentions of allocated arrays are determined by the numbers maxndata, maxnmeas and nchan which are copied in global variables which are private to the module. Another private global variable counts the performed index calculations and initialized to zero here. The number of counts in any subsequent base-time series should not exceed the value of the parameter maxndata; the same for the measurements number (base times per accumulation time) which should not exceed the parameter maxnmeas.

This function should be called, obviously, before the first calculation of indices.

Attention:
In addition to init() call, ALL the members of (private to module) channel parameter structures should be initialized by nchan calls to chan_init() made after the call to init().
If the parameters specify the storage dimentions which are less than that which were previously allocated, the storages are left unchanged.

Note:
This function must be kept in strict sync with compute().
See also:
chan_init() compute() done()

int napcomb int    a [inline]
 

Formula to get a Number of entrance apertures and their non-redundant combinations having a apertures

void statflux int    ndata,
int *    ncorr,
double    microexp,
int    k,
bool    isfilt = false,
double *    nonpois = 0,
double *    avg = 0,
double *    er2 = 0
 

Recurrence computer of average fluxes and their squared errors from the count series in channels.

Parameters:
ndata  Actual number of counts in the count series stored in the channel buffers (equal for all channels)
ncorr  array of numbers of corrected counts in series (i.e. replaced with mean of series if missing)
microexp  Exposure time of each count (microexposure) to scale the non-linearity parameter and fluxes in calculations (see chan_init())
k  sequential number of current channel series in the measurement session (i.e. this call is k-th to measure the statistics stored in avg and er2)
isfilt  To account for the long-term modulation of the signal (clouds, etc.) in dispersion sig
nonpois  non-Poisson parameters array[0..Nchan-1], by default - not computed
avgflux  Average flux array[0..Nchan-1], by default - the local storage accessible with getavgflux()
er2flux  Squared error of flux: array[0..Nchan-1], by default - the local storage accessible with geter2flux()
This is a third utility (after compute() and stattest()) which deals with the channel data series. It is suited for calculation of the average flux in a channel and its error. Counts are assumed to be non-correlated, so the squared error of average is k*ndata times less than the count dispersion.

The results are put in the global module storage of average fluxes (or other place if last parameters are not defaulted) or updated there on calls with k>1 (see below). They are permanently available with functions getavgflux() and geter2flux() after the first call with k=1 (unless the parameters avgflux and sigflux are specified explicitly). It is assumed that the storages for average flux and its dispersion are allocated with init().

For any call to the function, the average count and its dispersion are computed like follows (hereafter n stays for ndata parameter value):

Here all the counts in channels are already corrected for non-linearity individually using the channel parameter deadtime initialized by chan_init():

Note:
The deadtime-parameter must be set to zero in chan_init() before making statflux() for determination of the non-linearity of detectors itself. It should be noticed also that the background level in channels is ignored (assumed zero).
This utility may be used either as a plain average and its error computer or as a tool for calculation of the statictics of a long series consisting of multiple data pieces (base-time series). In both instances, the first call to the utility must have k=1. If so, the average flux values and their errors in flux storages are assumed to contain no information about the previous data series. Then they are assigned from the average count and its dispersion like follows:

that means that we express the average flux and its error in [counts per unity of microexposure].

When one wishes to obtain the statistics of a continued series of counts (base-times of the same accumulation time, i.e. with the same source of the signal), the values avgflux and er2flux are back-converted into the non-normalized counts avgcount and their dispersion er2count and updated for each consequent k-th array data (k>1) like follows:

where the correction of the dispersion for the low-frequency modulation of the average count is computed and added if isfilt==false. Note, that k must be incremented by user.

If the parameter nonpois is not null, then the estimate of the non-poissonity of the detector is computed for each channel as:

Before exiting the function, the updated parameters are again converted into the flux units similarly to the formula given above:

Note:
The output results are saved in the module average flux storages even if the avgflux[] and sigflux[] placeholders are explicit parameters. This allows to write the last obtained accumulated statistics with writeavgflux() and access them with getavgflux(), geter2flux().

void stattest int    ndata,
double    microexp
 

Compute the expected scintillation indices for the results of the MASS statistical test.

Parameters:
ndata  Number of counts in the channel buffers (equal for all channels)
microexp  Exposure time of each count (microexposure) to scale the non-linearity parameter and background in calculations (see chan_init())
This is the second utility (after compute()) which deals with the channel count series.

MASS statistical test is performed using the specially modulated flux from the control LED. The current through the control LED is modulated step-like synchronously with the counting time diagram with a period of four microexposures. During each first and third takts of this modulation the current is at the middle level, whilst at the second and the fourth takts it is increased and decreased, respectively, relative to this middle level.

The task of this utility is to determine these middle, increased and decreased light levels and to compute the ("theoretical") expected scintillation indices (SI) and DESI which correspond to this modulation (see compute()):

Here, for the specified way of modulation, the dispersion and autocovariances with lags 1 and 2 are calculated as

and Deltas with subscripts "0", "+" and "-" are the deviations of the middle, increased and decreased light levels, respectively, from the average level. Middle level may differ from average level if the positive and the negative variations are different in magnitude.

The averaged levels are corrected for non-linearity using the channel parameters set by chan_init() and the supplied microexposure time microexp. No correction for background is made.

The call of this utility implies that the module is initialized with init() the same way as for usual measurements with compute(). Since, normally, the compute() is also started on the same count series, the capacity nmeas of the index storage must be doubled while calling init() before the statistic test evaluation. It is assumed that no corrected data are present in the series (as if ncorr array in compute() contained zeros). So, damaged series should not be fed to stattest().

The expected values of indices are put in the index storage in the same way as compute() does. Since the flux modulation is the same in all the channels of MASS, cross-channel differential indices measured during the test (by indices()) are set to zero.

Note:
The "mode" set for the computed expected indices in the index storage is set to sc::MODEGEN to allow the simple averaging of them similarly to the case of the generalized mode measurements. Thus, the averaging of statistic test results must be done with average() with the first parameter true .

void writeavgflux FILE *    f,
scwhat    what,
bool    isgen,
const char *    stamp,
bool    write_nonpois = false
 

Write the average (accumulation-time related) channel fluxes.

Parameters:
what  AFLUX: write the average fluxes in channels, HEAD: write the header line
isgen  "false": write non-shifted values with errors, "true": write shifted values with errors
f  Disk file structure pointer
stamp  Reference string to put in the first column
nonpois  Supply the non-poissonity value for each channel as a third parameter
Returns:
0 if Ok, <0 if error
Function writes the average fluxes computed by average() and their errors on the disk in one ASCII line. If nonpois==true it also adds the non-poissonity parameter from the channel structure (see chan_init()). It is supposed that this parameter is updated by statflux() with non-default nonpois parameter before. The first token in the line is the reference stamp, which normally contains the prefix and UT record.

For writing the flux values and their errors, the format FLXFMT is used. Numbers are delimited with FLXDLM; the non-poissonity parameter has a fixed format "%6.4f".

See also:
writeavgidx() statflux()

void writeavgidx FILE *    f,
scwhat    what,
bool    isgen,
const char *    stamp
 

Write the average (accumulation-time related) indices on the disk.

Parameters:
what  DSI: write the average indices, HEAD: write the header line (give the stamp name in stamp then)
isgen  "false": write non-shifted values with errors, "true": write shifted values with errors
f  Disk file structure pointer
stamp  Reference string to put in the first column
Returns:
0 if Ok, <0 if error
Function writes the average indices computed by average() and their errors on the disk in one ASCII line. The first token in the line is the reference stamp (line prefix and UT normally).

For writing the index values and their errors, the format IDXFMT is used. Numbers are delimited with IDXDLM.

The index set is written in one line, which has the following structure: stamp, average normal and differential indices for all channels and their combinations, each followed by its error and average differential exposure indices (DESI) each followed by its error. The sets are taken from shifted or non-shifted parts of storages, according to the parameter isgen.

Note:
This function must be kept in strict sync with average().
See also:
init()

void writeidx FILE *    f,
scwhat    what,
const char *    stamp,
const char *    suffix = 0
 

Write the latest instant indices to the disk.

Parameters:
f  Disk file structure pointer
what  DSI: write the last obtained index set (both (D)SI and DESI), HEAD: write the header line
stamp  Reference string of Mode/UT to put in the first column (if what!=HEAD) or its column name (if what==HEAD)
suffix  Last-field string of a general purpose. Will be put after the last index value or last word of the header. By default - nothing to put.
Returns:
0 if Ok, <0 if error
Function writes the last computed indices on the disk in one ASCII line. The first token in the line is the reference stamp (which, e.g., contains the comment symbol "# ", Normal/Generalized mode symbol "N/G " and some word with the UT hour).

If what is HEAD, the header is created like follows:

<stamp (name)> SI(A) SI(B) .. DSI(AB) ....... DESI3(A) ..
        
where SI relate to normal indices, DSI - to differential indices, DESI3 are differential exposure indices with smoothing 3-element window. Header line is kept in sync with what is written in data-writing mode (what!=HEAD).

For writing the index values, the format IDXFMT is used. Numbers are delimited with IDXDLM. The header-writing call is only possible after the init() was called; data-writing is allowed after at least one compute() call.

The index set is written in one line, which has a structure corresponding to that given in the header: stamp, Nchannel normal indices, napcomb(Nchannel)-Nchannel differential indices, and finally Nchannel differential exposure indices (DESI).

As a last field, the suffix string may be printed. In MASS Software it is an optional address record to link the instantaneous index values with the count series data in the count-file from which they were derived.

  • This function must be kept in strict sync with compute().
  • The writeidx() must not be called if again() was already called after the compute() call.
See also:
init() compute() again()

void writemom FILE *    f,
scwhat    what,
const char *    stamp,
const char *    suffix = 0
 

Write the base-time accumulated signal moments on the disk.

Parameters:
f  Disk file structure pointer
what  MOM: write the moments, HEAD: the header line only
stamp  Reference string of Mode/UT to put in the first column (if what!=HEAD) or its column name (if what==HEAD)
suffix  Last-field string of a general purpose. Will be put after the last index value or last word of the header. By default - nothing to put.
Returns:
0 if Ok, <0 if error
Function writes the signal moments - means and dispersions and covariances on the disk in one ASCII line. The structure of the code is very similar to writeidx(). The first token in the line is the reference stamp (which normally contains the comment symbol "# ", Normal/Generalized mode symbol "N/G " and some word with the UT hour.

If what is HEAD, the header is created like follows:

<stamp (name)> MEAN(A) MEAN(B)... SIG(A) SIG(B) .. COV(AB) ... COV1(A) ... COV2(A) ..
        
where SIG relate to dispersions and COV to covariances of channels and to auto- and cross-covariance of the signal in channels with lag 1 and 2.

Note:
For writing the moment values, the format MOMFMT is used. Numbers are delimited with MOMDLM. The header-writing call is only possible after the init() was called; data-writing is allowed after at least one compute() call.
The set of moments is written in one line, which has a structure corresponding to that given in the header: stamp, means for all channels, napcomb(Nchan)-Nchan normal dispersions and covariance, then the same number of lag-1 auto- and cross-channel covariances, and finally Nchan auto-covariances with lag 2.

As a last field, the suffix string may be printed. In MASS Software it is an optional address record to link the instantaneous count moments with the count series data in the count-file from which they were derived.

Note:
This function must be kept in strict sync with compute(). The writemom() can be called only immediately after compute(), since the moments are saved for the last calculation only.
See also:
writeidx()


Variable Documentation

const int sc::DESIBIN = 3
 

Smoothing window width in DESI calculations. Used implicitly in compute() )

const char sc::FLXDLM[] = " "
 

Average flux file delimiter

const char sc::FLXFMT[] = "%s%7.2f"
 

Average flux per microexposure writing printf-format in the file with leading "%s" to insert a delimiter

const char sc::IDXDLM[] = " "
 

Index file delimiter

const char sc::IDXFMT[] = "%s%7.4f"
 

Index writing printf-format in the file with leading "%s" to insert a delimiter

const int sc::MAXLAG = 0
 

Maximal lag in calculations of the error of mean for correlated values

const int sc::MODEGEN = 1
 

Shifted flag isgen in average()

const int sc::MODENO = -1
 

Initial mode: unknown in isgen[]

const int sc::MODENORM = 0
 

Not-shifted flag isgen in average()

const char sc::MOMDLM[] = "\t"
 

Moment file delimiter

const char sc::MOMFMT[] = "%s%7.0f"
 

Moments (means, covariances) writing printf-format in the file with leading "%s" to insert a delimiter


Generated on Wed Jan 16 00:40:07 2002 for MASS Software by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001