Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/callback.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "callback.h"

#include <workspace.h>
#include "workspace_class.h"

void CallbackOperator::operator()(Workspace& ws_in) const try {
Expand Down
10 changes: 6 additions & 4 deletions src/core/absorption/cia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ void cia_interpolation(VectorView result,
default: T_order = 3; break;
}

using id = lagrange_interp::identity;

// Find frequency grid positions:
const auto f_lag = lagrange_interp::make_lags<f_order>(
const auto f_lag = lagrange_interp::make_lags<f_order, id>(
data_f_grid, f_grid_active, 0.5, "Frequency");

// Do the rest of the interpolation.
Expand All @@ -158,15 +160,15 @@ void cia_interpolation(VectorView result,
// Temperature and frequency interpolation.
const auto Tnew = matpack::cdata_t<Numeric, 1>{temperature};
if (T_order == 1) {
const auto T_lag = lagrange_interp::make_lags<1>(
const auto T_lag = lagrange_interp::make_lags<1, id>(
data_T_grid, Tnew, T_extrapolfac, "Temperature");
result_active = reinterp(cia_data.data, f_lag, T_lag).flatten();
} else if (T_order == 2) {
const auto T_lag = lagrange_interp::make_lags<2>(
const auto T_lag = lagrange_interp::make_lags<2, id>(
data_T_grid, Tnew, T_extrapolfac, "Temperature");
result_active = reinterp(cia_data.data, f_lag, T_lag).flatten();
} else if (T_order == 3) {
const auto T_lag = lagrange_interp::make_lags<3>(
const auto T_lag = lagrange_interp::make_lags<3, id>(
data_T_grid, Tnew, T_extrapolfac, "Temperature");
result_active = reinterp(cia_data.data, f_lag, T_lag).flatten();
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/core/absorption/predefined_absorption_models.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ void compute(
jac_targets.find(liquidcloud)};
const auto e = jac_targets.atm.end();
const bool do_freq_jac =
std::ranges::any_of(freq_jac, [e](auto& x) { return x != e; });
stdr::any_of(freq_jac, [e](auto& x) { return x != e; });

const bool do_temp_jac = temp_jac != e;

const bool do_vmrs_jac =
std::ranges::any_of(vmrs_jac, [e](auto& x) { return x != e; });
stdr::any_of(vmrs_jac, [e](auto& x) { return x != e; });

if (do_freq_jac or do_temp_jac or do_vmrs_jac) {
PropmatVector pm(f_grid.size());
Expand Down
6 changes: 4 additions & 2 deletions src/core/absorption/xsec_fit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ void XsecRecord::Extract(VectorView result,
RemoveNegativeXsec(fit_result);

{
const auto f_gp = lagrange_interp::make_lags<1>(
f_grid_active, data_f_grid_active, 0.5, "Frequency");
const auto f_gp =
lagrange_interp::make_lags<1, lagrange_interp::identity>(
f_grid_active, data_f_grid_active, 0.5, "Frequency");
const auto f_itw = reinterpweights(f_gp);

// Find frequency grid positions:
reinterp(xsec_interp, fit_result_active, f_itw, f_gp);
}
Expand Down
23 changes: 10 additions & 13 deletions src/core/atm/atm_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,21 +571,21 @@ void Point::check_and_fix() try {
ARTS_USER_ERROR_IF(nonstd::isnan(pressure), "Pressure is NaN")
ARTS_USER_ERROR_IF(nonstd::isnan(temperature), "Temperature is NaN")

if (std::ranges::all_of(wind, [](auto v) { return nonstd::isnan(v); })) {
if (stdr::all_of(wind, [](auto v) { return nonstd::isnan(v); })) {
wind = {0., 0., 0.};
} else {
ARTS_USER_ERROR_IF(
std::ranges::any_of(wind, [](auto v) { return nonstd::isnan(v); }),
stdr::any_of(wind, [](auto v) { return nonstd::isnan(v); }),
"Cannot have partially missing wind field. Consider setting the missing field to zero or add it completely.\n"
"Wind field [wind_u, wind_v, wind_w] is: {:B,}",
wind)
}

if (std::ranges::all_of(mag, [](auto v) { return nonstd::isnan(v); })) {
if (stdr::all_of(mag, [](auto v) { return nonstd::isnan(v); })) {
mag = {0., 0., 0.};
} else {
ARTS_USER_ERROR_IF(
std::ranges::any_of(mag, [](auto v) { return nonstd::isnan(v); }),
stdr::any_of(mag, [](auto v) { return nonstd::isnan(v); }),
"Cannot have partially missing magnetic field. Consider setting the missing field to zero or add it completely.\n"
"Magnetic field [mag_u, mag_v, mag_w] is: {:B,}",
mag)
Expand Down Expand Up @@ -1033,8 +1033,7 @@ void Atm::extend_in_pressure(
ArrayOfAtmPoint::const_iterator pos;

if (pressure_increasing) {
auto up =
std::ranges::lower_bound(atm, new_pressure, {}, &AtmPoint::pressure);
auto up = stdr::lower_bound(atm, new_pressure, {}, &AtmPoint::pressure);
auto lo = up - 1;

if (lo <= atm.begin()) {
Expand All @@ -1056,11 +1055,10 @@ void Atm::extend_in_pressure(
pos = up;
}
} else {
auto lo =
(std::ranges::lower_bound(
atm | std::views::reverse, new_pressure, {}, &AtmPoint::pressure) +
1)
.base();
auto lo = (stdr::lower_bound(
atm | stdv::reverse, new_pressure, {}, &AtmPoint::pressure) +
1)
.base();
auto up = lo - 1;

if (lo >= atm.end()) {
Expand All @@ -1083,8 +1081,7 @@ void Atm::extend_in_pressure(
}
}

if (std::ranges::any_of(prof, Cmp::eq(new_pressure), &AtmPoint::pressure))
return;
if (stdr::any_of(prof, Cmp::eq(new_pressure), &AtmPoint::pressure)) return;

const AscendingGrid altitudes =
logarithmic ? AscendingGrid{std::log(bounds[0]), std::log(bounds[1])}
Expand Down
5 changes: 2 additions & 3 deletions src/core/atm/atm_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <properties.h>
#include <quantum.h>
#include <species.h>

#include <stdexcept>

AtmKey to_wind(const String &);
Expand Down Expand Up @@ -238,9 +239,7 @@ struct Data {

[[nodiscard]] bool ok() const;

void regrid(const AscendingGrid &alt,
const LatGrid &lat,
const LonGrid &lon);
void regrid(const AscendingGrid &alt, const LatGrid &lat, const LonGrid &lon);
};

template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion src/core/atm/xml_atm.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "xml_atm.h"

#include "enumsIsoRatioOption.h"
#include <enumsIsoRatioOption.h>

void xml_io_stream<AtmPoint>::read(std::istream& is,
AtmPoint& v,
Expand Down
3 changes: 1 addition & 2 deletions src/core/coretypes/double_imanip.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#include "double_imanip.h"

#include <debug.h>
#include <fast_float/fast_float.h>

#include <istream>
#include <system_error>

#include <debug.h>

const double_imanip& double_imanip::operator>>(double& x) const {
std::istream& is = *in;
std::string buf;
Expand Down
2 changes: 1 addition & 1 deletion src/core/coretypes/double_imanip.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class double_imanip {
public:
const double_imanip& operator>>(double& x) const;

std::istream& operator>>(const double_imanip&) const ;
std::istream& operator>>(const double_imanip&) const;

friend const double_imanip& operator>>(std::istream& in,
const double_imanip& dm);
Expand Down
3 changes: 2 additions & 1 deletion src/core/coretypes/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ bool find_file(ArrayOfString& matches,
else {
for (const auto& path : paths) {
for (const auto& ext : extensions) {
const String fullpath{std::format("{}/{}{}", expand_path(path), efilename, ext)};
const String fullpath{
std::format("{}/{}{}", expand_path(path), efilename, ext)};

if (file_exists(fullpath)) {
if (std::find(matches.begin(), matches.end(), fullpath) ==
Expand Down
4 changes: 2 additions & 2 deletions src/core/coretypes/parameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Parameters parameters{};

\author Oliver Lemke
*/
void parse_path_from_environment(const String& envvar, ArrayOfString &paths) {
void parse_path_from_environment(const String &envvar, ArrayOfString &paths) {
char *envval = getenv(envvar.c_str());
if (envval) {
String pathstring(envval);
Expand All @@ -44,7 +44,7 @@ void parse_path_from_environment(const String& envvar, ArrayOfString &paths) {
while (String::npos != pos || String::npos != lastPos) {
paths.push_back(pathstring.substr(lastPos, pos - lastPos));
lastPos = pathstring.find_first_not_of(delim, pos);
pos = pathstring.find_first_of(delim, lastPos);
pos = pathstring.find_first_of(delim, lastPos);
}
}
}
4 changes: 2 additions & 2 deletions src/core/coretypes/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef parameters_h
#define parameters_h

#include "mystring.h"
#include <mystring.h>

struct Parameters {
/** List of paths to search for include files. */
Expand All @@ -20,6 +20,6 @@ struct Parameters {
ArrayOfString datapath{};
};

void parse_path_from_environment(const String& envvar, ArrayOfString &paths);
void parse_path_from_environment(const String& envvar, ArrayOfString& paths);

#endif // parameters_h
2 changes: 0 additions & 2 deletions src/core/disort-cpp/disort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include <ranges>
#include <vector>

#include "matpack_einsum.h"

namespace disort {
void radiances::resize(AscendingGrid f_grid,
DescendingGrid alt_grid_,
Expand Down
64 changes: 36 additions & 28 deletions src/core/disort-cpp/test-old-impl.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include <arts_constants.h>
#include <disort.h>

#include <iostream>
#include <ranges>

#include <arts_constants.h>

#include "artstime.h"
#include "cdisort/cdisort.h"
#include "configtypes.h"
Expand Down Expand Up @@ -174,26 +173,25 @@ void newimpl(bool print_results = false) {
const auto [a0, b0] = dis.flux_down(fd, 0);
const auto c0 = dis.flux_up(fd, 0);
std::cout << a0 << ',' << b0 << ',' << c0 << ',' << '\n';
for (auto t : tau | std::ranges::views::take(NLayers - 1)) {
for (auto t : tau | stdv::take(NLayers - 1)) {
const auto [a, b] = dis.flux_down(fd, t);
const auto c = dis.flux_up(fd, t);
std::cout << a << ',' << b << ',' << c << ',' << '\n';
}
}
}

std::pair<Numeric, Numeric> absrel(VectorView v1,
const ConstVectorView& v2) {
std::pair<Numeric, Numeric> absrel(VectorView v1, const ConstVectorView& v2) {
for (double i : v1) {
if (i == 0) std::cerr << "ERROR\n";
}

v1 -= v2;
const Numeric a_ = std::abs(std::ranges::max(
v1, [](auto a, auto b) { return std::abs(a) < std::abs(b); }));
const Numeric a_ = std::abs(
stdr::max(v1, [](auto a, auto b) { return std::abs(a) < std::abs(b); }));
v1 /= v2;
const Numeric b_ = std::abs(std::ranges::max(
v1, [](auto a, auto b) { return std::abs(a) < std::abs(b); }));
const Numeric b_ = std::abs(
stdr::max(v1, [](auto a, auto b) { return std::abs(a) < std::abs(b); }));
return {a_, b_};
}

Expand All @@ -214,14 +212,15 @@ void test_flat() try {
for (auto& o : omega_arr) o = draw();
Matrix Leg_coeffs_all(tau_arr.size(), 32);
for (auto&& v : Leg_coeffs_all)
v = std::array{1.00000000e+00, 7.50000000e-01, 5.62500000e-01, 4.21875000e-01,
3.16406250e-01, 2.37304688e-01, 1.77978516e-01, 1.33483887e-01,
1.00112915e-01, 7.50846863e-02, 5.63135147e-02, 4.22351360e-02,
3.16763520e-02, 2.37572640e-02, 1.78179480e-02, 1.33634610e-02,
1.00225958e-02, 7.51694682e-03, 5.63771011e-03, 4.22828259e-03,
3.17121194e-03, 2.37840895e-03, 1.78380672e-03, 1.33785504e-03,
1.00339128e-03, 7.52543458e-04, 5.64407594e-04, 4.23305695e-04,
3.17479271e-04, 2.38109454e-04, 1.78582090e-04, 1.33936568e-04};
v = std::array{
1.00000000e+00, 7.50000000e-01, 5.62500000e-01, 4.21875000e-01,
3.16406250e-01, 2.37304688e-01, 1.77978516e-01, 1.33483887e-01,
1.00112915e-01, 7.50846863e-02, 5.63135147e-02, 4.22351360e-02,
3.16763520e-02, 2.37572640e-02, 1.78179480e-02, 1.33634610e-02,
1.00225958e-02, 7.51694682e-03, 5.63771011e-03, 4.22828259e-03,
3.17121194e-03, 2.37840895e-03, 1.78380672e-03, 1.33785504e-03,
1.00339128e-03, 7.52543458e-04, 5.64407594e-04, 4.23305695e-04,
3.17479271e-04, 2.38109454e-04, 1.78582090e-04, 1.33936568e-04};

//const Numeric mu0 = 0.6;
//const Numeric I0 = Constant::pi / mu0;
Expand All @@ -233,7 +232,8 @@ void test_flat() try {
const std::vector<disort::BDRF> BDRF_Fourier_modes{
disort::BDRF{[](auto c, auto&, auto&) { c = 1; }}};
Matrix s_poly_coeffs(tau_arr.size(), 2);
for (auto&& v : s_poly_coeffs) v = std::array{172311.79936609, -102511.4417051};
for (auto&& v : s_poly_coeffs)
v = std::array{172311.79936609, -102511.4417051};
const Vector f_arr{Leg_coeffs_all[joker, NQuad_]};

// Optional (unused)
Expand Down Expand Up @@ -281,11 +281,13 @@ void test_flat() try {
dis.ungridded_u(u3, tau_arr, phi);
}

const auto [u2_abs, u2_rel] = absrel(u2.view_as(u2.size()), u1.view_as(u1.size()));
const auto [u2_abs, u2_rel] =
absrel(u2.view_as(u2.size()), u1.view_as(u1.size()));
std::cout << "u abs-max gridded: " << u2_abs << '\n';
std::cout << "u abs-rel gridded: " << u2_rel << '\n';

const auto [u3_abs, u3_rel] = absrel(u3.view_as(u3.size()), u1.view_as(u1.size()));
const auto [u3_abs, u3_rel] =
absrel(u3.view_as(u3.size()), u1.view_as(u1.size()));
std::cout << "u abs-max ungridded: " << u3_abs << '\n';
std::cout << "u abs-rel ungridded: " << u3_rel << '\n';

Expand Down Expand Up @@ -313,19 +315,25 @@ void test_flat() try {
dis.ungridded_flux(fu3, fd3, fb3, tau_arr);
}

const auto [fu2_abs, fu2_rel] = absrel(fu2.view_as(u2.size()), fu1.view_as(u1.size()));
const auto [fd2_abs, fd2_rel] = absrel(fd2.view_as(fd2.size()), fd1.view_as(fd1.size()));
const auto [fb2_abs, fb2_rel] = absrel(fb2.view_as(fb2.size()), fb1.view_as(fb1.size()));
const auto [fu2_abs, fu2_rel] =
absrel(fu2.view_as(u2.size()), fu1.view_as(u1.size()));
const auto [fd2_abs, fd2_rel] =
absrel(fd2.view_as(fd2.size()), fd1.view_as(fd1.size()));
const auto [fb2_abs, fb2_rel] =
absrel(fb2.view_as(fb2.size()), fb1.view_as(fb1.size()));
std::cout << "fu abs-max gridded: " << fu2_abs << '\n';
std::cout << "fu abs-rel gridded: " << fu2_rel << '\n';
std::cout << "fd abs-max gridded: " << fd2_abs << '\n';
std::cout << "fd abs-rel gridded: " << fd2_rel << '\n';
std::cout << "fb abs-max gridded: " << fb2_abs << '\n';
std::cout << "fb abs-rel gridded: " << fb2_rel << '\n';

const auto [fu3_abs, fu3_rel] = absrel(fu3.view_as(fu3.size()), fu1.view_as(u1.size()));
const auto [fd3_abs, fd3_rel] = absrel(fd3.view_as(fd3.size()), fd1.view_as(fd1.size()));
const auto [fb3_abs, fb3_rel] = absrel(fb3.view_as(fb3.size()), fb1.view_as(fb1.size()));
const auto [fu3_abs, fu3_rel] =
absrel(fu3.view_as(fu3.size()), fu1.view_as(u1.size()));
const auto [fd3_abs, fd3_rel] =
absrel(fd3.view_as(fd3.size()), fd1.view_as(fd1.size()));
const auto [fb3_abs, fb3_rel] =
absrel(fb3.view_as(fb3.size()), fb1.view_as(fb1.size()));
std::cout << "fu abs-max ungridded: " << fu3_abs << '\n';
std::cout << "fu abs-rel ungridded: " << fu3_rel << '\n';
std::cout << "fd abs-max ungridded: " << fd3_abs << '\n';
Expand Down Expand Up @@ -370,7 +378,7 @@ int main(int argc, char** argv) {
ts1.emplace_back("old")([]() { oldimpl(); });
}
std::cout << "old best: "
<< std::ranges::min(
<< stdr::min(
ts1,
[](auto a, auto b) { return a.count() < b.count(); },
&Timing::dt)
Expand All @@ -381,7 +389,7 @@ int main(int argc, char** argv) {
ts2.emplace_back("new")([]() { newimpl(); });
}
std::cout << "new best: "
<< std::ranges::min(
<< stdr::min(
ts2,
[](auto a, auto b) { return a.count() < b.count(); },
&Timing::dt)
Expand Down
Loading
Loading