casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
asdmbinaries::SDMDataObjectWriter Class Reference

A general class to write MIME messages containing ALMA binary data. More...

#include <SDMDataObjectWriter.h>

Public Member Functions

 SDMDataObjectWriter (const std::string &uid="uid://X0/X0/X0", const std::string &title="ALMA Binary Data")
 A constructor to write on standard output. More...
 
 SDMDataObjectWriter (std::ofstream *ofs, const std::string &uid="uid://X0/X0/X0", const std::string &title="ALMA Binary Data")
 A constructor to write in a file. More...
 
 SDMDataObjectWriter (std::ostringstream *oss, const std::string &uid="uid://X0/X0/X0", const std::string &title="ALMA Binary Data")
 A constructor to write in memory. More...
 
virtual ~SDMDataObjectWriter ()
 The destructor. More...
 
void done ()
 This method must be called to conclude the activity of this SDMDataObjectWriter. More...
 
void tpData (uint64_t startTime, const std::string &execBlockUID, uint32_t execBlockNum, uint32_t scanNum, uint32_t subscanNum, uint32_t numOfIntegrations, uint32_t numAntenna, const std::vector< SDMDataObject::Baseband > &basebands, uint64_t time, uint64_t interval, const std::vector< AxisNameMod::AxisName > &flagsAxes, const std::vector< FLAGSTYPE > &flags, const std::vector< AxisNameMod::AxisName > &actualTimesAxes, const std::vector< ACTUALTIMESTYPE > &actualTimes, const std::vector< AxisNameMod::AxisName > &actualDurationsAxes, const std::vector< ACTUALDURATIONSTYPE > &actualDurations, const std::vector< AxisNameMod::AxisName > &autoDataAxes, const std::vector< AUTODATATYPE > &autoData)
 Writes the full content of Total Power data in their respective attachments (global XML header, local XML header and binary attachments) on the MIME message stream. More...
 
void tpData (uint64_t startTime, const std::string &execBlockUID, uint32_t execBlockNum, uint32_t scanNum, uint32_t subscanNum, uint32_t numOfIntegrations, uint32_t numAntenna, const std::vector< SDMDataObject::Baseband > &basebands, uint64_t time, uint64_t interval, const std::vector< AxisNameMod::AxisName > &autoDataAxes, const std::vector< AUTODATATYPE > &autoData)
 Writes the full content of Total Power data in their respective attachments (global XML header, local XML header and binary attachments) on the MIME message stream. More...
 
void tpDataHeader (uint64_t startTime, const std::string &execBlockUID, uint32_t execBlockNum, uint32_t scanNum, uint32_t subscanNum, uint32_t numAntenna, SDMDataObject::DataStruct &dataStruct)
 Writes the XML global header on the MIME message stream, when binary data are Total Power data and will be written in successive steps with calls to tpAddIntegration. More...
 
void tpAddIntegration (uint32_t integrationNum, uint64_t time, uint64_t interval, const std::vector< FLAGSTYPE > &flags, const std::vector< ACTUALTIMESTYPE > &actualTimes, const std::vector< ACTUALDURATIONSTYPE > &actualDurations, const std::vector< AUTODATATYPE > &autoData)
 Writes one integration (local header + binary attachment) of total power data on the MIME message stream. More...
 
void wvrData (const std::string &execBlockUID, uint32_t execBlockNum, uint32_t scanNum, uint32_t subscanNum, uint32_t numTimes, uint32_t numAntennas, uint32_t numChannels, NetSidebandMod::NetSideband netSideband, uint64_t time, uint64_t interval, const std::vector< AUTODATATYPE > &wvrData, const std::vector< FLAGSTYPE > &flags)
 Writes water vapour radiometer (WVR) data in a MIME message conform with the BDF V2 format. More...
 
void corrDataHeader (uint64_t startime, const std::string &execBlockUID, uint32_t execBlockNum, uint32_t scanNum, uint32_t subscanNum, uint32_t numAntenna, CorrelationModeMod::CorrelationMode correlationMode, const OptionalSpectralResolutionType &spectralResolutionType, SDMDataObject::DataStruct &dataStruct)
 Writes the XML global header on the MIME message stream, when binary data are (sub)integrations produced by the correlator. More...
 
void addIntegration (uint32_t integrationNum, uint64_t time, uint64_t interval, const std::vector< FLAGSTYPE > &flags, const std::vector< ACTUALTIMESTYPE > &actualTimes, const std::vector< ACTUALDURATIONSTYPE > &actualDurations, const std::vector< ZEROLAGSTYPE > &zeroLags, const std::vector< INTCROSSDATATYPE > &crossData, const std::vector< AUTODATATYPE > &autoData)
 Writes one integration (local header + binary attachment) of correlator data on the MIME message stream. More...
 
void addIntegration (uint32_t integrationNum, uint64_t time, uint64_t interval, const std::vector< FLAGSTYPE > &flags, const std::vector< ACTUALTIMESTYPE > &actualTimes, const std::vector< ACTUALDURATIONSTYPE > &actualDurations, const std::vector< ZEROLAGSTYPE > &zeroLags, const std::vector< SHORTCROSSDATATYPE > &crossData, const std::vector< AUTODATATYPE > &autoData)
 Writes an integration (local header + binary attachment) on the MIME message stream. More...
 
void addIntegration (uint32_t integrationNum, uint64_t time, uint64_t interval, const std::vector< FLAGSTYPE > &flags, const std::vector< ACTUALTIMESTYPE > &actualTimes, const std::vector< ACTUALDURATIONSTYPE > &actualDurations, const std::vector< ZEROLAGSTYPE > &zeroLags, const std::vector< FLOATCROSSDATATYPE > &crossData, const std::vector< AUTODATATYPE > &autoData)
 Writes an integration (local header + binary attachment) on the MIME message stream. More...
 
void addSubintegration (uint32_t integrationNum, uint32_t subintegrationNum, uint64_t time, uint64_t interval, const std::vector< FLAGSTYPE > &flags, const std::vector< ACTUALTIMESTYPE > &actualTimes, const std::vector< ACTUALDURATIONSTYPE > &actualDurations, const std::vector< ZEROLAGSTYPE > &zeroLags, const std::vector< INTCROSSDATATYPE > &crossData, const std::vector< AUTODATATYPE > &autoData)
 Writes an subintegration (local header + binary attachment) on the MIME message stream. More...
 
void addSubintegration (uint32_t integrationNum, uint32_t subintegrationNum, uint64_t time, uint64_t interval, const std::vector< FLAGSTYPE > &flags, const std::vector< ACTUALTIMESTYPE > &actualTimes, const std::vector< ACTUALDURATIONSTYPE > &actualDurations, const std::vector< ZEROLAGSTYPE > &zeroLags, const std::vector< SHORTCROSSDATATYPE > &crossData, const std::vector< AUTODATATYPE > &autoData)
 Writes an subintegration (local header + binary attachment) on the MIME message stream. More...
 
void addSubintegration (uint32_t integrationNum, uint32_t subintegrationNum, uint64_t time, uint64_t interval, const std::vector< FLAGSTYPE > &flags, const std::vector< ACTUALTIMESTYPE > &actualTimes, const std::vector< ACTUALDURATIONSTYPE > &actualDurations, const std::vector< ZEROLAGSTYPE > &zeroLags, const std::vector< FLOATCROSSDATATYPE > &crossData, const std::vector< AUTODATATYPE > &autoData)
 Writes an subintegration (local header + binary attachment) on the MIME message stream. More...
 
uint64_t numBytes ()
 Returns the number of bytes written so far. More...
 
void output (const std::string &s)
 
void outputln (const std::string &s)
 
void output (const float *data, uint32_t numData)
 
void outputln (const float *data, uint32_t numData)
 
void outputln (const long long *data, uint32_t numData)
 
template<class T >
void output (const std::vector< T > &data)
 
template<class T >
void outputln (const std::vector< T > &data)
 
void outputln ()
 
void outputlnLocation (const std::string &name, const SDMDataSubset &sdmDataSubset)
 

Private Types

enum  OUTDEST {
  STDOUT,
  MEMORY,
  FILE
}
 
enum  States {
  START,
  S_TPDATA,
  S_TPDATAHEADER,
  S_ADDTPSUBSCAN,
  S_ADDTPINTEGRATION,
  S_WVRDATA,
  S_CORRDATAHEADER,
  S_ADDINTEGRATION,
  S_ADDSUBINTEGRATION,
  END
}
 A small finite state automaton to control the usage of SDMDataObjectWriter. More...
 
enum  Transitions {
  T_TPDATA,
  T_TPDATAHEADER,
  T_ADDTPSUBSCAN,
  T_ADDTPINTEGRATION,
  T_WVRDATA,
  T_CORRDATAHEADER,
  T_ADDINTEGRATION,
  T_ADDSUBINTEGRATION,
  T_DONE
}
 

Private Member Functions

void preamble ()
 Writes the very first part of the MIME message. More...
 
void postamble ()
 Write the very end of the MIME message. More...
 
void addData (uint32_t integrationNum, uint32_t subintegrationNum, uint64_t time, uint64_t interval, const std::vector< FLAGSTYPE > &flags, const std::vector< ACTUALTIMESTYPE > &actualTimes, const std::vector< ACTUALDURATIONSTYPE > &actualDurations, const std::vector< ZEROLAGSTYPE > &zeroLags, const std::vector< INTCROSSDATATYPE > &intCrossData, const std::vector< SHORTCROSSDATATYPE > &shortCrossData, const std::vector< FLOATCROSSDATATYPE > &floatCrossData, const std::vector< AUTODATATYPE > &autoData)
 
void checkState (Transitions t, const std::string &methodName)
 

Static Private Member Functions

static bool initClass ()
 
template<class Enum , class EnumHelper >
static std::vector< Enum > enumvec (const std::string &strliterals)
 A utility to fill a vector of <Enum> from a an array of c-strings. More...
 

Private Attributes

OUTDEST otype_
 
std::ofstream * ofs_
 
std::ostringstream * oss_
 
std::string uid_
 The ALMA uid of the MIME message. More...
 
std::string title_
 The title of the binary data. More...
 
std::string subscanPath_
 The subscan path. More...
 
