Weather Generator 1.1.0
Daily weather for any place and date from climate normals for C++23
Loading...
Searching...
No Matches
dasmig::weather Class Reference

One day's weather at one place. More...

#include <weathergen.hpp>

Public Member Functions

std::uint64_t seed () const
 Retrieve the random seed used to generate this weather.
 
const core::seed_signature & signature () const
 The seed and the data this weather was generated from.
 
std::string date_string () const
 ISO 8601 date string (YYYY-MM-DD).
 
std::string to_string () const
 Human-readable summary string.
 
void to_json (core::json_writer &w) const
 Write this weather as a JSON object.
 
std::string to_json () const
 This weather as a JSON document.
 
 operator std::string () const
 Implicit conversion to std::string.
 

Static Public Member Functions

static std::string time_string (std::chrono::sys_time< std::chrono::minutes > t)
 An instant as ISO 8601 UTC to the minute (2024-01-15T07:42Z).
 

Public Attributes

std::chrono::year_month_day date {}
 The day.
 
std::string cell
 Key of the climate cell drawn from.
 
double latitude {}
 Degrees north: the requested point, or the drawn cell's.
 
double longitude {}
 Degrees east: the requested point, or the drawn cell's.
 
double elevation {}
 Metres: the requested elevation, or the cell's.
 
double distance_km {}
 Distance from the point to land, km (0 on land; at most 100).
 
double tmin {}
 Lowest temperature, °C (°F).
 
double tmean {}
 Mean temperature, °C (°F): halfway between tmin and tmax.
 
double tmax {}
 Highest temperature, °C (°F).
 
bool frost {}
 tmin below 0 °C (32 °F).
 
double precipitation {}
 Precipitation, mm (in) of water (0 on a dry day).
 
double snowfall {}
 Fresh snow, cm (in): 10 cm per 10 mm of water.
 
precipitation_type type {precipitation_type::none}
 The form it falls in.
 
bool thunder {}
 Thunder heard (on rain or sleet days only).
 
double cloud_cover {}
 Mean cloud cover, 0 to 1.
 
double humidity {}
 Mean relative humidity, %.
 
double wind {}
 Mean wind speed at 10 m, m/s (mph).
 
double daylight_hours {}
 Time from sunrise to sunset, hours (0 in polar night, 24 in polar day).
 
double sunshine_hours {}
 
std::optional< std::chrono::sys_time< std::chrono::minutes > > sunrise {}
 Sunrise, UTC (unset in polar day and polar night). It can fall on the date before in UTC, far east of Greenwich.
 
std::optional< std::chrono::sys_time< std::chrono::minutes > > sunset {}
 Sunset, UTC (unset in polar day and polar night).
 
weather_condition condition {weather_condition::clear}
 The day in a word.
 
unit_system units {unit_system::metric}
 
std::vector< weather_hour > hours
 The day's 24 hours, when the request set hourly (empty otherwise).
 

Friends

class wtg
 
std::ostream & operator<< (std::ostream &os, const weather &v)
 Stream the summary to an output stream.
 

Detailed Description

One day's weather at one place.

Values are rounded for output: temperatures, precipitation, snowfall and wind to 0.1 (inches of precipitation to 0.01), cloud cover to 0.01, humidity to whole percent. The units are metric unless the request asked for imperial ones. Supports implicit conversion to std::string (a one-line summary), streaming via operator<< and JSON output via to_json().

Definition at line 323 of file weathergen.hpp.

Member Function Documentation

◆ date_string()

std::string dasmig::weather::date_string ( ) const
inline

ISO 8601 date string (YYYY-MM-DD).

Returns
The date.

Definition at line 368 of file weathergen.hpp.

◆ operator std::string()

dasmig::weather::operator std::string ( ) const
inline

Implicit conversion to std::string.

Returns
Summary string.

Definition at line 461 of file weathergen.hpp.

◆ seed()

std::uint64_t dasmig::weather::seed ( ) const
inline

Retrieve the random seed used to generate this weather.

Returns
The call seed; pass it to get_weather(request, seed) with the same request and data to replay this day.

Definition at line 359 of file weathergen.hpp.

◆ signature()

const core::seed_signature & dasmig::weather::signature ( ) const
inline

The seed and the data this weather was generated from.

Returns
The replay signature; data is wtg::data_hash() at the time of generation.

Definition at line 364 of file weathergen.hpp.

◆ time_string()

static std::string dasmig::weather::time_string ( std::chrono::sys_time< std::chrono::minutes >  t)
inlinestatic

An instant as ISO 8601 UTC to the minute (2024-01-15T07:42Z).

Parameters
tThe instant.
Returns
The string.

Definition at line 377 of file weathergen.hpp.

◆ to_json() [1/2]

std::string dasmig::weather::to_json ( ) const
inline

This weather as a JSON document.

Returns
Compact JSON, for example {"date":"2023-07-01","place":{...}, "condition":"light_rain","tmin":14.2,...,"signature":{...}}.

