Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks
felker opened this issue Jan 22, 2019 · 1 comment
Open
4 tasks

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

felker opened this issue Jan 22, 2019 · 1 comment
Labels
bug Broken functionality or unexpected result documentation Relating to the Wiki, Website, or Markdown files good first issue Ideal for developers looking to dive into the Athena++ codebase visualization Visualization scripts included in repository
Milestone

Comments

@felker
Copy link
Contributor

felker commented Jan 22, 2019

Summary of issue

vis/python/plot_mesh.py was first added to the repository by @jmstone in 0a10fa8 on 2016-04-14 and later generalized to accept -i, -o flags by @c-white in 8b0d5f5 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):

athena/src/mesh/mesh.cpp

Lines 1013 to 1021 in 1da278d

// close file, final outputs
if (dim>=2) std::fclose(fp);
std::cout << "Load Balancing:" << std::endl;
std::cout << " Minimum cost = " << mincost << ", Maximum cost = " << maxcost
<< ", Average cost = " << totalcost/nbtotal << std::endl << std::endl;
std::cout << "See the 'mesh_structure.dat' file for a complete list"
<< " of MeshBlocks." << std::endl;
std::cout << "Use 'python ../vis/python/plot_mesh.py' or gnuplot"
<< " to visualize mesh structure." << std::endl << std::endl;

(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

  • Document plot_mesh.py usage and limitations in Plotting Scripts
  • Fix any bugs with plot_mesh.py
  • Adjust or remove instructions from -m output
  • Make new directory vis/python/utils/ and move uniform.py, spherical_refinement.py, athena_read.py there since none of these files directly visualize anything unlike the 4x plot_*.py scripts.
@felker felker added bug Broken functionality or unexpected result documentation Relating to the Wiki, Website, or Markdown files visualization Visualization scripts included in repository good first issue Ideal for developers looking to dive into the Athena++ codebase labels Jan 22, 2019
@felker felker added this to the Future milestone Jan 22, 2019
@felker felker changed the title plot_mesh.py is undocumented in Wiki and plot_mesh.py is undocumented in Wiki and might not show plot Jan 22, 2019
@chengcli
Copy link

chengcli commented Jul 3, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken functionality or unexpected result documentation Relating to the Wiki, Website, or Markdown files good first issue Ideal for developers looking to dive into the Athena++ codebase visualization Visualization scripts included in repository
Projects
None yet
Development

No branches or pull requests

2 participants