SDMDataObject sdmDataObject_
 An SDMDataObject. More...
 
uint32_t sdmDataSubsetNum_
 The number of the SDMDataSubset being written. More...
 
bool done_
 Are we done with this ? More...
 
uint64_t numBytes_
 The number of bytes written so far. More...
 
States currentState_
 

Static Private Attributes

static const std::string MIMEBOUNDARY_1
 Two strings used as MIME boundaries. More...
 
static const std::string MIMEBOUNDARY_2
 
static const bool initClass_
 Class initialization stuff. More...
 
static std::vector
< AxisNameMod::AxisName > 
WVRDATAAXES
 The axes names definitions for WVR data and their related flags. More...
 
static std::vector
< AxisNameMod::AxisName > 
WVRDATAFLAGSAXES
 

Detailed Description

A general class to write MIME messages containing ALMA binary data.

An instance of this class can be used to write :

The MIME message is written on standard output, a disk file or a char buffer depending on the constructor used to create an instance of SDMDataObjectWriter.

How to use an instance of SDMDataObjectWriter.

Whatever is the type of binary data (total power, WVR, integration, subintegration) to write, the following scheme must be respected when using an SDMDataObjectWriter.

  1. Instantiate an SDMDataObjectWriter by using the appropriate constructor depending on the kind of desired output (standard output, disk file, memory).
  2. Write the binary data by using the appropriate methods depending on the kind of binary data.
  3. Conclude the usage of this instance of SDMDataObjectWriter by calling the done method (done()).

Example:

* // open a disk file
* ofstream osf("myCorrData.dat");
*
* // builds an SDMDataObjectWriter which will write the data in the file "myCorrData.dat".
* SDMDataObjectWriter sdmdow(&osf, "uid://X1/X2/X3", "ALMA Binary Data");
*
* // Here produce the binary data by using one the sequences detailed below.
* .
* .
* // done with sdmdow.
* sdmdow.done();
*
* // Do not forget to close the file !!
* osf.close()
* .
* .
*

Example of a MIME message output in an ostringstream :

* // create an osstringstream
* ostringstream oss;
*
* // builds an SDMDataObjectWriter which will write the data in the string attached to oss.
* SDMDataObjectWriter sdmdow(&oss, "uid://X1/X2/X3", "ALMA Binary Data");
*
* // Here produce the binary data by using one the sequences detailed below.
* .
* .
* // done with sdmdow.
* sdmdow.done();
*
* // Do whatever you want with oss.
* .
* .
* // And perhaps a good thing to erase the content of oss.
* oss.str("");
* .
* .
*

We detail now the different valid sequences for writing binary data depending on their kind.

How to write Total Power data.

single call to the tpData() method.

* sdmdow.tpData(123450000, // startTime
* "uid://X123/X4/X5", // execBlockUID
* 1, // execBlockNum
* 10, // scanNum
* 3, // subscanNum
* 100, // number of integrations
* 2, // number of antennas
* basebands, // vector of basebands.
* 171450000, // time
* 96000000, // interval
* axis, // names of axis
* autoData); // total power data values.
*

One may also consider to use in that order the methods tpDataHeader and addTPSubscan.

How to write WVR data.

One single call to the wvrData() method.

* sdmdow.wvrData("uid://X123/X4/X5", // execBlockUID,
* 1, // execBlockNum,
* 10, // scanNum,
* 3, // subscanNum,
* 100, // number of time stamps (i.e. size along the TIM axis),
* 8, // number of antennas,
* 4, // number of channels,
* DSB, // NetSideband characteristic,
* 171450000, // time,
* 96000000, // interval,
* wvrData, // the WVR data values,
* flags); // flags associated to the WVR data.
*
*

How to write integrations.

One single call to corrDataHeader() followed by one or more calls to addIntegration().

* // Write the global header.
* sdmdow.corrDataHeader(123450000, // startTime
* "uid://X123/X4/X5", // execBlockUID
* 1, // execBlockNum
* 10, // scanNum
* 3, // subscanNum
* 2, // numAntenna
* correlationMode, // the correlation mode.
* spectralResolution, // the spectral resolution.
* correlatorType, // the processor (correlator) type.
* dataStruct); // the description of the structure of the binary data.
*
* // And write the integrations (3 in that example).
* for (uint32_t i = 0; i < 3; i++) {
* .
* .
* .
* sdmdow.addIntegration(i+1, // integration's index.
* time, // midpoint
* interval, // time interval
* flags, // flags binary data
* actualTimes, // actual times binary data
* actualDurations, // actual durations binary data
* zeroLags, // zero lags binary data
* shortCrossData, // cross data (can be short or int)
* autoData); // single dish data.
* .
* .
* .
* }
*

How to write subintegrations.

One single call to corrDataHeader() followed by one or more calls to addSubintegration().