Definition at line 452 of file weathergen.hpp.

◆ to_json() [2/2]

void dasmig::weather::to_json ( core::json_writer &  w) const
inline

Write this weather as a JSON object.

Parameters
wWriter positioned where a value is allowed.

Definition at line 403 of file weathergen.hpp.

◆ to_string()

std::string dasmig::weather::to_string ( ) const
inline

Human-readable summary string.

Returns
For example 2023-07-01: light rain, 14.2 to 21.9 °C, 1.3 mm (57.6 to 71.4 °F, 0.05 in in imperial units).

Definition at line 385 of file weathergen.hpp.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const weather &  v 
)
friend

Stream the summary to an output stream.

Parameters
osOutput stream.
vThe weather to stream.
Returns
The stream.

Definition at line 470 of file weathergen.hpp.

◆ wtg

friend class wtg
friend

Definition at line 478 of file weathergen.hpp.

Member Data Documentation

◆ cell

std::string dasmig::weather::cell

Key of the climate cell drawn from.

Definition at line 327 of file weathergen.hpp.

◆ cloud_cover

double dasmig::weather::cloud_cover {}

Mean cloud cover, 0 to 1.

Definition at line 340 of file weathergen.hpp.

◆ condition

weather_condition dasmig::weather::condition {weather_condition::clear}

The day in a word.

Definition at line 350 of file weathergen.hpp.

◆ date

std::chrono::year_month_day dasmig::weather::date {}

The day.

Definition at line 326 of file weathergen.hpp.

◆ daylight_hours

double dasmig::weather::daylight_hours {}

Time from sunrise to sunset, hours (0 in polar night, 24 in polar day).

Definition at line 343 of file weathergen.hpp.

◆ distance_km

double dasmig::weather::distance_km {}

Distance from the point to land, km (0 on land; at most 100).

Definition at line 331 of file weathergen.hpp.

◆ elevation

double dasmig::weather::elevation {}

Metres: the requested elevation, or the cell's.

Definition at line 330 of file weathergen.hpp.

◆ frost

bool dasmig::weather::frost {}

tmin below 0 °C (32 °F).

Definition at line 335 of file weathergen.hpp.

◆ hours

std::vector<weather_hour> dasmig::weather::hours

The day's 24 hours, when the request set hourly (empty otherwise).

Definition at line 354 of file weathergen.hpp.

◆ humidity

double dasmig::weather::humidity {}

Mean relative humidity, %.

Definition at line 341 of file weathergen.hpp.

◆ latitude

double dasmig::weather::latitude {}

Degrees north: the requested point, or the drawn cell's.

Definition at line 328 of file weathergen.hpp.

◆ longitude

double dasmig::weather::longitude {}

Degrees east: the requested point, or the drawn cell's.

Definition at line 329 of file weathergen.hpp.

◆ precipitation

double dasmig::weather::precipitation {}

Precipitation, mm (in) of water (0 on a dry day).

Definition at line 336 of file weathergen.hpp.

◆ snowfall

double dasmig::weather::snowfall {}

Fresh snow, cm (in): 10 cm per 10 mm of water.

Definition at line 337 of file weathergen.hpp.

◆ sunrise

std::optional<std::chrono::sys_time<std::chrono::minutes> > dasmig::weather::sunrise {}

Sunrise, UTC (unset in polar day and polar night). It can fall on the date before in UTC, far east of Greenwich.

Definition at line 347 of file weathergen.hpp.

◆ sunset

std::optional<std::chrono::sys_time<std::chrono::minutes> > dasmig::weather::sunset {}

Sunset, UTC (unset in polar day and polar night).

Definition at line 349 of file weathergen.hpp.

◆ sunshine_hours

double dasmig::weather::sunshine_hours {}

Bright sunshine, hours: the daylight not covered by cloud.

Definition at line 344 of file weathergen.hpp.

◆ thunder

bool dasmig::weather::thunder {}

Thunder heard (on rain or sleet days only).

Definition at line 339 of file weathergen.hpp.

◆ tmax

double dasmig::weather::tmax {}

Highest temperature, °C (°F).

Definition at line 334 of file weathergen.hpp.

◆ tmean

double dasmig::weather::tmean {}

Mean temperature, °C (°F): halfway between tmin and tmax.

Definition at line 333 of file weathergen.hpp.

◆ tmin

double dasmig::weather::tmin {}

Lowest temperature, °C (°F).

Definition at line 332 of file weathergen.hpp.

◆ type

The form it falls in.

Definition at line 338 of file weathergen.hpp.

◆ units

unit_system dasmig::weather::units {unit_system::metric}

The units of the values above.

Definition at line 351 of file weathergen.hpp.

◆ wind

double dasmig::weather::wind {}

Mean wind speed at 10 m, m/s (mph).

Definition at line 342 of file weathergen.hpp.


The documentation for this class was generated from the following file: