@ -539,6 +539,9 @@ class NcZarrTypes
bool HasVar ( const MString & name ) const { return FindInd ( name , vars ) < vars . size ( ) ; }
bool HasAtt ( const MString & vname , const MString & aname ) const { return AttT ( vname , aname ) ! = AttType : : UNDEF ; }
bool HasAtt ( const MString & aname ) const { return AttT ( aname ) ! = AttType : : UNDEF ; }
const auto & Vars ( ) const { return vars ; }
const auto & Dims ( ) const { return dims ; }
} ;
class DimReqDef
@ -634,7 +637,6 @@ template<class C> class NcZarrRead: public C, public DimReqDef
d . Fillval ( )
} - > std : : convertible_to < DataType > ;
} )
fillout = data . Fillval ( ) ;
else // Data does'nt have own fillvalue, using variable fillvalue
fillout = static_cast < DataType > ( fillin ) ;
@ -675,8 +677,6 @@ template<class C> class NcZarrRead: public C, public DimReqDef
inind + + ;
}
michlib : : message ( " Variable " + vname + " , request size " + nval ) ;
for ( const auto & r : reqs ) michlib : : message ( r . name + " from " + r . beg + " , count " + r . count ) ;
return Error ( ) ;
}
@ -775,9 +775,13 @@ template<class C> class NcZarrRead: public C, public DimReqDef
if ( pdims [ ind ] . beg > = dlen ) return { pref , MString ( " Error parsing request: start index " ) + pdims [ ind ] . beg + " must be lesser then " + pdims [ ind ] . name + " size " + dlen } ;
if ( pdims [ ind ] . beg + pdims [ ind ] . count > dlen )
return { pref , MString ( " Error parsing request: start index " ) + pdims [ ind ] . beg + " with count " + pdims [ ind ] . count + " exceeds " + pdims [ ind ] . name + " size " + dlen } ;
// Ignore hyperplanes in requests for calculation of data dimensionality
if ( pdims [ transindex . back ( ) ] . count = = 1 ) transindex . pop_back ( ) ;
}
if ( transindex . size ( ) ! = Dimensionity < Data > ( ) ) return { pref , " Output data dimensions not correspondind request dimensions " } ;
if ( transindex . size ( ) ! = Dimensionity < Data > ( ) )
return { pref , MString ( " Output data dimensions ( " ) + Dimensionity < Data > ( ) + " ) not corresponding request dimensions ( " + transindex . size ( ) + " ) " } ;
switch ( C : : VarT ( vname ) )
{
case ( C : : VarType : : UNDEF ) : return { pref , " No variable with name " + vname + " (impossible) " } ;
@ -787,7 +791,7 @@ template<class C> class NcZarrRead: public C, public DimReqDef
case ( C : : VarType : : INT2 ) : return Read < typename C : : template Type < C : : VarType : : INT2 > > ( vname , transindex , data , transform , pdims ) ;
case ( C : : VarType : : INT4 ) : return Read < typename C : : template Type < C : : VarType : : INT4 > > ( vname , transindex , data , transform , pdims ) ;
case ( C : : VarType : : INT8 ) : return Read < typename C : : template Type < C : : VarType : : INT8 > > ( vname , transindex , data , transform , pdims ) ;
case ( C : : VarType : : UINT1 ) : return Read < typename C : : template Type < C : : VarType : : U INT1> > ( vname , transindex , data , transform , pdims ) ;
case ( C : : VarType : : UINT1 ) : return Read < typename C : : template Type < C : : VarType : : INT1 > > ( vname , transindex , data , transform , pdims ) ;
}
return { pref , " Internal error (impossible) " } ;
@ -819,4 +823,14 @@ template<class C> class NcZarrRead: public C, public DimReqDef
return Read ( vname , data , transform , pdims ) ;
}
// Request full one-dimensional variable
template < class Type > Error Read ( const MString & vname , std : : vector < Type > & out ) const
{
const auto & dnames = C : : DimNames ( vname ) ;
if ( dnames . size ( ) > 0 ) out . resize ( C : : DimSize ( dnames [ 0 ] ) ) ;
auto data = [ & vec = out ] ( size_t i ) - > Type & { return vec [ i ] ; } ;
return Read ( vname , data , std : : identity ( ) ) ;
}
} ;