* // Write the global header.
* sdmdow.corrDataHeader(123450000, // startTime
* "uid://X123/X4/X5", // execBlockUID
* 1, // execBlockNum
* 10, // scanNum
* 3, // subscanNum
* 2, // numAntenna
* correlationMode, // the correlation mode.
* spectralResolution, // the spectral resolution.
* processorType, // the processor type.
* dataStruct); // the description of the structure of the binary data.
*
* // And write the subintegrations (6 in that example).
* for (uint32_t i = 0; i < 3; i++) {
* for (uint32_t j = 0; j < 2; j++) {
* .
* .
* .
* sdmdow.addSubintegration(i+1, // integration's index.
* j+1, // subintegration's index
* time, // midpoint
* interval, // time interval
* flags, // flags binary data
* actualTimes, // actual times binary data
* actualDurations,// actual durations binary data
* zeroLags, // zero lags binary data
* shortCrossData, // cross data (can be short or int)
* autoData); // single dish data.
* .
* .
* .
* }
* }
*

Valid calls sequences.

The table below summarizes the valid call sequences when using an SDMDataObjectWriter. Any deviation from these rules will result in an SDMDataObjectWriterException thrown.

Valid sequences of methods calls
Total Power data WVR data Integration subIntegration
ctor, tpData, done ctor, wvrData, done ctor, corrDataHeader, addIntegration (one or more times), done ctor, corrDataHeader, addSubintegration (one or more times), done
ctor, tpDataHeader, addTPSubscan, done

Definition at line 266 of file SDMDataObjectWriter.h.

Member Enumeration Documentation

Enumerator
STDOUT 
MEMORY 
FILE 

Definition at line 797 of file SDMDataObjectWriter.h.

A small finite state automaton to control the usage of SDMDataObjectWriter.

Enumerator
START 
S_TPDATA 
S_TPDATAHEADER 
S_ADDTPSUBSCAN 
S_ADDTPINTEGRATION 
S_WVRDATA 
S_CORRDATAHEADER 
S_ADDINTEGRATION 
S_ADDSUBINTEGRATION 
END 

Definition at line 871 of file SDMDataObjectWriter.h.

Enumerator
T_TPDATA 
T_TPDATAHEADER 
T_ADDTPSUBSCAN 
T_ADDTPINTEGRATION 
T_WVRDATA 
T_CORRDATAHEADER 
T_ADDINTEGRATION 
T_ADDSUBINTEGRATION 
T_DONE 

Definition at line 872 of file SDMDataObjectWriter.h.

Constructor & Destructor Documentation

asdmbinaries::SDMDataObjectWriter::SDMDataObjectWriter ( const std::string &  uid = "uid://X0/X0/X0",
const std::string &  title = "ALMA Binary Data" 
)

A constructor to write on standard output.

The MIME message will be written to the standard output.

Parameters
uida string containing the ALMA uid of the MIME message.
titlea string defining the title for the binary data to be written.
asdmbinaries::SDMDataObjectWriter::SDMDataObjectWriter ( std::ofstream *  ofs,
const std::string &  uid = "uid://X0/X0/X0",
const std::string &  title = "ALMA Binary Data" 
)

A constructor to write in a file.

The MIME message will be written into the file attached to the ofstream argument.

Parameters
ofsan pointer to an ofstream object.
uida string containing the ALMA uid of the MIME message.
titlea string defining the title for the binary data to be written.
asdmbinaries::SDMDataObjectWriter::SDMDataObjectWriter ( std::ostringstream *  oss,
const std::string &  uid = "uid://X0/X0/X0",
const std::string &  title = "ALMA Binary Data" 
)

A constructor to write in memory.

The MIME message will be written in an ostringstream.

Parameters
ossa pointer to an ostringstream.
uida string containing the ALMA uid of the MIME message.
titlea string defining the title for the binary data to be written.
Note
*oss will be systematically cleared before the first write operation.
virtual asdmbinaries::SDMDataObjectWriter::~SDMDataObjectWriter ( )
virtual

The destructor.

Member Function Documentation

void asdmbinaries::SDMDataObjectWriter::addData ( uint32_t  integrationNum,
uint32_t  subintegrationNum,
uint64_t  time,
uint64_t  interval,
const std::vector< FLAGSTYPE > &  flags,
const std::vector< ACTUALTIMESTYPE > &  actualTimes,
const std::vector< ACTUALDURATIONSTYPE > &  actualDurations,
const std::vector< ZEROLAGSTYPE > &  zeroLags,
const std::vector< INTCROSSDATATYPE > &  intCrossData,
const std::vector< SHORTCROSSDATATYPE > &  shortCrossData,
const std::vector< FLOATCROSSDATATYPE > &  floatCrossData,
const std::vector< AUTODATATYPE > &  autoData 
)
private
void asdmbinaries::SDMDataObjectWriter::addIntegration ( uint32_t  integrationNum,
uint64_t  time,
uint64_t  interval,
const std::vector< FLAGSTYPE > &  flags,
const std::vector< ACTUALTIMESTYPE > &  actualTimes,
const std::vector< ACTUALDURATIONSTYPE > &  actualDurations,
const std::vector< ZEROLAGSTYPE > &  zeroLags,
const std::vector< INTCROSSDATATYPE > &  crossData,
const std::vector< AUTODATATYPE > &  autoData 
)

Writes one integration (local header + binary attachment) of correlator data on the MIME message stream.

