GRAVI Pipeline Reference Manual 1.7.2
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
gravi_astrometry.c File Reference
#include "gravi_astrometry.h"
#include "gravi_dfs.h"
#include "gravi_pfits.h"
#include "gravi_utils.h"
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_complex.h>
#include <gsl/gsl_complex_math.h>
#include <gsl/gsl_statistics.h>
#include <gsl/gsl_multimin.h>

Go to the source code of this file.

Data Structures

struct  _astrometry_data_
 
struct  _gravi_astrometry_model_params_
 

Macros

#define PI   3.14159265359
 
#define TWOPI   6.28318530718
 
#define MAS_TO_RAD   (2.0 * PI / (3600 * 360 * 1000))
 

Typedefs

typedef enum _find_closest_mode find_closest_mode
 
typedef struct _gravi_astrometry_model_params_ gravi_astrometry_model_params
 

Enumerations

enum  _find_closest_mode { FIND_MODE_NONE , FIND_MODE_BEFORE , FIND_MODE_AFTER }
 

Functions

static gsl_vector * load_vector (cpl_table *table, const char *name)
 Load data from table into GSL vector.
 
static gsl_matrix * load_matrix (cpl_table *table, const char *name)
 Load data from table into GSL matrix. Each table row is copied into the corresponding matrix row.
 
static gsl_matrix_complex * load_matrix_complex (cpl_table *table, const char *name)
 Load data from table into GSL matrix. Each table row is copied into the corresponding matrix row.
 
static cpl_error_code gravi_astrometry_scale_visibilities (astro_data *self, double factor)
 Scale VISDATA, VISREF, errors by scalar factor.
 
static cpl_error_code gravi_astrometry_mul_visibilities (astro_data *self, const gsl_vector *factor)
 Scale VISDATA, VISREF, errors by vector factor, broadcasting over wavelength axis.
 
static cpl_error_code gravi_astrometry_add_phase (astro_data *self, const gsl_matrix *phase)
 Add phase to visRef, updating errors accordingly.
 
static cpl_error_code gravi_astrometry_recentre_phase (astro_data *self, double xvalue, double yvalue)
 Recentre visRef and visRefError on the given position (in mas) by shifting the phases.
 
static cpl_size gravi_astrometry_find_closest_mjd (astro_data *self, astro_data **others, cpl_size n_other, find_closest_mode mode)
 Given observation and list of reference observations, find closest in time from the list.
 
static gsl_vector * average_vector_over_dits (gsl_vector *v, int ndit, int nchannel) CPL_ATTR_ALLOC
 
static gsl_matrix * average_matrix_over_dits (gsl_matrix *m, int ndit, int nchannel, int nwave, gsl_matrix_int *flag) CPL_ATTR_ALLOC
 
static gsl_matrix_complex * average_matrix_complex_over_dits (gsl_matrix_complex *m, int ndit, int nchannel, int nwave, gsl_matrix_int *flag) CPL_ATTR_ALLOC
 
static astro_datagravi_astrometry_average_over_dits (astro_data *self)
 Average input astro_data over DITs and return new flattened astro_data.
 
static gsl_matrix_complex * gravi_astrometry_calculate_visref_swap (astro_data **data, cpl_size ndata, double ra, double dec) CPL_ATTR_ALLOC
 
static gsl_matrix_complex * gravi_astrometry_create_swap_reference (astro_data **swap_data, cpl_size nswap)
 Centre swap data on zero OPD and extract average phase.
 
static double gravi_astrometry_calculate_chi2 (const gsl_vector *X, void *params)
 Evaluate chi^2 statistic.
 
static cpl_error_code gravi_astrometry_minimise_chi2_grid (gravi_astrometry_model_params *params, const gsl_vector *ra_grid, const gsl_vector *dec_grid, gsl_vector *ra_dec_out, gsl_matrix *chi2_map)
 
static cpl_error_code gravi_astrometry_minimise_chi2_descent (gravi_astrometry_model_params *params, double ra_guess, double dec_guess, gsl_vector *Xsolve)
 
static int _gsl_vector_int_sum (const gsl_vector_int *a)
 
cpl_error_code gravi_astrometry_filter_ftflux (astro_data *self, double threshold)
 Filter based on FT flux threshold and normalise.
 
cpl_error_code gravi_astrometry_normalise_to_ft (astro_data *self)
 Normalise visibilities to average FT flux.
 
astro_datagravi_astrometry_load (gravi_data *data)
 Load data for astrometry from a gravi_data.
 
cpl_error_code gravi_astrometry_dump (astro_data *self, FILE *handle)
 
void gravi_astrometry_delete (astro_data *self)
 
double gravi_astrometry_get_mean_ftflux (astro_data *self)
 
cpl_error_code gravi_astrometry_create_phase_reference (astro_data *self, astro_data **phase_refs, cpl_size nphase, astro_data **swaps, cpl_size nswap, cpl_parameterlist *parlist)
 Compute the final astrometric phase reference.
 
cpl_table * gravi_astrometry_get_phase_reference (astro_data *self)
 
cpl_error_code gravi_astrometry_reduce_swaps (astro_data **swap_data, cpl_size nswap, cpl_parameterlist *parlist)
 

Macro Definition Documentation

◆ MAS_TO_RAD

#define MAS_TO_RAD   (2.0 * PI / (3600 * 360 * 1000))

Definition at line 46 of file gravi_astrometry.c.

◆ PI

#define PI   3.14159265359

Definition at line 44 of file gravi_astrometry.c.

◆ TWOPI

#define TWOPI   6.28318530718

Definition at line 45 of file gravi_astrometry.c.

Typedef Documentation

◆ find_closest_mode

◆ gravi_astrometry_model_params

Enumeration Type Documentation

◆ _find_closest_mode

Enumerator
FIND_MODE_NONE 
FIND_MODE_BEFORE 
FIND_MODE_AFTER 

Definition at line 87 of file gravi_astrometry.c.

Function Documentation

◆ _gsl_vector_int_sum()

static int _gsl_vector_int_sum ( const gsl_vector_int *  a)
static

Definition at line 124 of file gravi_astrometry.c.

Referenced by gravi_astrometry_average_over_dits().

◆ average_matrix_complex_over_dits()

static gsl_matrix_complex * average_matrix_complex_over_dits ( gsl_matrix_complex *  m,
int  ndit,
int  nchannel,
int  nwave,
gsl_matrix_int *  flag 
)
static

◆ average_matrix_over_dits()

static gsl_matrix * average_matrix_over_dits ( gsl_matrix *  m,
int  ndit,
int  nchannel,
int  nwave,
gsl_matrix_int *  flag 
)
static

◆ average_vector_over_dits()

static gsl_vector * average_vector_over_dits ( gsl_vector *  v,
int  ndit,
int  nchannel 
)
static

Definition at line 1075 of file gravi_astrometry.c.

Referenced by gravi_astrometry_average_over_dits().

◆ gravi_astrometry_add_phase()

static cpl_error_code gravi_astrometry_add_phase ( astro_data self,
const gsl_matrix *  phase 
)
static

◆ gravi_astrometry_average_over_dits()

static astro_data * gravi_astrometry_average_over_dits ( astro_data self)
static

◆ gravi_astrometry_calculate_chi2()

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

Evaluate chi^2 statistic.

Parameters
xVector of model parameters [ra, dec].
paramsFit parameter values, of actual type gravi_astrometry_model_params.

Definition at line 1295 of file gravi_astrometry.c.

References FREE, gravi_astrometry_calculate_visref_swap(), _gravi_astrometry_model_params_::group1, _gravi_astrometry_model_params_::group2, _gravi_astrometry_model_params_::n1, _gravi_astrometry_model_params_::n2, _astrometry_data_::nchannel, and _astrometry_data_::nwave.

Referenced by gravi_astrometry_minimise_chi2_descent(), and gravi_astrometry_minimise_chi2_grid().

