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

Fix connected theta edges for plot3d #1237

Merged
merged 3 commits into from
Sep 2, 2024
Merged

Fix connected theta edges for plot3d #1237

merged 3 commits into from
Sep 2, 2024

Conversation

YigitElma
Copy link
Collaborator

Currently, if you don't give a full theta grid to plot_3d, it will connect the theta edges and end up this kind of plots,
image

I don't know about you, but I want it to behave like this,
image

@YigitElma
Copy link
Collaborator Author

YigitElma commented Aug 31, 2024

Here is the code to generate this plot,

import plotly.graph_objects as go
from desc.grid import LinearGrid
from desc.plotting import plot_3d
import numpy as np

fig = go.Figure()
for r in [0.3, 0.6, 1]:
    grid = LinearGrid(
        rho=r,
        theta=np.linspace(0, 2 * np.pi, 200),
        zeta=np.linspace(0, 2 * np.pi/eq.NFP, 200),
        sym=True,
    )
    plot_3d(eq, "|B|", grid=grid, fig=fig)
fig.show()

@YigitElma YigitElma added plotting stuff about plotting routines easy Short and simple to code or review labels Aug 31, 2024
@YigitElma YigitElma requested review from a team, rahulgaur104, f0uriest, ddudt, dpanici, kianorr, sinaatalay and unalmis and removed request for a team August 31, 2024 04:47
Copy link
Contributor

github-actions bot commented Aug 31, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +0.46 +/- 6.48     | +2.40e-03 +/- 3.38e-02 |  5.24e-01 +/- 2.3e-02  |  5.22e-01 +/- 2.5e-02  |
 test_equilibrium_init_medres            |     -0.37 +/- 1.06     | -1.55e-02 +/- 4.41e-02 |  4.14e+00 +/- 2.9e-02  |  4.15e+00 +/- 3.3e-02  |
 test_equilibrium_init_highres           |     -0.05 +/- 2.09     | -2.90e-03 +/- 1.15e-01 |  5.49e+00 +/- 6.0e-02  |  5.49e+00 +/- 9.8e-02  |
 test_objective_compile_dshape_current   |     -0.17 +/- 0.79     | -6.41e-03 +/- 3.02e-02 |  3.83e+00 +/- 1.5e-02  |  3.83e+00 +/- 2.6e-02  |
 test_objective_compute_dshape_current   |     +0.13 +/- 2.24     | +4.29e-06 +/- 7.69e-05 |  3.43e-03 +/- 6.4e-05  |  3.43e-03 +/- 4.3e-05  |
 test_objective_jac_dshape_current       |     -1.05 +/- 7.03     | -4.26e-04 +/- 2.85e-03 |  4.01e-02 +/- 1.6e-03  |  4.06e-02 +/- 2.4e-03  |
 test_perturb_2                          |     -0.30 +/- 2.18     | -5.28e-02 +/- 3.79e-01 |  1.74e+01 +/- 1.2e-01  |  1.74e+01 +/- 3.6e-01  |
 test_proximal_freeb_jac                 |     +0.49 +/- 1.35     | +3.67e-02 +/- 1.01e-01 |  7.52e+00 +/- 9.7e-02  |  7.48e+00 +/- 2.5e-02  |
 test_solve_fixed_iter                   |     -0.13 +/- 60.08    | -6.64e-03 +/- 2.96e+00 |  4.93e+00 +/- 2.1e+00  |  4.93e+00 +/- 2.1e+00  |
 test_build_transform_fft_midres         |     -0.02 +/- 3.25     | -9.48e-05 +/- 1.96e-02 |  6.02e-01 +/- 1.8e-02  |  6.02e-01 +/- 7.5e-03  |
 test_build_transform_fft_highres        |     -0.35 +/- 1.69     | -3.48e-03 +/- 1.68e-02 |  9.93e-01 +/- 8.9e-03  |  9.97e-01 +/- 1.4e-02  |
 test_equilibrium_init_lowres            |     -1.76 +/- 3.62     | -6.79e-02 +/- 1.40e-01 |  3.79e+00 +/- 1.8e-02  |  3.86e+00 +/- 1.4e-01  |
 test_objective_compile_atf              |     -0.04 +/- 4.81     | -3.23e-03 +/- 3.78e-01 |  7.86e+00 +/- 2.4e-01  |  7.87e+00 +/- 2.9e-01  |
 test_objective_compute_atf              |     +1.17 +/- 3.95     | +1.21e-04 +/- 4.06e-04 |  1.04e-02 +/- 2.6e-04  |  1.03e-02 +/- 3.2e-04  |
 test_objective_jac_atf                  |     -0.93 +/- 4.99     | -1.81e-02 +/- 9.66e-02 |  1.92e+00 +/- 8.9e-02  |  1.94e+00 +/- 3.7e-02  |
 test_perturb_1                          |     +0.64 +/- 4.86     | +8.16e-02 +/- 6.16e-01 |  1.27e+01 +/- 4.2e-01  |  1.27e+01 +/- 4.5e-01  |
 test_proximal_jac_atf                   |     -0.64 +/- 1.41     | -5.24e-02 +/- 1.16e-01 |  8.19e+00 +/- 7.4e-02  |  8.24e+00 +/- 8.9e-02  |
 test_proximal_freeb_compute             |     -0.80 +/- 0.96     | -1.48e-03 +/- 1.76e-03 |  1.82e-01 +/- 1.3e-03  |  1.84e-01 +/- 1.2e-03  |

Copy link

codecov bot commented Aug 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.31%. Comparing base (b683e85) to head (f1af4e2).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1237      +/-   ##
==========================================
- Coverage   95.32%   95.31%   -0.02%     
==========================================
  Files          90       90              
  Lines       22713    22713              
==========================================
- Hits        21651    21648       -3     
- Misses       1062     1065       +3     
Files with missing lines Coverage Δ
desc/plotting.py 95.66% <100.00%> (-0.08%) ⬇️

... and 2 files with indirect coverage changes

@f0uriest
Copy link
Member

f0uriest commented Sep 1, 2024

Does this still work correctly if the surface is closed?

@YigitElma
Copy link
Collaborator Author

Does this still work correctly if the surface is closed?

Those were also behaving well with this change. I can test again, it was really late when I tested it yesterday.

@YigitElma
Copy link
Collaborator Author

YigitElma commented Sep 2, 2024

Does this still work correctly if the surface is closed?

Yes, it works, unless you specifically give a grid like this,

eq = get("ATF")
grid = LinearGrid(
        rho=1.,
        theta=np.linspace(0, 2 * np.pi, 200, endpoint=False),
        zeta=np.linspace(0, 2 * np.pi/eq.NFP, 200),
    )
plot_3d(eq, '|B|', grid=grid)

image

Because if you don't give a grid, the default grid created by _get_grid() function uses endpoint=True which inherently closes the surface.

@YigitElma YigitElma merged commit 941f020 into master Sep 2, 2024
24 checks passed
@YigitElma YigitElma deleted the yge/plot3d branch September 2, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy Short and simple to code or review plotting stuff about plotting routines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants