本文整理汇总了C++中DataFile::DataFilename方法的典型用法代码示例。如果您正苦于以下问题:C++ DataFile::DataFilename方法的具体用法?C++ DataFile::DataFilename怎么用?C++ DataFile::DataFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFile
的用法示例。
在下文中一共展示了DataFile::DataFilename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddDataFile
/** Create new DataFile, or return existing DataFile. */
DataFile* DataFileList::AddDataFile(FileName const& nameIn, ArgList& argIn,
DataFile::DataFormatType typeIn)
{
// If no filename, no output desired
if (nameIn.empty()) return 0;
FileName fname( nameIn );
// Append ensemble number if set.
//rprintf("DEBUG: Setting up data file '%s' with ensembleNum %i\n", nameIn.base(), ensembleNum_);
if (ensembleNum_ != -1)
fname.Append( "." + integerToString(ensembleNum_) );
// Check if filename in use by CpptrajFile.
CpptrajFile* cf = GetCpptrajFile(fname);
if (cf != 0) {
mprinterr("Error: Data file name '%s' already in use by text output file '%s'.\n",
fname.full(), cf->Filename().full());
return 0;
}
// Check if this filename already in use
DataFile* Current = GetDataFile(fname);
// If no DataFile associated with name, create new DataFile
if (Current==0) {
Current = new DataFile();
if (Current->SetupDatafile(fname, argIn, typeIn, debug_)) {
mprinterr("Error: Setting up data file %s\n", fname.full());
delete Current;
return 0;
}
fileList_.push_back(Current);
} else {
// Set debug level
Current->SetDebug(debug_);
// If a type was specified, make sure it matches.
if (typeIn != DataFile::UNKNOWN_DATA && typeIn != Current->Type()) {
mprinterr("Error: '%s' is type %s but has been requested as type %s.\n",
Current->DataFilename().full(), Current->FormatString(),
DataFile::FormatString( typeIn ));
return 0;
}
// Check for keywords that do not match file type
DataFile::DataFormatType kType = DataFile::GetFormatFromArg( argIn );
if (kType != DataFile::UNKNOWN_DATA && kType != Current->Type())
mprintf("Warning: %s is type %s but type %s keyword specified; ignoring keyword.\n",
Current->DataFilename().full(), Current->FormatString(),
DataFile::FormatString( kType ));
// Process Arguments
if (!argIn.empty())
Current->ProcessArgs( argIn );
}
return Current;
}
示例2: Execute
Exec::RetType Exec_Precision::Execute(CpptrajState& State, ArgList& argIn) {
// Next string is DataSet(s)/DataFile that command pertains to.
std::string name1 = argIn.GetStringNext();
if (name1.empty()) {
mprinterr("Error: No filename/setname given.\n");
return CpptrajState::ERR;
}
// This will break if dataset name starts with a digit...
int width = argIn.getNextInteger(12);
if (width < 1) {
mprintf("Error: Cannot set width < 1 (%i).\n", width);
return CpptrajState::ERR;
}
int precision = argIn.getNextInteger(4);
if (precision < 0) precision = 0;
DataFile* df = State.DFL().GetDataFile(name1);
if (df != 0) {
mprintf("\tSetting precision for all sets in %s to %i.%i\n", df->DataFilename().base(),
width, precision);
df->SetDataFilePrecision(width, precision);
} else {
State.DSL().SetPrecisionOfDataSets( name1, width, precision );
}
return CpptrajState::OK;
}
示例3: Init
// Action_FilterByData::Init()
Action::RetType Action_FilterByData::Init(ArgList& actionArgs, ActionInit& init, int debugIn)
{
maxmin_ = init.DSL().AddSet( DataSet::INTEGER, actionArgs.GetStringKey("name"), "Filter" );
if (maxmin_ == 0) return Action::ERR;
DataFile* maxminfile = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs );
if (maxminfile != 0)
maxminfile->AddDataSet( maxmin_ );
// Get min and max args.
while (actionArgs.Contains("min"))
Min_.push_back( actionArgs.getKeyDouble("min", 0.0) );
while (actionArgs.Contains("max"))
Max_.push_back( actionArgs.getKeyDouble("max", 0.0) );
if (Min_.empty()) {
mprinterr("Error: At least one 'min' arg must be specified.\n");
return Action::ERR;
}
if (Max_.empty()) {
mprinterr("Error: At least one 'max' arg must be specified.\n");
return Action::ERR;
}
if (Min_.size() != Max_.size()) {
mprinterr("Error: # of 'min' args (%zu) != # of 'max' args (%zu)\n",
Min_.size(), Max_.size());
return Action::ERR;
}
// Get DataSets from remaining arguments
Dsets_.AddSetsFromArgs( actionArgs.RemainingArgs(), init.DSL() );
if (Dsets_.empty()) {
mprinterr("Error: No data sets specified.\n");
return Action::ERR;
}
if ( Dsets_.size() < Min_.size() ) {
mprinterr("Error: More 'min'/'max' args (%zu) than data sets (%zu).\n",
Min_.size(), Dsets_.size());
return Action::ERR;
}
if ( Dsets_.size() > Min_.size() ) {
unsigned int Nremaining = Dsets_.size() - Min_.size();
double useMin = Min_.back();
double useMax = Max_.back();
mprintf("Warning: More data sets than 'min'/'max' args.\n"
"Warning: Using min=%f and max=%f for last %zu data sets.\n",
useMin, useMax, Nremaining);
for (unsigned int ds = 0; ds < Nremaining; ++ds) {
Min_.push_back( useMin );
Max_.push_back( useMax );
}
}
mprintf(" FILTER: Filtering out frames using %zu data sets.\n", Dsets_.size());
for (unsigned int ds = 0; ds < Dsets_.size(); ds++)
mprintf("\t%.4f < '%s' < %.4f\n", Min_[ds], Dsets_[ds]->legend(), Max_[ds]);
if (maxminfile != 0)
mprintf("\tFilter frame info will be written to %s\n", maxminfile->DataFilename().full());
return Action::OK;
}
示例4: Init
// Action_Grid::Init()
Action::RetType Action_Grid::Init(ArgList& actionArgs, ActionInit& init, int debugIn)
{
debug_ = debugIn;
nframes_ = 0;
// Get output filename
std::string filename = actionArgs.GetStringKey("out");
// Get grid options
grid_ = GridInit( "GRID", actionArgs, init.DSL() );
if (grid_ == 0) return Action::ERR;
# ifdef MPI
if (ParallelGridInit(init.TrajComm(), grid_)) return Action::ERR;
# endif
// Get extra options
max_ = actionArgs.getKeyDouble("max", 0.80);
madura_ = actionArgs.getKeyDouble("madura", 0);
smooth_ = actionArgs.getKeyDouble("smoothdensity", 0);
invert_ = actionArgs.hasKey("invert");
pdbfile_ = init.DFL().AddCpptrajFile(actionArgs.GetStringKey("pdb"),"Grid PDB",DataFileList::PDB,true);
density_ = actionArgs.getKeyDouble("density",0.033456);
if (actionArgs.hasKey("normframe")) normalize_ = TO_FRAME;
else if (actionArgs.hasKey("normdensity")) normalize_ = TO_DENSITY;
else normalize_ = NONE;
if (normalize_ != NONE && (smooth_ > 0.0 || madura_ > 0.0)) {
mprinterr("Error: Normalize options are not compatible with smoothdensity/madura options.\n");
init.DSL().RemoveSet( grid_ );
return Action::ERR;
}
// Get mask
std::string maskexpr = actionArgs.GetMaskNext();
if (maskexpr.empty()) {
mprinterr("Error: GRID: No mask specified.\n");
init.DSL().RemoveSet( grid_ );
return Action::ERR;
}
mask_.SetMaskString(maskexpr);
// Setup output file
// For backwards compat., if no 'out' assume next string is filename
if (filename.empty() && actionArgs.Nargs() > 1 && !actionArgs.Marked(1))
filename = actionArgs.GetStringNext();
DataFile* outfile = init.DFL().AddDataFile(filename, actionArgs);
if (outfile != 0) outfile->AddDataSet((DataSet*)grid_);
// Info
mprintf(" GRID:\n");
GridInfo( *grid_ );
if (outfile != 0) mprintf("\tGrid will be printed to file %s\n", outfile->DataFilename().full());
mprintf("\tGrid data set: '%s'\n", grid_->legend());
mprintf("\tMask expression: [%s]\n",mask_.MaskString());
if (pdbfile_ != 0)
mprintf("\tPseudo-PDB will be printed to %s\n", pdbfile_->Filename().full());
if (normalize_ == TO_FRAME)
mprintf("\tGrid will be normalized by number of frames.\n");
else if (normalize_ == TO_DENSITY)
mprintf("\tGrid will be normalized to a density of %g molecules/Ang^3.\n", density_);
// TODO: print extra options
return Action::OK;
}
示例5: Init
// Action_VelocityAutoCorr::Init()
Action::RetType Action_VelocityAutoCorr::Init(ArgList& actionArgs, ActionInit& init, int debugIn)
{
if (actionArgs.hasKey("usevelocity")) {
mprinterr("Error: The 'usevelocity' keyword is deprecated. Velocity information\n"
"Error: is now used by default if present. To force cpptraj to use\n"
"Error: coordinates to estimate velocities (not recommended) use the\n"
"Error: 'usecoords' keyword.\n");
return Action::ERR;
}
useVelInfo_ = !actionArgs.hasKey("usecoords");
if (mask_.SetMaskString( actionArgs.GetMaskNext() )) return Action::ERR;
DataFile* outfile = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs );
diffout_ = init.DFL().AddCpptrajFile( actionArgs.GetStringKey("diffout"),
"VAC diffusion constants", DataFileList::TEXT, true );
maxLag_ = actionArgs.getKeyInt("maxlag", -1);
tstep_ = actionArgs.getKeyDouble("tstep", 1.0);
useFFT_ = !actionArgs.hasKey("direct");
normalize_ = actionArgs.hasKey("norm");
// Set up output data set
VAC_ = init.DSL().AddSet(DataSet::DOUBLE, actionArgs.GetStringNext(), "VAC");
if (VAC_ == 0) return Action::ERR;
// TODO: This should just be a scalar
diffConst_ = init.DSL().AddSet(DataSet::DOUBLE,
MetaData(VAC_->Meta().Name(), "D", MetaData::NOT_TS));
if (diffConst_ == 0) return Action::ERR;
if (outfile != 0) outfile->AddDataSet( VAC_ );
# ifdef MPI
trajComm_ = init.TrajComm();
if (trajComm_.Size() > 1 && !useVelInfo_)
mprintf("\nWarning: When calculating velocities between consecutive frames,\n"
"\nWarning: 'velocityautocorr' in parallel will not work correctly if\n"
"\nWarning: coordinates have been modified by previous actions (e.g. 'rms').\n\n");
diffConst_->SetNeedsSync( false );
# endif
mprintf(" VELOCITYAUTOCORR:\n"
"\tCalculate velocity auto-correlation function for atoms in mask '%s'\n",
mask_.MaskString());
if (useVelInfo_)
mprintf("\tUsing velocity information present in frames.\n");
else
mprintf("\tCalculating velocities between consecutive frames from coordinates.\n");
if (outfile != 0)
mprintf("\tOutput velocity autocorrelation function '%s' to '%s'\n", VAC_->legend(),
outfile->DataFilename().full());
mprintf("\tWriting diffusion constants to '%s'\n", diffout_->Filename().full());
if (maxLag_ < 1)
mprintf("\tMaximum lag will be half total # of frames");
else
mprintf("\tMaximum lag is %i frames", maxLag_);
mprintf(", time step between frames is %f ps\n", tstep_);
if (useFFT_)
mprintf("\tUsing FFT to calculate autocorrelation function.\n");
else
mprintf("\tUsing direct method to calculate autocorrelation function.\n");
if (normalize_)
mprintf("\tNormalizing autocorrelation function to 1.0\n");
return Action::OK;
}
示例6: Setup
// Analysis_Wavelet::Setup
Analysis::RetType Analysis_Wavelet::Setup(ArgList& analyzeArgs, DataSetList* datasetlist,
TopologyList* PFLin, DataFileList* DFLin, int debugIn)
{
// Attempt to get COORDS DataSet from DataSetList. If none specified the
// default COORDS set will be used.
std::string setname = analyzeArgs.GetStringKey("crdset");
coords_ = (DataSet_Coords*)datasetlist->FindCoordsSet( setname );
if (coords_ == 0) {
mprinterr("Error: Could not locate COORDS set corresponding to %s\n", setname.c_str());
return Analysis::ERR;
}
// Get keywords
DataFile* outfile = DFLin->AddDataFile( analyzeArgs.GetStringKey("out"), analyzeArgs );
setname = analyzeArgs.GetStringKey("name");
// TODO: Check defaults
nb_ = analyzeArgs.getKeyInt("nb", 0); // FIXME: Should be more descriptive? nscale?
if (nb_ < 1) {
mprinterr("Error: Scaling number must be > 0\n");
return Analysis::ERR;
}
S0_ = analyzeArgs.getKeyDouble("s0", 0.2);
ds_ = analyzeArgs.getKeyDouble("ds", 1.0/3.0);
correction_ = analyzeArgs.getKeyDouble("correction", 1.01);
chival_ = analyzeArgs.getKeyDouble("chival", 0.2231);
// Wavelet type: default to Morlet
std::string wavelet_name = analyzeArgs.GetStringKey("type");
if (wavelet_name.empty())
wavelet_type_ = W_MORLET;
else {
wavelet_type_ = W_NONE;
for (int itoken = 0; itoken != (int)W_NONE; itoken++)
if (wavelet_name.compare(Tokens_[itoken].key_) == 0) {
wavelet_type_ = (WaveletType)itoken;
break;
}
if (wavelet_type_ == W_NONE) {
mprinterr("Error: Unrecognized wavelet type: %s\n", wavelet_name.c_str());
return Analysis::ERR;
}
}
// Atom mask
mask_.SetMaskString( analyzeArgs.GetMaskNext() );
// Set up output data set
output_ = datasetlist->AddSet( DataSet::MATRIX_FLT, setname, "WAVELET" );
if (output_ == 0) return Analysis::ERR;
if (outfile != 0) outfile->AddDataSet( output_ );
mprintf(" WAVELET: Using COORDS set '%s', wavelet type %s\n",
coords_->legend(), Tokens_[wavelet_type_].description_);
mprintf("\tCalculating for atoms in mask '%s'\n", mask_.MaskString());
mprintf("\tScaling wavelet %i times starting from %g with delta of %g\n",
nb_, S0_, ds_);
mprintf("\tCorrection: %g\n", correction_);
mprintf("\tChiVal: %g\n", chival_);
if (outfile != 0) mprintf("\tOutput to '%s'\n", outfile->DataFilename().full());
return Analysis::OK;
}
示例7: Init
// Action_AtomicFluct::Init()
Action::RetType Action_AtomicFluct::Init(ArgList& actionArgs, TopologyList* PFL, DataSetList* DSL, DataFileList* DFL, int debugIn)
{
// Get frame # keywords
if (InitFrameCounter(actionArgs)) return Action::ERR;
// Get other keywords
bfactor_ = actionArgs.hasKey("bfactor");
calc_adp_ = actionArgs.hasKey("calcadp");
adpoutfile_ = DFL->AddCpptrajFile(actionArgs.GetStringKey("adpout"), "PDB w/ADP",
DataFileList::PDB);;
if (adpoutfile_!=0) calc_adp_ = true; // adpout implies calcadp
if (calc_adp_ && !bfactor_) bfactor_ = true;
DataFile* outfile = DFL->AddDataFile( actionArgs.GetStringKey("out"), actionArgs );
if (actionArgs.hasKey("byres"))
outtype_ = BYRES;
else if (actionArgs.hasKey("bymask"))
outtype_ = BYMASK;
else if (actionArgs.hasKey("byatom") || actionArgs.hasKey("byatm"))
outtype_ = BYATOM;
// Get Mask
Mask_.SetMaskString( actionArgs.GetMaskNext() );
// Get DataSet name
std::string setname = actionArgs.GetStringNext();
// Add output dataset
MetaData md( setname );
md.SetTimeSeries( MetaData::NOT_TS );
if (bfactor_)
md.SetLegend("B-factors");
else
md.SetLegend("AtomicFlx");
dataout_ = DSL->AddSet( DataSet::XYMESH, md, "Fluct" );
if (dataout_ == 0) {
mprinterr("Error: AtomicFluct: Could not allocate dataset for output.\n");
return Action::ERR;
}
if (outfile != 0)
outfile->AddDataSet( dataout_ );
mprintf(" ATOMICFLUCT: calculating");
if (bfactor_)
mprintf(" B factors");
else
mprintf(" atomic positional fluctuations");
if (outfile != 0)
mprintf(", output to file %s", outfile->DataFilename().full());
mprintf("\n Atom mask: [%s]\n",Mask_.MaskString());
FrameCounterInfo();
if (calc_adp_) {
mprintf("\tCalculating anisotropic displacement parameters.\n");
if (adpoutfile_!=0) mprintf("\tWriting PDB with ADP to '%s'\n", adpoutfile_->Filename().full());
}
if (!setname.empty())
mprintf("\tData will be saved to set named %s\n", setname.c_str());
return Action::OK;
}
示例8: AddCpptrajFile
// TODO: Accept const ArgList so arguments are not reset?
CpptrajFile* DataFileList::AddCpptrajFile(FileName const& nameIn,
std::string const& descrip,
CFtype typeIn, bool allowStdout)
{
// If no filename and stdout not allowed, no output desired.
if (nameIn.empty() && !allowStdout) return 0;
FileName name;
CpptrajFile* Current = 0;
int currentIdx = -1;
if (!nameIn.empty()) {
name = nameIn;
// Append ensemble number if set.
if (ensembleNum_ != -1)
name.Append( "." + integerToString(ensembleNum_) );
// Check if filename in use by DataFile.
DataFile* df = GetDataFile(name);
if (df != 0) {
mprinterr("Error: Text output file name '%s' already in use by data file '%s'.\n",
nameIn.full(), df->DataFilename().full());
return 0;
}
// Check if this filename already in use
currentIdx = GetCpptrajFileIdx( name );
if (currentIdx != -1) Current = cfList_[currentIdx];
}
// If no CpptrajFile associated with name, create new CpptrajFile
if (Current==0) {
switch (typeIn) {
case TEXT: Current = new CpptrajFile(); break;
case PDB: Current = (CpptrajFile*)(new PDBfile()); break;
}
Current->SetDebug(debug_);
// Set up file for writing.
//if (Current->SetupWrite( name, debug_ ))
if (Current->OpenWrite( name ))
{
mprinterr("Error: Setting up text output file %s\n", name.full());
delete Current;
return 0;
}
cfList_.push_back( Current );
cfData_.push_back( CFstruct(descrip, typeIn) );
} else {
// If Current type does not match typeIn do not allow.
if (typeIn != cfData_[currentIdx].Type()) {
mprinterr("Error: Cannot change type of text output for '%s'.\n", Current->Filename().full());
return 0;
}
Current->SetDebug(debug_);
// Update description
if (!descrip.empty())
cfData_[currentIdx].UpdateDescrip( descrip );
}
return Current;
}
示例9: Setup
Analysis::RetType Analysis_AutoCorr::Setup(ArgList& analyzeArgs, DataSetList* datasetlist,
TopologyList* PFLin, DataFileList* DFLin, int debugIn)
{
const char* calctype;
std::string setname = analyzeArgs.GetStringKey("name");
DataFile* outfile = DFLin->AddDataFile( analyzeArgs.GetStringKey("out"), analyzeArgs );
lagmax_ = analyzeArgs.getKeyInt("lagmax",-1);
calc_covar_ = !analyzeArgs.hasKey("nocovar");
usefft_ = !analyzeArgs.hasKey("direct");
// Select datasets from remaining args
ArgList dsetArgs = analyzeArgs.RemainingArgs();
for (ArgList::const_iterator dsa = dsetArgs.begin(); dsa != dsetArgs.end(); ++dsa)
dsets_ += datasetlist->GetMultipleSets( *dsa );
if (dsets_.empty()) {
mprinterr("Error: autocorr: No data sets selected.\n");
return Analysis::ERR;
}
// If setname is empty generate a default name
if (setname.empty())
setname = datasetlist->GenerateDefaultName( "autocorr" );
// Setup output datasets
int idx = 0;
MetaData md( setname );
for (DataSetList::const_iterator DS = dsets_.begin(); DS != dsets_.end(); ++DS) {
md.SetIdx( idx++ );
DataSet* dsout = datasetlist->AddSet( DataSet::DOUBLE, md );
if (dsout==0) return Analysis::ERR;
dsout->SetLegend( (*DS)->Meta().Legend() );
outputData_.push_back( dsout );
// Add set to output file
if (outfile != 0) outfile->AddDataSet( outputData_.back() );
}
if (calc_covar_)
calctype = "covariance";
else
calctype = "correlation";
mprintf(" AUTOCORR: Calculating auto-%s for %i data sets:\n", calctype, dsets_.size());
dsets_.List();
if (lagmax_!=-1)
mprintf("\tLag max= %i\n", lagmax_);
if ( !setname.empty() )
mprintf("\tSet name: %s\n", setname.c_str() );
if ( outfile != 0 )
mprintf("\tOutfile name: %s\n", outfile->DataFilename().base());
if (usefft_)
mprintf("\tUsing FFT to calculate %s.\n", calctype);
else
mprintf("\tUsing direct method to calculate %s.\n", calctype);
return Analysis::OK;
}
示例10: Setup
// Analysis_VectorMath::Setup()
Analysis::RetType Analysis_VectorMath::Setup(ArgList& analyzeArgs, DataSetList* DSLin, DataFileList* DFLin, int debugIn)
{
// Get Vectors
vinfo1_ = (DataSet_Vector*)DSLin->FindSetOfType( analyzeArgs.GetStringKey("vec1"),
DataSet::VECTOR );
vinfo2_ = (DataSet_Vector*)DSLin->FindSetOfType( analyzeArgs.GetStringKey("vec2"),
DataSet::VECTOR );
if (vinfo1_ == 0 ) {
mprinterr("Error: 'vec1' not found.\n");
return Analysis::ERR;
}
if (vinfo2_ == 0) {
mprinterr("Error: 'vec2' not found.\n");
return Analysis::ERR;
}
std::string setname = analyzeArgs.GetStringKey("name");
norm_ = analyzeArgs.hasKey("norm");
// Check for dotproduct/crossproduct keywords
DataOut_ = 0;
if (analyzeArgs.hasKey("dotproduct")) {
mode_ = DOTPRODUCT;
if ((DataOut_ = DSLin->AddSet(DataSet::DOUBLE, setname, "Dot")) == 0) return Analysis::ERR;
} else if (analyzeArgs.hasKey("dotangle")) {
mode_ = DOTANGLE;
norm_ = true; // Vecs must be normalized for angle calc to work
if ((DataOut_ = DSLin->AddSet(DataSet::DOUBLE, setname, "Angle")) == 0) return Analysis::ERR;
} else if (analyzeArgs.hasKey("crossproduct")) {
mode_ = CROSSPRODUCT;
if ((DataOut_ = DSLin->AddSet(DataSet::VECTOR, setname, "Cross")) == 0) return Analysis::ERR;
} else
mode_ = DOTPRODUCT;
// Set up output file in DataFileList if necessary
DataFile* outfile = DFLin->AddDataFile( analyzeArgs.GetStringKey("out"), analyzeArgs );
if (outfile != 0) outfile->AddDataSet( DataOut_ );
// Print Status
mprintf(" VECTORMATH: Calculating %s of vectors %s and %s\n",
ModeString[mode_], vinfo1_->legend(), vinfo2_->legend());
if (norm_) mprintf("\tVectors will be normalized.\n");
if (outfile != 0)
mprintf("\tResults are written to %s\n", outfile->DataFilename().full());
return Analysis::OK;
}
示例11: Init
// Action_VelocityAutoCorr::Init()
Action::RetType Action_VelocityAutoCorr::Init(ArgList& actionArgs, ActionInit& init, int debugIn)
{
useVelInfo_ = actionArgs.hasKey("usevelocity");
mask_.SetMaskString( actionArgs.GetMaskNext() );
DataFile* outfile = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs );
maxLag_ = actionArgs.getKeyInt("maxlag", -1);
tstep_ = actionArgs.getKeyDouble("tstep", 1.0);
useFFT_ = !actionArgs.hasKey("direct");
normalize_ = actionArgs.hasKey("norm");
// Set up output data set
VAC_ = init.DSL().AddSet(DataSet::DOUBLE, actionArgs.GetStringNext(), "VAC");
if (VAC_ == 0) return Action::ERR;
if (outfile != 0) outfile->AddDataSet( VAC_ );
# ifdef MPI
trajComm_ = init.TrajComm();
if (trajComm_.Size() > 1 && !useVelInfo_)
mprintf("\nWarning: When calculating velocities between consecutive frames,\n"
"\nWarning: 'velocityautocorr' in parallel will not work correctly if\n"
"\nWarning: coordinates have been modified by previous actions (e.g. 'rms').\n\n");
# endif
mprintf(" VELOCITYAUTOCORR:\n"
"\tCalculate velocity auto-correlation function for atoms in mask '%s'\n",
mask_.MaskString());
if (useVelInfo_)
mprintf("\tUsing velocity information present in frames.\n");
else
mprintf("\tCalculating velocities between consecutive frames.\n");
if (outfile != 0)
mprintf("\tOutput data set '%s' to '%s'\n", VAC_->legend(),
outfile->DataFilename().full());
if (maxLag_ < 1)
mprintf("\tMaximum lag will be half total # of frames");
else
mprintf("\tMaximum lag is %i frames", maxLag_);
mprintf(", time step is %f ps\n", tstep_);
if (useFFT_)
mprintf("\tUsing FFT to calculate autocorrelation function.\n");
else
mprintf("\tUsing direct method to calculate autocorrelation function.\n");
if (normalize_)
mprintf("\tNormalizing autocorrelation function to 1.0\n");
return Action::OK;
}
示例12: Init
// Action_GridFreeEnergy::init()
Action::RetType Action_GridFreeEnergy::Init(ArgList& actionArgs, ActionInit& init, int debugIn)
{
// Get output filename
DataFile* outfile = init.DFL().AddDataFile(actionArgs.GetStringNext(), actionArgs);
if (outfile == 0) {
mprinterr("Error: GridFreeEnergy: no output filename specified.\n");
return Action::ERR;
}
// Get grid options (<nx> <dx> <ny> <dy> <nz> <dz> [box|origin] [negative])
grid_ = GridInit( "GridFreeEnergy", actionArgs, init.DSL() );
if (grid_ == 0) return Action::ERR;
# ifdef MPI
if (ParallelGridInit(init.TrajComm(), grid_)) return Action::ERR;
# endif
//grid_.PrintXplor( filename_, "", "REMARKS Change in Free energy from bulk solvent with bin normalisation of " + integerToString(currentLargestVoxelOccupancyCount) );
// Get mask
std::string maskexpr = actionArgs.GetMaskNext();
if (maskexpr.empty()) {
mprinterr("Error: GridFreeEnergy: No mask specified.\n");
init.DSL().RemoveSet( grid_ );
return Action::ERR;
}
mask_.SetMaskString(maskexpr);
// Get extra args
tempInKevin_ = actionArgs.getKeyDouble("temp", 293.0);
outfile->AddDataSet( grid_ );
// Info
mprintf("Warning: DNAIONTRACKER is experimental code!\n");
mprintf(" GridFreeEnergy\n");
GridInfo( *grid_ );
mprintf("\tGrid will be printed to file %s\n",outfile->DataFilename().full());
mprintf("\tMask expression: [%s]\n",mask_.MaskString());
mprintf("\tTemp is : %f K\n",tempInKevin_);
// Allocate grid
//if (GridAllocate()) return 1;
return Action::OK;
}
示例13: Setup
// Analysis_FFT::Setup()
Analysis::RetType Analysis_FFT::Setup(ArgList& analyzeArgs, DataSetList* datasetlist, DataFileList* DFLin, int debugIn)
{
std::string setname = analyzeArgs.GetStringKey("name");
DataFile* outfile = DFLin->AddDataFile(analyzeArgs.GetStringKey("out"), analyzeArgs);
dt_ = analyzeArgs.getKeyDouble("dt",1.0);
// Select datasets from remaining args
if (input_dsets_.AddSetsFromArgs( analyzeArgs.RemainingArgs(), *datasetlist )) {
mprinterr("Error: Could not add data sets.\n");
return Analysis::ERR;
}
if (input_dsets_.empty()) {
mprinterr("Error: No input data sets.\n");
return Analysis::ERR;
}
// If setname is empty generate a default name
if (setname.empty())
setname = datasetlist->GenerateDefaultName( "FFT" );
// Setup output datasets.
int idx = 0;
if ( input_dsets_.size() == 1 )
idx = -1; // Only one input set, no need to refer to it by index
for ( Array1D::const_iterator DS = input_dsets_.begin();
DS != input_dsets_.end(); ++DS)
{
DataSet* dsout = datasetlist->AddSet( DataSet::DOUBLE, MetaData(setname, idx++) );
if (dsout==0) return Analysis::ERR;
dsout->SetLegend( (*DS)->Meta().Legend() );
output_dsets_.push_back( (DataSet_1D*)dsout );
if (outfile != 0) outfile->AddDataSet( dsout );
}
mprintf(" FFT: Calculating FFT for %u data sets.\n", input_dsets_.size());
mprintf("\tTime step: %f\n", dt_);
if ( !setname.empty() )
mprintf("\tSet name: %s\n", setname.c_str() );
if ( outfile != 0 )
mprintf("\tOutfile name: %s\n", outfile->DataFilename().base());
return Analysis::OK;
}
示例14: Init
//.........这里部分代码省略.........
if (actionArgs.hasKey("x") ) {
axis_ = DX;
area_coord_[0] = DY;
area_coord_[1] = DZ;
} else if (actionArgs.hasKey("y") ) {
axis_ = DY;
area_coord_[0] = DX;
area_coord_[1] = DZ;
} else if (actionArgs.hasKey("z") ) {
axis_ = DZ;
area_coord_[0] = DX;
area_coord_[1] = DY;
}
property_ = NUMBER;
if (actionArgs.hasKey("number") ) property_ = NUMBER;
else if (actionArgs.hasKey("mass") ) property_ = MASS;
else if (actionArgs.hasKey("charge") ) property_ = CHARGE;
else if (actionArgs.hasKey("electron") ) property_ = ELECTRON;
binType_ = CENTER;
if (actionArgs.hasKey("bincenter")) binType_ = CENTER;
else if (actionArgs.hasKey("binedge") ) binType_ = EDGE;
delta_ = actionArgs.getKeyDouble("delta", 0.01);
if (delta_ <= 0) {
mprinterr("Error: Delta must be > 0.0\n");
return Action::ERR;
}
// for compatibility with ptraj, ignored because we rely on the atom code to
// do the right thing, see Atom.{h,cpp}
if (actionArgs.hasKey("efile"))
mprintf("Warning: The 'efile' keyword is deprecated.\n");
// read the rest of the command line as a series of masks
std::string maskstr;
unsigned int idx = 1;
while ( (maskstr = actionArgs.GetMaskNext() ) != emptystring) {
masks_.push_back( AtomMask(maskstr) );
if (dsname.empty())
dsname = init.DSL().GenerateDefaultName("DENSITY");
MetaData MD(dsname, "avg", idx);
MD.SetTimeSeries( MetaData::NOT_TS );
// Hold average density
DataSet* ads = init.DSL().AddSet( DataSet::DOUBLE, MD );
if (ads == 0) return Action::ERR;
ads->SetLegend( NoWhitespace(masks_.back().MaskExpression()) );
AvSets_.push_back( ads );
if (outfile != 0) outfile->AddDataSet( ads );
// Hold SD density
MD.SetAspect("sd");
DataSet* sds = init.DSL().AddSet( DataSet::DOUBLE, MD );
if (sds == 0) return Action::ERR;
sds->SetLegend( NoWhitespace("sd(" + masks_.back().MaskExpression() + ")") );
SdSets_.push_back( sds );
if (outfile != 0) outfile->AddDataSet( sds );
# ifdef MPI
ads->SetNeedsSync( false ); // Populated in Print()
sds->SetNeedsSync( false );
# endif
idx++;
}
if (masks_.empty()) {
// If no masks assume we want total system density.
if (dsname.empty())
dsname = actionArgs.GetStringNext();
density_ = init.DSL().AddSet(DataSet::DOUBLE, dsname, "DENSITY");
if (density_ == 0) return Action::ERR;
if (outfile != 0) outfile->AddDataSet( density_ );
image_.InitImaging( true );
// Hijack delta for storing sum of masses
delta_ = 0.0;
} else {
// Density selected by mask(s) along an axis
density_ = 0;
histograms_.resize(masks_.size() );
}
mprintf(" DENSITY:");
if (density_ == 0) {
const char* binStr[] = {"center", "edge"};
mprintf(" Determining %s density for %zu masks.\n", PropertyStr_[property_], masks_.size());
mprintf("\troutine version: %s\n", ROUTINE_VERSION_STRING);
mprintf("\tDelta is %f\n", delta_);
mprintf("\tAxis is %s\n", AxisStr_[axis_]);
mprintf("\tData set name is '%s'\n", dsname.c_str());
mprintf("\tData set aspect [avg] holds the mean, aspect [sd] holds standard deviation.\n");
mprintf("\tBin coordinates will be to bin %s.\n", binStr[binType_]);
} else {
mprintf(" No masks specified, calculating total system density in g/cm^3.\n");
mprintf("\tData set name is '%s'\n", density_->legend());
}
if (outfile != 0)
mprintf("\tOutput to '%s'\n", outfile->DataFilename().full());
return Action::OK;
}
示例15: Setup
Analysis::RetType Analysis_AutoCorr::Setup(ArgList& analyzeArgs, AnalysisSetup& setup, int debugIn)
{
const char* calctype;
std::string setname = analyzeArgs.GetStringKey("name");
DataFile* outfile = setup.DFL().AddDataFile( analyzeArgs.GetStringKey("out"), analyzeArgs );
lagmax_ = analyzeArgs.getKeyInt("lagmax",-1);
calc_covar_ = !analyzeArgs.hasKey("nocovar");
usefft_ = !analyzeArgs.hasKey("direct");
// Select datasets from remaining args
dsets_.clear();
ArgList dsetArgs = analyzeArgs.RemainingArgs();
for (ArgList::const_iterator dsa = dsetArgs.begin(); dsa != dsetArgs.end(); ++dsa) {
DataSetList setsIn = setup.DSL().GetMultipleSets( *dsa );
for (DataSetList::const_iterator ds = setsIn.begin(); ds != setsIn.end(); ++ds) {
if ( (*ds)->Group() != DataSet::SCALAR_1D && (*ds)->Type() != DataSet::VECTOR )
mprintf("Warning: Set '%s' type not supported in AUTOCORR - skipping.\n",
(*ds)->legend());
else
dsets_.push_back( *ds );
}
}
if (dsets_.empty()) {
mprinterr("Error: No data sets selected.\n");
return Analysis::ERR;
}
// If setname is empty generate a default name
if (setname.empty())
setname = setup.DSL().GenerateDefaultName( "autocorr" );
// Setup output datasets
MetaData md( setname );
for (unsigned int idx = 0; idx != dsets_.size(); idx++) {
md.SetIdx( idx );
DataSet* dsout = setup.DSL().AddSet( DataSet::DOUBLE, md );
if (dsout==0) return Analysis::ERR;
dsout->SetLegend( dsets_[idx]->Meta().Legend() );
outputData_.push_back( dsout );
// Add set to output file
if (outfile != 0) outfile->AddDataSet( outputData_.back() );
}
if (calc_covar_)
calctype = "covariance";
else
calctype = "correlation";
mprintf(" AUTOCORR: Calculating auto-%s for %i data sets:\n\t", calctype, dsets_.size());
for (unsigned int idx = 0; idx != dsets_.size(); ++idx)
mprintf(" %s", dsets_[idx]->legend());
mprintf("\n");
if (lagmax_!=-1)
mprintf("\tLag max= %i\n", lagmax_);
if ( !setname.empty() )
mprintf("\tSet name: %s\n", setname.c_str() );
if ( outfile != 0 )
mprintf("\tOutfile name: %s\n", outfile->DataFilename().base());
if (usefft_)
mprintf("\tUsing FFT to calculate %s.\n", calctype);
else
mprintf("\tUsing direct method to calculate %s.\n", calctype);
return Analysis::OK;
}