FireSTARR
Loading...
Searching...
No Matches
FireWeather.h
1/* Copyright (c) Queen's Printer for Ontario, 2020. */
2/* Copyright (c) His Majesty the King in Right of Canada as represented by the Minister of Natural Resources, 2021-2025. */
3
4/* SPDX-License-Identifier: AGPL-3.0-or-later */
5
6#pragma once
7#include <map>
8#include <set>
9#include <vector>
10#include "FuelLookup.h"
11#include "FWI.h"
12#ifdef DEBUG_FWI_WEATHER
13#include "Log.h"
14#endif
15namespace fs
16{
17namespace fuel
18{
19class FuelType;
20}
21namespace wx
22{
23// use an array instead of a map since number of values is so small and access should be faster
24using SurvivalMap = array<vector<float>, NUMBER_OF_FUELS>;
29{
30public:
34 virtual ~FireWeather();
39 FireWeather(FireWeather&& rhs) = default;
40 FireWeather(const FireWeather& rhs) = delete;
46 FireWeather& operator=(FireWeather&& rhs) noexcept = default;
47 FireWeather& operator=(const FireWeather& rhs) = delete;
53 [[nodiscard]] const FwiWeather* at(const DurationSize time) const
54 {
55#ifdef DEBUG_FWI_WEATHER
56 logging::check_fatal(time < 0 || time >= MAX_DAYS, "Invalid weather time %f", time);
57#endif
58 return weather_by_hour_by_day_->at(util::time_index(time, min_date_));
59 }
66 [[nodiscard]] ThresholdSize survivalProbability(const DurationSize time,
67 const FuelCodeSize& in_fuel) const
68 {
69 return survival_probability_->at(in_fuel).at(util::time_index(time, min_date_));
70 }
75 [[nodiscard]] constexpr Day minDate() const
76 {
77 return min_date_;
78 }
83 [[nodiscard]] constexpr Day maxDate() const
84 {
85 return max_date_;
86 }
91 [[nodiscard]] constexpr size_t weightedDsr() const noexcept
92 {
93 return weighted_dsr_;
94 }
99 [[nodiscard]] const vector<const FwiWeather*>* getWeather()
100 {
102 }
103
111 FireWeather(const set<const fuel::FuelType*>& used_fuels,
112 Day min_date,
113 Day max_date,
114 vector<const FwiWeather*>* weather_by_hour_by_day);
115private:
119 const vector<const FwiWeather*>* weather_by_hour_by_day_;
123 const SurvivalMap* survival_probability_;
136};
143[[nodiscard]] constexpr bool operator==(const FireWeather& lhs, const FireWeather& rhs)
144{
145 if (!(lhs.maxDate() == rhs.maxDate() && lhs.minDate() == rhs.minDate()))
146 {
147 return false;
148 }
149 // FIX: why is this a warning?
150 for (Day day = lhs.minDate() + static_cast<Day>(1); day <= lhs.maxDate(); ++day)
151 {
152 for (auto hour = 0; hour < DAY_HOURS; ++hour)
153 {
154 const auto time = static_cast<DurationSize>(day) + hour / 24.0;
155 if (lhs.at(time) != rhs.at(time))
156 {
157 return false;
158 }
159 }
160 }
161 return true;
162}
169[[nodiscard]] constexpr bool operator!=(const FireWeather& lhs, const FireWeather& rhs)
170{
171 return !(lhs == rhs);
172}
173}
174}
A stream of weather that gets used by a Scenario every Iteration.
Definition FireWeather.h:29
FireWeather & operator=(FireWeather &&rhs) noexcept=default
Move assignment.
ThresholdSize survivalProbability(const DurationSize time, const FuelCodeSize &in_fuel) const
Probability of survival in given fuel at given time.
Definition FireWeather.h:66
constexpr size_t weightedDsr() const noexcept
Weighted Danger Severity Rating for the stream.
Definition FireWeather.h:91
const vector< const FwiWeather * > * getWeather()
Weather by hour by day.
Definition FireWeather.h:99
constexpr Day maxDate() const
Maximum date present in FireWeather.
Definition FireWeather.h:83
FireWeather(FireWeather &&rhs)=default
Move constructor.
virtual ~FireWeather()
Destructor.
Definition FireWeather.cpp:17
const SurvivalMap * survival_probability_
Probability of survival for fuels fuel at each time.
Definition FireWeather.h:123
Day min_date_
Minimum date present in stream.
Definition FireWeather.h:127
constexpr Day minDate() const
Minimum date present in FireWeather.
Definition FireWeather.h:75
const vector< const FwiWeather * > * weather_by_hour_by_day_
FwiWeather by hour by Day.
Definition FireWeather.h:119
Day max_date_
Maximum date present in stream.
Definition FireWeather.h:131
const FwiWeather * at(const DurationSize time) const
Get FwiWeather for given time.
Definition FireWeather.h:53
size_t weighted_dsr_
Weighted Danger Severity Rating for the stream.
Definition FireWeather.h:135
A Weather value with calculated FWI indices.
Definition FWI.h:209