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

Apodization for frequency monitors #574

Merged
merged 1 commit into from
Nov 17, 2022
Merged

Conversation

dbochkov-flexcompute
Copy link
Contributor

Specification of apodization for frequency monitors

note that I set width to be a non-optional parameters, because generally there doesn't seem to be a common default value


@pd.validator("end", always=True, allow_reuse=True)
def end_greater_than_start(cls, val, values):
"""Ensure sure end is greater than or equal to start."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ensure sure



class ApodizationSpec(Tidy3dBaseModel):
"""Stores specifications for the apodizaton of frequency monitors.
Copy link
Collaborator

Choose a reason for hiding this comment

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

frequency-domain

)

width: pd.PositiveFloat = pd.Field(
...,
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about setting the default to None and just skipping the apodization on the backend if width is None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it, however I am worried that a user might not realize/just forget they have to set width, so they would use ApodizationSpec(start=1, end=2) and not get any apodization in their results. I guess we could set all start, end, and width to None by default, and a validator that checks if either start or end is not None, then width must not be None as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes sense to me yeah.

ApodizationSpec(width=1),
title="Apodization Specification",
description="Sets parameters of (optional) apodization.",
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Sets parameters of (optional) apodization. Apodization applies a windowing function to the Fourier transform of the time-domain fields into frequency-domain ones, and can be used to truncate the beginning and/or end of the time signal, for example to eliminate the source pulse when studying the eigenmodes of a system. Note: apodization affects the normalization of the frequency-domain fields.",

or something along those lines

raise SetupError("End apodization begins before start apodization ends.")
return val

@pd.validator("width", always=True, allow_reuse=True)
def width_provided(cls, val, values):
"""Ensure end is greater than or equal to start."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wrong docstring

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, fixed!

@dbochkov-flexcompute dbochkov-flexcompute merged commit 79fe521 into develop Nov 17, 2022
@tylerflex tylerflex deleted the daniil/apodization branch May 16, 2023 14:21
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.

2 participants