COPASI API  4.16.103
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CTimeSeries Class Reference

#include <CTimeSeries.h>

Inheritance diagram for CTimeSeries:
Inheritance graph
[legend]
Collaboration diagram for CTimeSeries:
Collaboration graph
[legend]

Public Member Functions

void allocate (const size_t &steps)
 
void clear ()
 
virtual bool compile (std::vector< CCopasiContainer * > listOfContainer, const CCopasiDataModel *pDataModel)
 
 CTimeSeries ()
 
 CTimeSeries (const CTimeSeries &src)
 
virtual void finish ()
 
C_FLOAT64 getConcentrationData (const size_t &step, const size_t &variable) const
 
const C_FLOAT64getData (const size_t &step, const size_t &variable) const
 
const std::string & getKey (const size_t &variable) const
 
const size_t & getNumVariables () const
 
const size_t & getRecordedSteps () const
 
std::string getSBMLId (const size_t &variable, const CCopasiDataModel *pDataModel) const
 
const std::string & getTitle (const size_t &variable) const
 
void increaseAllocation ()
 
virtual void output (const Activity &activity)
 
int save (const std::string &fileName, bool writeConcentrations=false, const std::string &separator="\t") const
 
virtual void separate (const Activity &activity)
 
 ~CTimeSeries ()
 
- Public Member Functions inherited from COutputInterface
virtual void close ()
 
 COutputInterface ()
 
 COutputInterface (const COutputInterface &src)
 
virtual const std::set< const
CCopasiObject * > & 
getObjects () const
 
virtual ~COutputInterface ()
 

Private Member Functions

CTimeSeriesoperator= (const CTimeSeries &)
 

Private Attributes

size_t mAllocatedSteps
 
CVector< size_t > mCompartment
 
std::vector< std::string > mKeys
 
C_FLOAT64 mNumberToQuantityFactor
 
C_FLOAT64mpEnd
 
C_FLOAT64mpIt
 
CVector< size_t > mPivot
 
const CStatempState
 
size_t mRecordedSteps
 
std::vector< std::string > mTitles
 

Static Private Attributes

static C_FLOAT64 mDummyFloat
 
static std::string mDummyString
 

Additional Inherited Members

- Public Types inherited from COutputInterface
enum  Activity { BEFORE = 0x01, DURING = 0x02, AFTER = 0x04 }
 
- Protected Types inherited from CMatrix< C_FLOAT64 >
typedef C_FLOAT64 elementType
 
- Protected Member Functions inherited from CMatrix< C_FLOAT64 >
bool applyPivot (const CVector< size_t > &pivot)
 
virtual C_FLOAT64array ()
 
virtual const C_FLOAT64array () const
 
 CMatrix (size_t rows=0, size_t cols=0)
 
 CMatrix (const CMatrix< C_FLOAT64 > &src)
 
virtual size_t numCols () const
 
virtual size_t numRows () const
 
virtual elementTypeoperator() (const size_t &row, const size_t &col)
 
virtual const elementTypeoperator() (const size_t &row, const size_t &col) const
 
virtual CMatrix< C_FLOAT64 > & operator= (const CMatrix< C_FLOAT64 > &rhs)
 
virtual CMatrix< C_FLOAT64 > & operator= (const C_FLOAT64 &value)
 
virtual C_FLOAT64operator[] (size_t row)
 
virtual const C_FLOAT64operator[] (size_t row) const
 
virtual void resize (size_t rows, size_t cols, const bool &copy=false)
 
virtual size_t size () const
 
virtual ~CMatrix ()
 
- Protected Attributes inherited from COutputInterface
std::set< const CCopasiObject * > mObjects
 
- Protected Attributes inherited from CMatrix< C_FLOAT64 >
C_FLOAT64mArray
 
size_t mCols
 
size_t mRows
 

Detailed Description

Definition at line 28 of file CTimeSeries.h.

Constructor & Destructor Documentation

CTimeSeries::CTimeSeries ( )

Default constructor

Definition at line 40 of file CTimeSeries.cpp.

