Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions doc/cpptraj.lyx
Original file line number Diff line number Diff line change
Expand Up @@ -7809,6 +7809,11 @@ dataset { legend <legend> <set> |
name <new name> [legendset <set>] |
\end_layout

\begin_layout LyX-Code
shift [above <value> by <offset>] [below <value> by <offset>]
<set arg0> ...
\end_layout

\begin_layout LyX-Code
[mode <mode>] [type <type>] <set arg1> [<set arg 2> ...]
\end_layout
Expand Down Expand Up @@ -8180,6 +8185,61 @@ name> Inverted output set name.
<set>] String data set containing legends
\end_layout

\end_deeper
\begin_layout Description
shift
\begin_inset space ~
\end_inset


\end_layout

\begin_deeper
\begin_layout Description
[above
\begin_inset space ~
\end_inset

<value>
\begin_inset space ~
\end_inset

by
\begin_inset space ~
\end_inset

<offset>] Values in set(s) above <value> will be shifted by <offset>.
\end_layout

\begin_layout Description
[below
\begin_inset space ~
\end_inset

<value>
\begin_inset space ~
\end_inset

by
\begin_inset space ~
\end_inset

<offset>] Values in set(s) below <value> will be shifted by <offset>.
\end_layout

\begin_layout Description
<set
\begin_inset space ~
\end_inset

arg0>
\begin_inset space ~
\end_inset

...
Set(s) to shift.
\end_layout

