Skip to content

Commit 876f533

Browse files
authored
Merge pull request #116 from forefireAPI/dev
[docs] update pyforefire example on readme for clarity
2 parents dee8310 + 15f3107 commit 876f533

1 file changed

Lines changed: 45 additions & 3 deletions

File tree

bindings/python/README.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ You can build and install the package into your current Python interpreter in ed
6565

6666
## Usage
6767

68-
After installation, you can use PyForeFire in your Python code as follows:
68+
### Verifying the Installation
69+
70+
The first step is to confirm that the PyForeFire library was installed and linked correctly. The following code creates a `ForeFire` instance and defines a simulation domain.
6971

7072
```python
7173
import pyforefire as forefire
@@ -80,9 +82,49 @@ myCmd = "FireDomain[sw=(0.,0.,0.);ne=(%f,%f,0.);t=0.]" % (sizeX, sizeY)
8082

8183
# Execute the command
8284
ff.execute(myCmd)
85+
print("PyForeFire installed and domain created successfully.")
86+
```
87+
88+
If this script runs without an `ImportError` or linking error, your installation is working. *Note: You may see warnings about missing fuel tables, which is expected at this stage.*
89+
90+
### Running a Simple Simulation
91+
92+
To see a simulation in action, this example starts a fire in the center of a domain and runs it for 1000 seconds.
93+
94+
```python
95+
import pyforefire as forefire
96+
97+
ff = forefire.ForeFire()
98+
99+
# 1. Define a 10km x 10km simulation domain
100+
sim_shape = (10000, 10000)
101+
ff.execute(f'FireDomain[sw=(0,0,0);ne=({sim_shape[0]},{sim_shape[1]},0);t=0]')
102+
103+
# 2. Set a simple propagation model (isotropic, i.e., a perfect circle)
104+
ff.addLayer("propagation", "Iso", "propagationModel")
105+
106+
# 3. Start a fire in the center of the domain
107+
ff.execute(f'startFire[loc=({sim_shape[0]/2},{sim_shape[1]/2},0.0)]')
108+
109+
# 4. Run the simulation forward by 1000 seconds
110+
ff.execute("step[dt=1000]")
111+
112+
# 5. Print the state of the fire front to the console
113+
print(ff.execute("print[]"))
83114
```
84115

85-
Additionally, helper modules are provided which make use of NumPy and Matplotlib for data processing and visualization.
116+
This will produce text output describing the location of the fire front nodes.
117+
118+
To generate a `circle.kml` file for visualization in Google Earth, you can set the `dumpMode` parameter before the final print command:
119+
```python
120+
# Optional: Set output mode to KML and save to a file
121+
ff["dumpMode"] = "kml"
122+
ff.execute("print[circle.kml]")
123+
```
124+
125+
### More Advanced Examples
126+
127+
For more complex examples that use real-world data (like fuel, topography, and wind), please see the scripts located in the `tests/python/` directory of the main repository.
86128

87129
---
88130

@@ -119,4 +161,4 @@ This project is licensed under the terms specified in the `LICENSE` file.
119161
## Project URLs
120162

121163
- **Homepage:** [https://github.com/forefireAPI/forefire](https://github.com/forefireAPI/forefire)
122-
- **Documentation:** [https://forefire.readthedocs.io/en/latest/](https://forefire.readthedocs.io/en/latest/)
164+
- **Documentation:** [https://forefire.readthedocs.io/en/latest/](https://forefire.readthedocs.io/en/latest/)

0 commit comments

Comments
 (0)