40  :
43  mAllocatedSteps(0),
44  mRecordedSteps(0),
45  mpIt(mArray),
46  mpEnd(mArray + size()),
47  mpState(NULL),
48  mTitles(),
49  mCompartment(),
50  mPivot(),
51  mKeys(),
53 {}
C_FLOAT64 * mpEnd
Definition: CTimeSeries.h:182
std::vector< std::string > mTitles
Definition: CTimeSeries.h:192
size_t mRecordedSteps
Definition: CTimeSeries.h:172
C_FLOAT64 * mArray
Definition: CMatrix.h:87
const CState * mpState
Definition: CTimeSeries.h:187
CVector< size_t > mPivot
Definition: CTimeSeries.h:203
C_FLOAT64 mNumberToQuantityFactor
Definition: CTimeSeries.h:213
virtual size_t size() const
Definition: CMatrix.h:132
C_FLOAT64 * mpIt
Definition: CTimeSeries.h:177
size_t mAllocatedSteps
Definition: CTimeSeries.h:167
CVector< size_t > mCompartment
Definition: CTimeSeries.h:198
std::vector< std::string > mKeys
Definition: CTimeSeries.h:208
CTimeSeries::CTimeSeries ( const CTimeSeries src)

Copy constructor

Parameters
constCTimeSeries & src

Definition at line 55 of file CTimeSeries.cpp.

55  :
56  COutputInterface(src),
61  mpEnd(mArray + size()),
62  mpState(src.mpState),
63  mTitles(src.mTitles),
65  mPivot(src.mPivot),
66  mKeys(src.mKeys),
68 {}
C_FLOAT64 * mpEnd
Definition: CTimeSeries.h:182
std::vector< std::string > mTitles
Definition: CTimeSeries.h:192
size_t mRecordedSteps
Definition: CTimeSeries.h:172
C_FLOAT64 * mArray
Definition: CMatrix.h:87
const CState * mpState
Definition: CTimeSeries.h:187
CVector< size_t > mPivot
Definition: CTimeSeries.h:203
C_FLOAT64 mNumberToQuantityFactor
Definition: CTimeSeries.h:213
virtual size_t size() const
Definition: CMatrix.h:132
C_FLOAT64 * mpIt
Definition: CTimeSeries.h:177
size_t mAllocatedSteps
Definition: CTimeSeries.h:167
CVector< size_t > mCompartment
Definition: CTimeSeries.h:198
std::vector< std::string > mKeys
Definition: CTimeSeries.h:208
CTimeSeries::~CTimeSeries ( )

Destructor

Definition at line 70 of file CTimeSeries.cpp.

71 {}

Member Function Documentation

void CTimeSeries::allocate ( const size_t &  steps)

The maximal number of recorded steps. This must be set before compiling

Parameters
constsize_t & steps

Definition at line 73 of file CTimeSeries.cpp.

References mAllocatedSteps.

Referenced by CQGLNetworkPainter::createDataSets(), CTSSATask::initialize(), CTrajectoryTask::initialize(), and CCrossSectionTask::initialize().

74 {
75  // The actual allocation is deferred to compile
76  mAllocatedSteps = steps;
77 }
size_t mAllocatedSteps
Definition: CTimeSeries.h:167
void CTimeSeries::clear ( )

Clear the time series

Definition at line 96 of file CTimeSeries.cpp.

References mAllocatedSteps, CMatrix< C_FLOAT64 >::mArray, mCompartment, mKeys, mNumberToQuantityFactor, COutputInterface::mObjects, mpEnd, mpIt, mPivot, mpState, mRecordedSteps, CMatrix< C_FLOAT64 >::mRows, mTitles, CMatrix< CType >::resize(), CVector< CType >::resize(), and CMatrix< C_FLOAT64 >::size().

Referenced by CTrajectoryTask::initialize(), CTSSATask::initialize(), and CCrossSectionTask::initialize().

97 {
98  mObjects.clear();
101  mRecordedSteps = 0;
102  mpIt = mArray;
103  mpEnd = mArray + size();
104  mpState = NULL;
105  mTitles.clear();
106  mCompartment.resize(0);
107  mPivot.resize(0);
108  mKeys.clear();
110 }
C_FLOAT64 * mpEnd
Definition: CTimeSeries.h:182
std::vector< std::string > mTitles
Definition: CTimeSeries.h:192
size_t mRecordedSteps
Definition: CTimeSeries.h:172
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
C_FLOAT64 * mArray
Definition: CMatrix.h:87
const CState * mpState
Definition: CTimeSeries.h:187
CVector< size_t > mPivot
Definition: CTimeSeries.h:203
virtual void resize(size_t rows, size_t cols, const bool &copy=false)
Definition: CMatrix.h:151
std::set< const CCopasiObject * > mObjects
C_FLOAT64 mNumberToQuantityFactor
Definition: CTimeSeries.h:213
virtual size_t size() const
Definition: CMatrix.h:132
C_FLOAT64 * mpIt
Definition: CTimeSeries.h:177
size_t mAllocatedSteps
Definition: CTimeSeries.h:167
CVector< size_t > mCompartment
Definition: CTimeSeries.h:198
std::vector< std::string > mKeys
Definition: CTimeSeries.h:208
bool CTimeSeries::compile ( std::vector< CCopasiContainer * >  listOfContainer,
const CCopasiDataModel pDataModel 
)
virtual

compile the object list from name vector

Parameters
std::vector<CCopasiContainer * > listOfContainer
constCCopasiDataModel* pDataModel
Returns
bool success

Reimplemented from COutputInterface.

Definition at line 113 of file CTimeSeries.cpp.

References CVectorCore< CType >::array(), C_INVALID_INDEX, CStateTemplate::endFixed(), CCopasiObject::getCN(), CMetab::getCompartment(), CMetabNameInterface::getDisplayName(), CStateTemplate::getEntities(), CStateTemplate::getIndex(), CModel::getKey(), CCopasiDataModel::getModel(), CModel::getNumber2QuantityFactor(), CModel::getState(), CModel::getStateTemplate(), CStateTemplate::getUserOrder(), mAllocatedSteps, CMatrix< C_FLOAT64 >::mArray, mCompartment, mKeys, mNumberToQuantityFactor, COutputInterface::mObjects, mpEnd, mpIt, mPivot, mpState, mRecordedSteps, mTitles, CCopasiDataModel::ObjectFromName(), CMatrix< CType >::resize(), CVector< CType >::resize(), CVectorCore< CType >::size(), and CMatrix< C_FLOAT64 >::size().

Referenced by CQGLNetworkPainter::createDataSets().

115 {
116  const CModel * pModel =
117  dynamic_cast< const CModel * >(pDataModel->ObjectFromName(listOfContainer, pDataModel->getModel()->getCN()));
118 
119  if (pModel == NULL)
120  return false;
121 
122  mpState = & pModel->getState();
123 
124  const CStateTemplate & Template = pModel->getStateTemplate();
125 
126  // We store all variables of the system.
127  // The reason for this is that events will be able to change even fixed values.
128  CModelEntity *const* it = Template.getEntities();
129  CModelEntity *const* end = Template.endFixed();
130 
131  size_t i, imax = end - it;
132 
134 
135  mObjects.clear();
136 
137  mPivot.resize(imax);
138  mTitles.resize(imax);
139  mCompartment.resize(imax);
140  mKeys.resize(imax);
141 
142  mRecordedSteps = 0;
143  mpIt = mArray;
144  mpEnd = mArray + size();
146 
148 
149  const CMetab * pMetab;
150 
151  for (i = 0; it != end; ++i, ++it)
152  {
153  if ((pMetab = dynamic_cast< const CMetab *>(*it)) != NULL)
154  {
155  mTitles[i] = CMetabNameInterface::getDisplayName(pModel, *pMetab, false);
156  mCompartment[i] = Template.getIndex(pMetab->getCompartment());
157  }
158  else
159  {
160  mTitles[i] = (*it)->getObjectDisplayName();
161  }
162 
163  mKeys[i] = (*it)->getKey();
164 
165  mObjects.insert((*it)->getValueReference());
166  }
167 
168  mTitles[0] = "Time";
169  mKeys[0] = pModel->getKey();
170 
171  const size_t * pUserOrder = Template.getUserOrder().array();
172  const size_t * pUserOrderEnd = pUserOrder + Template.getUserOrder().size();
173  it = Template.getEntities();
174 
175  for (i = 0; pUserOrder != pUserOrderEnd; ++pUserOrder)
176  mPivot[i++] = *pUserOrder;
177 
178  return true;
179 }
C_FLOAT64 * mpEnd
Definition: CTimeSeries.h:182
virtual CCopasiObjectName getCN() const
std::vector< std::string > mTitles
Definition: CTimeSeries.h:192
size_t mRecordedSteps
Definition: CTimeSeries.h:172
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
#define C_INVALID_INDEX
Definition: copasi.h:222
size_t getIndex(const CModelEntity *entity) const
Definition: CState.cpp:231
C_FLOAT64 * mArray
Definition: CMatrix.h:87
static std::string getDisplayName(const CModel *model, const std::string &key, const bool &quoted)
Definition: CMetab.h:178
const CState * mpState
Definition: CTimeSeries.h:187
const C_FLOAT64 & getNumber2QuantityFactor() const
Definition: CModel.cpp:2357
CModelEntity ** endFixed()
Definition: CState.cpp:213
CVector< size_t > mPivot
Definition: CTimeSeries.h:203
const std::string & getKey() const
Definition: CModel.cpp:1142
virtual void resize(size_t rows, size_t cols, const bool &copy=false)
Definition: CMatrix.h:151
std::set< const CCopasiObject * > mObjects
size_t size() const
Definition: CVector.h:100
C_FLOAT64 mNumberToQuantityFactor
Definition: CTimeSeries.h:213
CType * array()
Definition: CVector.h:139
const CStateTemplate & getStateTemplate() const
Definition: CModel.cpp:1172
virtual size_t size() const
Definition: CMatrix.h:132
C_FLOAT64 * mpIt
Definition: CTimeSeries.h:177
Definition: CModel.h:50
const CState & getState() const
Definition: CModel.cpp:1771
const CVector< size_t > & getUserOrder() const
Definition: CState.cpp:201
size_t mAllocatedSteps
Definition: CTimeSeries.h:167
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
const CCompartment * getCompartment() const
Definition: CMetab.cpp:222
CVector< size_t > mCompartment
Definition: CTimeSeries.h:198
CModelEntity ** getEntities()
Definition: CState.cpp:204
std::vector< std::string > mKeys
Definition: CTimeSeries.h:208
void CTimeSeries::finish ( )
virtual

Finish the output

Reimplemented from COutputInterface.

Definition at line 223 of file CTimeSeries.cpp.

224 {}
C_FLOAT64 CTimeSeries::getConcentrationData ( const size_t &  step,
const size_t &  variable 
) const

Retrieve the data (concentration for species) for the indexed step and variable

Parameters
constsize_t & step
constsize_t & variable
Returns
const C_FLOAT64 & data

Definition at line 243 of file CTimeSeries.cpp.

References C_INVALID_INDEX, CMatrix< C_FLOAT64 >::mArray, CMatrix< C_FLOAT64 >::mCols, mCompartment, mDummyFloat, mNumberToQuantityFactor, mPivot, and mRecordedSteps.

Referenced by CQGLNetworkPainter::createDataSets(), CQTimeSeriesDM::data(), and save().

245 {
246  if (step < mRecordedSteps && var < mCols)
247  {
248  const size_t & Col = mPivot[var];
249 
250  if (mCompartment[Col] != C_INVALID_INDEX)
251  return *(mArray + step * mCols + Col) * mNumberToQuantityFactor / *(mArray + step * mCols + mCompartment[Col]);
252  else
253  return *(mArray + step * mCols + Col);
254  }
255 
256  return mDummyFloat;
257 }
size_t mRecordedSteps
Definition: CTimeSeries.h:172
#define C_INVALID_INDEX
Definition: copasi.h:222
C_FLOAT64 * mArray
Definition: CMatrix.h:87
CVector< size_t > mPivot
Definition: CTimeSeries.h:203
static C_FLOAT64 mDummyFloat
Definition: CTimeSeries.h:223
C_FLOAT64 mNumberToQuantityFactor
Definition: CTimeSeries.h:213
CVector< size_t > mCompartment
Definition: CTimeSeries.h:198
const C_FLOAT64 & CTimeSeries::getData ( const size_t &  step,
const size_t &  variable 
) const

