inr-kit / tovtk

Python meshtal -> VTK converter
GNU General Public License v3.0
1 stars 4 forks source link

Missing parentheses in call to 'print'. #1

Open thomsonm1230 opened 2 months ago

thomsonm1230 commented 2 months ago

(base) [mt1@feahn01 run03-mcnp-6.2.0]$ python -m tovtk meshtal Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/home/mt1/Scripts/tovtk-git/tovtk/main.py", line 1, in from .main import main File "/home/mt1/Scripts/tovtk-git/tovtk/main.py", line 148 print normalization_note.format(c1, c2) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)? (base) [mt1@feahn01 run03-mcnp-6.2.0]$

travleev commented 2 months ago

Hello, thank you for the comment.

Originally, tovtk was written for Python-2 and than later updated to Python-3, see py3 branch. At that time Python-3 was not yet the standard, thus the update was not merged to the main branch.

If you installed tovtk following installation instructions in README.md, do the following to get the Python-3 version:

>cd tovtk-git
>git checkout py3

Please report here whether this works for you.

thomsonm1230 commented 2 months ago

Thanks for the response. Installing the py3 branch did overcome that issue, however it raised another error:

    (base) [mt1@feahn01 run03-mcnp-6.2.0]$ python -m tovtk meshtal

    Normalization constants not applied, generated vtk files contain data
    exactly as in meshtal files. For ITER applications, normalization constants
    for flux [1/cm2s] and heat [W/cm3]:

    Ch =       3.156767e+06
    Cf =       1.970295e+19

    To normalize tallies in Paraview, use Programmable filter. For example, to
    compute total heating from the neutron and photon components:

    v1 = inputs[0].CellData['val']
    v2 = inputs[1].CellData['val']

    output.CellData.append((v1 + v2)*Ch, 'Total heating')

    Reading meshtal ... complete
    Number of energy bins: 1
    Number of x bins: 269
    Number of y bins: 225
    Number of z bins: 269
    Number of values: 16281225
    Traceback (most recent call last):
    File "<frozen runpy>", line 198, in _run_module_as_main
    File "<frozen runpy>", line 88, in _run_code
    File "/home/mt1/Scripts/tovtk-py3/tovtk-py3/tovtk/__main__.py", line 3, in <module>
    main()
    File "/home/mt1/Scripts/tovtk-py3/tovtk-py3/tovtk/main.py", line 209, in main
    ws = rectangular(fname, x, y, z, rvals, errs=rerrs, descr=descr)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/mt1/Scripts/tovtk-py3/tovtk-py3/tovtk/main.py", line 134, in rectangular
    writer.SetInput(grid)
    ^^^^^^^^^^^^^^^
    AttributeError: 'vtkmodules.vtkIOXML.vtkXMLRectilinearGridWriter' object has no attribute 'SetInput'. Did you mean: 'GetInput'?

I already had vtk version 9.3.1 installed, could that be the issue?

travleev commented 2 months ago

Thanks!

The latter error is due to a bug in checking the vtk version. I cannot currently push to this repository, so I will later create a seprarate issue for this bug. For now, to get rid of the error, simply add "9" to the string on line 130 of tovtk/main.py. E.g., instead of

    if _vtkVersion[0] in '68':

it should read

    if _vtkVersion[0] in '689':

Hope this helps.