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;
120 EncodingODIM(
const drain::image::Image & image) : scaling(ownScaling), scalingConst(image.getScaling()), explicitSettings(NONE) {
121 initFromImage(image);
126 initFromImage(image);
134 explicitSettings = odim.explicitSettings;
160 EncodingODIM & setScaling(
double gain,
double offset = NAN);
162 EncodingODIM & setScaling(
double gain,
double offset,
double undetect,
double nodata);
166 return ((scaling.
scale != 0.0) && (!
type.empty()) && (
type.at(0) !=
'*'));
174 return (odim1.
type == odim2.
type) &&
175 (odim1.scaling.
scale == odim2.scaling.
scale) &&
177 (odim1.undetect == odim2.undetect) &&
182 void setRange(
double min,
double max);
192 const char typechar = drain::Type::getTypeChar(t);
193 if (this->type.empty())
194 this->type = typechar;
196 if (this->type.at(0) != typechar)
197 mout.
warn(
"different types: " , this->type ,
'/' , typechar );
200 scaling.set(1.0, 0.0);
203 if (typechar !=
'*'){
204 undetect = drain::Type::call<drain::typeMin, double>(t);
205 nodata = drain::Type::call<drain::typeMax, double>(t);
208 undetect = drain::Type::call<drain::typeMin, double>(this->type);
209 nodata = drain::Type::call<drain::typeMax, double>(this->type);
217 void setTypeDefaults(){
218 setTypeDefaults(this->type);
224 return (x != undetect) && (x !=
nodata);
338 const ODIMPathElemSeq & getAttributeGroups();
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & warn(const TT &... args)
Possible error, but execution can continue.
Definition Log.h:430
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:247
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:173
double scaleInverse(double y) const
Converts a quantity to storage scale: x = (y-offset)/gain .
Definition EncodingODIM.h:235
void addShortKeys()
Creates a short alias (attrib) for each (group):(attrib). Example: "gain" => "what:gain".
Definition EncodingODIM.h:290
static const ODIMPathElemSeq & attributeGroups
Copies contents of this to a h5 group.
Definition EncodingODIM.h:325
std::string type
This is non-standard (not in ODIM), but a practical means of handling storage type of datasets.
Definition EncodingODIM.h:152
double scaleForward(double x) const
Converts a quantity from storage scale: y = offset + gain*y .
Definition EncodingODIM.h:229
static void checkType(Hi5Tree &dst)
Traverses recursively subtrees and checks the types of PolarODIM variables.
Definition EncodingODIM.h:306
virtual void updateLenient(const EncodingODIM &odim)
Todo: keep the function, but move implementation to (future single-exec) register ?
Definition EncodingODIM.cpp:229
double getMin() const
Returns the minimum physical value that can be returned using current storage type,...
Definition EncodingODIM.cpp:394
void copyFrom(const drain::image::Image &data)
Copies image attributes and type . Experimental.
Definition EncodingODIM.cpp:269
bool isValue(double x) const
Returns true for a valid measurement value, false for undetect and nodata marker values.
Definition EncodingODIM.h:223
void clear()
Resets the values.
Definition EncodingODIM.cpp:183
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:187
double nodata
data[n]/what (obligatory)
Definition EncodingODIM.h:157
double getMax() const
Returns the minimum physical value that can be returned using current storage type,...
Definition EncodingODIM.cpp:418
void grantShortKeys(drain::ReferenceMap &ref)
Creates a short alias (attrib) for each (group):(attrib). Example: "gain" => "what:gain".
Definition EncodingODIM.cpp:252
static const group_t ALL_LEVELS
Abbreviation for linking (referencing) attributes at different levels (tree depths).
Definition ODIMPath.h:121
unsigned int group_t
In H5, "groups" correspond to directories or folders in file system.
Definition ODIMPath.h:92
Definition DataSelector.cpp:44