6 #ifndef _NetCDFCFCollection_h_
7 #define _NetCDFCFCollection_h_
14 #include <vapor/MyBase.h>
15 #include <vapor/UDUnitsClass.h>
16 #include <vapor/NetCDFCollection.h>
41 virtual int Initialize(
42 const std::vector <string> &files
62 return(std::find( _coordinateVars.begin(), _coordinateVars.end(), var) != _coordinateVars.end());
82 return(std::find( _auxCoordinateVars.begin(),
83 _auxCoordinateVars.end(), var) != _auxCoordinateVars.end());
96 return(std::find( _latCoordVars.begin(),
97 _latCoordVars.end(), var) != _latCoordVars.end());
109 return(std::find( _lonCoordVars.begin(),
110 _lonCoordVars.end(), var) != _lonCoordVars.end());
122 return(std::find( _timeCoordVars.begin(),
123 _timeCoordVars.end(), var) != _timeCoordVars.end());
136 return(std::find( _vertCoordVars.begin(),
137 _vertCoordVars.end(), var) != _vertCoordVars.end());
155 virtual bool IsVertCoordVarUp(
string var)
const;
199 virtual std::vector <string> GetDataVariableNames(
int ndim,
bool spatial)
const;
234 virtual int GetVarCoordVarNames(
string var, std::vector <string> &cvars)
const;
249 virtual int GetVarUnits(
string var,
string &units)
const;
300 virtual bool GetMissingValue(
string varname,
double &mv)
const;
304 virtual int OpenRead(
size_t ts,
string varname);
313 virtual bool IsVertDimensionless(
string cvar)
const;
341 virtual int InstallStandardVerticalConverter(
342 string cvar,
string newvar,
string units =
"meters"
353 virtual void UninstallStandardVerticalConverter(
string cvar) ;
364 bool GetMapProjectionProj4(
365 string varname,
string &proj4string
368 void FormatTimeStr(
double time,
string &str)
const;
370 friend std::ostream &operator<<(
378 DerivedVar_ocean_s_coordinate_g1(
380 const std::map <string, string> &formula_map
382 virtual ~DerivedVar_ocean_s_coordinate_g1();
384 virtual int Open(
size_t ts);
385 virtual int ReadSlice(
float *slice,
int);
386 virtual int Read(
float *buf,
int);
387 virtual int SeekSlice(
int offset,
int whence,
int fd);
388 virtual int Close(
int) {_is_open =
false;
return(0); };
389 virtual bool TimeVarying()
const {
return(
false); };
390 virtual std::vector <size_t> GetSpatialDims()
const {
return(_dims); }
391 virtual std::vector <string> GetSpatialDimNames()
const {
return(_dimnames); }
392 virtual size_t GetTimeDim()
const {
return(0); }
393 virtual string GetTimeDimName()
const {
return(
""); };
394 virtual bool GetMissingValue(
double &mv)
const {mv=0.0;
return(
false); }
397 std::vector <size_t> _dims;
398 std::vector <string> _dimnames;
414 class DerivedVar_ocean_s_coordinate_g2 :
public NetCDFCollection::DerivedVar {
417 DerivedVar_ocean_s_coordinate_g2(
418 NetCDFCFCollection *ncdfcf,
419 const std::map <string, string> &formula_map
421 virtual ~DerivedVar_ocean_s_coordinate_g2();
423 virtual int Open(
size_t ts);
424 virtual int ReadSlice(
float *slice,
int);
425 virtual int Read(
float *buf,
int);
426 virtual int SeekSlice(
int offset,
int whence,
int fd);
427 virtual int Close(
int) {_is_open =
false;
return(0); };
428 virtual bool TimeVarying()
const {
return(
false); };
429 virtual std::vector <size_t> GetSpatialDims()
const {
return(_dims); }
430 virtual std::vector <string> GetSpatialDimNames()
const {
return(_dimnames); }
431 virtual size_t GetTimeDim()
const {
return(0); }
432 virtual string GetTimeDimName()
const {
return(
""); };
433 virtual bool GetMissingValue(
double &mv)
const {mv=0.0;
return(
false); }
436 std::vector <size_t> _dims;
437 std::vector <string> _dimnames;
454 class DerivedVar_AHSPC :
public NetCDFCollection::DerivedVar {
458 NetCDFCFCollection *ncdfcf,
459 const std::map <string, string> &formula_map
461 virtual ~DerivedVar_AHSPC();
462 virtual float GetMax() {
return _max; }
463 virtual float GetMin() {
return _min; }
464 virtual void SetMax(
float val) { _max = val; }
465 virtual void SetMin(
float val) { _min = val; }
466 virtual int Open(
size_t ts);
467 virtual int ReadSlice(
float *slice,
int);
468 virtual int Read(
float *buf,
int);
469 virtual int SeekSlice(
int offset,
int whence,
int fd);
470 virtual int Close(
int) {_is_open =
false;
return(0); };
471 virtual bool TimeVarying()
const {
return(
false); };
472 virtual std::vector <size_t> GetSpatialDims()
const {
return(_dims); }
473 virtual std::vector <string> GetSpatialDimNames()
const {
return(_dimnames); }
474 virtual size_t GetTimeDim()
const {
return(0); }
475 virtual string GetTimeDimName()
const {
return(
""); };
476 virtual bool GetMissingValue(
double &mv)
const {mv=0.0;
return(
false); }
479 virtual int CalculateElevation();
480 virtual int DCZ2(
const float* PS1,
const float* PHIS1,
481 float** TV2,
const int NL,
482 const float P0,
float** HYBA,
float** HYBB,
483 const int KLEV,
const int MLON,
const int MLON2,
484 float** HYPDLN,
float** HYALPH,
float** PTERM,
486 std::vector <size_t> _dims;
487 std::vector <string> _dimnames;
506 class DerivedVar_noop :
public NetCDFCollection::DerivedVar {
510 NetCDFCFCollection *ncdfcf,
511 const std::map <string, string> &formula_map
513 virtual ~DerivedVar_noop() {}
515 virtual int Open(
size_t ts);
516 virtual int ReadSlice(
float *slice,
int fd);
517 virtual int Read(
float *buf,
int fd);
518 virtual int SeekSlice(
int offset,
int whence,
int fd);
519 virtual int Close(
int fd) {
return(_ncdfc->Close(fd)); };
520 virtual bool TimeVarying()
const {
return(_ncdfc->IsTimeVarying(_zvar)); };
521 virtual std::vector <size_t> GetSpatialDims()
const {
522 return(_ncdfc->GetSpatialDims(_zvar));
524 virtual std::vector <string> GetSpatialDimNames()
const {
525 return(_ncdfc->GetSpatialDimNames(_zvar));
527 virtual size_t GetTimeDim()
const {
528 return(_ncdfc->GetTimeDim(_zvar));
530 virtual string GetTimeDimName()
const {
531 return(_ncdfc->GetTimeDimName(_zvar));
534 virtual bool GetMissingValue(
double &mv)
const {
535 return(_ncdfc->GetMissingValue(_zvar, mv));
543 std::map <string, DerivedVar *> _derivedVarsMap;
544 std::vector <std::string> _coordinateVars;
545 std::vector <std::string> _auxCoordinateVars;
546 std::vector <std::string> _lonCoordVars;
547 std::vector <std::string> _latCoordVars;
548 std::vector <std::string> _vertCoordVars;
549 std::vector <std::string> _timeCoordVars;
556 std::map <string, double> _missingValueMap;
558 std::vector <std::string> _GetCoordAttrs(
559 const NetCDFSimple::Variable &varinfo
562 int _Initialize(
const std::vector <string> &files);
572 bool _IsCoordinateVar(
const NetCDFSimple::Variable &varinfo)
const;
592 const NetCDFSimple::Variable &varinfo
606 const NetCDFSimple::Variable &varinfo
622 bool _IsVertCoordVar(
623 const NetCDFSimple::Variable &varinfo
636 bool _IsTimeCoordVar(
637 const NetCDFSimple::Variable &varinfo
640 bool _GetMissingValue(
string varname,
string &attname,
double &mv)
const;
641 void _GetMissingValueMap(map <string, double> &missingValueMap)
const;
644 string formula_terms, map <string, string> &parsed_terms
const UDUnits * GetUDUnits() const
virtual std::vector< string > GetVertCoordVars() const
virtual std::vector< string > GetLonCoordVars() const
Wrapper for a collection of netCDF files.
virtual bool IsAuxCoordVarCF(string var) const
virtual bool IsLonCoordVar(string var) const
virtual bool IsVertCoordVar(string var) const
virtual bool IsTimeCoordVar(string var) const
virtual bool IsLatCoordVar(string var) const
virtual std::vector< string > GetTimeCoordVars() const
virtual std::vector< string > GetLatCoordVars() const
virtual bool IsCoordVarCF(string var) const
Wrapper for a collection of netCDF files.