Parameters
integrationNumthe index (1 based) of the integration.
timetime of the integration.
intervalinterval of the integration.
flagsthe values of flags.
actualTimesthe values of actualTimes.
actualDurationsthe values of actualDurations.
zeroLagsthe values of zeroLags.
crossDatathe values of crossData (encoded in int).
autoDatathe values of autoData.
Exceptions
SDMDataObjectWriterException
Note
This method is to be used when cross data are coded with "int" values.
If this integration contains only cross data (CROSS_ONLY) , the autoData parameter is ignored. A empty vector can be passed as an actual parameter.
void asdmbinaries::SDMDataObjectWriter::addIntegration ( uint32_t  integrationNum,
uint64_t  time,
uint64_t  interval,
const std::vector< FLAGSTYPE > &  flags,
const std::vector< ACTUALTIMESTYPE > &  actualTimes,
const std::vector< ACTUALDURATIONSTYPE > &  actualDurations,
const std::vector< ZEROLAGSTYPE > &  zeroLags,
const std::vector< SHORTCROSSDATATYPE > &  crossData,
const std::vector< AUTODATATYPE > &  autoData 
)

Writes an integration (local header + binary attachment) on the MIME message stream.

Parameters
integrationNumthe index (1 based) of the integration.
timetime of the integration.
intervalinterval of the integration.
flagsthe values of flags.
actualTimesthe values of actualTimes.
actualDurationsthe values of actualDurations.
zeroLagsthe values of zeroLags.
crossDatathe values of crossData (encoded in short).
autoDatathe values of autoData.
Exceptions
SDMDataObjectWriterException
Note
This method is to be used when cross data are coded with "short" values.
If this integration contains only cross data (CROSS_ONLY) , the autoData parameter is ignored. A empty vector can be passed as an actual parameter.
void asdmbinaries::SDMDataObjectWriter::addIntegration ( uint32_t  integrationNum,
uint64_t  time,
uint64_t  interval,
const std::vector< FLAGSTYPE > &  flags,
const std::vector< ACTUALTIMESTYPE > &  actualTimes,
const std::vector< ACTUALDURATIONSTYPE > &  actualDurations,
const std::vector< ZEROLAGSTYPE > &  zeroLags,
const std::vector< FLOATCROSSDATATYPE > &  crossData,
const std::vector< AUTODATATYPE > &  autoData 
)

Writes an integration (local header + binary attachment) on the MIME message stream.

Parameters
integrationNumthe index (1 based) of the integration.
timetime of the integration.
intervalinterval of the integration.
flagsthe values of flags.
actualTimesthe values of actualTimes.
actualDurationsthe values of actualDurations.
zeroLagsthe values of zeroLags.
crossDatathe values of crossData (encoded in float).
autoDatathe values of autoData.
Exceptions
SDMDataObjectWriterException
Note
This method is to be used when cross data are coded with "float" values.
If this integration contains only cross data (CROSS_ONLY) , the autoData parameter is ignored. A empty vector can be passed as an actual parameter.
void asdmbinaries::SDMDataObjectWriter::addSubintegration ( uint32_t  integrationNum,
uint32_t  subintegrationNum,
uint64_t  time,
uint64_t  interval,
const std::vector< FLAGSTYPE > &  flags,
const std::vector< ACTUALTIMESTYPE > &  actualTimes,
const std::vector< ACTUALDURATIONSTYPE > &  actualDurations,
const std::vector< ZEROLAGSTYPE > &  zeroLags,
const std::vector< INTCROSSDATATYPE > &  crossData,
const std::vector< AUTODATATYPE > &  autoData 
)

Writes an subintegration (local header + binary attachment) on the MIME message stream.

Parameters
integrationNumthe index (1 based) of the integration.
subintegrationNumthe index(1 based) of the subintegration.
timetime of the integration.
intervalinterval of the integration.
flagsthe values of flags.
actualTimesthe values of actualTimes.
actualDurationsthe values of actualDurations.
zeroLagsthe values of zeroLags.
crossDatathe values of crossData (encoded in int).
autoDatathe values of autoData.
Exceptions
SDMDataObjectWriterException
Note
This method is to be used when cross data are coded with "int" values.
If this integration contains only cross data (CROSS_ONLY) , the autoData parameter is ignored. A empty vector can be passed as an actual parameter.
void asdmbinaries::SDMDataObjectWriter::addSubintegration ( uint32_t  integrationNum,
uint32_t  subintegrationNum,
uint64_t  time,
uint64_t  interval,
const std::vector< FLAGSTYPE > &  flags,
const std::vector< ACTUALTIMESTYPE > &  actualTimes,
const std::vector< ACTUALDURATIONSTYPE > &  actualDurations,
const std::vector< ZEROLAGSTYPE > &  zeroLags,
const std::vector< SHORTCROSSDATATYPE > &  crossData,
const std::vector< AUTODATATYPE > &  autoData 
)

Writes an subintegration (local header + binary attachment) on the MIME message stream.

