PrincetonUniversity / athena

Athena++ radiation GRMHD code and adaptive mesh refinement (AMR) framework
https://www.athena-astro.app
BSD 3-Clause "New" or "Revised" License
240 stars 128 forks source link

plot_mesh.py is undocumented in Wiki and might not show plot #204

Open felker opened 5 years ago

felker commented 5 years ago

Summary of issue

vis/python/plot_mesh.py was first added to the repository by @jmstone in 0a10fa8a53e115032013a2dc5d2e4775b89d998c on 2016-04-14 and later generalized to accept -i, -o flags by @c-white in 8b0d5f5423284d9a4e470c753e8aa113e1012dd7 on 2017-11-03.

The only page in the Wiki that mentions it is the Tutorial page SMR and AMR. Even there, it only tangentially appears in the example output of the ./athena -m 1 command, while the actual tutorial text instructs the user to use gnuplot to view the SMR mesh structure.

At a minimum, I feel like it should be documented in Plotting Scripts like plot_lines.py, plot_slice.py, plot_spherical.py. And/or it should be removed from being mentioned in the stdout output of Mesh::OutputMeshStructure(int dim): https://github.com/PrincetonUniversity/athena/blob/1da278d86e7a959331ee7eb05a290800aca0f1d1/src/mesh/mesh.cpp#L1013-L1021 (this also assumes the default directory hierarchy, e.g. that the user ran Athena++ in bin/ subdirectory of the root repository directory)

When I was testing the SMR checks in #200, I tried to use plot_mesh.py to visualize the spherical-polar refined meshes, but I believe the script assumes that the mesh_structure.dat data was generated using the Cartesian coordinate system. This should be explicitly noted, perhaps in the script name.

Also, the script would only work with -o [file], see below.

Steps to reproduce

make clean; python ./configure.py --prob=linear_wave; make -j
bin/athena -d temp -i inputs/hydro/athinput.linear_wave3d mesh/refinement=static meshblock/nx1=16 meshblock/nx2=16 meshblock/nx3=16 -m 1
python vis/python/plot_mesh.py -i mesh_structure.dat

With either Python 2 or 3 on my macOS system, the last command causes the plt.show() function to return immediately without displaying the image. I believe this is platform-specific behavior depending on the interactivity of the matplotlib backend (toggled with plt.ioff() and plt.ion()), but do the other vis/python/plot* scripts behave this way? It very much appeared like a bug in the script.

Adding -o test.png to the final command produces the correct image in the file.

To-do

chengcli commented 1 year ago

Bump it up. Travis CI test failed by this file.

I found that this file does not pass python lint with flake8.

I tested with the existing .travis.yml, but the build failed. Here is the error:

Skipping the before_install step, as specified in the configuration.

Skipping the install step, as specified in the configuration.
before_script.1

0.02s$ if [ "$TRAVIS_OS_NAME" == "linux" ]; then pyenv global 3.6; fi
before_script.2

2.42s$ python3 -m pip install --upgrade --user pip
before_script.3

0.35s$ python3 --version; pip3 --version
before_script.4

12.24s$ pip3 install --user --only-binary=:all: --no-binary=termcolor numpy flake8 h5py scipy colorama termcolor matplotlib || true

3.42s$ python3 -m flake8 --exclude=cpplint.py,openmpi-* && echo "Finished linting Python files with flake8"

./vis/python/plot_mesh.py:43:19: E275 missing whitespace after keyword

The command "python3 -m flake8 --exclude=cpplint.py,openmpi-* && echo "Finished linting Python files with flake8"" exited with 1.
cache.2

store build cache

This error is caused by this statement on line 43

                # append zero if 2D
                if(len(numbers_str) > 2):
                    z.append(float(numbers_str[2]))
                else:

The lint fails because there is no space after if