GRAVI Pipeline Reference Manual 1.8.0
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
gravi_demodulate.c File Reference
#include <cpl.h>
#include <math.h>
#include <time.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_multimin.h>
#include <gsl/gsl_statistics.h>
#include "gravi_demodulate.h"
#include "gravi_pfits.h"
#include "gravi_utils.h"

Go to the source code of this file.

Data Structures

struct  _demodulation_model_params_
 

Macros

#define FT   0
 
#define SC   1
 
#define STEPS_PER_SECOND   500
 
#define MAX_SECONDS_PER_CHUNK   100
 
#define PI   3.14159265359
 
#define TWOPI   6.28318530718
 

Typedefs

typedef struct _demodulation_model_params_ model_params
 

Functions

static cpl_size diode_column_index (int tele, int diode, int side)
 Return column index in VOLT table for specific diode.
 
static double model_x (const gsl_vector *X, int step)
 
static double model_y (const gsl_vector *X, int step)
 
static double modulation_model_chi2 (const gsl_vector *X, void *params)
 Calculate chi^2 statistic for modulation model.
 
static cpl_error_code fit_model_modulation (const gsl_vector *vx, const gsl_vector *vy, gsl_vector *Xsolve)
 Fit the modulation model to voltage data for a single diode.
 
cpl_error_code gravi_metrology_demodulate (gravi_data *met_data, cpl_boolean zero_subtracted)
 Demodulate the metrology.
 

Variables

const cpl_size ntel = 4
 
const cpl_size ndiode = 4
 
const cpl_size nside = 2
 
const double diode_zeros []
 

Macro Definition Documentation

◆ FT

#define FT   0

Definition at line 54 of file gravi_demodulate.c.

◆ MAX_SECONDS_PER_CHUNK

#define MAX_SECONDS_PER_CHUNK   100

Definition at line 58 of file gravi_demodulate.c.

◆ PI

#define PI   3.14159265359

Definition at line 60 of file gravi_demodulate.c.

◆ SC

#define SC   1

Definition at line 55 of file gravi_demodulate.c.

◆ STEPS_PER_SECOND

#define STEPS_PER_SECOND   500

Definition at line 57 of file gravi_demodulate.c.

◆ TWOPI

#define TWOPI   6.28318530718

Definition at line 61 of file gravi_demodulate.c.

Typedef Documentation

◆ model_params

Function Documentation

◆ diode_column_index()

static cpl_size diode_column_index ( int  tele,
int  diode,
int  side 
)
static

Return column index in VOLT table for specific diode.

Parameters
teleTelescope in {0..3}
diodeDiode in {0..3}
side0 (FT) or 1 (SC)
Returns
Column index for xvolts, add one for corresponding yvolts

Definition at line 76 of file gravi_demodulate.c.

References FT.

Referenced by gravi_metrology_demodulate().

◆ fit_model_modulation()

cpl_error_code fit_model_modulation ( const gsl_vector *  vx,
const gsl_vector *  vy,
gsl_vector *  Xsolve 
)
static

Fit the modulation model to voltage data for a single diode.

Parameters
vxx voltages
vyy voltages
zxx zero offset
zyy zero offset
[out]Xsolvereturned best-fit parameters, which must already be allocated.
Returns
CPL_ERROR_NONE if fit successful

Definition at line 404 of file gravi_demodulate.c.

References cpl_msg_debug(), FREE, modulation_model_chi2(), PI, SIGN, TWOPI, and _demodulation_model_params_::volts_x.

Referenced by gravi_metrology_demodulate().

◆ gravi_metrology_demodulate()

cpl_error_code gravi_metrology_demodulate ( gravi_data met_data,
cpl_boolean  zero_subtracted 
)

Demodulate the metrology.

Parameters
[in,out]met_datainput table of metrology data
[in]zero_subtractedflag indicating metrology has been zero-subtracted using DARK
Returns
CPL_ERROR_NONE for successful demodulation.

Definition at line 161 of file gravi_demodulate.c.