Parameters
integrationNumthe index (1 based) of the integration.
subintegrationNumthe index(1 based) of the subintegration.
timetime of the integration.
intervalinterval of the integration.
flagsthe values of flags.
actualTimesthe values of actualTimes.
actualDurationsthe values of actualDurations.
zeroLagsthe values of zeroLags.
crossDatathe values of crossData (encoded in short).
autoDatathe values of autoData.
Exceptions
SDMDataObjectWriterException
Note
This method is to be used when cross data are coded with "short" values.
If this integration contains only cross data (CROSS_ONLY) , the autoData parameter is ignored. A empty vector can be passed as an actual parameter.
void asdmbinaries::SDMDataObjectWriter::addSubintegration ( uint32_t  integrationNum,
uint32_t  subintegrationNum,
uint64_t  time,
uint64_t  interval,
const std::vector< FLAGSTYPE > &  flags,
const std::vector< ACTUALTIMESTYPE > &  actualTimes,
const std::vector< ACTUALDURATIONSTYPE > &  actualDurations,
const std::vector< ZEROLAGSTYPE > &  zeroLags,
const std::vector< FLOATCROSSDATATYPE > &  crossData,
const std::vector< AUTODATATYPE > &  autoData 
)

Writes an subintegration (local header + binary attachment) on the MIME message stream.

Parameters
integrationNumthe index (1 based) of the integration.
subintegrationNumthe index(1 based) of the subintegration.
timetime of the integration.
intervalinterval of the integration.
flagsthe values of flags.
actualTimesthe values of actualTimes.
actualDurationsthe values of actualDurations.
zeroLagsthe values of zeroLags.
crossDatathe values of crossData (encoded in float).
autoDatathe values of autoData.
Exceptions
SDMDataObjectWriterException
Note
This method is to be used when cross data are coded with "float" values.
If this integration contains only cross data (CROSS_ONLY) , the autoData parameter is ignored. A empty vector can be passed as an actual parameter.
void asdmbinaries::SDMDataObjectWriter::checkState ( Transitions  t,
const std::string &  methodName 
)
private
void asdmbinaries::SDMDataObjectWriter::corrDataHeader ( uint64_t  startime,
const std::string &  execBlockUID,
uint32_t  execBlockNum,
uint32_t  scanNum,
uint32_t  subscanNum,
uint32_t  numAntenna,
CorrelationModeMod::CorrelationMode  correlationMode,
const OptionalSpectralResolutionType spectralResolutionType,
SDMDataObject::DataStruct dataStruct 
)

Writes the XML global header on the MIME message stream, when binary data are (sub)integrations produced by the correlator.

Parameters
startimestart time.
execBlockUIDthe UID of the exec block.
execBlockNumthe index of the exec block.
scanNumthe index of the scan.
subscanNumthe index of the subscan.
numAntennathe number of antenna.
correlationModethe correlation mode code.
spectralResolutionthe spectral resolution code.
dataStructthe description of the binary data structure.
Exceptions
SDMDataObjectWriterException
void asdmbinaries::SDMDataObjectWriter::done ( )

This method must be called to conclude the activity of this SDMDataObjectWriter.

It completes the MIME message.

Note
Do not forget to call it when you have finished to write your binary data !
It does not close the file attached to the output stream if any, this operation is left to the user.
template<class Enum , class EnumHelper >
static std::vector<Enum> asdmbinaries::SDMDataObjectWriter::enumvec ( const std::string &  strliterals)
inlinestaticprivate

A utility to fill a vector of <Enum> from a an array of c-strings.

Definition at line 830 of file SDMDataObjectWriter.h.

static bool asdmbinaries::SDMDataObjectWriter::initClass ( )
staticprivate
uint64_t asdmbinaries::SDMDataObjectWriter::numBytes ( )

Returns the number of bytes written so far.

This method can be used at any time during the life of an instance of SDMDataObjectWriter. It returns the number of bytes emitted on the output (memory, standard output, disk file...) as the methods of this class, except done, are called.

  • This number is set to 0 at the creation of an SDMDataObjectWriter,
  • it is incremented accordingly with the number of bytes emitted by the different methods, except done,
  • it is reset to 0 by a call to the method done.
Returns
an uint64_t.
void asdmbinaries::SDMDataObjectWriter::output ( const std::string &  s)
void asdmbinaries::SDMDataObjectWriter::output ( const float *  data,
uint32_t  numData 
)
template<class T >
void asdmbinaries::SDMDataObjectWriter::output ( const std::vector< T > &  data)
inline

Definition at line 769 of file SDMDataObjectWriter.h.

References FILE, MEMORY, numBytes_, ofs_, oss_, otype_, and STDOUT.

void asdmbinaries::SDMDataObjectWriter::outputln ( const std::string &  s)
void asdmbinaries::SDMDataObjectWriter::outputln ( const float *  data,
uint32_t  numData 
)
void asdmbinaries::SDMDataObjectWriter::outputln ( const long long *  data,
uint32_t  numData 
)
template<class T >
void asdmbinaries::SDMDataObjectWriter::outputln ( const std::vector< T > &  data)
inline

Definition at line 787 of file SDMDataObjectWriter.h.

References casa::data, and outputln().

void asdmbinaries::SDMDataObjectWriter::outputln ( )

Referenced by outputln().

void asdmbinaries::SDMDataObjectWriter::outputlnLocation ( const std::string &  name,
const SDMDataSubset sdmDataSubset 
)
void asdmbinaries::SDMDataObjectWriter::postamble ( )
private

