-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
640 lines (565 loc) · 43 KB
/
Program.cs
File metadata and controls
640 lines (565 loc) · 43 KB
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
/*
* WUI-NITY TEST CASE GENERATOR
*
* WRITTEN BY NIKOLAOS KALOGEROPOULOS
* AS PART OF AN FYP PROJECT
* IMPERIAL COLLEGE LONDON
*
* SUPERVISED BY PROF. GUILLERMO REIN
* PART OF THE WUI-NITY PROJECT
* MARCH 2021
*
* ------------------------------------------------------------------------------
*
* WHAT IT DOES::
*
* THIS PROGRAM CREATES FARSITE INPUT FILES (OLD VERSION) WHICH ARE INPUTS TO THE WUI-NITY PLATFORM.
* IT IS FOR PROGRAM TESTING PURPOSES, AND INVESTIGATING THE EFFECT OF DIFFERENT PARAMETERS INTO THE SIMULATION RESULTS.
* IT PROVIDES AN EASY WAY TO CREATE SUCH CUSTOM CASES WITHOUT THE USE OF EXTERNAL PROGRAM.
*
* HOW TO USE::
*
* FIRST CREATE THE FUEL FILE IN PAINT, USING FOUR STANDARD COLORS. EACH COLOR REPRESENTS A STANDARD FUEL MODE:
*
* WHITE: NO FUEL
* RED: GRASS (STANDARD FUEL 1)
* BLUE: SHRUBBERY (STANDARD FUEL 5)
* GREEN: THIN FOREST (STANDARD FUEL 8)
* BLACK: STANDARD FOREST (STANDARD FUEL 10)
*
* EDIT THE SIZE OF THE PAINT CANVAS TO THE SIZE OF THE RASTER YOU WANT TO MAKE AND COLOR APPROPRIATELY. ANY PIXELS THAT DO NOT
* HAVE ANY OF THE FIVE COLORS WILL BE DEFAULTED TO NO FUEL. PLACE THE FILE IN THE INPUT FILES FOLDER (PATH IS HARDCODED FOR NOW)
*
* ONCE THE FILE IS THERE, RUN THE PROGRAM AND FILL IN EACH INPUT REQUEST. ONCE THAT IS DONE, ALL THE INPUT FILES SHOULD HAVE BEEN SUCCESSFULLY GENERATED.
* NOTE THAT THE FUEL MOISTURES FILE IS NOT YET GENERATED BY THE PROGRAM, BUT INSTEAD USES A STANDARD FILE
*
* VERISON HISTORY::
*
* V1.0: INTIAL COMMAND LINE RELEASE (28/03)
*
* KNOWN BUGS::
*
* -
*
* FUTURE IMPROVEMENTS::
*
* -
*
* ULTIMATE GOAL""
*
* THE ULTIMATE GOAL OF THIS PROGRAM IS FULL INTEGRATION IN THE WUI-NITY PLATFORM. THE USED WOULD USE SLIDERS, BOXES, AND A DRAWING
* INTERFACE TO SET ALL THE VALUES INSTEAD OF USING A TERMINAL AND THE EXTERNAL PAINT PROGRAM.
*
* NOTES::
*
* >THIS PROGRAM DOES NOT GENERATE LANDSCAPE FILES. THERE IS A SEPARATE ROUTINE IN WUI-NITY THAT GENERATES LANDSCAPE FILES.
* >THIS PROGRAM DOES NOT GENERATE IGNITION FILES. MORE RESEARCH NEEDS TO BE DONE TO UNDERSTAND HOW THESE FILES WORK.
* >THIS PROGRAM DOES NOT GENERATE FUEL MOISTURE FILES. MORE RESEARCH IS NEEDED INTO WHAT THOSE VALUES MEAN AND HOW THEY CHANGE.
* -------------------------------------------------------------------------------
*/
using System;
using System.IO;
using System.Drawing; //needed to be downloaded, not part of basic .net
using System.Linq;
using System.Runtime.CompilerServices;
namespace FireScenarioGenerator
{
class SetFiles
{
public void setWeatherData(string condition, int days, string savepath) //method to save the wind and weather data.
{
int maxTemp; //initialise the needed variables
int minTemp;
int maxHumid;
int minHumid;
switch (condition) //switch statement to set the variables. for some reason the variables are converted to sort of "private" in the switch. thus the other method has to be called in each case.
{
case "warm and humid": //typical values for a warm and humid Greek day
maxTemp = 30;
minTemp = 20;
maxHumid = 50;
minHumid = 20;
setWeatherFile(maxTemp, minTemp, maxHumid, minHumid, days, savepath);
break;
case "cold and humid": //typical values for a cold and humid Greek day
maxTemp = 12;
minTemp = 1;
maxHumid = 50;
minHumid = 20;
setWeatherFile(maxTemp, minTemp, maxHumid, minHumid, days, savepath);
break;
case "warm and dry": //typical values for a warm and dry Greek day
maxTemp = 30;
minTemp = 20;
maxHumid = 10;
minHumid = 30;
setWeatherFile(maxTemp, minTemp, maxHumid, minHumid, days, savepath);
break;
case "cold and dry": //typical values for a cold and dry Greek day
maxTemp = 12;
minTemp = 1;
maxHumid = 10;
minHumid = 10;
setWeatherFile(maxTemp, minTemp, maxHumid, minHumid, days, savepath);
break;
}
}
public void setGroundData(float slope, int aspect, int nrows, int ncols, int cell, string savepath) //set all the data that dictates the ground (elevation, slope, aspect)
{
setAspectFile(savepath, nrows, ncols, cell, aspect); //set the aspect file. Aspect is the direction towards the ground is rising.
setSlopeFile(savepath, nrows, ncols, cell, slope); //set the elevation file
float[,] elevation = new float[ncols, nrows];
float slopeX = (float)(slope * Math.Cos((aspect - 180) * Math.PI / 180));
float slopeY = (float)(slope * Math.Sin((aspect - 180) * Math.PI / 180));
for (int x = 0; x < ncols; x++) //for each cell in the matrix
{
for (int y = 0; y < nrows; y++)
{
elevation[x, y] = (float)Math.Tan(slopeX * Math.PI / 180) * cell * x - (float)Math.Tan(slopeY * Math.PI / 180) * cell * y; //calculate the elevation by addid the added height to the previous cell
}
}
float minValue = elevation.Cast<float>().Min();
if (minValue < 0)
{
for (int x = 0; x < ncols; x++) //for each cell in the matrix
{
for (int y = 0; y < nrows; y++)
{
elevation[x, y] = elevation[x, y] - minValue;
}
}
}
setElevationFile(savepath, nrows, ncols, cell, elevation); //write everything to a file
}
public void setGroundData(int[] slope, int aspect, int nrows, int ncols, int cell, string savepath) //set all the data that dictates the ground (elevation, slope, aspect)
{
//Aspect file
setInitialBlurb(nrows, ncols, cell, savepath + "aspect.asc"); //write the blurb
using (var sw = File.AppendText(savepath + "aspect.asc")) //continue writing on the same file (otherwise, erases whatever was written previously)
{
for (int x = 0; x < nrows; x++) //for all elements in the matrix
{
for (int y = 0; y < ncols / 2; y++)
{
sw.Write(90 + " "); //write zero (the slope rises perfectly upwards.
}
for (int y = ncols / 2; y < ncols; y++)
{
sw.Write(270 + " "); //write zero (the slope rises perfectly upwards.
}
sw.Write("\n"); //start a new line
}
sw.Flush(); //i dont really know
sw.Close(); //close opened output text file
}
Console.WriteLine("aspect.asc file generated.");
//Slope File
setInitialBlurb(nrows, ncols, cell, savepath + "slope.asc"); //write the blurb
using (var sw = File.AppendText(savepath + "slope.asc")) //continue writing on the same file (otherwise, erases whatever was written previously)
{
for (int x = 0; x < nrows; x++) //for all elements in the matrix
{
for (int y = 0; y < ncols / 2; y++)
{
sw.Write(slope[0] + " "); //write zero (the slope rises perfectly upwards.
}
for (int y = ncols / 2; y < ncols; y++)
{
sw.Write(slope[1] + " "); //write zero (the slope rises perfectly upwards.
}
sw.Write("\n"); //start a new line
}
sw.Flush(); //i dont really know
sw.Close(); //close opened output text file
}
Console.WriteLine("slope.asc file generated.");
//Elevation File
float[,] elevation = new float[ncols, nrows];
for (int y = 0; y < ncols; y++) //for all elements in the matrix
{
for (int x = 0; x < nrows / 2; x++)
{
elevation[x, y] = (float)Math.Sin(slope[0] * 3.14 / 180) * ((nrows / 2) - x) * cell; //write zero (the slope rises perfectly upwards.
}
for (int x = ncols / 2; x < nrows; x++)
{
elevation[x, y] = (float)Math.Sin(slope[1] * 3.14 / 180) * (x - (nrows / 2)) * cell; //write zero (the slope rises perfectly upwards.
}
}
float minValue = elevation.Cast<float>().Min();
if (minValue < 0)
{
for (int x = 0; x < ncols; x++) //for each cell in the matrix
{
for (int y = 0; y < nrows; y++)
{
elevation[x, y] = elevation[x, y] - minValue;
}
}
}
setElevationFile(savepath, nrows, ncols, cell, elevation); //write everything to a file
}
private void setWeatherFile(int maxTemp, int minTemp, int maxHumid, int minHumid, int days, string savepath) //write weather file to a file.
{
using (var sw = new StreamWriter(savepath)) //start writing on a savepath file
{
sw.Write("METRIC" + "\n"); //state what units are used (metric = m, kg, s etc).
for (int day = 1; day <= days; day++) //for all elements in the output array
{
sw.Write("1 " + day + " 0 " + "600 " + "1500 " + minTemp + " " + maxTemp + " " + maxHumid + " " + minHumid + " " + "200" + "\n"); //output a line of the file
}
sw.Flush(); //i dont really know
sw.Close(); //close opened output text file
}
Console.WriteLine("weather.wtr file generated."); //send confirmation message
}
public void setWindFile(int magnitude, int direction, int days, string savepath) //set wind file, wind from downwards vertical
{
using (var sw = new StreamWriter(savepath)) //start writing on the savepath file.
{
sw.Write("METRIC" + "\n");
for (int day = 1; day <= days; day++) //for all elements in the output array
{
for (int hour = 0; hour < 2400; hour += 100)
{
sw.Write("1 " + day + " " + hour + " " + magnitude + " " + direction + " " + "0 \n"); //write the file line.
}
}
sw.Flush(); //i dont really know
sw.Close(); //close opened output text file
}
Console.WriteLine("wind.wnd file generated."); //send confirmation message
}
private void setInitialBlurb(int nrows, int ncols, int cellsize, string savepath) //method to set the initial blurb that some files have that define the raster.
{
using (var sw = new StreamWriter(savepath)) //start writing in the savepath file
{
sw.Write("ncols" + " " + ncols + "\n"); //start setting all the values.
sw.Write("nrows" + " " + nrows + "\n");
sw.Write("xllcorner 0" + "\n");
sw.Write("yllcorner 0" + "\n");
sw.Write("cellsize" + " " + cellsize + "\n");
sw.Write("NODATA_value -9999 " + "\n");
}
}
private void setAspectFile(string savepath, int nrows, int ncols, int cellsize, int aspect) //write the aspect file.
{
setInitialBlurb(nrows, ncols, cellsize, savepath + "aspect.asc"); //write the blurb
using (var sw = File.AppendText(savepath + "aspect.asc")) //continue writing on the same file (otherwise, erases whatever was written previously)
{
for (int x = 0; x < nrows; x++) //for all elements in the matrix
{
for (int y = 0; y < ncols; y++)
{
sw.Write(aspect + " "); //write zero (the slope rises perfectly upwards.
}
sw.Write("\n"); //start a new line
}
sw.Flush(); //i dont really know
sw.Close(); //close opened output text file
}
Console.WriteLine("aspect.asc file generated."); //send confirmation message
}
private void setSlopeFile(string savepath, int nrows, int ncols, int cellsize, float slope) //write the slope file
{
setInitialBlurb(nrows, ncols, cellsize, savepath + "slope.asc"); //write the blurb
using (var sw = File.AppendText(savepath + "slope.asc")) //continue writing on the same file (otherwise, erases whatever was written previously)
{
for (int x = 0; x < nrows; x++) //for all elements in the matrix
{
for (int y = 0; y < ncols; y++)
{
sw.Write(slope + " "); //write the slope value in the file
}
sw.Write("\n"); //start a new line
}
sw.Flush(); //i dont really know
sw.Close(); //close opened output text file
}
Console.WriteLine("slope.asc file generated."); //send confirmation message
}
private void setElevationFile(string savepath, int nrows, int ncols, int cellsize, float[,] elevation) //write the elevation file
{
setInitialBlurb(nrows, ncols, cellsize, savepath + "elevation.asc"); //write the blurb
using (var sw = File.AppendText(savepath + "elevation.asc")) //continue writing on the same file
{
for (int x = 0; x < nrows; x++) //for all elements in the matrix
{
for (int y = 0; y < ncols; y++)
{
sw.Write(elevation[y, x] + " "); //write the elevation value in the file
}
sw.Write("\n"); //start a new line
}
sw.Flush(); //i dont really know
sw.Close(); //close opened output text file
}
Console.WriteLine("elevation.asc file generated."); //send confirmation message
}
public void setAdjustmentFile(string path) //write the adjustment file (for now, it is just set as no adjustment on any fuels)
{
using (var sw = new StreamWriter(path)) //start writing on the savepath file
{
for (int i = 1; i <= 256; i++) //for all the 255 fuel types
{
sw.Write(i + " " + 1); //write 1 (no adjustment)
}
sw.Flush(); //i dont really know
sw.Close(); //close opened output text file
}
Console.WriteLine("adjustment.adj file generated."); //send confirmation message
}
public int[,] getFuelMatrix(string photopath) //get the fuel matrix from the fuels image
{
Bitmap FuelInputMap = new Bitmap(photopath); //read the color of each pixed in the photo and save it as a bitmap
Color fuel1 = Color.FromArgb(237, 28, 36); //set the RGB value of the RED color.
Color fuel2 = Color.FromArgb(0, 162, 232); //set the RGB value of the BLUE color.
Color fuel3 = Color.FromArgb(34, 177, 76); //set the RGB value of the GREEN color.
Color fuel4 = Color.FromArgb(0, 0, 0); //set the RGB value of the BLACK color.
int[,] fuels = new int[FuelInputMap.Width, FuelInputMap.Height]; //instantiate the fuels matrix
for (int x = 0; x < FuelInputMap.Width; x++) //for every element in the matrix
{
for (int y = 0; y < FuelInputMap.Height; y++)
{
if (FuelInputMap.GetPixel(x, y) == fuel1) //if the pixel is red
{
fuels[x, y] = 101; //set it as standard fuel mode 1
}
else if (FuelInputMap.GetPixel(x, y) == fuel2) //if the pixel is blue
{
fuels[x, y] = 122; //set it as standard fuel mode 5
}
else if (FuelInputMap.GetPixel(x, y) == fuel3) //if the pixel is green
{
fuels[x, y] = 142; //set it as standard fuel mode 8
}
else if (FuelInputMap.GetPixel(x, y) == fuel4) //if the pixel is black
{
fuels[x, y] = 162; //set it as standard fuel mode 10
}
else //if none of the above apply
{
Console.WriteLine("invalid color, setting as no fuel"); //send debug message
fuels[x, y] = 0; //set it as no fuel
}
}
}
Console.WriteLine("fuel.asc matrix generated."); //send confirmation message
return fuels; //return the fuels matrix
}
public void setFuelsFile(string savepath, int nrows, int ncols, int cellsize, int[,] fuels) //write the fuels file.
{
setInitialBlurb(nrows, ncols, cellsize, savepath); //write the initial blurb
using (var sw = File.AppendText(savepath)) //continue writing on the same file
{
for (int y = 0; y < nrows; y++) //for all elements in the matrix
{
for (int x = 0; x < ncols; x++)
{
sw.Write(fuels[x, y] + " "); //write the fuel mode
}
sw.Write("\n"); //new line
}
sw.Flush(); //i dont really know
sw.Close(); //close opened output text file
}
Console.WriteLine("fuel.asc file generated."); //send confirmation message
}
public void setCrownFiles(string savepath, int nrows, int ncols, int cellsize, int[,] fuels) //Set all the crown fire related files (crown height, canopy cover, crown density, tree height, stand height)
{
float[,] canopyCover = new float[fuels.GetLength(0), fuels.GetLength(1)]; //instantiate all the relevant matrices
float[,] CrownDensity = new float[fuels.GetLength(0), fuels.GetLength(1)];
float[,] BaseHeight = new float[fuels.GetLength(0), fuels.GetLength(1)];
float[,] StandHeight = new float[fuels.GetLength(0), fuels.GetLength(1)];
float[,,] canopyData = new float[fuels.GetLength(0), fuels.GetLength(1), 4]; //instantiate an overall matrix. the above five matrices will be saved in this, making it easier to pass all the data around (and condense later code)
for (int x = 0; x < fuels.GetLength(0); x++) //for all elements in the fuel matrix
{
for (int y = 0; y < fuels.GetLength(1); y++)
{
if (fuels[x, y] == 101 || fuels[x, y] == 0) //change the values depending on the fuel
{
canopyCover[x, y] = 0; //grass, shrubs, or no fuel
CrownDensity[x, y] = 0;
BaseHeight[x, y] = 0;
StandHeight[x, y] = 0;
}
else if (fuels[x, y] == 122) //sparse forest
{
canopyCover[x, y] = 0; //percent canopy cover
CrownDensity[x, y] = 0; //crown bulk height is 30 meters above the ground
BaseHeight[x, y] = 0; //tree height is 30 meters (unsure as to what the different is with the above. the above seems to not be used anymore)
StandHeight[x, y] = 0; //also unsure, has something to do with spotting calculations
}
else if (fuels[x, y] == 142) //sparse forest
{
canopyCover[x, y] = 40; //percent canopy cover
CrownDensity[x, y] = 0.13f; //crown bulk height is 30 meters above the ground
BaseHeight[x, y] = 1.6f; //tree height is 30 meters (unsure as to what the different is with the above. the above seems to not be used anymore)
StandHeight[x, y] = 12; //also unsure, has something to do with spotting calculations
}
else if (fuels[x, y] == 162) //dense forest
{
canopyCover[x, y] = 55;
CrownDensity[x, y] = 0.11f;
BaseHeight[x, y] = 3;
StandHeight[x, y] = 19;
}
canopyData[x, y, 0] = canopyCover[x, y]; //pass all the values in the big matrix
canopyData[x, y, 1] = CrownDensity[x, y];
canopyData[x, y, 2] = BaseHeight[x, y];
canopyData[x, y, 3] = StandHeight[x, y];
}
}
string[] outputfiles = new string[4] { "canopy.asc", "crownbulkdensity.asc", "height.asc", "standheight.asc" }; //save all the output file names in one array, so then we only need to write the "make file" method once below
for (int i = 0; i < outputfiles.Length; i++) //for each file
{
setInitialBlurb(nrows, ncols, cellsize, savepath + outputfiles[i]); //write the initial blurb
using (var sw = File.AppendText(savepath + outputfiles[i])) //continue writing on the same file
{
for (int y = 0; y < nrows; y++) //for each value in the matrix
{
for (int x = 0; x < ncols; x++)
{
sw.Write(canopyData[x, y, i] + " "); //insert the relevant value
}
sw.Write("\n"); //new line
}
sw.Flush(); //i dont really know
sw.Close(); //close opened output text file
}
Console.WriteLine(outputfiles[i] + " file generated."); //send confirmation message
}
}
}
abstract class CallMethods
{
public static void ConsoleCall()
{
Console.WriteLine("This program creates the input files for FARSITE(old version) and WUI-NITY. Current version is restrictive in the options it provides but still functional.\n"); //Write the intial information text
Console.WriteLine("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \n");
Console.WriteLine("!!!!!!!!!!!!!!Make sure the fuels.png image is in the Input folder.!!!!!!!!!!!!!!\n");
Console.WriteLine("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \n");
Console.WriteLine("Input the x dimension of the fuels.png raster (pixel size)\n");
int xDim = Convert.ToInt32(Console.ReadLine()); //get xDim
Console.WriteLine("Input the y dimension of the fuels.png raster (pixel size)\n");
int yDim = Convert.ToInt32(Console.ReadLine()); //get ydim
Console.WriteLine("Write the size of each pixel/raster point (in meters)\n");
int cellsize = Convert.ToInt32(Console.ReadLine()); //get cellsize
Console.WriteLine("Write the slope of the raster.\n");
int slope = Convert.ToInt32(Console.ReadLine()); //get slope
Console.WriteLine("Write the azimuth of the raster.\n");
int azimuth = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Write the direction of the wind (measured clockwise from the downwards vertical, in degrees\n");
int WindDirection = Convert.ToInt32(Console.ReadLine()); //get wind direction
Console.WriteLine("Write the magnitude of the wind (in kph)\n");
int WindMagnitude = Convert.ToInt32(Console.ReadLine()); //get wind magnitude
Console.WriteLine("Write the temperature and moisture conditions of the simulation. The standard choices are: cold and dry, cold and wet, warm and dry, warm and wet.\n");
string TemperatureConditions = Console.ReadLine(); //get the temperature and moisture condition
Console.WriteLine("Write how many days the simulation will last");
int days = Convert.ToInt32(Console.ReadLine()); //get the simulation duration
Console.WriteLine("All Inputs Accepted. Note: Input paths are hardcoded for now."); //send a confirmation message
Console.WriteLine("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \n");
string OutputFolder = @"D:\OneDrive - Imperial College London\Documents\Coding Projects\FireScenarioGenerator\FireScenarioGenerator\Output\"; //input and output folder paths are hardcoded for now.
string InputFolder = @"D:\OneDrive - Imperial College London\Documents\Coding Projects\FireScenarioGenerator\FireScenarioGenerator\Input\";
if (!Directory.Exists(OutputFolder))
{
Directory.CreateDirectory(OutputFolder);
}
SetFiles setter = new SetFiles(); //instantiate the set files object
string WeatherSavePath = OutputFolder + "weather.wtr"; //set all the output paths, combined with the relevant file name
string WindSavePath = OutputFolder + "wind.wnd";
string GroundSaveFolder = OutputFolder; //this is setup in the method, as three different files depend on it
string AdjustmentSavePath = OutputFolder + "adjustment.adj";
string FuelsSavePath = OutputFolder + "fuel.asc";
setter.setWeatherData(TemperatureConditions, days, WeatherSavePath); //calculate the weather data (and save the file)
setter.setWindFile(WindMagnitude, WindDirection, days, WindSavePath); //calculate and save the wind data
setter.setGroundData(slope, azimuth, yDim, xDim, cellsize, GroundSaveFolder); //set the ground data (elevation, slope, azimuth)
setter.setAdjustmentFile(AdjustmentSavePath); //set adjustment path
int[,] fuels = setter.getFuelMatrix(InputFolder + "fuels.png"); //read the fuels image
setter.setFuelsFile(FuelsSavePath, yDim, xDim, cellsize, fuels); //write the fuels matrix to file
setter.setCrownFiles(OutputFolder, yDim, xDim, cellsize, fuels); //write all five crown fire related files (including canopy cover)
}
public static void sourceCall()
{
int xDim = 126;
int yDim = 126;
int cellsize = 30;
float slope = 21;
int azimuth = 233;
int WindDirection = 0;
int WindMagnitude = 30; //get wind magnitude
string TemperatureConditions = "warm and dry"; //get the temperature and moisture condition
int days = 15;
bool valleySlope = false;
int[] valleySlopeMag = { 15, 5 };
Console.WriteLine("All Inputs Accepted. Note: Input paths are hardcoded for now."); //send a confirmation message
Console.WriteLine("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \n");
string OutputFolder = @"D:\OneDrive - Imperial College London\Documents\Coding Projects\FireScenarioGenerator\FireScenarioGenerator\Output\"; //input and output folder paths are hardcoded for now.
string InputFolder = @"D:\OneDrive - Imperial College London\Documents\Coding Projects\FireScenarioGenerator\FireScenarioGenerator\Input\";
if (!Directory.Exists(OutputFolder))
{
Directory.CreateDirectory(OutputFolder);
}
SetFiles setter = new SetFiles(); //instantiate the set files object
string WeatherSavePath = OutputFolder + "weather.wtr"; //set all the output paths, combined with the relevant file name
string WindSavePath = OutputFolder + "wind.wnd";
string GroundSaveFolder = OutputFolder; //this is setup in the method, as three different files depend on it
string AdjustmentSavePath = OutputFolder + "adjustment.adj";
string FuelsSavePath = OutputFolder + "fuel.asc";
setter.setWeatherData(TemperatureConditions, days, WeatherSavePath); //calculate the weather data (and save the file)
setter.setWindFile(WindMagnitude, WindDirection, days, WindSavePath); //calculate and save the wind data
if (valleySlope)
{
setter.setGroundData(valleySlopeMag, azimuth, yDim, xDim, cellsize, GroundSaveFolder);
}
else
{
setter.setGroundData(slope, azimuth, yDim, xDim, cellsize, GroundSaveFolder);
}
//set the ground data (elevation, slope, azimuth)
setter.setAdjustmentFile(AdjustmentSavePath); //set adjustment path
int[,] fuels = setter.getFuelMatrix(InputFolder + "fuels.png"); //read the fuels image
setter.setFuelsFile(FuelsSavePath, yDim, xDim, cellsize, fuels); //write the fuels matrix to file
setter.setCrownFiles(OutputFolder, yDim, xDim, cellsize, fuels); //write all five crown fire related files (including canopy cover)
}
public static void MultiCall()
{
int numberOfCases = 28;
int[] xDim = { 25, 50, 100, 150, 200, 300, 600, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 600, 600, 600, 600, 600, 300, 300, 300, 300, 300 }; //get xDim
int[] yDim = xDim; //get ydim
int[] cellsize = { 24, 12, 6, 4, 3, 2, 1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 }; //get cellsize
int slope = 0;
int aspect = 0;
int WindDirection = 90; //get wind direction
int[] WindMagnitude = { 0, 0, 0, 0, 0, 0, 0, 6, 12, 18, 24, 30, 0, 0, 0, 0, 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0 }; //get wind magnitude
string TemperatureConditions = "warm and dry"; //get the temperature and moisture condition
int days = 5; //get the simulation duration
string OutputFolder = @"C:\Users\nikos\OneDrive\Desktop\PERILvKPERIL\ComparisonCases"; //input and output folder paths are hardcoded for now.
string InputFolder = @"C:\Users\nikos\OneDrive\Desktop\PERILvKPERIL\ComparisonCases";
SetFiles setter = new SetFiles(); //instantiate the set files object
for (int i = 27; i < numberOfCases; i++)
{
Directory.CreateDirectory(OutputFolder + "/case" + (i + 1));
string WeatherSavePath = OutputFolder + "/case" + (i + 1) + "/weather.wtr"; //set all the output paths, combined with the relevant file name
string WindSavePath = OutputFolder + "/case" + (i + 1) + "/wind.wnd";
string GroundSaveFolder = OutputFolder + "/case" + (i + 1) + "/"; //this is setup in the method, as three different files depend on it
string AdjustmentSavePath = OutputFolder + "/case" + (i + 1) + "/adjustment.adj";
string FuelsSavePath = OutputFolder + "/case" + (i + 1) + "/fuel.asc";
setter.setWeatherData(TemperatureConditions, days, WeatherSavePath); //calculate the weather data (and save the file)
setter.setWindFile(WindMagnitude[i], WindDirection, days, WindSavePath); //calculate and save the wind data
setter.setGroundData(slope, aspect, yDim[i], xDim[i], cellsize[i], GroundSaveFolder); //set the ground data (elevation, slope, azimuth)
setter.setAdjustmentFile(AdjustmentSavePath); //set adjustment path
int[,] fuels = setter.getFuelMatrix(InputFolder + "/fuels" + (i + 1) + ".png"); //read the fuels image
setter.setFuelsFile(FuelsSavePath, yDim[i], xDim[i], cellsize[i], fuels); //write the fuels matrix to file
setter.setCrownFiles(OutputFolder + "/case" + (i + 1) + "/", yDim[i], xDim[i], cellsize[i], fuels);
}
}
}
class Program
{
static void Main(String[] args)
{
CallMethods.sourceCall();
}
}
}