Describe the bug
This is a continuation of Issue #18 submitted by @mathfire, which was caused by the PyVistaQF script requiring an old version of pyVista. As per @amarcozzi, these issues can be resolved by using the conda/pip requirements in the QF distribution (found in dep/python3_requirements), but those requirements will only work in a narrow range of Python versions (e.g. 3.8.16). However, I found that a relatively limited number of changes can be made to the code so that the script will work with newer versions of Python and pyVista, which may eliminate the need for a separate environment just to run the script.
Relevant package versions in requirements:
pyvista==0.31.3
numpy==1.18.1
(Python==3.8.16)
Package version in my current evironment:
pyvista==0.41.1
numpy==1.23.5
(Python==3.10.9)
My goal is to document the changes I made so that the PyVistaQF.py script is compatible with these newer versions to hopefully take away some versioning headaches. I will group the "bugs" into 3 categories: pyvista updates, numpy updates, and true bugs in the code. If I find any more I will add to this issue.
To Reproduce
Run PyVistaQF.py with PyVistaQF_example.inp. Both can be found in QF_5.2.3/scripts/postprocessing/python3. The QF run I am using can be found here (request access if outside NMC).
Desktop
QF Version: QFVD 5.2.3
OS: Mac
Hardware SPECs: Most likely not applicable, but I am using my NMC Mac, which has ARM
Updates and fixes
PyVista Updates
Issue: point_arrays is no longer an attribute of a pyvista.StructuredGrid object
@ntutland thank you for the detailed explanations. All of your comments have been included into the new PyVista with the option of using python 3.8 or 3.10.
Describe the bug This is a continuation of Issue #18 submitted by @mathfire, which was caused by the PyVistaQF script requiring an old version of pyVista. As per @amarcozzi, these issues can be resolved by using the conda/pip requirements in the QF distribution (found in dep/python3_requirements), but those requirements will only work in a narrow range of Python versions (e.g. 3.8.16). However, I found that a relatively limited number of changes can be made to the code so that the script will work with newer versions of Python and pyVista, which may eliminate the need for a separate environment just to run the script.
Relevant package versions in requirements: pyvista==0.31.3 numpy==1.18.1 (Python==3.8.16)
Package version in my current evironment: pyvista==0.41.1 numpy==1.23.5 (Python==3.10.9)
My goal is to document the changes I made so that the PyVistaQF.py script is compatible with these newer versions to hopefully take away some versioning headaches. I will group the "bugs" into 3 categories: pyvista updates, numpy updates, and true bugs in the code. If I find any more I will add to this issue.
To Reproduce Run PyVistaQF.py with PyVistaQF_example.inp. Both can be found in QF_5.2.3/scripts/postprocessing/python3. The QF run I am using can be found here (request access if outside NMC).
Desktop
Updates and fixes
PyVista Updates
Issue:
point_arrays
is no longer an attribute of apyvista.StructuredGrid
objectpoint_arrays
withpoint_data
terrain_top.point_arrays['heights'] = terrain_top.points[:, 2]
-->terrain_top.point_data['heights'] = terrain_top.points[:, 2]
Issue:
cell_arrays
is no longer an attribute of apyvista.UnstructuredGrid
objectcell_arrays
withcell_data
fuel_dens["CANOPY_GRID"].cell_arrays['Fuel Density'] = ftemp[1:, :, :].flatten(order='F')
-->fuel_dens["CANOPY_GRID"].cell_data['Fuel Density'] = ftemp[1:, :, :].flatten(order='F')
Issue:
xlabel
,ylabel
, andzlabel
are deprecated (throws a warning, not an error)xtitle
,ytitle
, andztitle
, respectivelyplotter.show_grid(font_size=fontsize, xlabel='X [m]', ylabel='Y [m]', zlabel='Z [m]')
-->plotter.show_grid(font_size=fontsize, xtitle='X [m]', ytitle='Y [m]', ztitle='Z [m]')
Numpy updates
The following do not result in errors, but are deprecated and result in lots of annoying warnings
np.int
andnp.float
are deprecatedint
andfloat
, respectively. (OR replace with np.int64/np.float64 or np.int32/np.float32 if desired)nslices = np.int(plot_params['NSLICES'])
-->nslices = int(plot_params['NSLICES'])
True bug fixes
I noticed these when I changed the fireTracking flag in the input file to 1.
Issue:
fuel_dens
dictionary has no key 'VAL'.if fuel_dens['VAL'][it][kk, jj, ii] > 0.0:
-->if fuel_dens['DATA'][it][kk, jj, ii] > 0.0:
Issue: trackingOffset expects values in input string to be separated by spaces
tracking_offset = tracking_offset.split(", ", 2)
-->tracking_offset = tracking_offset.split(",", 2)
Updated Script
I will keep an up-to-date version of the script with my fixes here (request permission if outside NMC).