Retrieve the data (particle number for species) for the indexed step and variable

Parameters
constsize_t & step
constsize_t & variable
Returns
const C_FLOAT64 & data

Definition at line 234 of file CTimeSeries.cpp.

References CMatrix< C_FLOAT64 >::mArray, CMatrix< C_FLOAT64 >::mCols, mDummyFloat, mPivot, and mRecordedSteps.

Referenced by CQTimeSeriesDM::data(), QTimeCourseAnimation::getMax(), QTimeCourseAnimation::getValue(), and save().

236 {
237  if (step < mRecordedSteps && var < mCols)
238  return *(mArray + step * mCols + mPivot[var]);
239 
240  return mDummyFloat;
241 }
size_t mRecordedSteps
Definition: CTimeSeries.h:172
C_FLOAT64 * mArray
Definition: CMatrix.h:87
CVector< size_t > mPivot
Definition: CTimeSeries.h:203
static C_FLOAT64 mDummyFloat
Definition: CTimeSeries.h:223
const std::string & CTimeSeries::getKey ( const size_t &  variable) const

Retrieve the key of the model entity of the indexed variable (column)

Parameters
constsize_t & variable
Returns
const std::string & key

Definition at line 267 of file CTimeSeries.cpp.

References CMatrix< C_FLOAT64 >::mCols, mDummyString, mKeys, and mPivot.

Referenced by CQGLNetworkPainter::createDataSets(), QTimeCourseAnimation::getIndex(), and getSBMLId().

268 {
269  if (var < mCols)
270  return mKeys[mPivot[var]];
271 
272  return mDummyString;
273 }
static std::string mDummyString
Definition: CTimeSeries.h:218
CVector< size_t > mPivot
Definition: CTimeSeries.h:203
std::vector< std::string > mKeys
Definition: CTimeSeries.h:208
const size_t & CTimeSeries::getNumVariables ( ) const

Retrieve the number of variables (columns)

Returns
size_t & numVariables

Definition at line 231 of file CTimeSeries.cpp.

References CMatrix< C_FLOAT64 >::mCols.

Referenced by CQTimeSeriesDM::columnCount(), CQGLNetworkPainter::createDataSets(), QTimeCourseAnimation::getIndex(), QTimeCourseAnimation::getMax(), and save().

232 {return mCols;}
const size_t & CTimeSeries::getRecordedSteps ( ) const

Retrieve the number of time steps (rows)

Returns
const size_t & recordedSteps

Definition at line 228 of file CTimeSeries.cpp.

References mRecordedSteps.

Referenced by CQGLNetworkPainter::createDataSets(), QTimeCourseAnimation::getMax(), QTimeCourseAnimation::getScales(), QTimeCourseAnimation::initialize(), and CQTimeSeriesDM::rowCount().

229 {return mRecordedSteps;}
size_t mRecordedSteps
Definition: CTimeSeries.h:172
std::string CTimeSeries::getSBMLId ( const size_t &  variable,
const CCopasiDataModel pDataModel 
) const

get the id of the SBML object corresponding to column indexed by variable. If there is no corresponding SBML object (e.g. if the model comes from a COPASI file) the empty string is returned.

Parameters
constsize_t & variable
Returns
const std::string SBMLId

Definition at line 275 of file CTimeSeries.cpp.

References CKeyFactory::get(), getKey(), CCopasiRootContainer::getKeyFactory(), and mDummyString.