◆ gravi_astrometry_calculate_visref_swap()

static gsl_matrix_complex * gravi_astrometry_calculate_visref_swap ( astro_data **  data,
cpl_size  ndata,
double  ra,
double  dec 
)
static

◆ gravi_astrometry_create_phase_reference()

cpl_error_code gravi_astrometry_create_phase_reference ( astro_data self,
astro_data **  phase_refs,
cpl_size  nphase,
astro_data **  swaps,
cpl_size  nswap,
cpl_parameterlist *  parlist 
)

Compute the final astrometric phase reference.

Parameters
selfastro_data to compute ref for.
phase_refslist of astro_data to compute ref from.
nphaselength of list.
swapslist of astro_data to compute swap ref from.
nswaplength of list.
parlistrecipe parameters, esp. "calib_strategy".

Definition at line 770 of file gravi_astrometry.c.

References _astrometry_data_::amp_ref_astro, average_matrix_complex_over_dits(), average_matrix_over_dits(), cpl_msg_debug(), CPLCHECK_INT, _astrometry_data_::filename, FIND_MODE_AFTER, FIND_MODE_BEFORE, _astrometry_data_::flag, FREE, gravi_astrometry_find_closest_mjd(), _astrometry_data_::nchannel, _astrometry_data_::ndit, _astrometry_data_::nwave, _astrometry_data_::phase_ref_astro, _astrometry_data_::swap, and _astrometry_data_::vis_ref.

Referenced by gravity_astrometry().

◆ gravi_astrometry_create_swap_reference()

static gsl_matrix_complex * gravi_astrometry_create_swap_reference ( astro_data **  swap_data,
cpl_size  nswap 
)
static

Centre swap data on zero OPD and extract average phase.

Parameters
swap_datalist of astro_data for swaps.
nswaplength of list.

Definition at line 1632 of file gravi_astrometry.c.

References average_matrix_complex_over_dits(), FREE, gravi_astrometry_recentre_phase(), _astrometry_data_::nchannel, _astrometry_data_::ndit, _astrometry_data_::nwave, _astrometry_data_::swap, _astrometry_data_::swap_astrometry_fit, and _astrometry_data_::vis_ref.

Referenced by gravi_astrometry_reduce_swaps().

◆ gravi_astrometry_delete()

void gravi_astrometry_delete ( astro_data self)

◆ gravi_astrometry_dump()

cpl_error_code gravi_astrometry_dump ( astro_data self,
FILE *  handle 
)

◆ gravi_astrometry_filter_ftflux()

cpl_error_code gravi_astrometry_filter_ftflux ( astro_data self,
double  threshold 
)

◆ gravi_astrometry_find_closest_mjd()

cpl_size gravi_astrometry_find_closest_mjd ( astro_data self,
astro_data **  others,
cpl_size  n_other,
find_closest_mode  mode 
)
static

Given observation and list of reference observations, find closest in time from the list.

Parameters
selfbaseline astro_data.
otherslist of reference astro_data.
n_otherlength of list.
modeif FIND_MODE_BEFORE, require closest that precedes. If FIND_MODE_AFTER, require closest that succeeds. Else, return closest regardless of sign of time difference.
Returns
index into passed list that is closest, or -1 if invalid.

Definition at line 717 of file gravi_astrometry.c.

References FIND_MODE_AFTER, FIND_MODE_BEFORE, and _astrometry_data_::mjd.

Referenced by gravi_astrometry_create_phase_reference().

◆ gravi_astrometry_get_mean_ftflux()

double gravi_astrometry_get_mean_ftflux ( astro_data self)

◆ gravi_astrometry_get_phase_reference()

cpl_table * gravi_astrometry_get_phase_reference ( astro_data self)

Return CPL table with the final astrometric phase reference. Return CPL table with the final astrometric phase reference.

Parameters
selfastro_data to extract table from.
Note
Row axis of table corresponds to wavelength.

Definition at line 1018 of file gravi_astrometry.c.

References _astrometry_data_::amp_ref_astro, CPLCHECK_NUL, FREE, _astrometry_data_::nchannel, _astrometry_data_::ndit, _astrometry_data_::nwave, _astrometry_data_::phase_ref_astro, _astrometry_data_::vis_ref_cov, and _astrometry_data_::vis_ref_pcov.

Referenced by gravity_astrometry().

◆ gravi_astrometry_load()

astro_data * gravi_astrometry_load ( gravi_data data)

◆ gravi_astrometry_minimise_chi2_descent()

static cpl_error_code gravi_astrometry_minimise_chi2_descent ( gravi_astrometry_model_params params,
double  ra_guess,
double  dec_guess,
gsl_vector *  Xsolve 
)
static

◆ gravi_astrometry_minimise_chi2_grid()

static cpl_error_code gravi_astrometry_minimise_chi2_grid ( gravi_astrometry_model_params params,
const gsl_vector *  ra_grid,
const gsl_vector *  dec_grid,
gsl_vector *  ra_dec_out,
gsl_matrix *  chi2_map 
)
static

◆ gravi_astrometry_mul_visibilities()

static cpl_error_code gravi_astrometry_mul_visibilities ( astro_data self,
const gsl_vector *  factor 
)
static

Scale VISDATA, VISREF, errors by vector factor, broadcasting over wavelength axis.

Parameters
selfastro_data to modify inplace.
factorvector of scaling factors, of size self->ndit * self->nchannel.

Definition at line 256 of file gravi_astrometry.c.

References FREE, _astrometry_data_::nchannel, _astrometry_data_::ndit, _astrometry_data_::nwave, _astrometry_data_::nwave_ft, _astrometry_data_::vis_ref, _astrometry_data_::vis_ref_cov, _astrometry_data_::vis_ref_pcov, _astrometry_data_::visdata, and _astrometry_data_::visdata_ft.

Referenced by gravi_astrometry_normalise_to_ft().

◆ gravi_astrometry_normalise_to_ft()

cpl_error_code gravi_astrometry_normalise_to_ft ( astro_data self)

◆ gravi_astrometry_recentre_phase()

static cpl_error_code gravi_astrometry_recentre_phase ( astro_data self,
double  xvalue,
double  yvalue 
)
static

◆ gravi_astrometry_reduce_swaps()

cpl_error_code gravi_astrometry_reduce_swaps ( astro_data **  swap_data,
cpl_size  nswap,
cpl_parameterlist *  parlist 
)

◆ gravi_astrometry_scale_visibilities()

static cpl_error_code gravi_astrometry_scale_visibilities ( astro_data self,
double  factor 
)
static

Scale VISDATA, VISREF, errors by scalar factor.

Parameters
selfastro_data to modify inplace.
factorscaling factor.

Definition at line 232 of file gravi_astrometry.c.

References _astrometry_data_::nchannel, _astrometry_data_::ndit, _astrometry_data_::vis_ref, _astrometry_data_::vis_ref_cov, _astrometry_data_::vis_ref_pcov, _astrometry_data_::visdata, and _astrometry_data_::visdata_ft.

Referenced by gravi_astrometry_load().

◆ load_matrix()

static gsl_matrix * load_matrix ( cpl_table *  table,
const char *  name 
)
static

Load data from table into GSL matrix. Each table row is copied into the corresponding matrix row.

Definition at line 165 of file gravi_astrometry.c.

Referenced by gravi_astrometry_load().

◆ load_matrix_complex()

static gsl_matrix_complex * load_matrix_complex ( cpl_table *  table,
const char *  name 
)
static

Load data from table into GSL matrix. Each table row is copied into the corresponding matrix row.

Definition at line 196 of file gravi_astrometry.c.

Referenced by gravi_astrometry_load().

◆ load_vector()

static gsl_vector * load_vector ( cpl_table *  table,
const char *  name 
)
static

Load data from table into GSL vector.

Definition at line 139 of file gravi_astrometry.c.

Referenced by gravi_astrometry_load().