26 #include <pni/core/types.hpp>
27 #include <pni/core/type_erasures.hpp>
29 #include "../algorithms/create_field.hpp"
30 #include "../algorithms/create_attribute.hpp"
31 #include "../algorithms/write.hpp"
32 #include "../algorithms/get_name.hpp"
33 #include "../algorithms/get_unit.hpp"
34 #include "../algorithms/as_field.hpp"
35 #include "../algorithms/as_group.hpp"
36 #include "../algorithms/get_size.hpp"
37 #include "../algorithms/get_shape.hpp"
38 #include "../nxobject.hpp"
65 static pni::core::string
unit(
const node &field_node);
90 static pni::core::shape_t
chunk(
const node &field_node);
122 const node &field_node)
128 string field_name =
name(field_node);
129 shape_t field_shape =
shape(field_node);
130 type_id_t tid =
type_id(field_node);
131 shape_t chunk_shape =
chunk(field_node);
133 if(chunk_shape.empty())
135 chunk_shape = field_shape;
139 if(field_shape.size()==1)
140 chunk_shape[0] = 1024;
144 if(chunk_shape.size() != field_shape.size())
145 throw shape_mismatch_error(EXCEPTION_RECORD,
146 "Rank of chunk and dimensions tag do not match!");
151 bool use_compression =
false;
152 bool use_shuffle =
false;
153 size_t compression_rate = 0;
154 auto strategy = field_node.get_child_optional(
"strategy");
158 use_compression = data_from_xml<bool>(
162 use_shuffle = data_from_xml<bool>(
166 compression_rate = data_from_xml<size_t>(
177 typedef typename trait_type::deflate_type deflate_type;
179 deflate_type comp(compression_rate,use_shuffle);
180 f =
create_field(parent,tid,field_name,field_shape,chunk_shape,comp);
183 f =
create_field(parent,tid,field_name,field_shape,chunk_shape);
187 write(create_attribute<string>(f,
"long_name"),
192 write(create_attribute<string>(f,
"units"),
231 field_node.put(
"<xmlattr>.name",fo.name());
232 field_node.put(
"<xmlattr>.type",str_from_type_id(fo.type_id()));
235 if(fo.attributes.exists(
"units"))
237 fo.attributes[
"units"].read(buffer);
238 field_node.put(
"<xmlattr>.units",buffer);
242 if(fo.attributes.exists(
"long_name"))
244 fo.attributes[
"long_name"].read(buffer);
245 field_node.put(
"<xmlattr>.long_name",buffer);
249 auto s = get_shape<shape_t>(f);
static pni::core::shape_t chunk(const node &field_node)
get chunk shape
Definition: field.cpp:65
static pni::core::string long_name(const node &field_node)
return long name
Definition: field.cpp:51
bool has_attribute(const node &parent, const pni::core::string &name)
check for attribute existence
nexus object traits
Definition: nxobject_traits.hpp:44
read and write field data
Definition: field.hpp:53
static node object_to_xml(const nxobject< GTYPE, FTYPE, ATYPE, LTYPE > &f)
create XML object from field
Definition: field.hpp:222
size_t get_size(const OTYPE< IMPID > &o)
get number of elements
Definition: get_size.hpp:61
static pni::core::type_id_t type_id(const node &io_node)
get type id
Definition: io_node.cpp:72
nxobject< GTYPE, FTYPE, ATYPE, LTYPE > create_field(const nxobject< GTYPE, FTYPE, ATYPE, LTYPE > &location, const PATHT &path, const STYPE &shape, const STYPE &chunk, const FILTERT &filter)
field construction
Definition: create_field.hpp:232
Definition: cbf_reader.hpp:41
static pni::core::string unit(const node &field_node)
return field unit
Definition: field.cpp:37
boost::property_tree::ptree node
alias for ptree
Definition: node.hpp:39
FTYPE as_field(const nxobject< GTYPE, FTYPE, ATYPE, LTYPE > &o)
as field wrapper
Definition: as_field.hpp:166
static node object_to_xml(const pni::core::shape_t &s)
create dimension node
Definition: dimensions.cpp:105
static pni::core::string name(const node &io_node)
return object name
Definition: io_node.cpp:54
static nxobject< GTYPE, FTYPE, ATYPE, LTYPE > object_from_xml(const nxobject< GTYPE, FTYPE, ATYPE, LTYPE > &parent, const node &field_node)
create field from XML
Definition: field.hpp:121
implementation code type map
Definition: nximp_code_map.hpp:37
node get_attribute(const node &parent, const pni::core::string &name)
get attribute node
boost::variant< GTYPE, FTYPE, ATYPE, LTYPE > nxobject
Definition: nxobject.hpp:44
static pni::core::shape_t shape(const node &io_node)
return object shape
Definition: io_node.cpp:61
general IO objects
Definition: io_node.hpp:43
void write(const OTYPE< IMPID > &o, const ATYPE &a)
write data to an attribute or field
Definition: write.hpp:61