![]() |
cacao
Release 0.1.03-dev
Compute And Control For Adaptive Optics
|
linear auto-regressive predictive filter More...
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <malloc.h>
#include <math.h>
#include <stdlib.h>
#include <semaphore.h>
#include <sched.h>
#include <assert.h>
#include <sys/stat.h>
#include <gsl/gsl_multimin.h>
#include <gsl/gsl_multifit.h>
#include <fitsio.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_eigen.h>
#include <gsl/gsl_cblas.h>
#include <gsl/gsl_blas.h>
#include <time.h>
#include "CommandLineInterface/CLIcore.h"
#include "00CORE/00CORE.h"
#include "COREMOD_tools/COREMOD_tools.h"
#include "COREMOD_memory/COREMOD_memory.h"
#include "COREMOD_arith/COREMOD_arith.h"
#include "COREMOD_iofits/COREMOD_iofits.h"
#include "statistic/statistic.h"
#include "info/info.h"
#include "linopt_imtools/linopt_imtools.h"
#include "linARfilterPred/linARfilterPred.h"
Macros | |
#define | MODULE_SHORTNAME_DEFAULT "" |
#define | MODULE_DESCRIPTION "Linear auto-regressive predictive filters" |
#define | MODULE_APPLICATION "milk" |
Functions | |
errno_t | LINARFILTERPRED_LoadASCIIfiles_cli () |
errno_t | LINARFILTERPRED_SelectBlock_cli () |
errno_t | linARfilterPred_repeat_shift_X_cli () |
errno_t | LINARFILTERPRED_Build_LinPredictor_cli () |
errno_t | LINARFILTERPRED_Apply_LinPredictor_cli () |
errno_t | LINARFILTERPRED_ScanGain_cli () |
errno_t | LINARFILTERPRED_PF_updatePFmatrix_cli () |
errno_t | LINARFILTERPRED_PF_RealTimeApply_cli () |
static errno_t | init_module_CLI () |
int | NBwords (const char sentence[]) |
long | LINARFILTERPRED_LoadASCIIfiles (double tstart, double dt, long NBpt, long NBfr, const char *IDoutname) |
load ascii file(s) into image cube More... | |
imageID | LINARFILTERPRED_SelectBlock (const char *IDin_name, const char *IDblknb_name, long blkNB, const char *IDout_name) |
imageID | linARfilterPred_repeat_shift_X (const char *IDin_name, long NBstep, const char *IDout_name) |
Expand 2D image/matrix in X direction by repeat and shift. More... | |
imageID | LINARFILTERPRED_Build_LinPredictor (const char *IDin_name, long PForder, float PFlag, double SVDeps, double RegLambda, const char *IDoutPF_name, __attribute__((unused)) int outMode, int LOOPmode, float LOOPgain, int testmode) |
imageID | LINARFILTERPRED_Apply_LinPredictor_RT (const char *IDfilt_name, const char *IDin_name, const char *IDout_name) |
imageID | LINARFILTERPRED_Apply_LinPredictor (const char *IDfilt_name, const char *IDin_name, float PFlag, const char *IDout_name) |
imageID | LINARFILTERPRED_PF_updatePFmatrix (const char *IDPF_name, const char *IDPFM_name, float alpha) |
imageID | LINARFILTERPRED_PF_RealTimeApply (const char *IDmodevalIN_name, long IndexOffset, int semtrig, const char *IDPFM_name, long NBPFstep, const char *IDPFout_name, int nbGPU, long loop, long NBiter, int SAVEMODE, float tlag, long PFindex) |
float | LINARFILTERPRED_ScanGain (char *IDin_name, float multfact, float framelag) |
linear auto-regressive predictive filter
Implements Empirical Orthogonal Functions
#define MODULE_APPLICATION "milk" |
#define MODULE_DESCRIPTION "Linear auto-regressive predictive filters" |
#define MODULE_SHORTNAME_DEFAULT "" |
|
static |
imageID LINARFILTERPRED_Apply_LinPredictor | ( | const char * | IDfilt_name, |
const char * | IDin_name, | ||
float | PFlag, | ||
const char * | IDout_name | ||
) |
errno_t LINARFILTERPRED_Apply_LinPredictor_cli | ( | ) |
imageID LINARFILTERPRED_Apply_LinPredictor_RT | ( | const char * | IDfilt_name, |
const char * | IDin_name, | ||
const char * | IDout_name | ||
) |
imageID LINARFILTERPRED_Build_LinPredictor | ( | const char * | IDin_name, |
long | PForder, | ||
float | PFlag, | ||
double | SVDeps, | ||
double | RegLambda, | ||
const char * | IDoutPF_name, | ||
__attribute__((unused)) int | outMode, | ||
int | LOOPmode, | ||
float | LOOPgain, | ||
int | testmode | ||
) |
Build predictive filter from real-time AO telemetry
Optional input and output pixel masks select active input & output
If LOOPmode = 1, operate in a loop, and re-run filter computation everytime IDin_name changes
if <IFoutPF_name>_PFparam image exist, read parameters from it: PFlag, SVDeps, RegLambda, LOOPgain create it in shared memory by default
If image named <IDoutPF_name>_PFparam exists, the predictive filter parameters are read from it instead of the function arguments.
This mode is particularly useful in LOOP mode if the user needs to change the parameters between LOOP iterations.
The goal of this function is to build a linear link between input and output variables.
Input variables values are provided by the input telemetry image which is first read to measure dimensions, and allocate memory.
Note that an optional variable selection step allows only a subset of the telemetry variables to be considered.
If 2D image:
If 3D image
Once input telemetry size measured, arrays are created:
If image "inmask" exists, use it to select which variables are active. Otherwise, all variables are active
The number of active input variables is stored in NBpixin.
By default, the output variables are the same as the input variables, so the prediction is performed on the same variables as the input.
With inmask and outmask, input AND output variables can be selected amond the telemetry.
Arrays are created:
PFlag_run needs to be read before entering the loop as some array sizes depend on its value.
Note: column / row description follows FITS file viewing conventions.
The data matrix is build from the telemetry. Each column (= time sample) of the data matrix consists of consecutives columns (= time sample) of the input telemetry.
Variable naming:
Data matrix is stored as image of size NBmvec x mvecsize, to be fed to routine compute_SVDpseudoInverse in linopt_imtools (CPU mode) or in cudacomp (GPU mode)
Regularization can be added to penalize strong coefficients in the predictive filter. It is optionally implemented by adding extra columns at the end of the data matrix.
Data matrix conventions :
In LOOP mode, LOOP STARTS HERE
STEP: Read parameters from external image (optional)
STEP: In loop mode, wait for input data to arrive
STEP: Copy IDin to IDincp
Necessary as input may be continuously changing between consecutive loop iterations.
STEP: if DC_MODE==1, compute average value from each variable
STEP: Fill up data matrix PFmatD from input telemetry
STEP: Write regularization coefficients (optional)
STEP: Compute Pseudo-Inverse of PFmatD
If using MAGMA, call function CUDACOMP_magma_compute_SVDpseudoInverse()
Otherwise, call function linopt_compute_SVDpseudoInverse()
Result (pseudoinverse) is stored in image PFmatC
In LOOP mode, LOOP ENDS HERE
errno_t LINARFILTERPRED_Build_LinPredictor_cli | ( | ) |
long LINARFILTERPRED_LoadASCIIfiles | ( | double | tstart, |
double | dt, | ||
long | NBpt, | ||
long | NBfr, | ||
const char * | IDoutname | ||
) |
load ascii file(s) into image cube
resamples sequence(s) of data points INPUT FILES HAVE TO BE NAMED seq000.dat, seq001.dat etc...
file starts at tstart, sampling = dt NBpt per file NBfr files
errno_t LINARFILTERPRED_LoadASCIIfiles_cli | ( | ) |
imageID LINARFILTERPRED_PF_RealTimeApply | ( | const char * | IDmodevalIN_name, |
long | IndexOffset, | ||
int | semtrig, | ||
const char * | IDPFM_name, | ||
long | NBPFstep, | ||
const char * | IDPFout_name, | ||
int | nbGPU, | ||
long | loop, | ||
long | NBiter, | ||
int | SAVEMODE, | ||
float | tlag, | ||
long | PFindex | ||
) |
measure time
errno_t LINARFILTERPRED_PF_RealTimeApply_cli | ( | ) |
imageID LINARFILTERPRED_PF_updatePFmatrix | ( | const char * | IDPF_name, |
const char * | IDPFM_name, | ||
float | alpha | ||
) |
errno_t LINARFILTERPRED_PF_updatePFmatrix_cli | ( | ) |
imageID linARfilterPred_repeat_shift_X | ( | const char * | IDin_name, |
long | NBstep, | ||
const char * | IDout_name | ||
) |
Expand 2D image/matrix in X direction by repeat and shift.
errno_t linARfilterPred_repeat_shift_X_cli | ( | ) |
float LINARFILTERPRED_ScanGain | ( | char * | IDin_name, |
float | multfact, | ||
float | framelag | ||
) |
errno_t LINARFILTERPRED_ScanGain_cli | ( | ) |
imageID LINARFILTERPRED_SelectBlock | ( | const char * | IDin_name, |
const char * | IDblknb_name, | ||
long | blkNB, | ||
const char * | IDout_name | ||
) |
errno_t LINARFILTERPRED_SelectBlock_cli | ( | ) |
int NBwords | ( | const char | sentence[] | ) |