References cpl_msg_debug(), cpl_msg_info(), CPLCHECK_INT, diode_column_index(), diode_zeros, fit_model_modulation(), FREE, FT, gravi_data_get_header, gravi_data_get_table(), GRAVI_METROLOGY_EXT, gravi_msg_function_exit, gravi_msg_function_start, MAX_SECONDS_PER_CHUNK, ndiode, nside, ntel, SC, and STEPS_PER_SECOND.

Referenced by gravity_vis().

◆ model_x()

static double model_x ( const gsl_vector *  X,
int  step 
)
static

Definition at line 117 of file gravi_demodulate.c.

References STEPS_PER_SECOND, and TWOPI.

Referenced by modulation_model_chi2().

◆ model_y()

static double model_y ( const gsl_vector *  X,
int  step 
)
static

Definition at line 128 of file gravi_demodulate.c.

References STEPS_PER_SECOND, and TWOPI.

Referenced by modulation_model_chi2().

◆ modulation_model_chi2()

double modulation_model_chi2 ( const gsl_vector *  X,
void *  params 
)
static

Calculate chi^2 statistic for modulation model.

Parameters
Xvector of model parameters [a, b, pha1, pha2]
paramspointer to model_params struct
Returns
chi^2 statistic evaluated for the supplied model parameters.

Definition at line 358 of file gravi_demodulate.c.

References model_x(), model_y(), STEPS_PER_SECOND, _demodulation_model_params_::volts_x, and _demodulation_model_params_::volts_y.

Referenced by fit_model_modulation().

Variable Documentation

◆ diode_zeros

const double diode_zeros[]
Initial value:
= {
-0.0039217663072871976, -0.005375368693370768, -0.0039996565553508424, -0.0025503151499257103,
-0.004993987370698725, -0.0025982105556817733, -0.0033492901476214598, -0.0024666122995294915,
-0.004914056163432626, -0.004605706229646769, -0.0024913748841215717, -0.0025406836901383087,
-0.0035045471990661765, -0.004864493604480354, -0.0038971489167063875, -0.002645429318536674,
-0.0031186035580824016, -0.0030236901965512925, -0.00455348514695007, -0.0027973126198521715,
-0.00329832479577174, -0.004717880979213343, -0.0038105012008050844, -0.0034806513678800706,
-0.004843769955531035, -0.0038383890934418244, -0.003413267406206906, -0.0032447329693567305,
-0.0019067813627941682, -0.003741090151381262, -0.0031293194990934074, -0.002917132698761452,
-0.003846563742841961, -0.0016110031116351089, -0.004055586210967794, -0.004665653836460701,
-0.0035651245279117107, -0.003703624441150295, -0.0042027507769680774, -0.003685527333212408,
-0.0018717967368672794, -0.004309454414641543, -0.004161530517996172, -0.003603457935318008,
-0.0031196452749965883, -0.003456638711821881, -0.005237079636108828, -0.0029119219882156274,
-0.002883279151359765, -0.0044843120806118035, -0.0033190561101935586, -0.004244083297006716,
-0.005334829455674041, -0.004158489195313494, -0.00242824997808483, -0.0018624941393818074,
-0.0029737356896519826, -0.004348274099950943, -0.002654502952395225, -0.0030576540586404475,
-0.0032698514683164475, -0.003638017106725761, -0.0029787962274195018, -0.002629800558439812,
0.0005056591585058203, 0.0006414248583206548, 0.0005120370824436637, 0.0006245251138490539,
0.0002781845526483057, -0.00026739218921257777, 0.0005758898707200935, 0.0003888211264503715,
0.00036289398311494447, 6.419787480760673e-05, 0.0008198190512220566, 0.0007714407655275396,
0.0008010985218159154, 9.667686713004861e-05, 0.0008396378442216361, 0.0005619108431658763
}

Diode zero offsets from Stefan Gillesen dated TODO To be updated with new values dated TODO Ordering is such that it matches the VOLT column in the metrology data Used iff no DARK was provided

Definition at line 94 of file gravi_demodulate.c.

Referenced by gravi_metrology_demodulate().

◆ ndiode

const cpl_size ndiode = 4

◆ nside

const cpl_size nside = 2

Definition at line 86 of file gravi_demodulate.c.

Referenced by gravi_metrology_demodulate().

◆ ntel

const cpl_size ntel = 4