3#if !defined(LOOS_AMBER_NETCDF_HPP)
4#define LOOS_AMBER_NETCDF_HPP
11#include <loos_defs.hpp>
13#include <Trajectory.hpp>
14#include <exceptions.hpp>
16#include <amber_traj.hpp>
36 class VarTypeDecider {
39 static int read(
const int id,
const int var,
const size_t* st,
const size_t *co, T* ip) {
return(0); }
47 template<>
class VarTypeDecider<float> {
49 static int read(
const int id,
const int var,
const size_t* st,
const size_t* co,
float* ip) {
50 return(nc_get_vara_float(
id, var, st, co, ip));
54 template<>
class VarTypeDecider<double> {
56 static int read(
const int id,
const int var,
const size_t* st,
const size_t* co,
double* ip) {
57 return(nc_get_vara_double(
id, var, st, co, ip));
75 explicit AmberNetcdf(
const std::string& s,
const uint na)
77 _coord_data(
new GCoord::element_type[na*3]),
78 _velocity_data(
new GCoord::element_type[na*3]),
79 _box_data(
new GCoord::element_type[3]),
97 std::string
description()
const {
return(
"Amber trajectory (netCDF)"); }
98 static pTraj create(
const std::string& fname,
const AtomicGroup& model) {
100 return(pTraj(
new AmberNetcdf(fname, model.size())));
102 return(pTraj(
new AmberTraj(fname, model.size())));
117 std::vector<GCoord> res;
118 for (uint i=0; i<_natoms; i += 3)
119 res.push_back(
GCoord(_coord_data[i], _coord_data[i+1], _coord_data[i+2]));
129 void init(
const char* name,
const uint
natoms);
130 void readGlobalAttributes();
131 std::string readGlobalAttribute(
const std::string& name);
132 void readRawFrame(
const uint frameno);
137 void seekNextFrameImpl() { }
138 void seekFrameImpl(
const uint
frame) { }
139 void rewindImpl() { }
141 std::vector<GCoord> velocitiesImpl()
const;
145 GCoord::element_type* _coord_data;
146 GCoord::element_type* _velocity_data;
147 GCoord::element_type* _box_data;
156 int _cell_lengths_id;
158 std::string _title, _application, _program, _programVersion, _conventions, _conventionVersion;
Class for reading Amber Trajectories in NetCDF format.
Definition amber_netcdf.hpp:67
std::string description() const
Return a string describing trajectory format.
Definition amber_netcdf.hpp:97
uint natoms() const
Definition amber_netcdf.hpp:105
virtual bool hasVelocities() const
Whether or not the trajectory format supports velocities.
Definition amber_netcdf.hpp:112
virtual double velocityConversionFactor() const
Conversion applied to velocities to get to \AA/ps.
Definition amber_netcdf.hpp:113
uint nframes() const
Number of frames in the trajectory.
Definition amber_netcdf.hpp:106
bool hasPeriodicBox() const
Definition amber_netcdf.hpp:109
float timestep() const
Timestep per frame.
Definition amber_netcdf.hpp:107
GCoord periodicBox() const
Returns the periodic box for the current frame/trajectory.
Definition amber_netcdf.hpp:110
std::vector< GCoord > coords() const
Returns the current frames coordinates as a vector of GCoords.
Definition amber_netcdf.hpp:116
Class for reading amber coordinate trajectories.
Definition amber_traj.hpp:48
Class for handling groups of Atoms (pAtoms, actually)
Definition AtomicGroup.hpp:108
Base-class for polymorphic trajectories.
Definition Trajectory.hpp:65
Namespace for most things not already encapsulated within a class.
Definition version.cpp:3
bool isFileNetCDF(const std::string &fname)
Returns true if the file is a NetCDF file.
Definition amber_netcdf.cpp:9