11#include "matpack_data.h"
12#include "matpack_arrays.h"
21 const Index n=time_stamps.
nelem();
22 if (arr.
nelem() not_eq n)
23 throw std::runtime_error(
"Cannot sort, time array does not agree with sorting array size");
31 for (Index i=0; i<n; i++)
32 out[i] = arr[sortings[i]];
37#define TIME_SORT_MACRO(VAR) \
38void time_stampsSort(VAR & out, const ArrayOfTime& time_stamps, const VAR & in, const Verbosity&) \
39{out = TimeSortTemplate(in, time_stamps);}
59 for (
auto& array: in) {
60 for (
auto& val: array) {
69#define FLATTEN_MACRO(VAR) \
70void Flatten(VAR & out, const Array< VAR > & in, const Verbosity&) \
71{out = FlattenArrayTemplate(in);}
80 if (in.nelem() == 0) {
83 const Index n = in.nelem();
84 const Index m = in[0].nelem();
86 if (not std::all_of(in.cbegin(), in.cend(), [m](
auto&
v){return m == v.nelem();}))
87 throw std::runtime_error(
"Can only flatten array of same length data");
90 for (Index i=0; i<n; i++)
91 out(i, joker) = in[i];
97 if (in.nelem() == 0) {
98 out = Tensor3(0, 0, 0);
100 const Index n = in.nelem();
101 const Index
c = in[0].ncols();
102 const Index r = in[0].nrows();
104 if (not std::all_of(in.cbegin(), in.cend(), [
c](
auto&
v){return c == v.ncols();})) {
105 throw std::runtime_error(
"Can only flatten array of same size data");
106 }
else if (not std::all_of(in.cbegin(), in.cend(), [r](
auto&
v){return r == v.nrows();})) {
107 throw std::runtime_error(
"Can only flatten array of same size data");
110 out = Tensor3(n, r,
c);
111 for (Index i=0; i<n; i++)
112 out(i, joker, joker) = in[i];
118 if (in.nelem() == 0) {
119 out = Tensor4(0, 0, 0, 0);
121 const Index n = in.nelem();
122 const Index
c = in[0].ncols();
123 const Index r = in[0].nrows();
124 const Index p = in[0].npages();
126 if (not std::all_of(in.cbegin(), in.cend(), [
c](
auto&
v){return c == v.ncols();})) {
127 throw std::runtime_error(
"Can only flatten array of same size data");
128 }
else if (not std::all_of(in.cbegin(), in.cend(), [r](
auto&
v){return r == v.nrows();})) {
129 throw std::runtime_error(
"Can only flatten array of same size data");
130 }
else if (not std::all_of(in.cbegin(), in.cend(), [p](
auto&
v){return p == v.npages();})) {
131 throw std::runtime_error(
"Can only flatten array of same size data");
134 out = Tensor4(n, p, r,
c);
135 for (Index i=0; i<n; i++)
136 out(i, joker, joker, joker) = in[i];
142 if (in.nelem() == 0) {
143 out = Tensor5(0, 0, 0, 0, 0);
145 const Index n = in.nelem();
146 const Index
c = in[0].ncols();
147 const Index r = in[0].nrows();
148 const Index p = in[0].npages();
149 const Index
b = in[0].nbooks();
151 if (not std::all_of(in.cbegin(), in.cend(), [
c](
auto&
v){return c == v.ncols();})) {
152 throw std::runtime_error(
"Can only flatten array of same size data");
153 }
else if (not std::all_of(in.cbegin(), in.cend(), [r](
auto&
v){return r == v.nrows();})) {
154 throw std::runtime_error(
"Can only flatten array of same size data");
155 }
else if (not std::all_of(in.cbegin(), in.cend(), [p](
auto&
v){return p == v.npages();})) {
156 throw std::runtime_error(
"Can only flatten array of same size data");
157 }
else if (not std::all_of(in.cbegin(), in.cend(), [
b](
auto&
v){return b == v.nbooks();})) {
158 throw std::runtime_error(
"Can only flatten array of same size data");
161 out = Tensor5(n,
b, p, r,
c);
162 for (Index i=0; i<n; i++)
163 out(i, joker, joker, joker, joker) = in[i];
169 if (in.nelem() == 0) {
170 out = Tensor6(0, 0, 0, 0, 0, 0);
172 const Index n = in.nelem();
173 const Index
c = in[0].ncols();
174 const Index r = in[0].nrows();
175 const Index p = in[0].npages();
176 const Index
b = in[0].nbooks();
177 const Index s = in[0].nshelves();
179 if (not std::all_of(in.cbegin(), in.cend(), [
c](
auto&
v){return c == v.ncols();})) {
180 throw std::runtime_error(
"Can only flatten array of same size data");
181 }
else if (not std::all_of(in.cbegin(), in.cend(), [r](
auto&
v){return r == v.nrows();})) {
182 throw std::runtime_error(
"Can only flatten array of same size data");
183 }
else if (not std::all_of(in.cbegin(), in.cend(), [p](
auto&
v){return p == v.npages();})) {
184 throw std::runtime_error(
"Can only flatten array of same size data");
185 }
else if (not std::all_of(in.cbegin(), in.cend(), [
b](
auto&
v){return b == v.nbooks();})) {
186 throw std::runtime_error(
"Can only flatten array of same size data");
187 }
else if (not std::all_of(in.cbegin(), in.cend(), [s](
auto&
v){return s == v.nshelves();})) {
188 throw std::runtime_error(
"Can only flatten array of same size data");
191 out = Tensor6(n, s,
b, p, r,
c);
192 for (Index i=0; i<n; i++)
193 out(i, joker, joker, joker, joker, joker) = in[i];
199 if (in.nelem() == 0) {
200 out = Tensor7(0, 0, 0, 0, 0, 0, 0);
202 const Index n = in.nelem();
203 const Index
c = in[0].ncols();
204 const Index r = in[0].nrows();
205 const Index p = in[0].npages();
206 const Index
b = in[0].nbooks();
207 const Index s = in[0].nshelves();
208 const Index
w = in[0].nvitrines();
210 if (not std::all_of(in.cbegin(), in.cend(), [
c](
auto&
v){return c == v.ncols();})) {
211 throw std::runtime_error(
"Can only flatten array of same size data");
212 }
else if (not std::all_of(in.cbegin(), in.cend(), [r](
auto&
v){return r == v.nrows();})) {
213 throw std::runtime_error(
"Can only flatten array of same size data");
214 }
else if (not std::all_of(in.cbegin(), in.cend(), [p](
auto&
v){return p == v.npages();})) {
215 throw std::runtime_error(
"Can only flatten array of same size data");
216 }
else if (not std::all_of(in.cbegin(), in.cend(), [
b](
auto&
v){return b == v.nbooks();})) {
217 throw std::runtime_error(
"Can only flatten array of same size data");
218 }
else if (not std::all_of(in.cbegin(), in.cend(), [s](
auto&
v){return s == v.nshelves();})) {
219 throw std::runtime_error(
"Can only flatten array of same size data");
220 }
else if (not std::all_of(in.cbegin(), in.cend(), [
w](
auto&
v){return w == v.nvitrines();})) {
221 throw std::runtime_error(
"Can only flatten array of same size data");
224 out = Tensor7(n,
w, s,
b, p, r,
c);
225 for (Index i=0; i<n; i++)
226 out(i, joker, joker, joker, joker, joker, joker) = in[i];
Stuff related to time in ARTS.
This can be used to make arrays out of anything.
Index nelem() const ARTS_NOEXCEPT
Array< T > FlattenArrayTemplate(const Array< Array< T > > &in)
#define TIME_SORT_MACRO(VAR)
#define FLATTEN_MACRO(VAR)
Array< T > TimeSortTemplate(const Array< T > &arr, const ArrayOfTime &time_stamps)
void Flatten(Matrix &out, const ArrayOfVector &in, const Verbosity &)
WORKSPACE METHOD: Flatten.
Declarations having to do with the four output streams.
Contains sorting routines.
void get_sorted_indexes(ArrayOfIndex &sorted, const T &data)
get_sorted_indexes