10 template<
class T,
int D>
class OutputHdfIterationHelper:
11 public OutputHdfIterationHelperBase {
14 const std::string& Data_name)
15 : h(H), d(Data_name) {}
17 void add_iteration(
const Array<T, D-1>& dt)
19 TinyVector<int, D+1> sz;
20 bool incoming_smaller =
false;
21 if(data.cols() == 0) {
22 for(
int i = 0; i < D - 1; ++i)
23 sz[i + 2] = dt.shape()[i];
27 for(
int i = 0; i < D - 1; ++i) {
30 if(dt.shape()[i] > data.shape()[i + 2]) {
31 sz[i+2] = dt.shape()[i];
32 }
else if(dt.shape()[i] < data.shape()[i + 2]) {
33 incoming_smaller =
true;
34 sz[i+2] = data.shape()[i+2];
36 sz[i+2] = data.shape()[i+2];
40 sz[1] = data.cols() + 1;
42 data.resizeAndPreserve(sz);
44 if (incoming_smaller) {
47 TinyVector<int, D-1> lower(0);
48 RectDomain<D-1> dt_subdomain(lower, dt.shape());
53 subset(data)(dt_subdomain) = dt;
58 virtual void write() { h->hdf_file().write_field(d, data); }
60 Array<T, 1> subset(
const Array<T, 3>& V)
61 {
return V(0, V.cols() - 1, Range::all());}
62 Array<T, 2> subset(
const Array<T, 4>& V)
63 {
return V(0, V.cols() - 1, Range::all(), Range::all());}
64 Array<T, 3> subset(
const Array<T, 5>& V)
65 {
return V(0, V.cols() - 1, Range::all(), Range::all(), Range::all());}
71 template<
class T>
class OutputHdfIterationHelper<T, 1> :
72 public OutputHdfIterationHelperBase {
75 const std::string& Data_name)
76 : h(H), d(Data_name) {}
77 void add_iteration(
const T& dt)
79 data.resizeAndPreserve(1, data.cols() + 1);
80 data(0, data.cols() - 1) = dt;
82 virtual void write() { h->hdf_file().write_field(d, data); }
93 typedef std::map<std::string,
96 BOOST_FOREACH(vt&
p, data)
102 (
const std::string& Dataset_name,
105 if(data.count(Dataset_name) == 0)
107 (
new OutputHdfIterationHelper<T, 1>
108 (h, iteration_group +
"/" + Dataset_name));
110 hlp = boost::dynamic_pointer_cast<OutputHdfIterationHelper<T, 1> >
111 (data[Dataset_name]);
112 hlp->add_iteration(Val);
116 (
const std::string& Dataset_name,
117 const blitz::Array<T, D>& Val)
119 if(data.count(Dataset_name) == 0)
121 (
new OutputHdfIterationHelper<T, D + 1>
122 (h, iteration_group +
"/" + Dataset_name));
124 hlp = boost::dynamic_pointer_cast<OutputHdfIterationHelper<T, D + 1> >
125 (data[Dataset_name]);
126 hlp->add_iteration(Val);
143 const blitz::Array<int, 1>& Val);
145 const blitz::Array<std::string, 1>& Val);
147 const blitz::Array<const char*, 1>& Val);
149 const blitz::Array<double, 1>& Val);
152 const blitz::Array<int, 2>& Val);
154 const blitz::Array<std::string, 2>& Val);
156 const blitz::Array<const char*, 2>& Val);
158 const blitz::Array<double, 2>& Val);
161 const blitz::Array<int, 3>& Val);
163 const blitz::Array<std::string, 3>& Val);
165 const blitz::Array<const char*, 3>& Val);
167 const blitz::Array<double, 3>& Val);
void write_data_t(const std::string &Dataset_name, T Val)
Apply value function to a blitz array.
Contains classes to abstract away details in various Spurr Radiative Transfer software.