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;
307 virtual bool GetMissingValue(
string varname,
double &mv)
const;
311 virtual int OpenRead(
size_t ts,
string varname);
320 virtual bool IsVertDimensionless(
string cvar)
const;
348 virtual int InstallStandardVerticalConverter(
349 string cvar,
string newvar,
string units =
"meters"
360 virtual void UninstallStandardVerticalConverter(
string cvar) ;
379 virtual int InstallStandardTimeConverter(
380 string cvar,
string newvar,
string units =
"seconds"
391 virtual void UninstallStandardTimeConverter(
string cvar) ;
406 void InstallDerivedCoordVar(
string varname, DerivedVar *derivedVar,
int axis);
410 void RemoveDerivedVar(
string varname);
422 bool GetMapProjectionProj4(
423 string varname,
string &proj4string
426 void FormatTimeStr(
double time,
string &str)
const;
428 friend std::ostream &operator<<(
436 DerivedVar_ocean_s_coordinate_g1(
438 const std::map <string, string> &formula_map
440 virtual ~DerivedVar_ocean_s_coordinate_g1();
442 virtual int Open(
size_t ts);
443 virtual int ReadSlice(
float *slice,
int);
444 virtual int Read(
float *buf,
int);
445 virtual int SeekSlice(
int offset,
int whence,
int fd);
446 virtual int Close(
int) {_is_open =
false;
return(0); };
447 virtual bool TimeVarying()
const {
return(
false); };
448 virtual std::vector <size_t> GetSpatialDims()
const {
return(_dims); }
449 virtual std::vector <string> GetSpatialDimNames()
const {
return(_dimnames); }
450 virtual size_t GetTimeDim()
const {
return(0); }
451 virtual string GetTimeDimName()
const {
return(
""); };
452 virtual bool GetMissingValue(
double &mv)
const {mv=0.0;
return(
false); }
455 std::vector <size_t> _dims;
456 std::vector <string> _dimnames;
472 class DerivedVar_ocean_s_coordinate_g2 :
public NetCDFCollection::DerivedVar {
475 DerivedVar_ocean_s_coordinate_g2(
476 NetCDFCFCollection *ncdfcf,
477 const std::map <string, string> &formula_map
479 virtual ~DerivedVar_ocean_s_coordinate_g2();
481 virtual int Open(
size_t ts);
482 virtual int ReadSlice(
float *slice,
int);
483 virtual int Read(
float *buf,
int);
484 virtual int SeekSlice(
int offset,
int whence,
int fd);
485 virtual int Close(
int) {_is_open =
false;
return(0); };
486 virtual bool TimeVarying()
const {
return(
false); };
487 virtual std::vector <size_t> GetSpatialDims()
const {
return(_dims); }
488 virtual std::vector <string> GetSpatialDimNames()
const {
return(_dimnames); }
489 virtual size_t GetTimeDim()
const {
return(0); }
490 virtual string GetTimeDimName()
const {
return(
""); };
491 virtual bool GetMissingValue(
double &mv)
const {mv=0.0;
return(
false); }
494 std::vector <size_t> _dims;
495 std::vector <string> _dimnames;
512 class DerivedVar_AHSPC :
public NetCDFCollection::DerivedVar {
516 NetCDFCFCollection *ncdfcf,
517 const std::map <string, string> &formula_map
519 virtual ~DerivedVar_AHSPC();
520 virtual float GetMax() {
return _max; }
521 virtual float GetMin() {
return _min; }
522 virtual void SetMax(
float val) { _max = val; }
523 virtual void SetMin(
float val) { _min = val; }
524 virtual int Open(
size_t ts);
525 virtual int ReadSlice(
float *slice,
int);
526 virtual int Read(
float *buf,
int);
527 virtual int SeekSlice(
int offset,
int whence,
int fd);
528 virtual int Close(
int) {_is_open =
false;
return(0); };
529 virtual bool TimeVarying()
const {
return(
false); };
530 virtual std::vector <size_t> GetSpatialDims()
const {
return(_dims); }
531 virtual std::vector <string> GetSpatialDimNames()
const {
return(_dimnames); }
532 virtual size_t GetTimeDim()
const {
return(0); }
533 virtual string GetTimeDimName()
const {
return(
""); };
534 virtual bool GetMissingValue(
double &mv)
const {mv=0.0;
return(
false); }
537 virtual int CalculateElevation();
538 virtual int DCZ2(
const float* PS1,
const float* PHIS1,
539 float** TV2,
const int NL,
540 const float P0,
float** HYBA,
float** HYBB,
541 const int KLEV,
const int MLON,
const int MLON2,
542 float** HYPDLN,
float** HYALPH,
float** PTERM,
544 std::vector <size_t> _dims;
545 std::vector <string> _dimnames;
564 class DerivedVar_noop :
public NetCDFCollection::DerivedVar {
568 NetCDFCFCollection *ncdfcf,
569 const std::map <string, string> &formula_map,
string units
571 virtual ~DerivedVar_noop() {}
573 virtual int Open(
size_t ts);
574 virtual int ReadSlice(
float *slice,
int fd);
575 virtual int Read(
float *buf,
int fd);
576 virtual int SeekSlice(
int offset,
int whence,
int fd);
577 virtual int Close(
int fd) {
return(_ncdfc->Close(fd)); };
578 virtual bool TimeVarying()
const {
return(_ncdfc->IsTimeVarying(_zvar)); };
579 virtual std::vector <size_t> GetSpatialDims()
const {
580 return(_ncdfc->GetSpatialDims(_zvar));
582 virtual std::vector <string> GetSpatialDimNames()
const {
583 return(_ncdfc->GetSpatialDimNames(_zvar));
585 virtual size_t GetTimeDim()
const {
586 return(_ncdfc->GetTimeDim(_zvar));
588 virtual string GetTimeDimName()
const {
589 return(_ncdfc->GetTimeDimName(_zvar));
592 virtual bool GetMissingValue(
double &mv)
const {
593 return(_ncdfc->GetMissingValue(_zvar, mv));
599 string _native_units;
600 string _derived_units;
603 class DerivedVarTime :
public NetCDFCollection::DerivedVar {
606 NetCDFCFCollection *ncdfcf,
607 string native_var,
string native_units,
string derived_units
609 virtual ~DerivedVarTime();
611 virtual int Open(
size_t ts);
612 virtual int ReadSlice(
float *slice,
int);
613 virtual int Read(
float *buf,
int);
614 virtual int SeekSlice(
int offset,
int whence,
int fd);
615 virtual int Close(
int) {
return(0); };
616 virtual bool TimeVarying()
const {
return(
true); };
617 virtual std::vector <size_t> GetSpatialDims()
const {
return(_dims); }
618 virtual std::vector <string> GetSpatialDimNames()
const {
return(_dimnames); }
619 virtual size_t GetTimeDim()
const {
return(_timedim); }
620 virtual string GetTimeDimName()
const {
return(_timedimname); };
621 virtual bool GetMissingValue(
double &mv)
const {mv=0.0;
return(
false); }
625 string _native_units;
626 string _derived_units;
627 std::vector <size_t> _dims;
628 std::vector <string> _dimnames;
636 std::map <string, DerivedVar *> _derivedVarsMap;
637 std::vector <std::string> _coordinateVars;
638 std::vector <std::string> _auxCoordinateVars;
639 std::vector <std::string> _lonCoordVars;
640 std::vector <std::string> _latCoordVars;
641 std::vector <std::string> _vertCoordVars;
642 std::vector <std::string> _timeCoordVars;
649 std::map <string, double> _missingValueMap;
651 std::vector <std::string> _GetCoordAttrs(
652 const NetCDFSimple::Variable &varinfo
655 int _Initialize(
const std::vector <string> &files);
665 bool _IsCoordinateVar(
const NetCDFSimple::Variable &varinfo)
const;
685 const NetCDFSimple::Variable &varinfo
699 const NetCDFSimple::Variable &varinfo
715 bool _IsVertCoordVar(
716 const NetCDFSimple::Variable &varinfo
729 bool _IsTimeCoordVar(
730 const NetCDFSimple::Variable &varinfo
733 bool _GetMissingValue(
string varname,
string &attname,
double &mv)
const;
734 void _GetMissingValueMap(map <string, double> &missingValueMap)
const;
737 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.