VDIFIO is a library to create, access and modify headers for VDIF formatted data. Documentation for the VDIF standard is available at:
int createVDIFHeader(vdif_header *header, int framelength, int threadid, int bits, int nchan, int iscomplex, char stationid[3]);
Populate the values for a vdif header. Memory is assume to have been prellocated. All time values (e.g. Epoch) are set to zero - they need to be set seperately
Function to completely fill header struct, returns non-zero on error */
int getVDIFThreadID(vdif_header *header);
Return the thread ID
int getVDIFFrameBytes(vdif_header *header);
Return the number of bytes occupied by the entire VDIF frame (note internally VDIF divides this values by 8)
int getVDIFFrameMJD(vdif_header *header);
Return the MJD daynumber of the current VDIF frame (incorporating the current Epoch plus seconds of offset from Epoch).
int getVDIFFrameSecond(vdif_header *header);
Return the current number of seconds since 00:00UT for the current VDIF frame time (essentially seconds%86400)
double getVDIFDMJD(vdif_header *header, int framepersec);
Return the MJD daynumber and fraction of the current VDIF frame (incorporating the current Epoch plus seconds of offset from Epoch).
int getVDIFFrameNumber(vdif_header *header);
Return the current VDIF frame number
int getVDIFStationID(vdif_header *header);
Return the VDIF station ID
int getVDIFBitsPerSample(vdif_header *header);
Return the number of bits per sample (note VDIF internally encodes this -1)
int getVDIFNumChannels(vdif_header *header);
Return the number of channels in the data array. Not VDIF encodes this internally as a power of 2
int getVDIFFrameInvalid(vdif_header *header);
Return the VDIF frame validity bit
int getVDIFFullSecond(vdif_header *header);
Return the number of seconds since VDIF Epoch
int getVDIFEpoch(vdif_header *header);
Return the VDIF Epoch
/* Functions to set just one value from a raw header */
void setVDIFFrameMJD(vdif_header *header, int framemjd);
Set …
void setVDIFMJDSec(vdif_header *header, uint64_t mjdsec);
Set …
void setVDIFFrameSecond(vdif_header *header, int framesecond);
Set the VDIF header seconds from epoch.
void setVDIFFrameNumber(vdif_header *header, int framenumber);
Set the VDIF header frame number
void setVDIFFrameInvalid(vdif_header *header, unsigned int invalid);
Set the header validity bit to 0 or 1.
void setVDIFFrameBytes(vdif_header *header, int bytes);
Set the frame size in bytes (internally VDIF stores this a number of 8byte words).
void setVDIFNumChannels(vdif_header *header, int numchannels);
Set the freame number of channels. Internally VDIF stores this as a power of 2.
void setVDIFThreadID(vdif_header *header, int threadid);
Set the frame thread ID.
int setVDIFTime(vdif_header *header, time_t time);
Set the VDIF seconds since epoch to the passed time (in Unix Epoch). Assume the Epoch has been set appropriately.
void setVDIFEpoch(vdif_header *header, int mjd);
Set the VDIF Epoch to the nearest MJD earlier than the passed MJD daynumer.
int nextVDIFHeader(vdif_header *header, int framepersec);
Increment the VDIF frame number, incrementing seconds since Epoch as appropriate. framepersec needs to be passed to correctly wrap the frame counter.