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 |
|
Enumeration of entities to access or write on the disk, to use in get...() and write...() functions. |
|
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.
|
|
Return the name for a given index of entrance aperture or combination of apertures.
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. |
|
Average scintillation indices and compute their squared errors.
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.
|
|
Average a matrix of values along the second dimention with row selection.
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 ![]()
If a given lag is more than nrow, the maximal lag is taken as nrow-1.
|
|
Initialize channel data in static channel array element.
|
|
Compute the normal and differential (aperture and exposure) scintillation indices.
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:
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:
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. |
|
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().
|
|
Get the average flux in the channel in [counts per ms].
See notes to getidx(). |
|
Get the averaged index value.
|
|
Get pointer to the array of average scintillation indices.
|
|
Get the number of measurements done in a current accumulation time.
|
|
Get the squared error of average flux in channel in [(counts per ms)^2].
See notes to getidx(). |
|
Get the squared error of the averaged index.
|
|
Get pointer to the array of errors of average scintillation indices.
|
|
Get the instant index value.
|
|
Get pointer to the array of instant scintillation indices.
|
|
Get the mean count in the channel in [counts per ms].
|
|
Get the second moment of counts in channel in [(counts per ms)^2].
|
|
Return the sequential number of index in storage by its name (ID).
|
|
Initialize the structures to put the scintillation indices.
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.
|
|
Formula to get a Number of entrance apertures and their non-redundant combinations having a apertures |
|
Recurrence computer of average fluxes and their squared errors from the count series in channels.
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(): ![]()
![]()
that means that we express the average flux and its error 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 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: ![]()
|
|
Compute the expected scintillation indices for the results of the MASS statistical test.
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.
|
|
Write the average (accumulation-time related) channel fluxes.
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".
|
|
Write the average (accumulation-time related) indices on the disk.
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.
|
|
Write the latest instant indices to the disk.
If what is HEAD, the header is created like follows: <stamp (name)> SI(A) SI(B) .. DSI(AB) ....... DESI3(A) .. 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.
|
|
Write the base-time accumulated signal moments on the disk.
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) ..
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.
|
|
Smoothing window width in DESI calculations. Used implicitly in compute() ) |
|
Average flux file delimiter |
|
Average flux per microexposure writing printf-format in the file with leading "%s" to insert a delimiter |
|
Index file delimiter |
|
Index writing printf-format in the file with leading "%s" to insert a delimiter |
|
Maximal lag in calculations of the error of mean for correlated values |
|
Shifted flag isgen in average() |
|
Initial mode: unknown in isgen[] |
|
Not-shifted flag isgen in average() |
|
Moment file delimiter |
|
Moments (means, covariances) writing printf-format in the file with leading "%s" to insert a delimiter |