QUIC-Fire-TT / ttrs_quicfire

ttrs_quicfire is a Python library to easily configure burn models for plots of land defined using shape files for the quicfire model.
MIT License
0 stars 1 forks source link

Implement Topography #2

Closed zacharycope0 closed 2 years ago

zacharycope0 commented 2 years ago

Feature Description QF is able to use the topo.dat file built from fastfuels but I build the original workflow for flatlands only. I would like topo to be run as a default.

Getting Started

  1. Add Boolean for using topo (default to true) qf.build_ff_domain(dom, FF_request=False, use_topo=True):
  2. If true: add topo.dat to the run folder.
  3. If true: topo.inp should have the following format:

!Relative filepath to topo .dat file (ex:: "../path/to/topo.dat") "topo.dat" 5 !Topo flag 0:Flat 1:Gaussian Hill 3:Constant slope with flat section 5:Custom .dat 1 !Smoothing Flag 1 !#of smoothing iterations 1500 !Total startup iterations 500 !Iteration Reset Period

  1. If true: the QU_simparams.inp should be 3x the topographic relief or height of the tallest fuel +100m (whichever is greater). To implement a dynamically generated dz array we will need finish building build_parabolic_dz_array() in print_inp_files.py (see issue fix build_parabolic_dz_array())**.

Screenshots Add any other context or screenshots about the feature request here.

cbonesteel commented 2 years ago

I've been messing around with this a bit and have just been trying to get the top.dat file into the run folder through QF_Arrays export_fuel function, currently ignoring the flag. I have discovered however, that elevation data is stored differently than the rest, so a call to fort_import throws this error:

Traceback (most recent call last):
  File "main.py", line 27, in <module>
    qf_arrs = qf.build_ff_domain(dom, FF_request=True, use_Topo=True)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ttrs_quicfire/quic_fire.py", line 398, in build_ff_domain
    qf_arrs = FF.build_ff_domain(dom, FUEL_PATH, FF_request, use_Topo)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ttrs_quicfire/build_FF_domain.py", line 204, in build_ff_domain
    return qf.QF_Fuel_Arrays(dom, out_dir)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ttrs_quicfire/quic_fire.py", line 99, in __init__
    self.topo = dat.fort_import(domain, os.path.join(FUEL_PATH, 'topo.dat'))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ttrs_quicfire/dat_file_functions.py", line 23, in fort_import
    data = data.reshape(domain.nz,domain.ny,domain.nx)
ValueError: cannot reshape array of size 115238 into shape (128,367,314)

This is a result of the varying lengths of the original .dat files.

bulk_density.dat Length: 14750464
moisture.dat Length: 14750464
depth.dat Length: 14750464
topo.dat Length: 115238

Perhaps the topo.dat data doesn't need to be reshaped at all and rather just copied? And if that is so then implementing the use_topo flag should be easier but the management of that file would not be in the same place as the rest of the fastfuels .dat files.

I will say I find this variation in data size rather odd since the fastfuels write function writes all four files at the same resolution.

zacharycope0 commented 2 years ago

I should have addressed that in my initial feature request. The topo.dat has an nz=1 since it is a 2-d array that describes the elevation of each cell.

cbonesteel commented 2 years ago

Everything through point 3 should be implemented now on the 2-topography branch. It seems like point 4 relies on Issue #3 so I'll take a look at that next.

zacharycope0 commented 2 years ago

Nice. You should probably work on the same branch for both problems.

cbonesteel commented 2 years ago

Point 4 should be resolved with the latest commit to 2-topography as mentioned in https://github.com/QUIC-Fire-TT/ttrs_quicfire/issues/3#issuecomment-1142556036. After this and issue #3 are closed the branch can be merged and a new release can be made.

zacharycope0 commented 2 years ago

Looks great! I have one fix: https://github.com/QUIC-Fire-TT/ttrs_quicfire/blob/a162c860b7312b13e6dd8764e6a32d6ac8eb54a4/ttrs_quicfire/print_inp_files.py#L302-L308

cbonesteel commented 2 years ago

I changed the fuel_height finder to what is below. On the example setup it gives me 41 which I believe is correct. https://github.com/QUIC-Fire-TT/ttrs_quicfire/blob/c3f2ad08376962237575fb3bd49bb3c5725e285c/ttrs_quicfire/print_inp_files.py#L302-L315

I also changed the following line back from the way you had it. This is because I am comparing the base numbers without the fuel height included. If the relief * 3 is greater than 100 then I add that ontop of the fuel height instead of just 100. https://github.com/QUIC-Fire-TT/ttrs_quicfire/blob/c3f2ad08376962237575fb3bd49bb3c5725e285c/ttrs_quicfire/print_inp_files.py#L319-L322