ARTS 2.5.4 (git: 31ce4f0e)
m_partfun.cc
Go to the documentation of this file.
1#include <filesystem>
2
3#include "math_funcs.h"
4#include "matpack.h"
5#include "messages.h"
6#include "mystring.h"
7#include "partfun.h"
8
9#include "xml_io.h"
10
12 const String& fileformat,
13 const String& dir,
14 const Numeric& Tlow,
15 const Numeric& Tupp,
16 const Index& N,
17 const Verbosity& verbosity) {
19 ARTS_USER_ERROR_IF(Tupp <= Tlow, "Need a range [low, high], has [", Tlow, ", ", Tupp, "]")
20 ARTS_USER_ERROR_IF(N < 2, "Need a positive step counter 2 or larger, has: ", N)
21
22 const auto d = std::filesystem::path(dir.c_str());
23 ARTS_USER_ERROR_IF(not std::filesystem::is_directory(d), "dir: ", dir, " is not a directory")
24
25 const Vector T = [&]{Vector x; nlinspace(x, Tlow, Tupp, N); return x;}();
26 const FileType ftype = string2filetype(fileformat);
27
28 for (auto& ir: Species::Isotopologues) {
30
31 PartitionFunctionsData data{PartitionFunctions::Type::Interp, Matrix(N, 2)};
32 for (Index i=0; i<N; i++) {
33 data.data(i, 0) = T[i];
34 data.data(i, 1) = PartitionFunctions::Q(T[i], ir);
35 }
36
37 xml_write_to_file(String((d / (ir.FullName() + ".xml").c_str()).native()),
38 data, ftype, 0, verbosity);
39 }
40 }
41}
The Vector class.
Definition: matpackI.h:899
#define ARTS_USER_ERROR_IF(condition,...)
Definition: debug.h:134
void WriteBuiltinPartitionFunctionsXML(const String &fileformat, const String &dir, const Numeric &Tlow, const Numeric &Tupp, const Index &N, const Verbosity &verbosity)
WORKSPACE METHOD: WriteBuiltinPartitionFunctionsXML.
Definition: m_partfun.cc:11
void nlinspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlinspace
Definition: math_funcs.cc:227
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Declarations having to do with the four output streams.
#define CREATE_OUT2
Definition: messages.h:205
This file contains the definition of String, the ARTS string class.
my_basic_string< char > String
The String type for ARTS.
Definition: mystring.h:216
constexpr bool has_partfun(const Species::IsotopeRecord &ir) noexcept
Definition: partfun.h:149
Numeric Q(Numeric T, const Species::IsotopeRecord &ir)
Definition: partfun.cc:14
constexpr std::array Isotopologues
A list of all ARTS isotopologues, note how the species enum class input HAS to be sorted.
Definition: isotopologues.h:57
invlib::Matrix< ArtsMatrix > Matrix
invlib wrapper type for ARTS matrices.
Definition: oem.h:33
#define N
Definition: rng.cc:164
#define d
This file contains basic functions to handle XML data files.
void xml_write_to_file(const String &filename, const T &type, const FileType ftype, const Index no_clobber, const Verbosity &verbosity)
Write data to XML file.
Definition: xml_io.h:172
FileType string2filetype(const String &file_format)
Definition: xml_io_base.cc:335
FileType
Definition: xml_io_base.h:42