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
2 changes: 1 addition & 1 deletion python/pyarts/plots/arts_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def calc_opacity_from_lookup(lookup,
p = (pgrid[1:] + pgrid[:-1]) / 2.
z = interp1d(p, z, fill_value='extrapolate')(lookup.p_grid.value)

return np.vstack([np.trapz(ialpha, z, axis=1) for ialpha in alpha])
return np.vstack([np.trapezoid(ialpha, z, axis=1) for ialpha in alpha])


def plot_arts_lookup(lookup,
Expand Down
42 changes: 34 additions & 8 deletions src/artstime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#include <ctime>

Time::Time(const String& t) {
ARTS_USER_ERROR_IF(
t.size() < 19,
"Invalid time format: \"",
t,
"\"\nExpected format: YYYY-MM-DD HH:MM:SS[.fractional_seconds]");

auto s = std::istringstream(t);
s >> *this;
}
Expand Down Expand Up @@ -104,17 +110,37 @@ std::ostream& operator<<(std::ostream& os, const Time& t)
std::istream& operator>>(std::istream& is, Time& t)
{
String ymd, hms;
is >> ymd >> hms;

is >> ymd;

ARTS_USER_ERROR_IF(
ymd.size() != 10,
"Time stream must look like \"YYYY-MM-DD HH:MM:SS[.fractional_seconds]\"\n"
"\"YYYY-MM-DD\" looks like: \"",
ymd,
'\"');

is >> hms;

ARTS_USER_ERROR_IF(
hms.size() < 8 or (hms.size() > 8 and hms[8] != '.'),
"Time stream must look like \"YYYY-MM-DD HH:MM:SS[.fractional_seconds]\"\n"
"\"HH:MM:SS[.fractional_seconds]\" looks like: \"",
hms,
'\"');

ArrayOfString YMD, HMS;
ymd.split(YMD, "-");
hms.split(HMS, ":");

ARTS_USER_ERROR_IF (YMD.nelem() not_eq HMS.nelem() and YMD.nelem() not_eq 3,
"Time stream must look like \"year-month-day hour:min:seconds\"\n"
"\"year-month-day\" looks like: ", ymd, '\n',
"\"hour:min:seconds\" looks like: ", hms);


ARTS_USER_ERROR_IF(
YMD.nelem() not_eq HMS.nelem() and YMD.nelem() not_eq 3,
"Time stream must look like \"YYYY-MM-DD HH:MM:SS[.fractional_seconds]\"\n"
"\"YYYY-MM-DD\" looks like: ",
ymd,
'\n',
"\"HH:MM:SS[.fractional_seconds]\" looks like: ",
hms);

// FIXME: C++20 has much better calendar handling
std::tm x;
x.tm_year = std::stoi(YMD[0]) - 1900;
Expand Down
Loading