276 {
277  std::string key = getKey(var);
278  std::string result("");
279 
280  if (key != mDummyString)
281  {
282  const CCopasiObject* pObject = CCopasiRootContainer::getKeyFactory()->get(key);
283 
284  if (pObject != NULL)
285  {
286  std::map<CCopasiObject*, SBase*>::const_iterator pos = const_cast<CCopasiDataModel*>(pDataModel)->getCopasi2SBMLMap().find(const_cast<CCopasiObject*>(pObject));
287 
288  if (pos != const_cast<CCopasiDataModel*>(pDataModel)->getCopasi2SBMLMap().end())
289  {
290  const SBase* pSBMLObject = pos->second;
291  const Compartment* pSBMLCompartment = NULL;
292  const Species* pSBMLSpecies = NULL;
293  const Parameter* pSBMLParameter = NULL;
294  const Model* pSBMLModel = NULL;
295 
296  switch (pSBMLObject->getTypeCode())
297  {
298  case SBML_COMPARTMENT:
299  pSBMLCompartment = dynamic_cast<const Compartment*>(pSBMLObject);
300 
301  if (pSBMLCompartment && pSBMLCompartment->isSetId())
302  {
303  result = pSBMLCompartment->getId();
304  }
305 
306  break;
307 
308  case SBML_SPECIES:
309  pSBMLSpecies = dynamic_cast<const Species*>(pSBMLObject);
310 
311  if (pSBMLSpecies && pSBMLSpecies->isSetId())
312  {
313  result = pSBMLSpecies->getId();
314  }
315 
316  break;
317 
318  case SBML_PARAMETER:
319  pSBMLParameter = dynamic_cast<const Parameter*>(pSBMLObject);
320 
321  if (pSBMLParameter && pSBMLParameter->isSetId())
322  {
323  result = pSBMLParameter->getId();
324  }
325 
326  break;
327 
328  case SBML_MODEL:
329  pSBMLModel = dynamic_cast<const Model*>(pSBMLObject);
330 
331  if (pSBMLModel && pSBMLModel->isSetId())
332  {
333  result = pSBMLModel->getId();
334  }
335 
336  break;
337 
338  default:
339  break;
340  }
341  }
342  }
343  }
344 
345  return result;
346 }
CCopasiObject * get(const std::string &key)
const std::string & getKey(const size_t &variable) const
static std::string mDummyString
Definition: CTimeSeries.h:218
static CKeyFactory * getKeyFactory()
const std::string & CTimeSeries::getTitle ( const size_t &  variable) const

Retrieve the title of the indexed variable (column)

Parameters
constsize_t & variable
Returns
const std::string & title

Definition at line 259 of file CTimeSeries.cpp.

References CMatrix< C_FLOAT64 >::mCols, mDummyString, mPivot, and mTitles.

Referenced by CQGLNetworkPainter::createDataSets(), CQTimeSeriesDM::headerData(), and save().

260 {
261  if (var < mCols)
262  return mTitles[mPivot[var]];
263 
264  return mDummyString;
265 }
std::vector< std::string > mTitles
Definition: CTimeSeries.h:192
static std::string mDummyString
Definition: CTimeSeries.h:218
CVector< size_t > mPivot
Definition: CTimeSeries.h:203
void CTimeSeries::increaseAllocation ( )

Increase the allocated space for the time series.

Definition at line 79 of file CTimeSeries.cpp.

References mAllocatedSteps, CMatrix< C_FLOAT64 >::mArray, CMatrix< C_FLOAT64 >::mCols, mpEnd, mpIt, mRecordedSteps, CMatrix< CType >::resize(), and CMatrix< C_FLOAT64 >::size().

Referenced by output(), and separate().

80 {
81  size_t diff;
82  diff = mAllocatedSteps / 4;
83 
84  if (diff < 10)
85  diff = 10;
86  else if (diff > 10000)
87  diff = 10000;
88 
89  mAllocatedSteps += diff;
91 
93  mpEnd = mArray + size();
94 }
C_FLOAT64 * mpEnd
Definition: CTimeSeries.h:182
size_t mRecordedSteps
Definition: CTimeSeries.h:172
C_FLOAT64 * mArray
Definition: CMatrix.h:87
virtual void resize(size_t rows, size_t cols, const bool &copy=false)
Definition: CMatrix.h:151
virtual size_t size() const
Definition: CMatrix.h:132
C_FLOAT64 * mpIt
Definition: CTimeSeries.h:177
size_t mAllocatedSteps
Definition: CTimeSeries.h:167
CTimeSeries& CTimeSeries::operator= ( const CTimeSeries )
private
void CTimeSeries::output ( const Activity activity)
virtual

Perform an output event for the current activity

Parameters
constActivity & activity

Reimplemented from COutputInterface.

Definition at line 182 of file CTimeSeries.cpp.

References C_FLOAT64, COutputInterface::DURING, CState::getTime(), increaseAllocation(), CMatrix< C_FLOAT64 >::mCols, mpEnd, mpIt, mpState, and mRecordedSteps.

Referenced by CQGLNetworkPainter::createDataSets().

183 {
184  if (activity != DURING)
185  return;
186 
187  // We may have to reallocate due to additional output caused from events
188  if (mpIt == mpEnd)
189  {
191  }
192 
193  if (mpIt != mpEnd)
194  {
195  memcpy(mpIt, &mpState->getTime(), mCols * sizeof(C_FLOAT64));
196  mpIt += mCols;
197  mRecordedSteps++;
198  }
199 }
C_FLOAT64 * mpEnd
Definition: CTimeSeries.h:182
size_t mRecordedSteps
Definition: CTimeSeries.h:172
const CState * mpState
Definition: CTimeSeries.h:187
const C_FLOAT64 & getTime() const
Definition: CState.cpp:325
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 * mpIt
Definition: CTimeSeries.h:177
void increaseAllocation()
Definition: CTimeSeries.cpp:79
int CTimeSeries::save ( const std::string &  fileName,
bool  writeConcentrations = false,
const std::string &  separator = "\t" 
) const

Save the time series to a file

Parameters
conststd::string & fileName
boolwriteConcentrations (default: false)
conststd::string& separator (default: "\t")
Returns
int retcode

Definition at line 348 of file CTimeSeries.cpp.

References C_FLOAT64, CLocaleString::fromUtf8(), getConcentrationData(), getData(), getNumVariables(), getTitle(), and mRecordedSteps.

Referenced by CQTimeSeriesWidget::slotSave().

349 {
350  std::ofstream fileStream(CLocaleString::fromUtf8(fileName).c_str());
351  std::ostringstream* stringStream = new std::ostringstream();
352  (*stringStream) << "# ";
353  size_t counter2;
354  size_t maxCount2 = this->getNumVariables();
355 
356  for (counter2 = 0; counter2 < maxCount2; ++counter2)
357  {
358  (*stringStream) << this->getTitle(counter2) << separator;
359  }
360 
361  (*stringStream) << std::endl;
362  fileStream << stringStream->str();
363 
364  if (!fileStream.good()) return 1;
365 
366  size_t counter;
367  size_t maxCount = mRecordedSteps;
368 
369  for (counter = 0; counter < maxCount; ++counter)
370  {
371  delete stringStream;
372  stringStream = new std::ostringstream();
373 
374  for (counter2 = 0; counter2 < maxCount2; ++counter2)
375  {
376  C_FLOAT64 value;
377 
378  if (writeParticleNumbers)
379  {
380  value = this->getData(counter, counter2);
381  }
382  else
383  {
384  value = this->getConcentrationData(counter, counter2);
385  }
386 
387  (*stringStream) << value << separator;
388  }
389 
390  (*stringStream) << std::endl;
391  fileStream << stringStream->str();
392 
393  if (!fileStream.good()) return 1;
394  }
395 
396  fileStream.close();
397  delete stringStream;
398  return 0;
399 }
C_FLOAT64 getConcentrationData(const size_t &step, const size_t &variable) const
const size_t & getNumVariables() const
size_t mRecordedSteps
Definition: CTimeSeries.h:172
const std::string & getTitle(const size_t &variable) const
const C_FLOAT64 & getData(const size_t &step, const size_t &variable) const
#define C_FLOAT64
Definition: copasi.h:92
static CLocaleString fromUtf8(const std::string &utf8)
void CTimeSeries::separate ( const Activity activity)
virtual

Introduce an additional separator into the output

Parameters
constActivity & activity

Reimplemented from COutputInterface.

Definition at line 202 of file CTimeSeries.cpp.

References C_FLOAT64, increaseAllocation(), CMatrix< C_FLOAT64 >::mCols, mpEnd, mpIt, and mRecordedSteps.

203 {
204  // We may have to reallocate due to additional output caused from events
205  if (mpIt == mpEnd)
206  {
208  }
209 
210  if (mpIt != mpEnd)
211  {
212  C_FLOAT64 * pIt = mpIt;
213  mpIt += mCols;
214  mRecordedSteps++;
215 
216  // We copy NaN to indicate separation, which is similar to plotting.
217  for (; pIt != mpIt; ++pIt)
218  *pIt = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
219  }
220 }
C_FLOAT64 * mpEnd
Definition: CTimeSeries.h:182
size_t mRecordedSteps
Definition: CTimeSeries.h:172
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 * mpIt
Definition: CTimeSeries.h:177
void increaseAllocation()
Definition: CTimeSeries.cpp:79

Member Data Documentation

size_t CTimeSeries::mAllocatedSteps
private

The number of allocated steps

Definition at line 167 of file CTimeSeries.h.

Referenced by allocate(), clear(), compile(), and increaseAllocation().

CVector< size_t > CTimeSeries::mCompartment
private

Vector of indexes pointing to the column storing the volume of the containing compartment for a species (C_INVALID_INDEX otherwise)

Definition at line 198 of file CTimeSeries.h.

Referenced by clear(), compile(), and getConcentrationData().

C_FLOAT64 CTimeSeries::mDummyFloat
staticprivate

Static C_FLOAT64 0.0 for performance reasons

Definition at line 223 of file CTimeSeries.h.

Referenced by getConcentrationData(), and getData().

std::string CTimeSeries::mDummyString
staticprivate

Static empty string for performance reasons

Definition at line 218 of file CTimeSeries.h.

Referenced by getKey(), getSBMLId(), and getTitle().

std::vector< std::string > CTimeSeries::mKeys
private

Vector storing the keys for the model entity represented by each column

Definition at line 208 of file CTimeSeries.h.

Referenced by clear(), compile(), and getKey().

C_FLOAT64 CTimeSeries::mNumberToQuantityFactor
private

Conversion factor needed for computing concentration data

Definition at line 213 of file CTimeSeries.h.

Referenced by clear(), compile(), and getConcentrationData().

C_FLOAT64* CTimeSeries::mpEnd
private

Iterator pointing beyond the last allocated step (row)

Definition at line 182 of file CTimeSeries.h.

Referenced by clear(), compile(), increaseAllocation(), output(), and separate().

C_FLOAT64* CTimeSeries::mpIt
private

Iterator pointing the next step (row) to be recorded

Definition at line 177 of file CTimeSeries.h.

Referenced by clear(), compile(), increaseAllocation(), output(), and separate().

CVector< size_t > CTimeSeries::mPivot
private

Pivot rearranging the columns to a more user friendly order

Definition at line 203 of file CTimeSeries.h.

Referenced by clear(), compile(), getConcentrationData(), getData(), getKey(), and getTitle().

const CState* CTimeSeries::mpState
private

Pointer to the state which has to be recorded.

Definition at line 187 of file CTimeSeries.h.

Referenced by clear(), compile(), and output().

size_t CTimeSeries::mRecordedSteps
private

The number of actually recorded steps

Definition at line 172 of file CTimeSeries.h.

Referenced by clear(), compile(), getConcentrationData(), getData(), getRecordedSteps(), increaseAllocation(), output(), save(), and separate().

std::vector< std::string > CTimeSeries::mTitles
private

Vector of column titles.

Definition at line 192 of file CTimeSeries.h.

Referenced by clear(), compile(), and getTitle().


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