User Tools

Site Tools


difx:vdifio

VDIFIO

VDIFIO is a library to create, access and modify headers for VDIF formatted data. Documentation for the VDIF standard is available at:

http://www.vlbi.org/vdif/

VDIFIO Functions

int createVDIFHeader(vdif_header *header, int dataarraylength, int threadid,  int bits, int nchan,
                     int iscomplex, char stationid[3]);

Populate the values for a vdif header. Memory is assume to have been preallocate. All time values (e.g. Epoch) are set to zero - they need to be set separately. Note that the dataarraylength is the size of the data portion of the VDIF frame (ie totalframesize minus headersize). VDIFIO divides this number by 8 internally to match the vdif specification.

Returns non-zero on error.

Functions to return header values

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 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. Note VDIF encodes this internally as a power of 2

int getVDIFComplex(vdif_header *header);

Return 1 if data is complex, 0 otherwise

int getVDIFLegacy(vdif_header *header);

Return 1 if header is legacy format (16byte), 0 otherwise (32byte)

int getVDIFHeaderBytes(vdif_header *header);

Returns size of VDIF header in bytes (16 or 32).

int getVDIFFrameInvalid(vdif_header *header);

Return the VDIF frame validity bit

int getVDIFFrameEpochSecOffset(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 of a raw header

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 frame number of channels. Internally VDIF stores this as a power of 2.

void setVDIFBitsPerSample(vdif_header *header, int nbits);

Set the number of bits per sample.

void setVDIFEpoch(vdif_header *header, int epoch);

Set the VDIF Epoch value directly.

void setVDIFFrameEpochSecOffset(vdif_header *header, int epoch);

Set the seconds since epoch directly.

void setVDIFThreadID(vdif_header *header, int threadid);

Set the frame thread ID.

Functions to set/get VDIF header times indirectly

The following functions assume the frame Epoch has already be set (except obviously setVDIFEpochMJD and setVDIFEpochTime).

void setVDIFEpochMJD(vdif_header *header, int mjd);

Set the VDIF epoch the the largest value before the given MJD.

int getVDIFEpochMJD(vdif_header *header);

Return the MJD corresponding to the current Epoch.

void setVDIFFrameMJDSec(vdif_header *header, uint64_t mjdsec);

Set the frame time based on the passed “mjd seconds” (seconds since MJD 0, ignoring leapseconds). Does not change the header fraction of a seconds value (frame number).

uint64_t getVDIFFrameMJDSec(vdif_header *header);

Returns the frame time in “mjd seconds” (seconds since MJD 0, ignoring leapseconds). Does not return the fraction of a second value (frame number).

void setVDIFFrameMJD(vdif_header *header, int mjd);

Sets the MJD portion of the current frame header. Does not set the current fraction of a day value

void setVDIFFrameSecond(vdif_header *header, int seconds);

Sets the time of the VDIF header to be seconds from UTC 00:00 of the current header time (ie sets the fraction of a day value of the time and does not change the day number).

int getVDIFFrameMJD(vdif_header *header);

Return the MJD day number 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 getVDIFFrameDMJD(vdif_header *header, int framepersec);

Return the MJD day number and fraction of day current VDIF frame as a double. Incorporates the current fraction of a second (ie frame number). Note the precision of storing a MJD as a double gives an accuracy in the order of 10usec.

int setVDIFEpochTime(vdif_header *header, time_t time);

Set the VDIF Epoch to the largest value less than time (in Unix Epoch).

int setVDIFFrameTime(vdif_header *header, time_t time);

Set the VDIF time the passed time (in Unix Epoch). Assume the Epoch has been set appropriately. Does not change the fraction of a second value.

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.

int incrementVDIFHeader(vdif_header *header, int framepersec, int64_t inc);

Increment the VDIF frame number num “inc” frames incrementing seconds since Epoch as appropriate. inc can be negative and the frames will be reduce by that many frames. inc can be larger than a second (arbitrarily large). No check is done to check the increment does not overflow the 30bit “seconds” field in the VDIF header. A check is made to ensure the header is not set to a value before the set Epoch. framepersec needs to be passed to correctly wrap the frame counter.

difx/vdifio.txt · Last modified: 2015/10/21 10:08 (external edit)