Write the very end of the MIME message.

void asdmbinaries::SDMDataObjectWriter::preamble ( )
private

Writes the very first part of the MIME message.

void asdmbinaries::SDMDataObjectWriter::tpAddIntegration ( uint32_t  integrationNum,
uint64_t  time,
uint64_t  interval,
const std::vector< FLAGSTYPE > &  flags,
const std::vector< ACTUALTIMESTYPE > &  actualTimes,
const std::vector< ACTUALDURATIONSTYPE > &  actualDurations,
const std::vector< AUTODATATYPE > &  autoData 
)

Writes one integration (local header + binary attachment) of total power data on the MIME message stream.

Parameters
integrationNumthe index (1 based) of the integration.
timetime of the integration.
intervalinterval of the integration.
flagsthe values of flags.
actualTimesthe values of actualTimes.
actualDurationsthe values of actualDurations.
autoDatathe values of autoData.
Exceptions
SDMDataObjectWriterException
Note
To be used repeatedly after one call to tpDataHeader until all the integrations of Total Power data have been acquired.
void asdmbinaries::SDMDataObjectWriter::tpData ( uint64_t  startTime,
const std::string &  execBlockUID,
uint32_t  execBlockNum,
uint32_t  scanNum,
uint32_t  subscanNum,
uint32_t  numOfIntegrations,
uint32_t  numAntenna,
const std::vector< SDMDataObject::Baseband > &  basebands,
uint64_t  time,
uint64_t  interval,
const std::vector< AxisNameMod::AxisName > &  flagsAxes,
const std::vector< FLAGSTYPE > &  flags,
const std::vector< AxisNameMod::AxisName > &  actualTimesAxes,
const std::vector< ACTUALTIMESTYPE > &  actualTimes,
const std::vector< AxisNameMod::AxisName > &  actualDurationsAxes,
const std::vector< ACTUALDURATIONSTYPE > &  actualDurations,
const std::vector< AxisNameMod::AxisName > &  autoDataAxes,
const std::vector< AUTODATATYPE > &  autoData 
)

Writes the full content of Total Power data in their respective attachments (global XML header, local XML header and binary attachments) on the MIME message stream.

Parameters
startTimestart time.
execBlockUIDthe UID of the exec block.
execBlockNumthe index of the exec block.
scanNumthe index of the scan.
subscanNumthe index of the subscan.
numOfIntegrationsthe number of integrations in that Subscan.
numAntennathe number of antenna.
basebandsa vector of Baseband describing the structure of the binary data.
time.
interval.
flagsthe values of flags (see note).
actualTimesthe values of actualTimes (see note).
actualDurationsthe values of actualDurations (see note).
autoDataAxesthe ordered set of axes names for autoData.
autoDatathe values of autoData.
autoDataNormalized
Exceptions
SDMDataObjectWriterException
Note
A vector with a null size can be passed when the (optional) attachment is absent.
this method allows to write Total Power data in a "one-call" way. An alternate solution consists in calling tpDataHeader and then addTPSubscan.
void asdmbinaries::SDMDataObjectWriter::tpData ( uint64_t  startTime,
const std::string &  execBlockUID,
uint32_t  execBlockNum,
uint32_t  scanNum,
uint32_t  subscanNum,
uint32_t  numOfIntegrations,
uint32_t  numAntenna,
const std::vector< SDMDataObject::Baseband > &  basebands,
uint64_t  time,
uint64_t  interval,
const std::vector< AxisNameMod::AxisName > &  autoDataAxes,
const std::vector< AUTODATATYPE > &  autoData 
)

Writes the full content of Total Power data in their respective attachments (global XML header, local XML header and binary attachments) on the MIME message stream.

Parameters
startTimestart time.
execBlockUIDthe UID of the exec block.
execBlockNumthe index of the exec block.
scanNumthe index of the scan.
subscanNumthe index of the subscan.
numOfIntegrationsthe number of integrations in that Subscan.
numAntennathe number of antenna.
basebandsa vector of Baseband describing the structure of the binary data.
time
interval
autoDataAxesthe ordered set of axes names for autoData.
autoDatathe values of autoData.
Exceptions
SDMDataObjectWriterException
Note
This method is kept for backward compatibility reasons. It's recommanded to use the "long" version of tpData which gives a full control of the optional attachments to be written.
void asdmbinaries::SDMDataObjectWriter::tpDataHeader ( uint64_t  startTime,
const std::string &  execBlockUID,
uint32_t  execBlockNum,
uint32_t  scanNum,
uint32_t  subscanNum,
uint32_t  numAntenna,
SDMDataObject::DataStruct dataStruct 
)

Writes the XML global header on the MIME message stream, when binary data are Total Power data and will be written in successive steps with calls to tpAddIntegration.

Parameters
startimestart time.
execBlockUIDthe UID of the exec block.
execBlockNumthe index of the exec block.
scanNumthe index of the scan.
subscanNumthe index of the subscan.
numAntennathe number of antenna.
dataStructthe description of the binary data structure.
Exceptions
SDMDataObjectWriterException
void asdmbinaries::SDMDataObjectWriter::wvrData ( const std::string &  execBlockUID,
uint32_t  execBlockNum,
uint32_t  scanNum,
uint32_t  subscanNum,
uint32_t  numTimes,
uint32_t  numAntennas,
uint32_t  numChannels,
NetSidebandMod::NetSideband  netSideband,
uint64_t  time,
uint64_t  interval,
const std::vector< AUTODATATYPE > &  wvrData,
const std::vector< FLAGSTYPE > &  flags 
)

