From f7e3c3d251dde2a00d4ddafaefa5e88a56b083fa Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Mon, 21 Apr 2025 16:48:35 -0700 Subject: [PATCH 01/18] trying to update plot code for bitrot; getting XIO crash, but making progress --- README.md | 6 +++--- cell2fire/utils/Plot.py | 14 +++++++------- cell2fire/utils/Stats.py | 30 +++++++++++++++++------------- requirements.txt | 2 +- setup.py | 2 +- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index feaa8069..2875d9c1 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,14 @@ ISSN={2624-893X} - g++ - Boost (C++) - Eigen (C++) -- Python 3.6 +- Python >3.6; you might need 3.12 - numpy - pandas - matplotlib - seaborn - tqdm - opencv -- imread +- imageio (replaced imread, April 2026) - networkx (for stats module) # Installation @@ -56,7 +56,7 @@ Installation may require some familiarity with C++, make, and Python. - make - cd ../.. - pip install -r requirements.txt # might not do anything -- python setup.py develop +- pip install -e . # Usage In order to run the simulator (after installation and cd to Cell2Fire/cell2fire), the following command can be used: diff --git a/cell2fire/utils/Plot.py b/cell2fire/utils/Plot.py index a7a30342..88018bfc 100644 --- a/cell2fire/utils/Plot.py +++ b/cell2fire/utils/Plot.py @@ -1,5 +1,5 @@ # coding: utf-8 -__version__ = "2.0" +__version__ = "2.1" __author__ = "Cristobal Pais" __maintainer__ = "Jaime Carrasco, Cristobal Pais, David Woodruff" __status__ = "Alpha Operational" @@ -7,7 +7,7 @@ # Importations # import sys import os -import imread +import cv2 #Visual importations from matplotlib.pylab import * @@ -686,14 +686,14 @@ def forest_plotV3_FreeMem(self, Cells_Obj, msg_list, counter, period, Year, show ''' # Mixes the evolution plots with the base forest (initial state for saving memory/time) def Mix(self,Folder,filen,Sim): - img = imread(os.path.join(Folder, "ForestInitial.png")) + img = cv2.imread(os.path.join(Folder, "ForestInitial.png")) fstr = str(filen).zfill(4) #Path and name of the file PathFile = os.path.join(Folder, "Plots", "Plots"+str(Sim), "forest" + fstr + ".png") # Reads the basic forest - img2 = imread(PathFile) + img2 = cv2.imread(PathFile) # Over plot gca().set_axis_off() @@ -710,7 +710,7 @@ def Mix(self,Folder,filen,Sim): def MultiFireMix(self,Folder,nSims,mode="Scale",probs=[]): # Read initial forest status - imgForest = imread(os.path.join(Folder, "ForestInitial.png")) + imgForest = cv2.imread(os.path.join(Folder, "ForestInitial.png")) #fstr = str(filen).zfill(4) # If no probs provided, alpha = 0.25 by default (otherwise, transparency is proportional to the fire probability) @@ -730,7 +730,7 @@ def MultiFireMix(self,Folder,nSims,mode="Scale",probs=[]): imgArray = [] for i in range(nSims): - imgArray.append(imread(PathFile[i])) + imgArray.append(cv2.imread(PathFile[i])) #print(imgArray[i].shape) # Summation mode: sum the pixels values for highlighting the intersections of fires (more intense than Scale) @@ -767,4 +767,4 @@ def MultiFireMix(self,Folder,nSims,mode="Scale",probs=[]): # Save the combined picture plt.savefig(os.path.join(Folder, "Plots", "MultiFire_Plot"+mode+".png"), dpi=200, bbox_inches='tight', pad_inches=0) - plt.close("all") \ No newline at end of file + plt.close("all") diff --git a/cell2fire/utils/Stats.py b/cell2fire/utils/Stats.py index 0fe8d9ec..f86b45bc 100644 --- a/cell2fire/utils/Stats.py +++ b/cell2fire/utils/Stats.py @@ -603,13 +603,14 @@ def GlobalFireSpreadEvo(self, CoordCells, onlyGraph=True, version=0): divider = make_axes_locatable(ax) cax1 = divider.append_axes("right", size="5%", pad=0.15) plt.colorbar(sm, cax=cax1) - + # both savefig calls used to have figsize=(200, 200), (april 2025) + plt.figure(figsize=(200,200)) plt.savefig(os.path.join(self._StatsFolder, "SpreadTree_FreqGraph_" + outname + ".png"), - dpi=200, figsize=(200, 200), + dpi=200, bbox_inches='tight', transparent=False) if self._pdfOutputs: plt.savefig(os.path.join(self._StatsFolder, "SpreadTree_FreqGraph_" + outname + ".pdf"), - dpi=200, figsize=(200, 200), + dpi=200, bbox_inches='tight', transparent=False) plt.close("all") @@ -681,14 +682,15 @@ def SimFireSpreadEvo(self, nSim, CoordCells, Colors, H=None, version=0, PlotPath = os.path.join(self._OutFolder, "Plots", "Plots" + str(nSim)) if os.path.isdir(PlotPath) is False: os.makedirs(PlotPath) - + # both savefig calls used to have figsize=(200, 200), (April 2025) + plt.figure(figsize=(200,200)) plt.savefig(os.path.join(PlotPath, "PropagationTree" + str(nSim) +".png"), - dpi=200, figsize=(200, 200), edgecolor='b', + dpi=200, edgecolor='b', bbox_inches='tight', transparent=False) if self._pdfOutputs: plt.savefig(os.path.join(PlotPath, "PropagationTree" + str(nSim) +".pdf"), - dpi=200, figsize=(200, 200), edgecolor='b', + dpi=200, edgecolor='b', bbox_inches='tight', transparent=False) @@ -823,14 +825,16 @@ def SimFireSpreadEvoV2(self, nSim, CoordCells, Colors, H=None, version=0, onlyGr #ax.set_aspect('auto') divider = make_axes_locatable(ax) cax1 = divider.append_axes("right", size="5%", pad=0.05) - plt.colorbar(sm, cax=cax1) + plt.colorbar(sm, cax=cax1) + # both savefig calls used to have figsize=(200, 200), (April 2025) + plt.figure(figsize=(200,200)) plt.savefig(os.path.join(PlotPath, "FireSpreadTree" + str(nSim) + "_" + str(version) + ".png"), - dpi=200, figsize=(200, 200), + dpi=200, bbox_inches='tight', transparent=False) if self._pdfOutputs: plt.savefig(os.path.join(PlotPath, "FireSpreadTree" + str(nSim) + "_" + str(version) + ".pdf"), - dpi=200, figsize=(200, 200), + dpi=200, bbox_inches='tight', transparent=False) plt.close("all") @@ -1201,11 +1205,11 @@ def HourlyStats(self): print("Hourly Stats:\n",Ah) # Hourly Summary - SummaryDF = Ah[["NonBurned", "Burned", "Harvested", "Hour"]].groupby('Hour')["NonBurned", "Burned", "Harvested"].mean() + SummaryDF = Ah[["NonBurned", "Burned", "Harvested", "Hour"]].groupby('Hour')[["NonBurned", "Burned", "Harvested"]].mean() SummaryDF.rename(columns={"NonBurned":"AVGNonBurned", "Burned":"AVGBurned", "Harvested":"AVGHarvested"}, inplace=True) - SummaryDF[["STDBurned", "STDHarvested"]] = Ah[["NonBurned", "Burned", "Harvested", "Hour"]].groupby('Hour')["Burned","Harvested"].std()[["Burned","Harvested"]] - SummaryDF[["MaxNonBurned", "MaxBurned"]] = Ah[["NonBurned", "Burned", "Harvested", "Hour"]].groupby('Hour')["NonBurned", "Burned"].max()[["NonBurned", "Burned"]] - SummaryDF[["MinNonBurned", "MinBurned"]] = Ah[["NonBurned", "Burned", "Harvested", "Hour"]].groupby('Hour')["NonBurned", "Burned"].min()[["NonBurned", "Burned"]] + SummaryDF[["STDBurned", "STDHarvested"]] = Ah[["NonBurned", "Burned", "Harvested", "Hour"]].groupby('Hour')[["Burned","Harvested"]].std()[["Burned","Harvested"]] + SummaryDF[["MaxNonBurned", "MaxBurned"]] = Ah[["NonBurned", "Burned", "Harvested", "Hour"]].groupby('Hour')[["NonBurned", "Burned"]].max()[["NonBurned", "Burned"]] + SummaryDF[["MinNonBurned", "MinBurned"]] = Ah[["NonBurned", "Burned", "Harvested", "Hour"]].groupby('Hour')[["NonBurned", "Burned"]].min()[["NonBurned", "Burned"]] Aux = (SummaryDF["AVGNonBurned"] + SummaryDF["AVGBurned"] + SummaryDF["AVGHarvested"]) SummaryDF["%AVGNonBurned"], SummaryDF["%AVGBurned"], SummaryDF["%AVGHarvested"] = SummaryDF["AVGNonBurned"] / Aux, SummaryDF["AVGBurned"] / Aux, SummaryDF["AVGHarvested"] / Aux SummaryDF.reset_index(inplace=True) diff --git a/requirements.txt b/requirements.txt index 6fb01505..6c1494fa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ numpy +scipy pandas matplotlib seaborn opencv-python -imread tqdm deap sphinx_rtd_theme diff --git a/setup.py b/setup.py index dc986a7d..50be41b1 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ author='Cristobal Pais, Jaime Carrasco, David Martell, David L. Woodruff, Andres Weintraub', author_email='dlwoodruff@ucdavis.edu', packages=packages, - install_requires=['numpy', 'pandas', 'matplotlib', 'seaborn', 'tqdm', 'imread', 'networkx', 'deap'], + install_requires=['numpy', 'pandas', 'matplotlib', 'seaborn', 'tqdm', 'opencv-python', 'networkx', 'deap'], extras_require={ 'doc': [ 'sphinx_rtd_theme', From 6882ec16f96151bd2d3774b6c960ed0577598abc Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Wed, 23 Apr 2025 15:27:37 -0700 Subject: [PATCH 02/18] tyring to get sub20x20.yml up to date --- .../{expl_heuristic.yml => expl_heuristic.lmy} | 0 .github/workflows/sub20x20.yml | 16 ++++++++-------- ..._datagenerator.yml => test_datagenerator.lmy} | 0 .../{test_dogrib.yml => test_dogrib.lmy} | 0 .github/workflows/{test_h1.yml => test_h1.lmy} | 0 .github/workflows/{test_h2.yml => test_h2.lmy} | 0 .github/workflows/{test_h3.yml => test_h3.lmy} | 0 ...test_randweather.yml => test_randweather.lmy} | 0 .../{test_readspot.yml => test_readspot.lmy} | 0 9 files changed, 8 insertions(+), 8 deletions(-) rename .github/workflows/{expl_heuristic.yml => expl_heuristic.lmy} (100%) rename .github/workflows/{test_datagenerator.yml => test_datagenerator.lmy} (100%) rename .github/workflows/{test_dogrib.yml => test_dogrib.lmy} (100%) rename .github/workflows/{test_h1.yml => test_h1.lmy} (100%) rename .github/workflows/{test_h2.yml => test_h2.lmy} (100%) rename .github/workflows/{test_h3.yml => test_h3.lmy} (100%) rename .github/workflows/{test_randweather.yml => test_randweather.lmy} (100%) rename .github/workflows/{test_readspot.yml => test_readspot.lmy} (100%) diff --git a/.github/workflows/expl_heuristic.yml b/.github/workflows/expl_heuristic.lmy similarity index 100% rename from .github/workflows/expl_heuristic.yml rename to .github/workflows/expl_heuristic.lmy diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index 2c19dc28..abd2ccc6 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -1,5 +1,7 @@ +# dropped the Docker container use (DLW April 2025) name: sub20x20 # Test2_zonghan + on: push: branches: [ main ] @@ -8,23 +10,21 @@ on: jobs: build: - + name: sub20x20 runs-on: ubuntu-latest - container: - image: dlwoodruff/c2fcondatest:latest - env: - PATH: /opt/conda/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: make C++ run: | cd cell2fire/Cell2FireC make + - name: install dependencies + run: | + pip install -r requirements.txt - name: setup the program run: | - python setup.py develop + pip install -e . - name: Lint with flake8 run: | diff --git a/.github/workflows/test_datagenerator.yml b/.github/workflows/test_datagenerator.lmy similarity index 100% rename from .github/workflows/test_datagenerator.yml rename to .github/workflows/test_datagenerator.lmy diff --git a/.github/workflows/test_dogrib.yml b/.github/workflows/test_dogrib.lmy similarity index 100% rename from .github/workflows/test_dogrib.yml rename to .github/workflows/test_dogrib.lmy diff --git a/.github/workflows/test_h1.yml b/.github/workflows/test_h1.lmy similarity index 100% rename from .github/workflows/test_h1.yml rename to .github/workflows/test_h1.lmy diff --git a/.github/workflows/test_h2.yml b/.github/workflows/test_h2.lmy similarity index 100% rename from .github/workflows/test_h2.yml rename to .github/workflows/test_h2.lmy diff --git a/.github/workflows/test_h3.yml b/.github/workflows/test_h3.lmy similarity index 100% rename from .github/workflows/test_h3.yml rename to .github/workflows/test_h3.lmy diff --git a/.github/workflows/test_randweather.yml b/.github/workflows/test_randweather.lmy similarity index 100% rename from .github/workflows/test_randweather.yml rename to .github/workflows/test_randweather.lmy diff --git a/.github/workflows/test_readspot.yml b/.github/workflows/test_readspot.lmy similarity index 100% rename from .github/workflows/test_readspot.yml rename to .github/workflows/test_readspot.lmy From 8476ed7d416407cc62feac17b5c952bc926b4cab Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Wed, 23 Apr 2025 15:32:33 -0700 Subject: [PATCH 03/18] working on yml --- .github/workflows/fullstat_allplot.yml | 15 +++++++-------- .github/workflows/sub20x20.yml | 3 +-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/fullstat_allplot.yml b/.github/workflows/fullstat_allplot.yml index b43a238e..728b4e15 100644 --- a/.github/workflows/fullstat_allplot.yml +++ b/.github/workflows/fullstat_allplot.yml @@ -1,4 +1,5 @@ name: fullstat_allplot # Kotaro Yama +# dropped the Docker container use (DLW April 2025) on: push: @@ -8,23 +9,21 @@ on: jobs: build: - + name: sub20x20 runs-on: ubuntu-latest - container: - image: dlwoodruff/c2fcondatest:latest - env: - PATH: /opt/conda/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: make C++ run: | cd cell2fire/Cell2FireC make + - name: install dependencies + run: | + pip install -r requirements.txt - name: setup the program run: | - python setup.py develop + pip install -e . - name: Lint with flake8 run: | diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index abd2ccc6..3b66d640 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -1,6 +1,5 @@ -# dropped the Docker container use (DLW April 2025) name: sub20x20 # Test2_zonghan - +# dropped the Docker container use (DLW April 2025) on: push: From 566f88d184959a362c155327c724389968c289f2 Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Wed, 23 Apr 2025 15:37:16 -0700 Subject: [PATCH 04/18] still working on getting yml to work for sub20x20 to get started --- .github/workflows/sub20x20.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index 3b66d640..f9d64c05 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -3,9 +3,15 @@ name: sub20x20 # Test2_zonghan on: push: - branches: [ main ] + branches: + - main pull_request: - branches: [ main ] + branches: + - main + +defaults: + run: + shell: bash -l {0} jobs: build: @@ -13,6 +19,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test_env + python-version: 3.12 + auto-activate-base: false - name: make C++ run: | From 1f610b762a419e777af06fc640100d9dea6145eb Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Wed, 23 Apr 2025 15:48:18 -0700 Subject: [PATCH 05/18] tried ymallint to get some help --- .github/workflows/sub20x20.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index f9d64c05..1140b030 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -3,15 +3,13 @@ name: sub20x20 # Test2_zonghan on: push: - branches: - - main + branches: [ main ] pull_request: - branches: - - main + branches: [ main ] defaults: - run: - shell: bash -l {0} + run: + shell: bash -l {0} jobs: build: @@ -31,7 +29,7 @@ jobs: make - name: install dependencies run: | - pip install -r requirements.txt + pip install -r requirements.txt - name: setup the program run: | pip install -e . @@ -60,4 +58,3 @@ jobs: ###env_vars: OS,PYTHON name: codecov-umbrella fail_ci_if_error: false - From ebb29e7f9778da257e6f7efecc0038388a462b77 Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Wed, 23 Apr 2025 15:52:01 -0700 Subject: [PATCH 06/18] install boost in yml file --- .../workflows/{fullstat_allplot.yml => fullstat_allplot.lmy} | 0 .github/workflows/sub20x20.yml | 2 ++ 2 files changed, 2 insertions(+) rename .github/workflows/{fullstat_allplot.yml => fullstat_allplot.lmy} (100%) diff --git a/.github/workflows/fullstat_allplot.yml b/.github/workflows/fullstat_allplot.lmy similarity index 100% rename from .github/workflows/fullstat_allplot.yml rename to .github/workflows/fullstat_allplot.lmy diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index 1140b030..9a2d4c56 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -23,6 +23,8 @@ jobs: python-version: 3.12 auto-activate-base: false + - name: Install Boost + run: sudo apt-get update && sudo apt-get install -y libboost-all-dev - name: make C++ run: | cd cell2fire/Cell2FireC From 9ec69caad1e3afba904c4cf5cac3cda343845aef Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Wed, 23 Apr 2025 16:02:33 -0700 Subject: [PATCH 07/18] adding eigen to yml --- .github/workflows/sub20x20.yml | 3 +++ .github/workflows/{testReadme1.yml => testReadme1.lmy} | 0 2 files changed, 3 insertions(+) rename .github/workflows/{testReadme1.yml => testReadme1.lmy} (100%) diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index 9a2d4c56..7817e7e9 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -25,6 +25,9 @@ jobs: - name: Install Boost run: sudo apt-get update && sudo apt-get install -y libboost-all-dev + - name: Install Eigen + run: sudo apt-get update && sudo apt-get install -y libeigen3-dev + - name: make C++ run: | cd cell2fire/Cell2FireC diff --git a/.github/workflows/testReadme1.yml b/.github/workflows/testReadme1.lmy similarity index 100% rename from .github/workflows/testReadme1.yml rename to .github/workflows/testReadme1.lmy From 6f14756ed431f7d9c96e1e3e635356478accb601 Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Wed, 23 Apr 2025 16:05:10 -0700 Subject: [PATCH 08/18] drop a tab from yml --- .github/workflows/sub20x20.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index 7817e7e9..f5b03381 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -3,9 +3,9 @@ name: sub20x20 # Test2_zonghan on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] defaults: run: @@ -27,7 +27,7 @@ jobs: run: sudo apt-get update && sudo apt-get install -y libboost-all-dev - name: Install Eigen run: sudo apt-get update && sudo apt-get install -y libeigen3-dev - + - name: make C++ run: | cd cell2fire/Cell2FireC From a9c2a13824f426d4c5285366a20695fee6c591fb Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Wed, 23 Apr 2025 16:09:17 -0700 Subject: [PATCH 09/18] install flake8 (it was in the docker image) --- .github/workflows/sub20x20.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index f5b03381..9dcab2ca 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -35,6 +35,7 @@ jobs: - name: install dependencies run: | pip install -r requirements.txt + pip install flake8 - name: setup the program run: | pip install -e . From a1975e2514ca36b252a7eca9b46b46d5370b3ecf Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Wed, 23 Apr 2025 16:10:22 -0700 Subject: [PATCH 10/18] remove a tab --- .github/workflows/sub20x20.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index 9dcab2ca..62caf436 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -35,7 +35,7 @@ jobs: - name: install dependencies run: | pip install -r requirements.txt - pip install flake8 + pip install flake8 - name: setup the program run: | pip install -e . From fcdba76c6543f9b43a5441d6374823dcd667fdac Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Wed, 23 Apr 2025 16:18:38 -0700 Subject: [PATCH 11/18] update one more yml file to match the start of sub20x20 --- ...t_randweather.lmy => test_randweather.yml} | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) rename .github/workflows/{test_randweather.lmy => test_randweather.yml} (67%) diff --git a/.github/workflows/test_randweather.lmy b/.github/workflows/test_randweather.yml similarity index 67% rename from .github/workflows/test_randweather.lmy rename to .github/workflows/test_randweather.yml index 989cd94c..3c32eba4 100644 --- a/.github/workflows/test_randweather.lmy +++ b/.github/workflows/test_randweather.yml @@ -1,31 +1,45 @@ name: randweather +# dropped the Docker container use (DLW April 2025) on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] + +defaults: + run: + shell: bash -l {0} jobs: build: - + name: sub20x20 runs-on: ubuntu-latest - container: - image: dlwoodruff/c2fcondatest:latest - env: - PATH: /opt/conda/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test_env + python-version: 3.12 + auto-activate-base: false + + - name: Install Boost + run: sudo apt-get update && sudo apt-get install -y libboost-all-dev + - name: Install Eigen + run: sudo apt-get update && sudo apt-get install -y libeigen3-dev - name: make C++ run: | cd cell2fire/Cell2FireC make + - name: install dependencies + run: | + pip install -r requirements.txt + pip install flake8 - name: setup the program run: | - python setup.py develop - + pip install -e . + - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From a8573f8288b1a077603cf42450c4e773a5d25bbb Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Wed, 23 Apr 2025 16:36:56 -0700 Subject: [PATCH 12/18] install pytest in the yml file and update codecov package to v3 --- .github/workflows/sub20x20.yml | 6 ++++-- .github/workflows/test_randweather.yml | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index 62caf436..7fadaa25 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -15,6 +15,7 @@ jobs: build: name: sub20x20 runs-on: ubuntu-latest + timeout-minutes: 60 steps: - uses: actions/checkout@v3 - uses: conda-incubator/setup-miniconda@v2 @@ -50,14 +51,15 @@ jobs: run: | cd cell2fire python main.py --input-instance-folder ../data/Sub20x20/ --output-folder ../results/Sub20x20 --ignitions --sim-years 1 --nsims 5 --finalGrid --weather rows --nweathers 1 --Fire-Period-Length 1.0 --output-messages --ROS-CV 0.0 --seed 123 --stats --allPlots --IgnitionRad 5 --grids --combine - + - name: Install pytest + run: pip install pytest - name: run tests run: | cd tests pytest test_20x20.py --cov=../cell2fire --cov=./ --cov-report=xml - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: file: ./tests/coverage.xml flags: unittests diff --git a/.github/workflows/test_randweather.yml b/.github/workflows/test_randweather.yml index 3c32eba4..8542fdc1 100644 --- a/.github/workflows/test_randweather.yml +++ b/.github/workflows/test_randweather.yml @@ -13,8 +13,10 @@ defaults: jobs: build: - name: sub20x20 + name: random weather runs-on: ubuntu-latest + timeout-minutes: 60 + steps: - uses: actions/checkout@v3 - uses: conda-incubator/setup-miniconda@v2 @@ -50,14 +52,15 @@ jobs: run: | cd cell2fire python main.py --input-instance-folder ../data/Harvest40x40/ --output-folder ../Harvest40x40 --ignitions --sim-years 2 --nsims 5 --grids --finalGrid --weather random --nweathers 200 --Fire-Period-Length 1.0 --output-messages --ROS-CV 0.8 --seed 123 --stats --allPlots --IgnitionRad 1 --combine --HarvestedCells ../data/Harvest40x40/band1_2.csv - + - name: Install pytest + run: pip install pytest - name: run tests run: | cd tests pytest test_randweather.py --cov=../cell2fire --cov=./ --cov-report=xml - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: file: ./tests/coverage.xml flags: unittests From 0c65c6f767343a3bd2ad5a61049a51557315de84 Mon Sep 17 00:00:00 2001 From: "David L. Woodruff" Date: Thu, 24 Apr 2025 11:12:02 -0700 Subject: [PATCH 13/18] dealing with deprecated np.int --- .../Cell2FireC_class.py | 6 ++--- cell2fire/Cell2FireC_class.py | 6 ++--- cell2fire/utils/Heuristics.py | 22 +++++++++---------- scratch/Cell2FireC_class.py | 6 ++--- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cell2fire/Cell2FireC/parallel_code/Cell2FireParallel/Cell2FirePython_Parallel/Cell2FireC_class.py b/cell2fire/Cell2FireC/parallel_code/Cell2FireParallel/Cell2FirePython_Parallel/Cell2FireC_class.py index c283b263..0d8d611c 100644 --- a/cell2fire/Cell2FireC/parallel_code/Cell2FireParallel/Cell2FirePython_Parallel/Cell2FireC_class.py +++ b/cell2fire/Cell2FireC/parallel_code/Cell2FireParallel/Cell2FirePython_Parallel/Cell2FireC_class.py @@ -308,7 +308,7 @@ def stats(self): print("Generating initial forest plot...") FBPlookup = os.path.join(self.args.InFolder, "fbp_lookup_table.csv") if self.args.HCells is not None: - HCarray = np.loadtxt(self.args.HCells, skiprows=1, delimiter=",")[1:].astype(np.int) + HCarray = np.loadtxt(self.args.HCells, skiprows=1, delimiter=",")[1:].astype(int) print("HCArray:", HCarray) print("GForestN:", self._GForestN) self._GForestN = self._GForestN.flatten() @@ -414,7 +414,7 @@ def stats_Heur(self, OutFolder, HCells=None): print("Generating initial forest plot...") FBPlookup = os.path.join(self.args.InFolder, "fbp_lookup_table.csv") if HCells is not None: - HCarray = np.loadtxt(HCells, skiprows=1, delimiter=",")[1:].astype(np.int) + HCarray = np.loadtxt(HCells, skiprows=1, delimiter=",")[1:].astype(int) self._GForestN = self._GForestN.flatten() for i in HCarray: self._GForestN[i-1] = -1 @@ -622,7 +622,7 @@ def heur(self, AvailCells=set(), BurntCells=set(), HarvestedCells=set()): # Create the aux DF for saving the harvested cells in different files depending on the treated fraction % np.savetxt(os.path.join(csvPath, SelHeur + "_" +str(fr) + ".csv"), - np.asarray([1] + actions).reshape(1, len(actions) + 1).astype(np.int), + np.asarray([1] + actions).reshape(1, len(actions) + 1).astype(int), delimiter=",", fmt="%d", header="Year,HCells", comments='') step += 1 diff --git a/cell2fire/Cell2FireC_class.py b/cell2fire/Cell2FireC_class.py index 02322355..e7b9d3f9 100644 --- a/cell2fire/Cell2FireC_class.py +++ b/cell2fire/Cell2FireC_class.py @@ -305,7 +305,7 @@ def stats(self): print("Generating initial forest plot...") FBPlookup = os.path.join(self.args.InFolder, "fbp_lookup_table.csv") if self.args.HCells is not None: - HCarray = np.loadtxt(self.args.HCells, skiprows=1, delimiter=",")[1:].astype(np.int) + HCarray = np.loadtxt(self.args.HCells, skiprows=1, delimiter=",")[1:].astype(int) print("HCArray:", HCarray) print("GForestN:", self._GForestN) self._GForestN = self._GForestN.flatten() @@ -411,7 +411,7 @@ def stats_Heur(self, OutFolder, HCells=None): print("Generating initial forest plot...") FBPlookup = os.path.join(self.args.InFolder, "fbp_lookup_table.csv") if HCells is not None: - HCarray = np.loadtxt(HCells, skiprows=1, delimiter=",")[1:].astype(np.int) + HCarray = np.loadtxt(HCells, skiprows=1, delimiter=",")[1:].astype(int) self._GForestN = self._GForestN.flatten() for i in HCarray: self._GForestN[i-1] = -1 @@ -619,7 +619,7 @@ def heur(self, AvailCells=set(), BurntCells=set(), HarvestedCells=set()): # Create the aux DF for saving the harvested cells in different files depending on the treated fraction % np.savetxt(os.path.join(csvPath, SelHeur + "_" +str(fr) + ".csv"), - np.asarray([1] + actions).reshape(1, len(actions) + 1).astype(np.int), + np.asarray([1] + actions).reshape(1, len(actions) + 1).astype(int), delimiter=",", fmt="%d", header="Year,HCells", comments='') step += 1 diff --git a/cell2fire/utils/Heuristics.py b/cell2fire/utils/Heuristics.py index cd1d3412..38b8d6f1 100644 --- a/cell2fire/utils/Heuristics.py +++ b/cell2fire/utils/Heuristics.py @@ -67,7 +67,7 @@ def GeneticSel(self, AvailCells, VolCells, Demand, Utility, Year): Given an individual, check the number of adjacent components (in matricial form) """ def adjConstraint(individual): - structure = np.ones((3, 3), dtype=np.int) + structure = np.ones((3, 3), dtype=int) labeled, ncomponents = label(individual, structure) return ncomponents """ @@ -917,8 +917,8 @@ def runHeur(self, AvailCells, Adjacents, VolCells, Demand, Utility, Year): # Update auxiliary sets toHarvestCells = set(idx[:Demand]) - TotalProduction += VolCells[np.asarray(idx[:Demand]).astype(np.int) - 1] - TotalUtility += Utility[np.asarray(idx[:Demand]).astype(np.int) - 1] + TotalProduction += VolCells[np.asarray(idx[:Demand]).astype(int) - 1] + TotalUtility += Utility[np.asarray(idx[:Demand]).astype(int) - 1] if self._verbose: print("Initial values") @@ -1034,8 +1034,8 @@ def runHeur(self, AvailCells, Adjacents, VolCells, Demand, Utility, Year): # Update auxiliary sets toHarvestCells = set(idx[:Demand]) - TotalProduction += VolCells[np.asarray(idx[:Demand]).astype(np.int) - 1] - TotalUtility += Utility[np.asarray(idx[:Demand]).astype(np.int) - 1] + TotalProduction += VolCells[np.asarray(idx[:Demand]).astype(int) - 1] + TotalUtility += Utility[np.asarray(idx[:Demand]).astype(int) - 1] if self._verbose: print("Initial values") @@ -1156,8 +1156,8 @@ def runHeur(self, AvailCells, Adjacents, VolCells, Demand, Utility, Year): # Update auxiliary sets toHarvestCells = set(idx[:Demand]) - TotalProduction += VolCells[np.asarray(idx[:Demand]).astype(np.int) - 1] - TotalUtility += Utility[np.asarray(idx[:Demand]).astype(np.int) - 1] + TotalProduction += VolCells[np.asarray(idx[:Demand]).astype(int) - 1] + TotalUtility += Utility[np.asarray(idx[:Demand]).astype(int) - 1] AvailCells -= set(idx[:Demand]) # Information @@ -1348,8 +1348,8 @@ def runHeur(self, AvailCells, Adjacents, VolCells, Demand, Utility, Year): # Update auxiliary sets toHarvestCells = set(idx[:Demand]) - TotalProduction += VolCells[np.asarray(idx[:Demand]).astype(np.int) - 1] - TotalUtility += Utility[np.asarray(idx[:Demand]).astype(np.int) - 1] + TotalProduction += VolCells[np.asarray(idx[:Demand]).astype(int) - 1] + TotalUtility += Utility[np.asarray(idx[:Demand]).astype(int) - 1] AvailCells -= set(idx[:Demand]) if self._verbose: @@ -1387,8 +1387,8 @@ def runHeur(self, AvailCells, Adjacents, VolCells, Demand, Utility, Year): # Update auxiliary sets toHarvestCells = set(idx[:Demand]) - TotalProduction += VolCells[np.asarray(idx[:Demand]).astype(np.int) - 1] - TotalUtility += Utility[np.asarray(idx[:Demand]).astype(np.int) - 1] + TotalProduction += VolCells[np.asarray(idx[:Demand]).astype(int) - 1] + TotalUtility += Utility[np.asarray(idx[:Demand]).astype(int) - 1] AvailCells -= set(idx[:Demand]) # Information diff --git a/scratch/Cell2FireC_class.py b/scratch/Cell2FireC_class.py index 3908bc16..38848627 100644 --- a/scratch/Cell2FireC_class.py +++ b/scratch/Cell2FireC_class.py @@ -304,7 +304,7 @@ def stats(self): print("Generating initial forest plot...") FBPlookup = os.path.join(self.args.InFolder, "fbp_lookup_table.csv") if self.args.HCells is not None: - HCarray = np.loadtxt(self.args.HCells, skiprows=1, delimiter=",")[1:].astype(np.int) + HCarray = np.loadtxt(self.args.HCells, skiprows=1, delimiter=",")[1:].astype(int) print("HCArray:", HCarray) print("GForestN:", self._GForestN) self._GForestN = self._GForestN.flatten() @@ -410,7 +410,7 @@ def stats_Heur(self, OutFolder, HCells=None): print("Generating initial forest plot...") FBPlookup = os.path.join(self.args.InFolder, "fbp_lookup_table.csv") if HCells is not None: - HCarray = np.loadtxt(HCells, skiprows=1, delimiter=",")[1:].astype(np.int) + HCarray = np.loadtxt(HCells, skiprows=1, delimiter=",")[1:].astype(int) self._GForestN = self._GForestN.flatten() for i in HCarray: self._GForestN[i-1] = -1 @@ -618,7 +618,7 @@ def heur(self, AvailCells=set(), BurntCells=set(), HarvestedCells=set()): # Create the aux DF for saving the harvested cells in different files depending on the treated fraction % np.savetxt(os.path.join(csvPath, SelHeur + "_" +str(fr) + ".csv"), - np.asarray([1] + actions).reshape(1, len(actions) + 1).astype(np.int), + np.asarray([1] + actions).reshape(1, len(actions) + 1).astype(int), delimiter=",", fmt="%d", header="Year,HCells", comments='') step += 1 From 5f598aa26d33a96ad673418f33e2e913147562a0 Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Thu, 24 Apr 2025 13:31:53 -0700 Subject: [PATCH 14/18] drop codecov --- .github/workflows/sub20x20.yml | 12 ++---------- .github/workflows/test_randweather.yml | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index 7fadaa25..5a4b6b07 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -56,13 +56,5 @@ jobs: - name: run tests run: | cd tests - pytest test_20x20.py --cov=../cell2fire --cov=./ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - with: - file: ./tests/coverage.xml - flags: unittests - ###env_vars: OS,PYTHON - name: codecov-umbrella - fail_ci_if_error: false + pytest test_20x20.py + diff --git a/.github/workflows/test_randweather.yml b/.github/workflows/test_randweather.yml index 8542fdc1..7616e0d0 100644 --- a/.github/workflows/test_randweather.yml +++ b/.github/workflows/test_randweather.yml @@ -57,14 +57,6 @@ jobs: - name: run tests run: | cd tests - pytest test_randweather.py --cov=../cell2fire --cov=./ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - with: - file: ./tests/coverage.xml - flags: unittests - ###env_vars: OS,PYTHON - name: codecov-umbrella - fail_ci_if_error: false + pytest test_randweather.py + From a97a04f3486d7f084d9acf629dccabdefc542fac Mon Sep 17 00:00:00 2001 From: "David L. Woodruff" Date: Thu, 24 Apr 2025 15:13:51 -0700 Subject: [PATCH 15/18] trying to get a few more tests updated --- ...{expl_heuristic.lmy => expl_heuristic.yml} | 47 +++++++++++-------- ...lstat_allplot.lmy => fullstat_allplot.yml} | 34 +++++++++----- .../{testReadme1.lmy => testReadme1.yml} | 47 +++++++++++-------- 3 files changed, 75 insertions(+), 53 deletions(-) rename .github/workflows/{expl_heuristic.lmy => expl_heuristic.yml} (59%) rename .github/workflows/{fullstat_allplot.lmy => fullstat_allplot.yml} (68%) rename .github/workflows/{testReadme1.lmy => testReadme1.yml} (58%) diff --git a/.github/workflows/expl_heuristic.lmy b/.github/workflows/expl_heuristic.yml similarity index 59% rename from .github/workflows/expl_heuristic.lmy rename to .github/workflows/expl_heuristic.yml index 725c92ca..2b8f0961 100644 --- a/.github/workflows/expl_heuristic.lmy +++ b/.github/workflows/expl_heuristic.yml @@ -1,30 +1,46 @@ name: expl_heuristic # Kotaro Yama +# dropped the Docker container use (DLW April 2025) + on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] + +defaults: + run: + shell: bash -l {0} jobs: build: - + name: sub20x20 runs-on: ubuntu-latest - container: - image: dlwoodruff/c2fcondatest:latest - env: - PATH: /opt/conda/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - + timeout-minutes: 60 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test_env + python-version: 3.12 + auto-activate-base: false + + - name: Install Boost + run: sudo apt-get update && sudo apt-get install -y libboost-all-dev + - name: Install Eigen + run: sudo apt-get update && sudo apt-get install -y libeigen3-dev - name: make C++ run: | cd cell2fire/Cell2FireC make + - name: install dependencies + run: | + pip install -r requirements.txt + pip install flake8 - name: setup the program run: | - python setup.py develop + pip install -e . - name: Lint with flake8 run: | @@ -40,14 +56,5 @@ jobs: - name: run tests run: | cd tests - pytest expl_heuristic.py --cov=../cell2fire --cov=./ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - file: ./tests/coverage.xml - flags: unittests - ###env_vars: OS,PYTHON - name: codecov-umbrella - fail_ci_if_error: false + pytest expl_heuristic.py diff --git a/.github/workflows/fullstat_allplot.lmy b/.github/workflows/fullstat_allplot.yml similarity index 68% rename from .github/workflows/fullstat_allplot.lmy rename to .github/workflows/fullstat_allplot.yml index 728b4e15..776d77a4 100644 --- a/.github/workflows/fullstat_allplot.lmy +++ b/.github/workflows/fullstat_allplot.yml @@ -3,16 +3,31 @@ name: fullstat_allplot # Kotaro Yama on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] + +defaults: + run: + shell: bash -l {0} jobs: build: name: sub20x20 runs-on: ubuntu-latest + timeout-minutes: 60 steps: - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test_env + python-version: 3.12 + auto-activate-base: false + + - name: Install Boost + run: sudo apt-get update && sudo apt-get install -y libboost-all-dev + - name: Install Eigen + run: sudo apt-get update && sudo apt-get install -y libeigen3-dev - name: make C++ run: | @@ -20,7 +35,8 @@ jobs: make - name: install dependencies run: | - pip install -r requirements.txt + pip install -r requirements.txt + pip install flake8 - name: setup the program run: | pip install -e . @@ -31,6 +47,7 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: create input data run: | cd cell2fire @@ -39,14 +56,5 @@ jobs: - name: run tests run: | cd tests - pytest fullstat_allplot.py --cov=../cell2fire --cov=./ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - file: ./tests/coverage.xml - flags: unittests - ###env_vars: OS,PYTHON - name: codecov-umbrella - fail_ci_if_error: false + pytest fullstat_allplot.py diff --git a/.github/workflows/testReadme1.lmy b/.github/workflows/testReadme1.yml similarity index 58% rename from .github/workflows/testReadme1.lmy rename to .github/workflows/testReadme1.yml index 803a2288..2d5c76e5 100644 --- a/.github/workflows/testReadme1.lmy +++ b/.github/workflows/testReadme1.yml @@ -1,30 +1,45 @@ name: Test First Readme Example +# dropped the Docker container use (DLW April 2025) on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] + +defaults: + run: + shell: bash -l {0} jobs: build: - + name: sub20x20 runs-on: ubuntu-latest - container: - image: dlwoodruff/c2fcondatest:latest - env: - PATH: /opt/conda/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - + timeout-minutes: 60 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test_env + python-version: 3.12 + auto-activate-base: false + + - name: Install Boost + run: sudo apt-get update && sudo apt-get install -y libboost-all-dev + - name: Install Eigen + run: sudo apt-get update && sudo apt-get install -y libeigen3-dev - name: make C++ run: | cd cell2fire/Cell2FireC make + - name: install dependencies + run: | + pip install -r requirements.txt + pip install flake8 - name: setup the program run: | - python setup.py develop + pip install -e . - name: Lint with flake8 run: | @@ -40,14 +55,6 @@ jobs: - name: run tests run: | cd tests - pytest test_doccmd1.py --cov=../cell2fire --cov=./ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - file: ./tests/coverage.xml - flags: unittests - ###env_vars: OS,PYTHON - name: codecov-umbrella - fail_ci_if_error: false + pytest test_doccmd1.py + From cadf1900118680cc0a31a15b5011bca814c00992 Mon Sep 17 00:00:00 2001 From: "David L. Woodruff" Date: Thu, 24 Apr 2025 16:17:50 -0700 Subject: [PATCH 16/18] try to modernize all tests yml --- .github/workflows/expl_heuristic.yml | 4 +- .github/workflows/fullstat_allplot.yml | 4 +- .github/workflows/sub20x20.yml | 1 + .github/workflows/testReadme1.yml | 4 +- .github/workflows/test_datagenerator.lmy | 49 ---------------- .github/workflows/test_datagenerator.yml | 57 ++++++++++++++++++ .../{test_dogrib.lmy => test_dogrib.yml} | 50 +++++++++------- .../workflows/{test_h1.lmy => test_h1.yml} | 48 ++++++++------- .../workflows/{test_h2.lmy => test_h2.yml} | 49 +++++++++------- .../workflows/{test_h3.lmy => test_h3.yml} | 50 +++++++++------- .github/workflows/test_readspot.lmy | 49 ---------------- .github/workflows/test_readspot.yml | 58 +++++++++++++++++++ 12 files changed, 240 insertions(+), 183 deletions(-) delete mode 100644 .github/workflows/test_datagenerator.lmy create mode 100644 .github/workflows/test_datagenerator.yml rename .github/workflows/{test_dogrib.lmy => test_dogrib.yml} (56%) rename .github/workflows/{test_h1.lmy => test_h1.yml} (57%) rename .github/workflows/{test_h2.lmy => test_h2.yml} (58%) rename .github/workflows/{test_h3.lmy => test_h3.yml} (58%) delete mode 100644 .github/workflows/test_readspot.lmy create mode 100644 .github/workflows/test_readspot.yml diff --git a/.github/workflows/expl_heuristic.yml b/.github/workflows/expl_heuristic.yml index 2b8f0961..7dddc5f1 100644 --- a/.github/workflows/expl_heuristic.yml +++ b/.github/workflows/expl_heuristic.yml @@ -14,7 +14,7 @@ defaults: jobs: build: - name: sub20x20 + name: expl_heuristic runs-on: ubuntu-latest timeout-minutes: 60 steps: @@ -52,6 +52,8 @@ jobs: run: | cd cell2fire python main.py --input-instance-folder ../data/Sub40x40/ --output-folder ../Results/Sub40_n5cv1 --ignitions --sim-years 1 --nsims 5 --grids --finalGrid --weather rows --nweathers 129 --Fire-Period-Length 1.0 --output-messages --ROS-CV 1.0 --seed 123 --IgnitionRad 0 --stats --spreadPlots --heuristic -1 + - name: Install pytest + run: pip install pytest - name: run tests run: | diff --git a/.github/workflows/fullstat_allplot.yml b/.github/workflows/fullstat_allplot.yml index 776d77a4..7f6c4720 100644 --- a/.github/workflows/fullstat_allplot.yml +++ b/.github/workflows/fullstat_allplot.yml @@ -13,7 +13,7 @@ defaults: jobs: build: - name: sub20x20 + name: fullStatAllPlot runs-on: ubuntu-latest timeout-minutes: 60 steps: @@ -52,6 +52,8 @@ jobs: run: | cd cell2fire python main.py --input-instance-folder ../data/dogrib/ --output-folder ../results/dogrib_n100cv05 --ignitions --sim-years 1 --nsims 3 --grids --finalGrid --weather rows --nweathers 1 --Fire-Period-Length 1.0 --output-messages --ROS-CV 0.5 --seed 123 --IgnitionRad 0 --stats --allPlots + - name: Install pytest + run: pip install pytest - name: run tests run: | diff --git a/.github/workflows/sub20x20.yml b/.github/workflows/sub20x20.yml index 5a4b6b07..45277503 100644 --- a/.github/workflows/sub20x20.yml +++ b/.github/workflows/sub20x20.yml @@ -51,6 +51,7 @@ jobs: run: | cd cell2fire python main.py --input-instance-folder ../data/Sub20x20/ --output-folder ../results/Sub20x20 --ignitions --sim-years 1 --nsims 5 --finalGrid --weather rows --nweathers 1 --Fire-Period-Length 1.0 --output-messages --ROS-CV 0.0 --seed 123 --stats --allPlots --IgnitionRad 5 --grids --combine + - name: Install pytest run: pip install pytest - name: run tests diff --git a/.github/workflows/testReadme1.yml b/.github/workflows/testReadme1.yml index 2d5c76e5..27eade58 100644 --- a/.github/workflows/testReadme1.yml +++ b/.github/workflows/testReadme1.yml @@ -13,7 +13,7 @@ defaults: jobs: build: - name: sub20x20 + name: readme1 runs-on: ubuntu-latest timeout-minutes: 60 steps: @@ -51,6 +51,8 @@ jobs: run: | cd cell2fire python main.py --input-instance-folder ../data/Sub40x40/ --output-folder ../results/Sub40x40 --ignitions --sim-years 1 --nsims 5 --finalGrid --weather rows --nweathers 1 --Fire-Period-Length 1.0 --output-messages --ROS-CV 0.0 --seed 123 --stats --allPlots --IgnitionRad 5 --grids --combine + - name: Install pytest + run: pip install pytest - name: run tests run: | diff --git a/.github/workflows/test_datagenerator.lmy b/.github/workflows/test_datagenerator.lmy deleted file mode 100644 index 554b6085..00000000 --- a/.github/workflows/test_datagenerator.lmy +++ /dev/null @@ -1,49 +0,0 @@ -name: test_datagenerator - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - container: - image: dlwoodruff/c2fcondatest:latest - env: - PATH: /opt/conda/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - - steps: - - uses: actions/checkout@v2 - - - name: make C++ - run: | - cd cell2fire/Cell2FireC - make - - name: setup the program - run: | - python setup.py develop - - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - - name: run tests - run: | - cd tests - pytest test_datagenentor.py --cov=../cell2fire --cov=./ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - file: ./tests/coverage.xml - flags: unittests - ###env_vars: OS,PYTHON - name: codecov-umbrella - fail_ci_if_error: false - diff --git a/.github/workflows/test_datagenerator.yml b/.github/workflows/test_datagenerator.yml new file mode 100644 index 00000000..f3cc420f --- /dev/null +++ b/.github/workflows/test_datagenerator.yml @@ -0,0 +1,57 @@ +name: test_datagenerator + +on: + push: + branches: [main] + pull_request: + branches: [main] + +defaults: + run: + shell: bash -l {0} + +jobs: + build: + name: test_datagenerator + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test_env + python-version: 3.12 + auto-activate-base: false + + - name: Install Boost + run: sudo apt-get update && sudo apt-get install -y libboost-all-dev + - name: Install Eigen + run: sudo apt-get update && sudo apt-get install -y libeigen3-dev + + - name: make C++ + run: | + cd cell2fire/Cell2FireC + make + - name: install dependencies + run: | + pip install -r requirements.txt + pip install flake8 + - name: setup the program + run: | + pip install -e . + + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Install pytest + run: pip install pytest + + - name: run tests + run: | + cd tests + pytest test_datagenentor.py + + diff --git a/.github/workflows/test_dogrib.lmy b/.github/workflows/test_dogrib.yml similarity index 56% rename from .github/workflows/test_dogrib.lmy rename to .github/workflows/test_dogrib.yml index 8d1acfe6..5330977d 100644 --- a/.github/workflows/test_dogrib.lmy +++ b/.github/workflows/test_dogrib.yml @@ -1,30 +1,45 @@ name: dogrib +# dropped the Docker container use (DLW April 2025) on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] + +defaults: + run: + shell: bash -l {0} jobs: build: - + name: test_dogrib runs-on: ubuntu-latest - container: - image: dlwoodruff/c2fcondatest:latest - env: - PATH: /opt/conda/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - + timeout-minutes: 60 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test_env + python-version: 3.12 + auto-activate-base: false + + - name: Install Boost + run: sudo apt-get update && sudo apt-get install -y libboost-all-dev + - name: Install Eigen + run: sudo apt-get update && sudo apt-get install -y libeigen3-dev - name: make C++ run: | cd cell2fire/Cell2FireC make + - name: install dependencies + run: | + pip install -r requirements.txt + pip install flake8 - name: setup the program run: | - python setup.py develop + pip install -e . - name: Lint with flake8 run: | @@ -32,22 +47,15 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: create input data run: | cd cell2fire python main.py --input-instance-folder ../data/dogrib/ --output-folder ../results/dogrib/ --ignitions --sim-years 1 --nsims 1 --finalGrid --weather rows --nweathers 1 --Fire-Period-Length 1.0 --output-messages --ROS-CV 0.0 --seed 123 --stats --allPlots --IgnitionRad 5 --grids --combine + - name: Install pytest + run: pip install pytest - name: run tests run: | cd tests - pytest test_dogrib.py --cov=../cell2fire --cov=./ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - file: ./tests/coverage.xml - flags: unittests - ###env_vars: OS,PYTHON - name: codecov-umbrella - fail_ci_if_error: false - + pytest test_dogrib.py diff --git a/.github/workflows/test_h1.lmy b/.github/workflows/test_h1.yml similarity index 57% rename from .github/workflows/test_h1.lmy rename to .github/workflows/test_h1.yml index 045922ca..0c1d6a44 100644 --- a/.github/workflows/test_h1.lmy +++ b/.github/workflows/test_h1.yml @@ -1,30 +1,45 @@ name: test_h1 # Kotaro Yama +# dropped the Docker container use (DLW April 2025) on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] + +defaults: + run: + shell: bash -l {0} jobs: build: - + name: test_h1 runs-on: ubuntu-latest - container: - image: dlwoodruff/c2fcondatest:latest - env: - PATH: /opt/conda/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - + timeout-minutes: 60 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test_env + python-version: 3.12 + auto-activate-base: false + + - name: Install Boost + run: sudo apt-get update && sudo apt-get install -y libboost-all-dev + - name: Install Eigen + run: sudo apt-get update && sudo apt-get install -y libeigen3-dev - name: make C++ run: | cd cell2fire/Cell2FireC make + - name: install dependencies + run: | + pip install -r requirements.txt + pip install flake8 - name: setup the program run: | - python setup.py develop + pip install -e . - name: Lint with flake8 run: | @@ -37,17 +52,10 @@ jobs: cd cell2fire python main.py --input-instance-folder ../data/Sub20x20/ --output-folder ../results/Sub20x20/Sub20_RW_RI_N10 --sim-years 2 --nsims 10 --finalGrid --weather random --nweathers 100 --Fire-Period-Length 1.0 --ROS-CV 0.0 --seed 123 --IgnitionRad 0 --stats --output-messages --ROS-Threshold 0 --HFI-Threshold 0 --heuristic 1 + - name: Install pytest + run: pip install pytest - name: run tests run: | cd tests - pytest test_h1.py --cov=../cell2fire --cov=./ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - file: ./tests/coverage.xml - flags: unittests - ###env_vars: OS,PYTHON - name: codecov-umbrella - fail_ci_if_error: false + pytest test_h1.py diff --git a/.github/workflows/test_h2.lmy b/.github/workflows/test_h2.yml similarity index 58% rename from .github/workflows/test_h2.lmy rename to .github/workflows/test_h2.yml index c24f13ee..f6130f0c 100644 --- a/.github/workflows/test_h2.lmy +++ b/.github/workflows/test_h2.yml @@ -1,30 +1,45 @@ name: test_h2 # Kotaro Yama +# dropped the Docker container use (DLW April 2025) on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] + +defaults: + run: + shell: bash -l {0} jobs: build: - + name: test_h2 runs-on: ubuntu-latest - container: - image: dlwoodruff/c2fcondatest:latest - env: - PATH: /opt/conda/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - + timeout-minutes: 60 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test_env + python-version: 3.12 + auto-activate-base: false + + - name: Install Boost + run: sudo apt-get update && sudo apt-get install -y libboost-all-dev + - name: Install Eigen + run: sudo apt-get update && sudo apt-get install -y libeigen3-dev - name: make C++ run: | cd cell2fire/Cell2FireC make + - name: install dependencies + run: | + pip install -r requirements.txt + pip install flake8 - name: setup the program run: | - python setup.py develop + pip install -e . - name: Lint with flake8 run: | @@ -32,22 +47,16 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: create input data run: | cd cell2fire python main.py --input-instance-folder ../data/Sub40x40/ --output-folder ../results/Sub40x40 --sim-years 2 --nsims 10 --finalGrid --weather random --nweathers 100 --Fire-Period-Length 1.0 --ROS-CV 0.0 --seed 123 --IgnitionRad 0 --stats --output-messages --ROS-Threshold 0 --HFI-Threshold 0 --heuristic 2 --customValue="../data/Sub40x40/values40x40.csv" + - name: Install pytest + run: pip install pytest - name: run tests run: | cd tests - pytest test_h2.py --cov=../cell2fire --cov=./ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - file: ./tests/coverage.xml - flags: unittests - ###env_vars: OS,PYTHON - name: codecov-umbrella - fail_ci_if_error: false + pytest test_h2.py diff --git a/.github/workflows/test_h3.lmy b/.github/workflows/test_h3.yml similarity index 58% rename from .github/workflows/test_h3.lmy rename to .github/workflows/test_h3.yml index aa80dd02..ddea068c 100644 --- a/.github/workflows/test_h3.lmy +++ b/.github/workflows/test_h3.yml @@ -1,30 +1,45 @@ name: test_h3 # Kotaro Yama +# dropped the Docker container use (DLW April 2025) on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] + +defaults: + run: + shell: bash -l {0} jobs: build: - + name: test_h3 runs-on: ubuntu-latest - container: - image: dlwoodruff/c2fcondatest:latest - env: - PATH: /opt/conda/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - + timeout-minutes: 60 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test_env + python-version: 3.12 + auto-activate-base: false + + - name: Install Boost + run: sudo apt-get update && sudo apt-get install -y libboost-all-dev + - name: Install Eigen + run: sudo apt-get update && sudo apt-get install -y libeigen3-dev - name: make C++ run: | cd cell2fire/Cell2FireC make + - name: install dependencies + run: | + pip install -r requirements.txt + pip install flake8 - name: setup the program run: | - python setup.py develop + pip install -e . - name: Lint with flake8 run: | @@ -32,22 +47,15 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: create input data run: | cd cell2fire python main.py --input-instance-folder ../data/Sub40x40/ --output-folder ../results/Sub40x40 --sim-years 2 --nsims 10 --finalGrid --weather random --nweathers 100 --Fire-Period-Length 1.0 --ROS-CV 0.0 --seed 123 --IgnitionRad 0 --stats --output-messages --ROS-Threshold 0 --HFI-Threshold 0 --heuristic 3 --customValue="../data/Sub40x40/values40x40.csv" + - name: Install pytest + run: pip install pytest - name: run tests run: | cd tests - pytest test_h3.py --cov=../cell2fire --cov=./ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - file: ./tests/coverage.xml - flags: unittests - ###env_vars: OS,PYTHON - name: codecov-umbrella - fail_ci_if_error: false - + pytest test_h3.py diff --git a/.github/workflows/test_readspot.lmy b/.github/workflows/test_readspot.lmy deleted file mode 100644 index 9d53d66e..00000000 --- a/.github/workflows/test_readspot.lmy +++ /dev/null @@ -1,49 +0,0 @@ -name: test_readspot - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - container: - image: dlwoodruff/c2fcondatest:latest - env: - PATH: /opt/conda/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - - steps: - - uses: actions/checkout@v2 - - - name: make C++ - run: | - cd cell2fire/Cell2FireC - make - - name: setup the program - run: | - python setup.py develop - - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - - name: run tests - run: | - cd tests/test_readspot - pytest test_readspot.py --cov=../../cell2fire --cov=../ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - file: ./tests/test_readspot/coverage.xml - flags: unittests - ###env_vars: OS,PYTHON - name: codecov-umbrella - fail_ci_if_error: false - diff --git a/.github/workflows/test_readspot.yml b/.github/workflows/test_readspot.yml new file mode 100644 index 00000000..4bba6513 --- /dev/null +++ b/.github/workflows/test_readspot.yml @@ -0,0 +1,58 @@ +name: test_readspot +# dropped the Docker container use (DLW April 2025) + +on: + push: + branches: [main] + pull_request: + branches: [main] + +defaults: + run: + shell: bash -l {0} + +jobs: + build: + name: test_readspot + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test_env + python-version: 3.12 + auto-activate-base: false + + - name: Install Boost + run: sudo apt-get update && sudo apt-get install -y libboost-all-dev + - name: Install Eigen + run: sudo apt-get update && sudo apt-get install -y libeigen3-dev + + - name: make C++ + run: | + cd cell2fire/Cell2FireC + make + - name: install dependencies + run: | + pip install -r requirements.txt + pip install flake8 + - name: setup the program + run: | + pip install -e . + + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Install pytest + run: pip install pytest + - name: run tests + run: | + cd tests/test_readspot + pytest test_readspot.py + + From c54e8b46af8454353b05f1f6fc3d650ca367c1f9 Mon Sep 17 00:00:00 2001 From: "David L. Woodruff" Date: Thu, 24 Apr 2025 18:00:28 -0700 Subject: [PATCH 17/18] have some tough graphics issues to work on... --- cell2fire/utils/Heuristics.py | 7 +++++-- cell2fire/utils/Stats.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cell2fire/utils/Heuristics.py b/cell2fire/utils/Heuristics.py index 38b8d6f1..7f34adee 100644 --- a/cell2fire/utils/Heuristics.py +++ b/cell2fire/utils/Heuristics.py @@ -28,7 +28,7 @@ # Genetic algorithm from deap import algorithms, base, creator, tools -from scipy.ndimage.measurements import label +from scipy.ndimage import label # Genetic selection object class GenHeur(object): @@ -1556,8 +1556,11 @@ def Global_FPVPlot(self, normalized=False, xticks=50, yticks=50): for _, spine in ax.spines.items():spine.set_visible(True) # Save + # savefig calls used to have figsize=(200, 200), (april 2025) + plt.figure(figsize=(200,200)) + plt.savefig(os.path.join(self._OutFolder, "Global_FPV_Graph_Normalized_v" + str(self._version)+ ".png"), - dpi=200, figsize=(200, 200), + dpi=200, bbox_inches='tight', transparent=False) plt.close("all") diff --git a/cell2fire/utils/Stats.py b/cell2fire/utils/Stats.py index f86b45bc..96142573 100644 --- a/cell2fire/utils/Stats.py +++ b/cell2fire/utils/Stats.py @@ -165,7 +165,7 @@ def BoxPlot(self, Data, xx="Hour", yy="Burned", xlab="Hours", ylab="# Burned Cel plt.title(title) #sns.set(style="darkgrid", font_scale=1.5) - ax = sns.boxplot(x=xx, y=yy, data=Data, linewidth=2.5, palette=pal).set(xlabel=xlab,ylabel=ylab) + ax = sns.boxplot(x=xx, y=yy, hue=xx, data=Data, linewidth=2.5, palette=pal, legend=False).set(xlabel=xlab, ylabel=ylab) if swarm: ax = sns.swarmplot(x=xx, y=yy, data=Data, linewidth=2.5, palette=pal).set(xlabel=xlab,ylabel=ylab) @@ -288,7 +288,7 @@ def BPHeatmap(self, WeightedScar, Path=None, nscen=10, sq=False, namePlot="BP_He plt.title(Title) # Modify existing map to have white values - cmap = cm.get_cmap('RdBu_r') + cmap = matplotlib.colormaps['RdBu_r'] lower = plt.cm.seismic(np.ones(1)*0.50) # Original is ones upper = cmap(np.linspace(0.5, 1, 100)) colors = np.vstack((lower,upper)) From a9a7f202b84516badfa0dd61b64a1b8e78188ed0 Mon Sep 17 00:00:00 2001 From: Dave Woodruff Date: Fri, 25 Apr 2025 09:51:34 -0700 Subject: [PATCH 18/18] trying to simply remove the plotsize argument from savefig call (also resurrected two figure initializations with plotsize arguments) --- cell2fire/utils/Heuristics.py | 8 ++++---- cell2fire/utils/Plot.py | 10 +++++++--- cell2fire/utils/Stats.py | 7 ++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cell2fire/utils/Heuristics.py b/cell2fire/utils/Heuristics.py index 7f34adee..970fcf7b 100644 --- a/cell2fire/utils/Heuristics.py +++ b/cell2fire/utils/Heuristics.py @@ -1557,8 +1557,6 @@ def Global_FPVPlot(self, normalized=False, xticks=50, yticks=50): # Save # savefig calls used to have figsize=(200, 200), (april 2025) - plt.figure(figsize=(200,200)) - plt.savefig(os.path.join(self._OutFolder, "Global_FPV_Graph_Normalized_v" + str(self._version)+ ".png"), dpi=200, bbox_inches='tight', transparent=False) @@ -1587,8 +1585,9 @@ def Global_FPVPlot(self, normalized=False, xticks=50, yticks=50): plt.colorbar(sm, cax=cax) # Save it to Heuristic folder + # removed figsize=(200, 200), April 2025 plt.savefig(os.path.join(self._OutFolder, "Global_FPV_Graph_v" + str(self._version)+ ".png"), - dpi=200, figsize=(200, 200), + dpi=200, bbox_inches='tight', transparent=False) plt.close("all") @@ -1638,9 +1637,10 @@ def Ind_FPVPlot(self, nSim, FPVMatrix, normalized=False): vmin=0, vmax=np.max((FPVMatrix))) # Save it to plots folder + # removed figsize=(200, 200) from savefig April 2025 plt.savefig(os.path.join(self._OutFolder, "Plots", "Plots" + str(nSim), "FPV_Graph" + str(nSim) + ".png"), - dpi=200, figsize=(200, 200), + dpi=200, bbox_inches='tight', transparent=False) plt.close("all") diff --git a/cell2fire/utils/Plot.py b/cell2fire/utils/Plot.py index 88018bfc..31139b1d 100644 --- a/cell2fire/utils/Plot.py +++ b/cell2fire/utils/Plot.py @@ -300,7 +300,8 @@ def forest_plotV3(self,Cells_Obj,msg_list,counter,period,Year,showtrue,r,col,Fol PathFile = os.path.join(Folder,"forest"+fstr+".png") #Save the file - plt.savefig(PathFile, dpi=200, figsize=(200, 200), bbox_inches='tight', transparent=True) + # removed figsize=(200, 200), April 2025 + plt.savefig(PathFile, dpi=200, bbox_inches='tight', transparent=True) plt.close("all") if showtrue == True: @@ -486,7 +487,9 @@ def forest_plotV3_Operational(self, Cells_Obj, msg_list, counter, period,Year, PathFile = os.path.join(Folder,"forest"+fstr+".png") #Save the file - plt.savefig(PathFile, dpi=200, figsize=(200, 200), bbox_inches='tight', transparent=True) + # removed figsize=(200, 200), April 2025 + + plt.savefig(PathFile, dpi=200, bbox_inches='tight', transparent=True) plt.close("all") if showtrue == True: @@ -670,7 +673,8 @@ def forest_plotV3_FreeMem(self, Cells_Obj, msg_list, counter, period, Year, show PathFile = os.path.join(Folder,"forest"+fstr+".png") #Save the file - plt.savefig(PathFile, dpi=200, figsize=(200, 200), bbox_inches='tight', transparent=True) + # removed figsize=(200, 200), April 2025 + plt.savefig(PathFile, dpi=200, bbox_inches='tight', transparent=True) plt.close("all") if showtrue == True: diff --git a/cell2fire/utils/Stats.py b/cell2fire/utils/Stats.py index 96142573..f0998999 100644 --- a/cell2fire/utils/Stats.py +++ b/cell2fire/utils/Stats.py @@ -604,7 +604,6 @@ def GlobalFireSpreadEvo(self, CoordCells, onlyGraph=True, version=0): cax1 = divider.append_axes("right", size="5%", pad=0.15) plt.colorbar(sm, cax=cax1) # both savefig calls used to have figsize=(200, 200), (april 2025) - plt.figure(figsize=(200,200)) plt.savefig(os.path.join(self._StatsFolder, "SpreadTree_FreqGraph_" + outname + ".png"), dpi=200, bbox_inches='tight', transparent=False) @@ -639,7 +638,7 @@ def SimFireSpreadEvo(self, nSim, CoordCells, Colors, H=None, version=0, # We generate the plot if print_graph: - # plt.figure(figsize = (15, 9)) + plt.figure(figsize = (15, 9)) # ??? consider removing (April 2025) # Font sizes plt.rcParams['font.size'] = 16 @@ -683,7 +682,6 @@ def SimFireSpreadEvo(self, nSim, CoordCells, Colors, H=None, version=0, if os.path.isdir(PlotPath) is False: os.makedirs(PlotPath) # both savefig calls used to have figsize=(200, 200), (April 2025) - plt.figure(figsize=(200,200)) plt.savefig(os.path.join(PlotPath, "PropagationTree" + str(nSim) +".png"), dpi=200, edgecolor='b', bbox_inches='tight', transparent=False) @@ -747,7 +745,7 @@ def SimFireSpreadEvoV2(self, nSim, CoordCells, Colors, H=None, version=0, onlyGr node_shape='s', node_color = Colors) - # plt.figure(figsize = (15, 9)) + plt.figure(figsize = (15, 9)) # consider removing (April 2025) # Font sizes plt.rcParams['font.size'] = 16 @@ -827,7 +825,6 @@ def SimFireSpreadEvoV2(self, nSim, CoordCells, Colors, H=None, version=0, onlyGr cax1 = divider.append_axes("right", size="5%", pad=0.05) plt.colorbar(sm, cax=cax1) # both savefig calls used to have figsize=(200, 200), (April 2025) - plt.figure(figsize=(200,200)) plt.savefig(os.path.join(PlotPath, "FireSpreadTree" + str(nSim) + "_" + str(version) + ".png"), dpi=200, bbox_inches='tight', transparent=False)