\end_deeper
\begin_layout Description
[mode
Expand Down Expand Up @@ -9219,6 +9279,25 @@ dataset dim xdim label Simulation min 1 step 1 Inverted*
writedata statecount.agr Inverted*
\end_layout

\begin_layout Standard
The dataset shift command can be used for wrapping circular values, such
as torsions.
For example, to ensure a pucker has a range from 0 to 360 instead of -180
to 180:
\end_layout

\begin_layout LyX-Code
pucker Furanoid @C2 @C3 @C4 @C5 @O2 cremer out CremerF.dat amplitude
\end_layout

\begin_layout LyX-Code
run
\end_layout

\begin_layout LyX-Code
dataset shift Furanoid below 0 by 360
\end_layout

\begin_layout Subsection
debug | prnlev
\end_layout
Expand Down
15 changes: 15 additions & 0 deletions src/DataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,21 @@ int DataFile::RemoveDataSet(DataSet* dataIn) {
return 0;
}

/** \return True if this DataFile contains any of the sets in the given set list.
* Matches are determined via memory address.
*/
bool DataFile::ContainsAnyOfSets(std::vector<DataSet*> const& setsIn) const {
for (std::vector<DataSet*>::const_iterator ds0 = setsIn.begin();
ds0 != setsIn.end(); ++ds0)
{
DataSet* tgt = *ds0;
for (DataSetList::const_iterator ds1 = SetList_.begin();
ds1 != SetList_.end(); ++ds1)
if (tgt == *ds1) return true;
}
return false;
}

// GetPrecisionArg()
static inline int GetPrecisionArg(std::string const& prec_str, int& width, int& prec)
{
Expand Down
2 changes: 2 additions & 0 deletions src/DataFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class DataFile {
int AddDataSet(DataSet*);
/// Remove a set from the DataFile.
int RemoveDataSet(DataSet*);
/// \return True if this DataFile contains any of the sets in given DataSetList
bool ContainsAnyOfSets(std::vector<DataSet*> const&) const;
/// Process DataFile-related arguments
int ProcessArgs(ArgList&);
int ProcessArgs(std::string const&); // TODO: Determine where this is used
Expand Down
9 changes: 9 additions & 0 deletions src/DataFileList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,15 @@ void DataFileList::ResetWriteStatus() {
(*df)->SetDFLwrite( true );
}

/** Check all DataFiles for sets in the given DataSetList. For DataFiles
* that contain any of these sets, reset their write status.
*/
void DataFileList::ResetWriteStatIfContain(std::vector<DataSet*> const& setsIn) {
for (DFarray::iterator df = fileList_.begin(); df != fileList_.end(); ++df)
if ( (*df)->ContainsAnyOfSets( setsIn ) )
(*df)->SetDFLwrite( true );
}

// DataFileList::ProcessDataFileArgs()
/** Process command relating to data files. */
int DataFileList::ProcessDataFileArgs(ArgList& dataArg) {
Expand Down
4 changes: 4 additions & 0 deletions src/DataFileList.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ class DataFileList {
void WriteAllDF();
/// \return true if DataFiles have not yet been written.
bool UnwrittenData() const;
/// Reset the write status of all DataFiles so they will be written
void ResetWriteStatus();
/// Reset the write status of DataFiles containing any of the input sets.
void ResetWriteStatIfContain(std::vector<DataSet*> const& dslIn);
/// Process any data file args
int ProcessDataFileArgs(ArgList&);
int Debug() const { return debug_; }
int EnsembleNum() const { return ensembleNum_; }
Expand Down
2 changes: 2 additions & 0 deletions src/DataSet_1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class DataSet_1D : public DataSet {
virtual double Xcrd(size_t) const = 0;
/// \return Memory address at position cast to void *. TODO may not need this anymore.
virtual const void* VoidPtr(size_t) const = 0;
/// Set Y value at given index
virtual void SetY(size_t, double) = 0;
// -------------------------------------------
/// \return Average over set Y values
double Avg() const { return Avg( 0 ); }
Expand Down
5 changes: 3 additions & 2 deletions src/DataSet_Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ class DataSet_Mesh : public DataSet_1D {
int MemAlloc(SizeArray const&);
void CopyBlock(size_t, const DataSet*, size_t, size_t);
// ----- DataSet_1D functions ----------------
double Dval(size_t idx) const { return mesh_y_[idx]; }
double Xcrd(size_t idx) const { return mesh_x_[idx]; }
double Dval(size_t idx) const { return mesh_y_[idx]; }
double Xcrd(size_t idx) const { return mesh_x_[idx]; }
const void* VoidPtr(size_t) const;
void SetY(size_t idx, double y) { mesh_y_[idx] = y; }
// -------------------------------------------
inline void AddXY(double,double);
double X(int i) const { return mesh_x_[i]; }
Expand Down
5 changes: 3 additions & 2 deletions src/DataSet_double.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ class DataSet_double : public DataSet_1D {
int MemAlloc(SizeArray const&);
void CopyBlock(size_t, const DataSet*, size_t, size_t);
// ----- DataSet_1D functions ----------------
double Dval(size_t idx) const { return Data_[idx]; }
double Xcrd(size_t idx) const { return Dim(0).Coord(idx); }
double Dval(size_t idx) const { return Data_[idx]; }
double Xcrd(size_t idx) const { return Dim(0).Coord(idx); }
const void* VoidPtr(size_t idx) const { return (void*)(&(Data_[0])+idx); }
void SetY(size_t idx, double y) { Data_[idx] = y; }
private:
std::vector<double> Data_;
};
Expand Down
5 changes: 3 additions & 2 deletions src/DataSet_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ class DataSet_float : public DataSet_1D {
int MemAlloc(SizeArray const&);
void CopyBlock(size_t, const DataSet*, size_t, size_t);
// ----- DataSet_1D functions ----------------
double Dval(size_t idx) const { return (double)Data_[idx]; }
double Xcrd(size_t idx) const { return Dim(0).Coord(idx); }
double Dval(size_t idx) const { return (double)Data_[idx]; }
double Xcrd(size_t idx) const { return Dim(0).Coord(idx); }
const void* VoidPtr(size_t idx) const { return (void*)(&(Data_[0])+idx); }
void SetY(size_t idx, double y) { Data_[idx] = (float)y; }
// -------------------------------------------
float* Ptr() { return &(Data_[0]); }
private:
Expand Down
1 change: 1 addition & 0 deletions src/DataSet_integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DataSet_integer : public DataSet_1D {
# endif
// ----- DataSet_1D functions ----------------
double Xcrd(size_t idx) const { return Dim(0).Coord(idx); }
void SetY(size_t idx, double y) { SetElement(idx, (int)y); }
// -------------------------------------------
//typedef std::vector<int>::iterator iterator;
//iterator begin() { return Data_.begin(); }
Expand Down
1 change: 1 addition & 0 deletions src/DataSet_pH.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class DataSet_pH : public DataSet_1D {
double Dval(size_t i) const { return (double)states_[i]; }
double Xcrd(size_t idx) const { return Dim(0).Coord(idx); }
const void* VoidPtr(size_t idx) const { return (void*)(&(states_[0])+idx); }
void SetY(size_t i, double y) { states_[i] = (int)y; }
// -------------------------------------------
void Resize(size_t, int);
void SetResidueInfo(Cph::CpRes const& r) { res_ = r; }
Expand Down
Loading