Writes water vapour radiometer (WVR) data in a MIME message conform with the BDF V2 format.

Parameters
execBlockUIDthe archive uid of the exec Block,
execBlockNumthe index of the exec Block,
scanNumthe number of the scan,
subscanNumthe number of the subscan,
numTimesthe number of time stamps (i.e. size along the TIM axis),
numAntennasthe number of antennas producing WVR data,
numChannelsthe number of channels in WVR data,
netSidebandthe NetSideband characteristic attached to WVR data,
timethe mid-point of the time range containing all the WVR data,
intervalthe duration of the time range containing all the WVR data,
wvrDatathe WVR data,
flagsthe flags associated to the WVR data.
Exceptions
SDMDataObjectWriterException
Note
  • see the constructor of the class and the done method for opening the output stream where the MIME message is actually written (file, memory...) and for closing it
  • the "startTime" element of the global header in the resulting MIME document will be filled with a value equal to 'time' - 'interval'/2,
  • 'time' and 'interval' express a number of nanoseconds. 'time' is an MJD,
  • 'wvrData' and 'flags' are both 1D arrays. Nonetheless they are expected to be the linearized versions of multi dimensional arrays whose axes are defined by the sequence TIM ANT SPP for the WVR data and TIM ANT for their flags, (SPP varying before ANT varying itself before TIM),
  • a vector of null size for the argument 'flags' will be interpreted as 'flags not available'.
  • a null value in at least one of the arguments 'numTimes', 'numAntennas' or 'numChannels' will trigger an SDMDataObjectWriterException.
  • a argument 'wvrData' with a size different from 'numTimes' * 'numAntennas' * 'numChannels' will trigger an SDMDataObjectWriterException.
  • an argument 'flags' with a size different from 0 and different from 'numTimes' * 'numAntennas' will trigger an SDMDataObjectWriterException.

Member Data Documentation

States asdmbinaries::SDMDataObjectWriter::currentState_
private

Definition at line 873 of file SDMDataObjectWriter.h.

bool asdmbinaries::SDMDataObjectWriter::done_
private

Are we done with this ?

Definition at line 864 of file SDMDataObjectWriter.h.

const bool asdmbinaries::SDMDataObjectWriter::initClass_
staticprivate

Class initialization stuff.

Definition at line 823 of file SDMDataObjectWriter.h.

const std::string asdmbinaries::SDMDataObjectWriter::MIMEBOUNDARY_1
staticprivate

Two strings used as MIME boundaries.

Definition at line 818 of file SDMDataObjectWriter.h.

const std::string asdmbinaries::SDMDataObjectWriter::MIMEBOUNDARY_2
staticprivate

Definition at line 819 of file SDMDataObjectWriter.h.

uint64_t asdmbinaries::SDMDataObjectWriter::numBytes_
private

The number of bytes written so far.

Definition at line 867 of file SDMDataObjectWriter.h.

Referenced by output().

std::ofstream* asdmbinaries::SDMDataObjectWriter::ofs_
private

Definition at line 799 of file SDMDataObjectWriter.h.

Referenced by output().

std::ostringstream* asdmbinaries::SDMDataObjectWriter::oss_
private

Definition at line 800 of file SDMDataObjectWriter.h.

Referenced by output().

OUTDEST asdmbinaries::SDMDataObjectWriter::otype_
private

Definition at line 798 of file SDMDataObjectWriter.h.

Referenced by output().

SDMDataObject asdmbinaries::SDMDataObjectWriter::sdmDataObject_
private

An SDMDataObject.

Definition at line 812 of file SDMDataObjectWriter.h.

uint32_t asdmbinaries::SDMDataObjectWriter::sdmDataSubsetNum_
private

The number of the SDMDataSubset being written.

Definition at line 815 of file SDMDataObjectWriter.h.

std::string asdmbinaries::SDMDataObjectWriter::subscanPath_
private

The subscan path.

Definition at line 809 of file SDMDataObjectWriter.h.

std::string asdmbinaries::SDMDataObjectWriter::title_
private

The title of the binary data.

Definition at line 806 of file SDMDataObjectWriter.h.

std::string asdmbinaries::SDMDataObjectWriter::uid_
private

The ALMA uid of the MIME message.

Definition at line 803 of file SDMDataObjectWriter.h.

std::vector<AxisNameMod::AxisName> asdmbinaries::SDMDataObjectWriter::WVRDATAAXES
staticprivate

The axes names definitions for WVR data and their related flags.

Definition at line 827 of file SDMDataObjectWriter.h.

std::vector<AxisNameMod::AxisName> asdmbinaries::SDMDataObjectWriter::WVRDATAFLAGSAXES
staticprivate

Definition at line 827 of file SDMDataObjectWriter.h.


The documentation for this class was generated from the following file: