31 #ifndef ENC_ODIM_STRUCT
32 #define ENC_ODIM_STRUCT
40 #include <drain/util/ReferenceMap.h>
41 #include <drain/util/Rectangle.h>
42 #include <drain/util/Time.h>
43 #include <drain/util/ValueScaling.h>
87 typedef enum {NONE=0, SCALING=1, RANGE=2} ExplicitSetting;
115 initFromImage(image);
120 initFromImage(image);
128 explicitSettings = odim.explicitSettings;
154 EncodingODIM & setScaling(
double gain,
double offset = NAN);
156 EncodingODIM & setScaling(
double gain,
double offset,
double undetect,
double nodata);
160 return ((scaling.
scale != 0.0) && (!
type.empty()) && (
type.at(0) !=
'*'));
168 return (odim1.
type == odim2.
type) &&
169 (odim1.scaling.
scale == odim2.scaling.
scale) &&
171 (odim1.undetect == odim2.undetect) &&
176 void setRange(
double min,
double max);
186 const char typechar = drain::Type::getTypeChar(t);
187 if (this->type.empty())
188 this->type = typechar;
190 if (this->type.at(0) != typechar)
191 mout.
warn(
"different types: " , this->type ,
'/' , typechar );
194 scaling.set(1.0, 0.0);
199 if (typechar !=
'*'){
200 undetect = drain::Type::call<drain::typeMin, double>(t);
201 nodata = drain::Type::call<drain::typeMax, double>(t);
204 undetect = drain::Type::call<drain::typeMin, double>(this->type);
205 nodata = drain::Type::call<drain::typeMax, double>(this->type);
213 void setTypeDefaults(){
214 setTypeDefaults(this->type);
220 return (x != undetect) && (x !=
nodata);
334 const ODIMPathElemSeq & getAttributeGroups();
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
Logger & warn(const TT &... args)
Possible error, but execution can continue.
Definition: Log.h:426
Definition: ReferenceMap.h:207
void setValues(const std::string &entries, char assignmentSymbol='=', char separatorSymbol=0)
Sets values. If strictness==STRICTLY_CLOSED, throws exception if tries to assign a non-existing entry...
Definition: SmartMap.h:311
void updateFromMap(const std::map< std::string, T2 > &m)
Assign values from a map. Updates existing entries only.
Definition: SmartMap.h:294
Utilities related to std::type_info.
Definition: Type.h:51
Linear scaling and physical range for image intensities.
Definition: ValueScaling.h:64
double & scale
Multiplicative coefficient \i a in: y = ax + b.
Definition: ValueScaling.h:68
double & offset
Additive coefficient \i b in: y = ax + b.
Definition: ValueScaling.h:71
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition: Image.h:184
Structure for data storage type, scaling and marker codes. Does not contain quantity.
Definition: EncodingODIM.h:75
double operator()(double y) const
Functor (why inverse?)
Definition: EncodingODIM.h:243
EncodingODIM(group_t initialize=ODIMPathElem::ALL_LEVELS)
Default constructor.
Definition: EncodingODIM.h:99
static bool haveSimilarEncoding(const EncodingODIM &odim1, const EncodingODIM &odim2)
Checks if data encoding is similar (storage type, gain, offset, undetect and nodata are the same).
Definition: EncodingODIM.h:167
double scaleInverse(double y) const
Converts a quantity to storage scale: x = (y-offset)/gain .
Definition: EncodingODIM.h:231
void addShortKeys()
Creates a short alias (attrib) for each (group):(attrib). Example: "gain" => "what:gain".
Definition: EncodingODIM.h:286
static const ODIMPathElemSeq & attributeGroups
Copies contents of this to a h5 group.
Definition: EncodingODIM.h:321
std::string type
This is non-standard (not in ODIM), but a practical means of handling storage type of datasets.
Definition: EncodingODIM.h:146
double scaleForward(double x) const
Converts a quantity from storage scale: y = offset + gain*y .
Definition: EncodingODIM.h:225
static void checkType(Hi5Tree &dst)
Traverses recursively subtrees and checks the types of PolarODIM variables.
Definition: EncodingODIM.h:302
virtual void updateLenient(const EncodingODIM &odim)
Todo: keep the function, but move implementation to (future single-exec) register ?
Definition: EncodingODIM.cpp:217
double getMin() const
Returns the minimum physical value that can be returned using current storage type,...
Definition: EncodingODIM.cpp:375
void copyFrom(const drain::image::Image &data)
Copies image attributes and type . Experimental.
Definition: EncodingODIM.cpp:250
bool isValue(double x) const
Returns true for a valid measurement value, false for undetect and nodata marker values.
Definition: EncodingODIM.h:219
void clear()
Resets the values.
Definition: EncodingODIM.cpp:171
void setTypeDefaults(const T &type, const std::string &values="")
Sets gain=1, offset=0, undetect=type_min, nodata=type_max. Note: sets type only if unset.
Definition: EncodingODIM.h:181
double nodata
data[n]/what (obligatory)
Definition: EncodingODIM.h:151
double getMax() const
Returns the minimum physical value that can be returned using current storage type,...
Definition: EncodingODIM.cpp:399
void grantShortKeys(drain::ReferenceMap &ref)
Creates a short alias (attrib) for each (group):(attrib). Example: "gain" => "what:gain".
Definition: EncodingODIM.cpp:233
static const group_t ALL_LEVELS
Abbreviation for linking (referencing) attributes at different levels (tree depths).
Definition: ODIMPath.h:118
drain::Flagger::ivalue_t group_t
In H5, "groups" correspond to "directories" or "folders" in Unix and Windows.
Definition: ODIMPath.h:91
Definition: DataSelector.cpp:44