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

add ESA driving functions docstring examples for monopoles #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fs446
Copy link
Member

@fs446 fs446 commented Mar 11, 2019

in all ESA driving functions we need to check the handling at

if Nc is None: what type to return such that no error occurs
The returned Nc = double is not working with the subsequent np.ones(Nc)

Furthermore for ease of documentation, i.e. same grid as all other examples, this nan-handling
plot(np.nan_to_num(d), selection, secondary_source)
helps to plot. NaN presumably occurs since grid and secondary source position coincide. Is there a more elegant way to avoid this. Anyway, I'd vote to change the grid for these examples.

@narahahn
Copy link
Member

Furthermore for ease of documentation, i.e. same grid as all other examples, this nan-handling
plot(np.nan_to_num(d), selection, secondary_source)
helps to plot. NaN presumably occurs since grid and secondary source position coincide. Is there a more elegant way to avoid this. Anyway, I'd vote to change the grid for these examples.

I didn't check all cases, but nan is already in the driving signals.
Presumably this is due to the Hankel function which returns nan for argument 0.

d[~idx] = d[~idx] + f[~idx] * jn(nu, k*r_s) * hankel2(nu, k*r[~idx])

@mgeier
Copy link
Member

mgeier commented Mar 13, 2019

The reason for the first problem is that np.ceil() returns floating point values instead of integers.

There are numerous issues about that, e.g.:

I see two options:

import math
Nc = math.ceil(2 * k * max(r) * alpha/np.pi)

or

Nc = np.ceil(2 * k * np.max(r) * alpha/np.pi).astype(int)

@mgeier
Copy link
Member

mgeier commented Mar 13, 2019

Regarding NaN values, I don't think we should convert them to zero, right?

Since now the ESA driving functions are in their own module, it's no problem to choose a different grid and/or array for the examples.

@fs446
Copy link
Member Author

fs446 commented Mar 13, 2019

Regarding NaN values, I don't think we should convert them to zero, right?

Yeah, that would be inappropriate. We rather should check what precisely happens. I have it on my list.

Since now the ESA driving functions are in their own module, it's no problem to choose a different grid and/or array for the examples.

Yeah, that's nice about the new handling. I will cover this as well ASAP.

@fs446
Copy link
Member Author

fs446 commented Mar 13, 2019

I see two options:

import math
Nc = math.ceil(2 * k * max(r) * alpha/np.pi)

or

Nc = np.ceil(2 * k * np.max(r) * alpha/np.pi).astype(int)

I'd vote for the second one, then we give a more clearer hint, that something is happening and we explicitly take care of it. The first solution is blurry, because it might only raise wondering why the coders did not use np.ceil...which is good, but we don't tell then.

@spors
Copy link
Member

spors commented Mar 15, 2019

I see two options:

import math
Nc = math.ceil(2 * k * max(r) * alpha/np.pi)

or

Nc = np.ceil(2 * k * np.max(r) * alpha/np.pi).astype(int)

I'd vote for the second one, then we give a more clearer hint, that something is happening and we explicitly take care of it. The first solution is blurry, because it might only raise wondering why the coders did not use np.ceil...which is good, but we don't tell then.

I also like the second variant!

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.

4 participants