FireSTARR
Loading...
Searching...
No Matches
FireWeather.h
1/* SPDX-License-Identifier: AGPL-3.0-or-later */
2#ifndef FS_FIREWEATHER_H
3#define FS_FIREWEATHER_H
4#include "stdafx.h"
5#include "FWI.h"
6namespace fs
7{
8class FuelType;
9// use an array instead of a map since number of values is so small and access should be faster
10using SurvivalMap = array<vector<float>, NUMBER_OF_FUELS>;
15{
16public:
17 virtual ~FireWeather() = default;
23 FireWeather(const set<const FuelType*>& used_fuels, const map<Day, FwiWeather>& data);
25 const set<const FuelType*>& used_fuels,
26 Day min_date,
27 Day max_date,
28 vector<FwiWeather> weather_by_hour_by_day
29 );
41 const FuelType* fuel,
42 const Day start_date,
43 const Dc& dc,
44 const Dmc& dmc,
45 const Ffmc& ffmc,
46 const Wind& wind
47 );
49 const set<const FuelType*>& used_fuels,
50 const Day start_date,
51 const Dc& dc,
52 const Dmc& dmc,
53 const Ffmc& ffmc,
54 const Wind& wind
55 );
56 FireWeather(FireWeather&& rhs) = default;
57 FireWeather(const FireWeather& rhs) = delete;
58 FireWeather& operator=(FireWeather&& rhs) noexcept = default;
59 FireWeather& operator=(const FireWeather& rhs) = delete;
65 [[nodiscard]] ptr<const FwiWeather> at(const DurationSize time) const;
72 [[nodiscard]] ThresholdSize survivalProbability(
73 const DurationSize time,
74 const FuelCodeSize& in_fuel
75 ) const;
80 [[nodiscard]] constexpr Day minDate() const { return min_date_; }
85 [[nodiscard]] constexpr Day maxDate() const { return max_date_; }
90 [[nodiscard]] const vector<ptr<const FwiWeather>>& getWeather()
91 {
93 }
94
95protected:
104 const set<const FuelType*>& used_fuels,
105 Day min_date,
106 Day max_date,
107 vector<ptr<const FwiWeather>>&& weather_by_hour_by_day
108 );
109
110private:
114 vector<ptr<const FwiWeather>> weather_by_hour_by_day_{};
127};
134[[nodiscard]] constexpr bool operator==(const FireWeather& lhs, const FireWeather& rhs)
135{
136 if (!(lhs.maxDate() == rhs.maxDate() && lhs.minDate() == rhs.minDate()))
137 {
138 return false;
139 }
140 // FIX: why is this a warning?
141 for (Day day = lhs.minDate() + static_cast<Day>(1); day <= lhs.maxDate(); ++day)
142 {
143 for (auto hour = 0; hour < DAY_HOURS; ++hour)
144 {
145 const auto time = static_cast<DurationSize>(day) + hour / 24.0;
146 if (lhs.at(time) != rhs.at(time))
147 {
148 return false;
149 }
150 }
151 }
152 return true;
153}
160[[nodiscard]] constexpr bool operator!=(const FireWeather& lhs, const FireWeather& rhs)
161{
162 return !(lhs == rhs);
163}
164}
165#endif
A stream of weather that gets used by a Scenario every Iteration.
Definition FireWeather.h:15
SurvivalMap survival_probability_
Probability of survival for fuels fuel at each time.
Definition FireWeather.h:118
ThresholdSize survivalProbability(const DurationSize time, const FuelCodeSize &in_fuel) const
Probability of survival in given fuel at given time.
Definition FireWeather.cpp:673
const vector< ptr< const FwiWeather > > & getWeather()
Weather by hour by day.
Definition FireWeather.h:90
ptr< const FwiWeather > at(const DurationSize time) const
Get FwiWeather for given time.
Definition FireWeather.cpp:666
constexpr Day minDate() const
Minimum date present in FireWeather.
Definition FireWeather.h:80
vector< ptr< const FwiWeather > > weather_by_hour_by_day_
FwiWeather by hour by Day.
Definition FireWeather.h:114
Day max_date_
Maximum date present in stream.
Definition FireWeather.h:126
Day min_date_
Minimum date present in stream.
Definition FireWeather.h:122
constexpr Day maxDate() const
Maximum date present in FireWeather.
Definition FireWeather.h:85
FireWeather(const set< const FuelType * > &used_fuels, const map< Day, FwiWeather > &data)
Constructor.
Definition FireWeather.cpp:562
An FBP fuel type.
Definition FuelType.h:42
Drought Code value.
Definition FWI.h:58
Duff Moisture Code value.
Definition FWI.h:34
Fine Fuel Moisture Code value.
Definition FWI.h:12
Wind with a Speed and Direction.
Definition Weather.h:59