VCSBeam
Functions
beam_vdif.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <mwalib.h>
#include <vdifio.h>
#include "vcsbeam.h"
#include "mwa_header.h"
#include "ascii_header.h"
Include dependency graph for beam_vdif.c:

Functions

void float2int8_trunc (float *f, int n, float min, float max, int8_t *i)
 Converts floats to 8-bit integers. More...
 
void vdif_write_second (struct vdifinfo *vf, vdif_header *vhdr, float *data_buffer_vdif)
 Writes a second's worth of data to a VDIF file. More...
 
void vdif_write_data (struct vdifinfo *vf, int8_t *output)
 Write VDIF data to file. More...
 
void vmPopulateVDIFHeader (vcsbeam_context *vm, beam_geom *beam_geom_vals, double mjd_start, double sec_offset)
 Populates a VDIF header with data derived from the observation. More...
 
void to_offset_binary (int8_t *i, int n)
 Convert from two's complement to "offset binary" (??) More...
 

Function Documentation

◆ float2int8_trunc()

void float2int8_trunc ( float *  f,
int  n,
float  min,
float  max,
int8_t *  i 
)

Converts floats to 8-bit integers.

Parameters
[in]fThe (source) buffer of floats
nThe number of floats in f
minThe smallest allowed float
maxThe largest allowed float
[out]iThe (destination) buffer of 8-bit integers

◆ to_offset_binary()

void to_offset_binary ( int8_t *  i,
int  n 
)

Convert from two's complement to "offset binary" (??)

Parameters
iAn array of integers to be converted
nThe number of integers in i

◆ vdif_write_data()

void vdif_write_data ( struct vdifinfo *  vf,
int8_t *  output 
)

Write VDIF data to file.

Parameters
vfA struct containing metadata about the target VDIF file
outputThe buffer to be written to file
Todo:
Make sure that the header file is unneccesarily re-written each time this function is called. If so, put this bit somewhere more sensible.

◆ vdif_write_second()

void vdif_write_second ( struct vdifinfo *  vf,
vdif_header *  vhdr,
float *  data_buffer_vdif 
)

Writes a second's worth of data to a VDIF file.

Parameters
vfA struct containing metadata about the target VDIF file
vhdrA pointer to the VDIF frame header buffer
data_buffer_vdifThe data to be written out

The data to be written out are first normalised and scaled to fit in the range -126 to 127 and demoted to integers. "Blocks" of data are then written to file, along with the appropriate binary headers for each "frame", via the function vdif_write_data().

◆ vmPopulateVDIFHeader()

void vmPopulateVDIFHeader ( vcsbeam_context *  vm,
beam_geom *  beam_geom_vals,
double  mjd_start,
double  sec_offset 
)

Populates a VDIF header with data derived from the observation.

Parameters
vmThe VCSBeam context struct
beam_geom_valsA beam_geom struct containing pointing information
mjd_startThe start MJD of the observation
sec_offsetThe offset from the start of the observation in seconds