-
Notifications
You must be signed in to change notification settings - Fork 2
/
LSDRasterAggregator.hpp
231 lines (190 loc) · 7.83 KB
/
LSDRasterAggregator.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// LSDRasterAggregator.hpp
// Land Surface Dynamics RasterAggregator
//
// An object within the University
// of Edinburgh Land Surface Dynamics group topographic toolbox
// that is a very general object for managing aggregated raster calculations
//
// Developed by:
// Simon M. Mudd
// Martin D. Hurst
// David T. Milodowski
// Stuart W.D. Grieve
// Declan A. Valters
// Fiona Clubb
//
// Copyright (C) 2013 Simon M. Mudd 2013
//
// Developer can be contacted by simon.m.mudd _at_ ed.ac.uk
//
// Simon Mudd
// University of Edinburgh
// School of GeoSciences
// Drummond Street
// Edinburgh, EH8 9XP
// Scotland
// United Kingdom
//
// This program is free software;
// you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation;
// either version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY;
// without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the
// GNU General Public License along with this program;
// if not, write to:
// Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301
// USA
//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include <fstream>
#include <math.h>
#include <iostream>
#include <map>
#include "LSDRaster.hpp"
#include "LSDFlowInfo.hpp"
using namespace std;
#ifndef RasterAggregator_HPP
#define RasterAggregator_HPP
/// @brief A general object for holding several different raster layers
class LSDRasterAggregator
{
public:
/// @brief the default constructor. This doesn't do anything.
LSDRasterAggregator() { create(); }
/// @brief This constructor requires a filename
/// @detail The filename and path point to files with the rasters
/// @param path The path to the files
/// @param file_prefix the prefix of the files
/// @author SMM
/// @date 10/02/2016
LSDRasterAggregator( string path, string file_prefix) { create(path,file_prefix); }
/// @brief This function load a csv file containing names of a DEMs and
/// (possibly) other rasters
/// @detail The first row of the file contains column headers and is ignored
/// Thereafter you have two columns in each row, comma seperated,
/// with the raster type as the first column and the raster filename
/// (with full path) as the second.
/// @param filename the name of the file
/// @author SMM
/// @date 10/02/2016
void load_raster_filenames(string filename);
/// @brief this function checks the existence and georeferencing of
/// the rasters outlined in the file list
/// @author SMM
/// @date 10/02/2016
void check_rasters();
/// @brief Prints the raster names and types to screen
/// @detail you must have loaded the rasters first
/// @author SMM
/// @date 28/11/2018
void print_raster_names_and_types_to_screen();
/// @brief You suply a vector of strings with raster types and this
/// return true if all of those raster types are present in the raster list
/// @param raster_types a vector of raster type strings
/// @return a bool: true if all types are in the list, false if not
/// @author SMM
/// @date 08/12/2018
bool check_raster_types(vector<string> raster_types);
/// @brief This computes the flux from each pixel in a raster
/// @param raster_types a vector of raster type strings
/// @return A raster of the fluxes
/// @author SMM
/// @date 13/12/2018
LSDRaster create_flux_raster(vector<string> raster_types);
protected:
/// the path to the cosmo data. Also used to print results
string path;
/// the prefix of the parameter files
string param_name;
/// A map for holding the different raster filenames
/// The index into the raster filenames is the raster type.
/// There are some commone raster types:
/// DEM is the DEM
/// ---more to come here---
map< string,string > raster_filenames;
/// A map holding the parameter values. These are stored as strings
/// and converted to the appropriate data type as needed
map<string,string> parameter_map;
/// The minimum slope for the fill function
float min_slope;
/// The boundary conditions for flow info calculations
vector<string> boundary_conditions;
private:
/// @brief the empty create function
void create();
/// @brief the create function used when calling a file
/// @param the path to the file. Must have the "/" at the end
/// @param file_prefix the prefix (without extension) of the parameter files
/// @author SMM
/// @date 10/02/2016
void create(string path, string file_prefix);
};
/// @brief A derived class that is used to compute erosion rates based on
/// concentrations of in-situ cosmogenic nuclides such as 10Be and 26Al
class LSDSedimentRouting: public LSDRasterAggregator
{
public:
/// @brief This constructor requires a filename
/// @detail The filename and path point to files with the rasters
/// @param path The path to the files
/// @param file_prefix the prefix of the files
/// @author SMM
/// @date 10/02/2016
LSDSedimentRouting( string path, string file_prefix) { create(path,file_prefix); }
/// @brief This checks for the parameter values specific to the sediment routing routines
/// @author SMM
/// @date 10/02/2016
void check_parameter_values();
/// @brief Prints the parameter values to screen
/// @author SMM
/// @date 10/02/2016
void print_parameter_values_to_screen();
// WILL NEED TO WORK ON THIS
vector<LSDRaster> get_required_rasters(LSDFlowInfo& FlowInfo);
/// @brief This calculates the suspended and bedload for a given node in the DEM
/// It can be called repeatedly to get the entire DEM
/// @param node The node at which you want to calculate suspended and bedload
/// @param FlowInfo the LSDFlowinfo object
/// @param RasterVec a vector of LSDRasters, the first element is the DEM,
/// the second element is the lithology, the third element is the flow distance
/// and the fourth element is the erosion rate
/// @return a vector containg the bedload and suspended load information
/// @author SMM
/// @date 22/03/2016
vector<float> calculate_suspended_and_bedload(int node, LSDFlowInfo& FlowInfo,
vector<LSDRaster> RasterVec);
protected:
/// The number of lithologies
int N_lithologies;
/// the erosion rate in mm/yr
float erosion_rate;
/// The erodibiliy coefficients in km^-1
/// The int is the index into the lithology (coded with an integer)
map<int,float> erodibility_coefficients;
/// The fertility coefficients: states the fraction in the source material
/// that contains zircon
/// The int is the index into the lithology (coded with an integer)
map<int,float> fertility_coefficients;
/// The fraction of the source material that is entered as suspended load
/// The int is the index into the lithology (coded with an integer)
map<int,float> source_1mm;
private:
/// @brief the create function used when calling a file
/// @param the path to the file. Must have the "/" at the end
/// @param file_prefix the prefix (without extension) of the parameter files
/// @author SMM
/// @date 10/02/2016
void create(string path, string file_prefix);
};
#endif