#include <weif.hxx>
Public Methods | |
wf_t () | |
Initialize the object fields with zero/null values. | |
void | clear () |
Release the z-grid and weight matrix and assigns them zero. More... | |
~wf_t () | |
Release all dynamic memory storages for deletion of object. More... | |
void | setaper (int nap, double diam=0, double *eps_in=0, double *eps_ou=0) |
Assign the reference size and relative diameters for apertures. More... | |
int | getnaper () const |
Return the number of apertures set in structure. More... | |
int | getnw () const |
Return the number of apertures and their combinations. More... | |
const char * | name (int index) const |
Give a name for respective weight. More... | |
void | setzgrid (double z0, double zmax, double dz, double dzmin) |
Generate the altitude grid given its parameters. More... | |
int | getnz () const |
Return the number of altitude steps in z-grid. More... | |
void | write (const char *filename) const |
Writes weight matrix with parameters in disk ASCII file. More... | |
int | checkfile (const char *filename) const |
Checks the weight file header values to conform the wf_t parameters (fields). More... | |
int | read (const char *filename) |
Read the object -- weight matrix and its parameters -- from the disk file. More... | |
void | calc (double *lambda, double *edist, int nedist, void(*progress)(int)) |
Calculate the weight matrix for a given energy distribution. More... | |
int | calcleff (double *lambda, double *edist, int nedist, int fix) |
Calculate the effective wavelength and 50%-levels of the light energy distribution and compares them with that set in member fields. More... | |
void | interpolate (wf_t *refwf, double shift, double *maxerr=0, int *iz_maxerr=0, int *iw_maxerr=0) |
Interpolate the weights from the reference object to the z-grid set in the object with a given optional z-shift. More... | |
double | getleff () const |
double | getblue () const |
double | getred () const |
double | getval (int iz, int iw) const |
Get the weight value for given weight and altitude indices. More... | |
void | copy (int lowiz, int hiiz, int iw, double *dest) const |
Copy (part of) a certain weight function to double-type array. More... | |
double | getalt (int iz) const |
Get the altitude grid value for a given altitude index. More... |
The allocation of the memory for double-type arrays is made in several member functions:
The constructor initializes the arrays and members with zeros; in all functions null pointer is a necessary demand for array to allow its allocation and, wise versa, if an array is not null, it is believed to be already allocated.
|
Release all dynamic memory storages for deletion of object.
The feature of setaper() to release all the memory on call with a zero argument is used. |
|
Calculate the weight matrix for a given energy distribution.
The weights are computed for the polychromatic case of incident light SED which involves the Fourier Transform of the SED divided by the wavelength. This FT is made by wf::make_fft() once before calculation of all weights and is represented in two global arrays as cubic spline coefficients. In order to have smoother shape, the SED is shifted to its origin (starting wavelength Before calculations, the weight matrix is allocated IF it was NULL. If it was not NULL, it is assumed that it was already allocated (e.g. in a previous call of this routine, say, with different en.dist.). Then, for all apertures, their combinations and for all altitudes in the z-grid, the function wf::weight() is called to make the weight integration itself. At the end, the SED characteristics computer calcleff() is called to fill in the respective spectral fields. It appears that effective wavelength represents best the shape of weights if they are computed for the "quasi-gaussian" approximation of SED with its actual FWHM. Meanwhile, the deviations may be as high as 10% from the exact shape, especially for differential indices of small apertures. The utility calls the external function progress() (if supplied as non-null) to visualize the degree of the made work. This degree, in percents, is an integer-type argument changing from 0 in the beginning to 100 at the end. Progress function is called twice per altitude step. Performance At the IBM P-III 667 MHz machine, the calculations of weights with 26 proportional steps of altitude (up to 20 km) and for 4 apertures take 14 seconds. |
|
Calculate the effective wavelength and 50%-levels of the light energy distribution and compares them with that set in member fields.
The result of comparison is returned: 0 if the difference is not significant, i.e. all three calculated numbers are within +/- EPSLEFF interval from the field values, and 1 if at least one of them differs by more than EPSLEFF. All wavelengths are in [mkm]. If the parameter \nedist is supplied as 0, the calculations and comparison are skipped and the fields leff, lblue and lred are reset to zero. 0 is returned. |
|
Checks the weight file header values to conform the wf_t parameters (fields).
The comparison is made until the first significant difference is found, in the following order: Z-grid, Apertures and Spectrum. The major source of the difference in weights is the spectrum of light and apertures geometry. Spectral characteristics in file (3 wavelengths, see calcleff()) must coincide to within EPSLEFF with given in wf; aperture diameters in wf_t and in file must differ not more than EPSD in a relative measure. Another determinator is an altitude grid. The range boundaries in file (z0 and zmax) must cover from both sides the range in wf_t to be allowed. Since the weights are normally well interpolated, the minimal spacing in altitude dzmin and altitude modifier dz in file do not have to coincide to that given in wf. Instead, they only have to be not more than EPSZ times larger than in wf_t. If the grid in the file is thinner, it is accepted. If no error is found in header, the function read() is called on the checked file with a trial weight structure. After call this structure is cleared and resulting error (if any ) is returned.
|
|
Release the z-grid and weight matrix and assigns them zero.
The signature of allocation of memory to zgrid and ws members of wf_t is non-zero z-dimention nz and non-zero respective pointers. Memory is released if only both nz and pointers are not zero. |
|
Copy (part of) a certain weight function to double-type array.
|
|
Get the altitude grid value for a given altitude index.
|
|
Return the member lblue value |
|
Return the member leff value |
|
Return the number of apertures set in structure.
|
|
Return the number of apertures and their combinations.
|
|
Return the number of altitude steps in z-grid.
|
|
Return the member lred value |
|
Get the weight value for given weight and altitude indices.
|
|
Interpolate the weights from the reference object to the z-grid set in the object with a given optional z-shift.
The parameter shift allows one to obtain the shifted weighting functions suited to work with the indices measured with the shifted pupil of the system (defocusing of the instrument). The negative altitudes when probed during the interpolation of the positively shifted functions are replaced with their absolute values. When negatively shifted function is stretched to reach the same zmax, the extrapolation case takes place. The rest parameters are three pointers to variables in which the user may receive the estimated maximal interpolation error of the weight, and the indices in z-grid and weight number where this maximal error was found. For example, for 4-aperture weight matrix (10 weights for each altitude), iz_maxerr = 2 and iw_maxerr = 5 will mean that maximal error maxerr was found at the third stage of the NEW altitude grid zgrid[2] and for the weight of AC-aperture combination. |
|
Give a name for respective weight.
|
|
Read the object -- weight matrix and its parameters -- from the disk file.
This function is meant to be used with files which were tested by checkfile() to contain exactly the needed data. It does not check the validity of numbers in file. The weight matrix and z-grid data are converted from character representation to floating point numbers with standard function "strtod" and thus checked to be indeed numbers. Otherwise, the nr::ERFIO is returned and the altitude where the error in weight value occured.
|
|
Assign the reference size and relative diameters for apertures.
Usage:
|
|
Generate the altitude grid given its parameters.
The grid may be either equidistant (if dzmin ==0) or proportional (dzmin !=0). The current restriction is that the altitude modifier should be positive. Equidistant grid is given as: ![]() where i is in [0,nz-1], nz conforms to the following condition: ![]() and ![]()
Proportional grid is constructed as follows: z[0] = z0 z[i] = z[i-1] + step step0 = z[i-1] * dz step = ( dzmin > step0 ) ? (step = dzmin) : (step = step0) ![]() and ![]() In both types of grid, z[nz-1] is replaced with zmax. This function is an interface to the lower-level private function zgrid_set() which works directly with the array wf_t::zgrid.
|
|
Writes weight matrix with parameters in disk ASCII file.
The format of the header line is following:
# <KEY> <VALUE1> [<VALUE2> [VALUE3 VALUE4]] where <KEY> is a single-letter designation of parameter and <VALUE> - its value(s). Keys are listed below with names of respective wf_t fields and description in brackets:
##Altit. W(A)/1E+11 W(B)/1E+11 ... W(AB)/1E+11 where 1E+11 is a number to which the values of weights are scaled in a file (weightscale). Any similar line which starts with "##" is interpreted by wf_t::read() as a comment. After the heading line "#Altit..." the z-grid and weight-matrix values go being separated with spaces for each altitude; thus -- one line per each altitude. |