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

apply phase to FieldData and SimulationData.plot_field #1271

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

tylerflex
Copy link
Collaborator

#1261

Adds

  • FieldData.apply_phase(phase :float) -> FieldData
  • phase argument to SimulationData.plot_field that either
    • applies a phase to the field data being plotted (if complex-valued)
    • warns the user that it will be ignored (if real-valued and phase is non-zero)

@e-g-melo
Copy link
Collaborator

@tylerflex, I am using the code below to generate a sequence of field images from a FieldMonitor and I am getting that warning about real-valued data. What should I do to get complex-valued data?

phi_range = np.linspace(0, 2*np.pi, 36)
for phi, i in zip(phi_range, range(0,len(phi_range))):  
    fig, ax = plt.subplots(1,1, figsize=(5,5), tight_layout=True)

    sim_data.plot_field("field_xy", "Ey", f=freq_c, ax=ax, phase=phi)
    
    ax.set_aspect('equal')       
    plt.savefig(f'DipAnim/dip_{i:03d}.png', bbox_inches='tight')
    plt.close()
image

@tylerflex
Copy link
Collaborator Author

My bad, there was a bug, It should be fixed now.

Copy link
Collaborator

@e-g-melo e-g-melo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tylerflex, thank you for this feature! It will help a lot in promoting Tidy3D within the teaching program context.

Both apply_field() and plot_field functions are working. However, the warning message still shows up when using plot_field.

image

@e-g-melo
Copy link
Collaborator

dip_anim_plot_field

@tylerflex
Copy link
Collaborator Author

great!

@tylerflex
Copy link
Collaborator Author

made all recommend changes

@tylerflex tylerflex merged commit 4f8ace2 into pre/2.5 Nov 27, 2023
14 checks passed
@tylerflex tylerflex deleted the tyler/phase branch November 27, 2023 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants