6 #ifndef _NetCDFCollection_h_
7 #define _NetCDFCollection_h_
13 #include <vapor/MyBase.h>
14 #include <vapor/NetCDFSimple.h>
128 virtual int Initialize(
129 const std::vector <string> &files,
130 const std::vector <string> &time_dimnames,
131 const std::vector <string> &time_coordvar
151 virtual bool VariableExists(
string varname)
const;
173 virtual bool VariableExists(
size_t ts,
string varname)
const;
185 return(_derivedVarsMap.find(varname) != _derivedVarsMap.end());
201 virtual bool IsStaggeredVar(
string varname)
const;
212 virtual bool IsStaggeredDim(
string dimname)
const;
231 virtual std::vector <string> GetVariableNames(
int ndim,
bool spatial)
const;
245 virtual std::vector <size_t> GetSpatialDims(
string varname)
const;
258 virtual std::vector <string> GetSpatialDimNames(
string varname)
const;
269 virtual size_t GetTimeDim(
string varname)
const;
280 virtual string GetTimeDimName(
string varname)
const;
296 virtual std::vector <size_t> GetDims(
string varname)
const ;
311 virtual std::vector <string> GetDimNames(
string varname)
const;
320 virtual bool IsTimeVarying(
string varname)
const;
334 std::vector <string> GetAttNames(
string varname)
const;
347 int GetAttType(
string varname,
string attname)
const;
363 void GetAtt(
string varname,
string attname, std::vector <double> &values)
const;
364 void GetAtt(
string varname,
string attname, std::vector <long> &values)
const;
365 void GetAtt(
string varname,
string attname,
string &values)
const;
383 virtual std::vector <string>
GetDimNames()
const {
return (_dimNames); };
398 virtual std::vector <size_t>
GetDims()
const {
return (_dimLens); };
449 virtual int GetTime(
size_t ts,
double &time)
const;
462 virtual int GetTimes(
string varname, std::vector <double> ×)
const;
474 virtual std::vector <double>
GetTimes()
const {
return (_times); };
490 size_t ts,
string varname,
string &file,
size_t &local_ts
502 virtual int GetVariableInfo(
519 virtual bool GetMissingValue(
string varname,
double &mv)
const;
538 virtual int OpenRead(
size_t ts,
string varname);
569 virtual int Read(
size_t start[],
size_t count[],
float *data,
int fd=0);
570 virtual int Read(
size_t start[],
size_t count[],
int *data,
int fd=0);
572 virtual int Read(
float *data,
int fd=0);
573 virtual int Read(
char *data,
int fd=0);
590 virtual int ReadNative(
size_t start[],
size_t count[],
float *data,
int fd=0);
591 virtual int ReadNative(
size_t start[],
size_t count[],
int *data,
int fd=0);
592 virtual int ReadNative(
size_t start[],
size_t count[],
char *data,
int fd=0);
594 virtual int ReadNative(
float *data,
int fd=0);
595 virtual int ReadNative(
int *data,
int fd=0);
617 virtual int ReadSlice(
float *data,
int fd=0);
635 virtual int ReadSliceNative(
float *data,
int fd=0);
656 virtual int SeekSlice(
int offset,
int whence,
int fd=0);
663 virtual int Close(
int fd=0);
675 _staggeredDims = dimnames;
689 _missingValAttName = attname;
700 friend std::ostream &operator<<(
710 const std::vector <string> &time_dimnames,
711 const std::map <
string, std::vector <double> > ×map,
720 int GetTime(
size_t ts,
double &time)
const;
721 std::vector <double> GetTimes()
const;
722 int GetTimeStep(
double time,
size_t &ts)
const;
723 size_t GetLocalTimeStep(
size_t ts)
const;
724 int GetFile(
size_t ts,
string &file)
const;
726 variable = _variable;
729 bool GetMissingValue(
string attname,
double &mv)
const;
731 friend std::ostream &operator<<(std::ostream &o,
const TimeVaryingVar &var);
741 std::vector <string> _files;
742 std::vector <tvmap_t> _tvmaps;
743 std::vector <size_t> _spatial_dims;
744 std::vector <string> _spatial_dim_names;
749 friend bool tvmap_cmp(
763 virtual int Open(
size_t ts) = 0;
764 virtual int ReadSlice(
float *slice,
int fd) = 0;
765 virtual int Read(
float *buf,
int fd) = 0;
766 virtual int SeekSlice(
int offset,
int whence,
int fd) = 0;
767 virtual int Close(
int fd) {
return(0); };
768 virtual bool TimeVarying()
const = 0;
769 virtual std::vector <size_t> GetSpatialDims()
const = 0;
770 virtual std::vector <string> GetSpatialDimNames()
const = 0;
771 virtual size_t GetTimeDim()
const = 0;
772 virtual string GetTimeDimName()
const = 0;
773 virtual bool GetMissingValue(
double &mv)
const = 0;
780 _derivedVarsMap[varname] = derivedVar;
784 std::map <string,DerivedVar*>::iterator itr = _derivedVarsMap.find(varname);
785 if (itr != _derivedVarsMap.end()) {
786 _derivedVarsMap.erase(varname);
792 bool _GetVariableInfo(
798 std::map <string, TimeVaryingVar > _variableList;
799 std::map <string, NetCDFSimple *> _ncdfmap;
800 std::vector <string> _staggeredDims;
801 std::vector <string> _dimNames;
802 std::vector <size_t> _dimLens;
803 string _missingValAttName;
804 std::map <string, vector <double> > _timesMap;
805 std::vector <double> _times;
806 std::vector <string> _failedVars;
807 std::map <string, DerivedVar *> _derivedVarsMap;
808 DerivedVar * _derivedVar;
816 DerivedVar *_derived_var;
822 unsigned char *_slicebuf;
824 unsigned char *_linebuf;
826 TimeVaryingVar _tvvars;
828 double _missing_value;
833 std::map<int, NetCDFCollection::fileHandle> _ovr_table;
835 int _InitializeTimesMap(
836 const std::vector <string> &files,
837 const std::vector <string> &time_dimnames,
838 const std::vector <string> &time_coordvars,
839 std::map <
string, std::vector <double> > ×Map,
840 std::vector <double> ×,
844 int _InitializeTimesMapCase1(
845 const std::vector <string> &files,
846 std::map <
string, std::vector <double> > ×Map
849 int _InitializeTimesMapCase2(
850 const std::vector <string> &files,
851 const std::vector <string> &time_dimnames,
852 std::map <
string, std::vector <double> > ×Map
855 int _InitializeTimesMapCase3(
856 const std::vector <string> &files,
857 const std::vector <string> &time_dimnames,
858 const std::vector <string> &time_coordvars,
859 std::map <
string, std::vector <double> > ×Map
862 void _InterpolateLine(
863 const float *src,
size_t n,
size_t stride,
864 bool has_missing,
float mv,
float *dst
867 void _InterpolateSlice(
868 size_t nx,
size_t ny,
bool xstag,
bool ystag,
869 bool has_missing,
float mv,
float *slice
873 NetCDFSimple *netcdf,
874 const std::vector <string> &time_coordvars,
875 const std::vector <string> &time_dimnames,
876 std::map <
string, std::vector <double> > ×map
880 NetCDFSimple *netcdf,
881 const NetCDFSimple::Variable &variable
885 const vector <NetCDFSimple::Variable> variables,
string varname
virtual std::vector< string > GetDimNames() const
virtual void SetMissingValueAttName(string attname)
virtual size_t GetNumTimeSteps() const
string GetTimeDimName() const
COMMON_API double GetTime()
void InstallDerivedVar(string varname, DerivedVar *derivedVar)
void GetVariableInfo(NetCDFSimple::Variable &variable) const
virtual size_t GetNumTimeSteps() const
virtual size_t GetNumTimeSteps(string varname) const
NetCDFSimple API interface.
std::vector< size_t > GetSpatialDims() const
virtual bool IsDerivedVar(string varname) const
void RemoveDerivedVar(string varname)
virtual size_t GetTimeDim(string varname) const
std::vector< string > GetSpatialDimNames() const
virtual std::vector< string > GetFailedVars() const
virtual std::vector< size_t > GetDims() const
bool GetTimeVarying() const
virtual int Close(int fd)
size_t GetNumTimeSteps() const
NetCDFCollection * _ncdfc
virtual void SetStaggeredDims(const std::vector< string > dimnames)
virtual std::vector< double > GetTimes() const
NetCDFSimple API interface.
DerivedVar(NetCDFCollection *ncdfc)
Wrapper for a collection of netCDF files.