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;
331 int GetXType(
string varname)
const;
345 std::vector <string> GetAttNames(
string varname)
const;
358 int GetAttType(
string varname,
string attname)
const;
374 void GetAtt(
string varname,
string attname, std::vector <double> &values)
const;
375 void GetAtt(
string varname,
string attname, std::vector <long> &values)
const;
376 void GetAtt(
string varname,
string attname,
string &values)
const;
394 virtual std::vector <string>
GetDimNames()
const {
return (_dimNames); };
409 virtual std::vector <size_t>
GetDims()
const {
return (_dimLens); };
460 virtual int GetTime(
size_t ts,
double &time)
const;
473 virtual int GetTimes(
string varname, std::vector <double> ×)
const;
485 virtual std::vector <double>
GetTimes()
const {
return (_times); };
501 size_t ts,
string varname,
string &file,
size_t &local_ts
513 virtual int GetVariableInfo(
530 virtual bool GetMissingValue(
string varname,
double &mv)
const;
549 virtual int OpenRead(
size_t ts,
string varname);
580 virtual int Read(
size_t start[],
size_t count[],
float *data,
int fd=0);
581 virtual int Read(
size_t start[],
size_t count[],
int *data,
int fd=0);
583 std::vector <size_t> start, std::vector <size_t> count,
float *data,
int fd=0);
585 std::vector <size_t> start, std::vector <size_t> count,
int *data,
int fd=0
588 virtual int Read(
float *data,
int fd=0);
589 virtual int Read(
char *data,
int fd=0);
606 virtual int ReadNative(
size_t start[],
size_t count[],
float *data,
int fd=0);
607 virtual int ReadNative(
size_t start[],
size_t count[],
int *data,
int fd=0);
608 virtual int ReadNative(
size_t start[],
size_t count[],
char *data,
int fd=0);
610 virtual int ReadNative(
float *data,
int fd=0);
611 virtual int ReadNative(
int *data,
int fd=0);
633 virtual int ReadSlice(
float *data,
int fd=0);
651 virtual int ReadSliceNative(
float *data,
int fd=0);
672 virtual int SeekSlice(
int offset,
int whence,
int fd=0);
679 virtual int Close(
int fd=0);
691 _staggeredDims = dimnames;
705 _missingValAttName = attname;
716 friend std::ostream &operator<<(
726 const std::vector <string> &time_dimnames,
727 const std::map <
string, std::vector <double> > ×map,
736 int GetTime(
size_t ts,
double &time)
const;
737 std::vector <double> GetTimes()
const;
738 int GetTimeStep(
double time,
size_t &ts)
const;
739 size_t GetLocalTimeStep(
size_t ts)
const;
740 int GetFile(
size_t ts,
string &file)
const;
742 variable = _variable;
745 bool GetMissingValue(
string attname,
double &mv)
const;
747 friend std::ostream &operator<<(std::ostream &o,
const TimeVaryingVar &var);
757 std::vector <string> _files;
758 std::vector <tvmap_t> _tvmaps;
759 std::vector <size_t> _spatial_dims;
760 std::vector <string> _spatial_dim_names;
765 friend bool tvmap_cmp(
779 virtual int Open(
size_t ts) = 0;
780 virtual int ReadSlice(
float *slice,
int fd) = 0;
781 virtual int Read(
float *buf,
int fd) = 0;
782 virtual int SeekSlice(
int offset,
int whence,
int fd) = 0;
783 virtual int Close(
int fd) {
return(0); };
784 virtual bool TimeVarying()
const = 0;
785 virtual std::vector <size_t> GetSpatialDims()
const = 0;
786 virtual std::vector <string> GetSpatialDimNames()
const = 0;
787 virtual size_t GetTimeDim()
const = 0;
788 virtual string GetTimeDimName()
const = 0;
789 virtual bool GetMissingValue(
double &mv)
const = 0;
796 _derivedVarsMap[varname] = derivedVar;
800 std::map <string,DerivedVar*>::iterator itr = _derivedVarsMap.find(varname);
801 if (itr != _derivedVarsMap.end()) {
802 _derivedVarsMap.erase(varname);
808 bool _GetVariableInfo(
814 std::map <string, TimeVaryingVar > _variableList;
815 std::map <string, NetCDFSimple *> _ncdfmap;
816 std::vector <string> _staggeredDims;
817 std::vector <string> _dimNames;
818 std::vector <size_t> _dimLens;
819 string _missingValAttName;
820 std::map <string, vector <double> > _timesMap;
821 std::vector <double> _times;
822 std::vector <string> _failedVars;
823 std::map <string, DerivedVar *> _derivedVarsMap;
824 DerivedVar * _derivedVar;
832 DerivedVar *_derived_var;
838 unsigned char *_slicebuf;
840 unsigned char *_linebuf;
842 TimeVaryingVar _tvvars;
844 double _missing_value;
849 std::map<int, NetCDFCollection::fileHandle> _ovr_table;
853 int _InitializeTimesMap(
854 const std::vector <string> &files,
855 const std::vector <string> &time_dimnames,
856 const std::vector <string> &time_coordvars,
857 std::map <
string, std::vector <double> > ×Map,
858 std::vector <double> ×,
862 int _InitializeTimesMapCase1(
863 const std::vector <string> &files,
864 std::map <
string, std::vector <double> > ×Map
867 int _InitializeTimesMapCase2(
868 const std::vector <string> &files,
869 const std::vector <string> &time_dimnames,
870 std::map <
string, std::vector <double> > ×Map
873 int _InitializeTimesMapCase3(
874 const std::vector <string> &files,
875 const std::vector <string> &time_dimnames,
876 const std::vector <string> &time_coordvars,
877 std::map <
string, std::vector <double> > ×Map
880 void _InterpolateLine(
881 const float *src,
size_t n,
size_t stride,
882 bool has_missing,
float mv,
float *dst
885 void _InterpolateSlice(
886 size_t nx,
size_t ny,
bool xstag,
bool ystag,
887 bool has_missing,
float mv,
float *slice
891 NetCDFSimple *netcdf,
892 const std::vector <string> &time_coordvars,
893 const std::vector <string> &time_dimnames,
894 std::map <
string, std::vector <double> > ×map
898 NetCDFSimple *netcdf,
899 const NetCDFSimple::Variable &variable
903 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.