User Tools

Site Tools


difx:vdifio

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

difx:vdifio [2015/01/28 12:58]
chrisphillips [VDIFIO Functions]
difx:vdifio [2015/10/21 10:08]
Line 1: Line 1:
-====== 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 ===== 
- 
- 
-<code C> 
- 
-int createVDIFHeader(vdif_header *header, int dataarraylength,​ int threadid, ​ int bits, int nchan, 
-                     int iscomplex, char stationid[3]);​ 
-</​code>​ 
- 
-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 === 
- 
-<code C> 
-int getVDIFThreadID(vdif_header *header); 
-</​code>​ 
- 
-Return the thread ID 
- 
- 
-<code C> 
-int getVDIFFrameBytes(vdif_header *header); 
-</​code>​ 
- 
-Return the number of bytes occupied by the entire VDIF frame (note internally VDIF divides this values by 8) 
- 
- 
-<code C> 
-int getVDIFFrameNumber(vdif_header *header); 
-</​code>​ 
- 
-Return the current VDIF frame number 
- 
-<code C> 
-int getVDIFStationID(vdif_header *header); 
-</​code>​ 
- 
-Return the VDIF station ID 
- 
-<code C> 
-int getVDIFBitsPerSample(vdif_header *header); 
-</​code>​ 
- 
-Return the number of bits per sample (note VDIF internally encodes this -1) 
- 
-<code C> 
-int getVDIFNumChannels(vdif_header *header); 
-</​code>​ 
- 
-Return the number of channels in the data array. Note VDIF encodes this internally as a power of 2 
- 
-<code C> 
-int getVDIFComplex(vdif_header *header); 
-</​code>​ 
- 
-Return 1 if data is complex, 0 otherwise 
- 
-<code C> 
-int getVDIFLegacy(vdif_header *header); 
-</​code>​ 
- 
-Return 1 if header is legacy format (16byte), 0 otherwise (32byte) 
- 
-<code C> 
-int getVDIFHeaderBytes(vdif_header *header); 
-</​code>​ 
- 
-Returns size of VDIF header in bytes (16 or 32). 
- 
-<code C> 
-int getVDIFFrameInvalid(vdif_header *header); 
-</​code>​ 
- 
-Return the VDIF frame validity bit 
- 
-<code C> 
-int getVDIFFrameEpochSecOffset(vdif_header *header); ​   ​ 
-</​code>​ 
- 
-Return the number of seconds since VDIF Epoch 
- 
-<code C> 
-int getVDIFEpoch(vdif_header *header); 
-</​code>​ 
- 
-Return the VDIF Epoch 
- 
-=== Functions to set just one value of a raw header === 
- 
- 
-<code C> 
-void setVDIFFrameNumber(vdif_header *header, int framenumber);​ 
-</​code>​ 
- 
-Set the VDIF header frame number 
- 
-<code C> 
-void setVDIFFrameInvalid(vdif_header *header, unsigned int invalid); 
-</​code>​ 
- 
-Set the header validity bit to 0 or 1. 
- 
-<code C> 
-void setVDIFFrameBytes(vdif_header *header, int bytes); 
-</​code>​ 
- 
-Set the frame size in bytes (internally VDIF stores this a number of 8byte words). 
- 
-<code C> 
-void setVDIFNumChannels(vdif_header *header, int numchannels);​ 
-</​code>​ 
- 
-Set the frame number of channels. Internally VDIF stores this as a power of 2. 
- 
-<code C> 
-void setVDIFEpoch(vdif_header *header, int epoch); 
-</​code>​ 
- 
-Set the VDIF Epoch value directly. 
- 
-<code C> 
-void setVDIFThreadID(vdif_header *header, int threadid); 
-</​code>​ 
- 
-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). 
- 
-<code C> 
-void setVDIFEpochMJD(vdif_header *header, int mjd); 
-</​code>​ 
- 
-Set the VDIF epoch the the largest value //before// the given MJD. 
- 
- 
-<code C> 
-int getVDIFEpochMJD(vdif_header *header); 
-</​code>​ 
- 
-Return the MJD corresponding to the current Epoch. 
- 
- 
-<code C> 
-void setVDIFFrameMJDSec(vdif_header *header, uint64_t mjdsec); 
-</​code>​ 
- 
-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). 
- 
-<code C> 
-uint64_t getVDIFFrameMJDSec(vdif_header *header); 
-</​code>​ 
- 
-Returns the frame time in "mjd seconds"​ (seconds since MJD 0, ignoring leapseconds). Does not return the fraction of a second value (frame number). 
- 
-<code C> 
-void setVDIFFrameMJD(vdif_header *header, int mjd); 
-</​code>​ 
- 
-Sets the MJD portion of the current frame header. Does //not// set the current fraction of a day value 
- 
- 
-<code C> 
-void setVDIFFrameSecond(vdif_header *header, int seconds); 
-</​code>​ 
- 
-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). 
- 
- 
-<code C> 
-int getVDIFFrameMJD(vdif_header *header); 
-</​code>​ 
- 
-Return the MJD day number of the current VDIF frame (incorporating the current Epoch plus seconds of offset from Epoch). 
- 
-<code C> 
-int getVDIFFrameSecond(vdif_header *header); 
-</​code>​ 
- 
-Return the current number of seconds since 00:00UT for the current VDIF frame time (essentially seconds%86400) 
- 
- 
-<code C> 
-double getVDIFFrameDMJD(vdif_header *header, int framepersec);​ 
-</​code>​ 
- 
-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. 
- 
- 
-<code C> 
-int setVDIFEpochTime(vdif_header *header, time_t time); 
-</​code>​ 
- 
-Set the VDIF Epoch to the largest value //less// than ''​time''​ (in Unix Epoch). ​ 
- 
-<code C> 
-int setVDIFFrameTime(vdif_header *header, time_t time); 
-</​code>​ 
- 
-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. 
- 
- 
-<code C> 
-int nextVDIFHeader(vdif_header *header, int framepersec);​ 
-</​code>​ 
- 
-Increment the VDIF frame number, incrementing seconds since Epoch as appropriate. ''​framepersec''​ needs to be passed to correctly wrap the frame counter. 
  
difx/vdifio.txt · Last modified: 2015/10/21 10:08 (external edit)