18 const Numeric& cold_temp,
19 const Numeric& hot_temp,
24 "Length of vectors must be correct");
26 y.resize(atm.nelem());
37 const ArrayOfVector& level0_data,
39 const Vector& cold_temp,
40 const Vector& hot_temp,
41 const Index& first_c_index,
45 level0_data.nelem() not_eq hot_temp.nelem(),
46 "Length of vectors must be correct");
48 level0_time.
nelem() not_eq 0,
49 "Bad level0_time length, must be empty of same as level0_data");
54 if (level0_time.
nelem()) {
55 sensor_time.resize(ybatch.nelem());
57 const Index pos = first_c_index - ((first_c_index > 1) ? 2 : 0);
58 for (Index i=0; i<sensor_time.
nelem(); i++) {
59 sensor_time[i] = level0_time[pos + 2*i];
68 const Index& disregard_first,
69 const Index& disregard_last,
73 const Index n=sensor_time.
nelem();
75 "Time vector length must match input data length");
79 "Time vector cannot decrease");
85 ArrayOfVector ybatch_out;
88 if (lims.front() == n) {
90 sensor_time_out.resize(0);
94 const Index k = ybatch[0].nelem();
96 [k](
auto& x){return x.nelem() == k;}),
97 "Bad frequency grid size in input data; expects all equal");
100 const Index m = lims.nelem() - 1;
102 "Must include last if time step covers all of the range");
103 ybatch_out = ArrayOfVector(m, Vector(k));
107 #pragma omp parallel for if (not arts_omp_in_parallel()) schedule(guided)
108 for (Index i=0; i<m; i++) {
109 sensor_time_out[i] =
mean_time(sensor_time, lims[i], lims[i+1]);
114 if (disregard_first) {
115 ybatch_out.erase(ybatch_out.begin());
116 sensor_time_out.erase(sensor_time_out.begin());
119 if (disregard_last) {
120 ybatch_out.pop_back();
121 sensor_time_out.pop_back();
125 sensor_time = sensor_time_out;
130 ArrayOfVector& ybatch,
132 const Vector& trop_temp,
133 const Numeric& targ_temp,
137 const Index n=ybatch.nelem();
138 const Index m=n ? ybatch[0].nelem() : 0;
143 [m](
auto& y){return y.nelem() not_eq m;}),
144 "Bad input size, all of ybatch must match itself");
147 "Bad input size, trop_temp must match ybatch or be 1-long,\n"
148 "trop_temp: [", trop_temp,
"]\ntrop_temp.nelem(): ",
149 trop_temp.nelem(),
"\nybatch.nelem(): ", n);
152 ybatch_corr = ArrayOfVector(n, Vector(3));
155 for (Index i=0; i<n; i++) {
156 ybatch_corr[i][2] = trop_temp.nelem() > 1 ? trop_temp[i] : trop_temp[0];
158 ybatch_corr[i][1] = std::exp(- std::log((ybatch_corr[i][2] - ybatch_corr[i][0]) / (ybatch_corr[i][2] - targ_temp)));
162 for (Index i=0; i<n; i++) {
163 ybatch[i] *= ybatch_corr[i][1];
164 ybatch[i] += ybatch_corr[i][2] * (1 - ybatch_corr[i][1]);
170 const ArrayOfVector& ybatch_corr,
174 const Index n=ybatch.nelem();
176 [](
auto& corr){return corr.nelem() not_eq 3;})) or ybatch_corr.nelem() not_eq n,
177 "Bad input size, all of ybatch_corr must match ybatch and have three elements each");
180 for (Index i=0; i<n; i++) {
181 ybatch[i] -= ybatch_corr[i][2] * (1 - ybatch_corr[i][1]);
182 ybatch[i] /= ybatch_corr[i][1];
192 for (Index i=0; i<y.nelem(); i++) {
193 y[i] = mask[i] ? std::numeric_limits<Numeric>::quiet_NaN() : y[i];
208 if (f_grid.nelem() not_eq y.nelem()) {
209 throw std::runtime_error(
"f_grid and y must have the same size");
212 if (not is_increasing(f_grid)) {
213 throw std::runtime_error(
"f_grid must be sorted and ever increasing");
216 if (f_grid.nelem() < 2) {
217 throw std::runtime_error(
"Must have at least 2 frequency grid points");
221 const Numeric F0 = f0 > 0 ? f0 :
mean(f_grid);
222 const Numeric DF = df > 0 ? df : 10 * (f_grid[1] - f_grid[0]);
224 if (f_grid[0] <= F0 or F0 >=
last(f_grid)) {
225 throw std::runtime_error(
"Needs F0 in the range of f_grid");
234 ArrayOfVector& ybatch,
238 for (Vector& y: ybatch) {
239 if (f_grid.nelem() not_eq y.nelem()) {
240 throw std::runtime_error(
"f_grid and all of ybatch must have the same size");
244 if (not is_increasing(f_grid)) {
245 throw std::runtime_error(
"f_grid must be sorted and ever increasing");
248 if (f_grid.nelem() < 2) {
249 throw std::runtime_error(
"Must have at least 2 frequency grid points");
253 const Numeric F0 = f0 > 0 ? f0 :
mean(f_grid);
254 const Numeric DF = df > 0 ? df : 10 * (f_grid[1] - f_grid[0]);
256 if (
last(f_grid) <= F0 or f_grid[0] >= F0) {
257 throw std::runtime_error(
"Needs F0 in the range of f_grid");
TimeStep mean(const ArrayOfTimeStep &dt)
Returns the mean time step.
ArrayOfIndex time_steps(const ArrayOfTime ×, const TimeStep &DT)
Finds the index matching demands in a list of times.
TimeStep time_stepper_selection(const String &time_step)
Returns a time step from valid string.
Time mean_time(const ArrayOfTime &ts, Index s, Index E)
Computes the average time in a list.
TimeStep median(ArrayOfTimeStep dt)
Returns the median time step.
Stuff related to time in ARTS.
Array< Time > ArrayOfTime
List of times.
This can be used to make arrays out of anything.
Index nelem() const ARTS_NOEXCEPT
#define ARTS_USER_ERROR_IF(condition,...)
void yDoublingMeanFocus(Vector &f_grid, Vector &y, const Numeric &f0, const Numeric &df, const Verbosity &)
WORKSPACE METHOD: yDoublingMeanFocus.
void yColdAtmHot(Vector &y, const Vector &cold, const Vector &atm, const Vector &hot, const Numeric &cold_temp, const Numeric &hot_temp, const Index &calib, const Verbosity &)
WORKSPACE METHOD: yColdAtmHot.
void ybatchTimeAveraging(ArrayOfVector &ybatch, ArrayOfTime &sensor_time, const String &time_step, const Index &disregard_first, const Index &disregard_last, const Verbosity &)
WORKSPACE METHOD: ybatchTimeAveraging.
void ybatchDoublingMeanFocus(Vector &f_grid, ArrayOfVector &ybatch, const Numeric &f0, const Numeric &df, const Verbosity &)
WORKSPACE METHOD: ybatchDoublingMeanFocus.
void ybatchColdAtmHotAtmCycle(ArrayOfVector &ybatch, ArrayOfTime &sensor_time, const ArrayOfVector &level0_data, const ArrayOfTime &level0_time, const Vector &cold_temp, const Vector &hot_temp, const Index &first_c_index, const Verbosity &)
WORKSPACE METHOD: ybatchColdAtmHotAtmCycle.
void yMaskOutsideMedianRange(Vector &y, const Numeric &dx, const Verbosity &)
WORKSPACE METHOD: yMaskOutsideMedianRange.
void ybatchTroposphericCorrectionNaiveMedianForward(ArrayOfVector &ybatch_corr, ArrayOfVector &ybatch, const ArrayOfIndex &range, const Vector &trop_temp, const Numeric &targ_temp, const Verbosity &)
WORKSPACE METHOD: ybatchTroposphericCorrectionNaiveMedianForward.
void ybatchTroposphericCorrectionNaiveMedianInverse(ArrayOfVector &ybatch, const ArrayOfVector &ybatch_corr, const Verbosity &)
WORKSPACE METHOD: ybatchTroposphericCorrectionNaiveMedianInverse.
void ybatchMaskOutsideMedianRange(ArrayOfVector &ybatch, const Numeric &dx, const Verbosity &verbosity)
WORKSPACE METHOD: ybatchMaskOutsideMedianRange.
Numeric last(ConstVectorView x)
last
Numeric nanmedian(const ConstVectorView &v, const ArrayOfIndex &pos)
Get the median of the vector in the range ignoring all non-normal values.
VectorView nanavg(VectorView y, const ArrayOfVector &ys, const Index start, const Index end_tmp)
Compute the average of the ranged ys ignoring all non-normal values.
ArrayOfVector caha(const ArrayOfVector &data, const Vector &tcvec, const Vector &thvec, const Index first_c_index)
Calibrate the data by CAHA.
Vector systemtemp(const Vector &pc, const Vector &ph, Numeric tc, Numeric th) noexcept
Computes the linear receiver temperature formula elementwise.
Vector calibration(const Vector &pc, const Vector &pa, const Vector &ph, Numeric tc, Numeric th) noexcept
Computes the linear calibration formula elementwise.
std::vector< bool > out_of_bounds(const Vector &x, const Numeric xmin, const Numeric xmax)
Masks values that are out of bounds in x.
Vector nanfocus(const Vector &x, const ArrayOfIndex &scaling)
Returns the re-averaged values of x according to scaling ignoring all non-normal values.
ArrayOfIndex focus_doublescaling(const Vector &x, const Numeric x0, const Numeric dx)
Returns the relative position scale for each value in x.
Stuff related to generating y-data from raw data.