jwave.utils
display_complex_field(field, figsize=(15, 8), max_intensity=None)
Displays the real and absolute value of a complex field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field |
Union[Field, jnp.ndarray, np.ndarray]
|
Complex field to plot. |
required |
figsize |
Tuple[int, int]
|
Figure size. |
(15, 8)
|
max_intensity |
Union[float, None]
|
Maximum intensity to plot. If None, the maximum intensity is set to the maximum absolute value of the field. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Tuple[Figure, np.ndarray]
|
Tuple[matplotlib.pyplot.figure, matplotlib.pyplot.axes]: Tuple of Figure object and Axes object. |
get_smallest_prime_factors(n)
Get the smallest prime factors of a given number.
Args n (int): The number to find the smallest prime factors for.
Returns: Set[int]: A set containing the smallest prime factors of the number.
is_numeric(x)
Check if x is a numeric value, including complex.
load_image_to_numpy(filepath, padding=0, image_size=None)
Loads an image from a filepath and returns it as a numpy array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
Filepath to the image. |
required |
padding |
int
|
Padding to add to the image. Defaults to 0. |
0
|
image_size |
Tuple[int, int]
|
Size of the image (excluding padding). Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray: Image as a numpy array. |
numbers_with_smallest_primes(min_range, max_range, max_prime=7)
Print the numbers within a given range that have smallest prime factors all less than or equal to a maximum value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_range |
int
|
The minimum value of the range to search within. |
required |
max_range |
int
|
The maximum value of the range to search within. |
required |
max_prime |
int
|
The maximum prime factor that numbers in the range can have. Default is 7. |
7
|
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
This function prints the qualifying numbers and their smallest prime factors. |
plot_comparison(field1, field2, title='', names=('', ''), cmap='seismic', vmin=None, vmax=None)
Plots two 2D fields side by side, and shows the difference between them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field1 |
jnp.ndarray
|
First field |
required |
field2 |
jnp.ndarray
|
Second Field |
required |
title |
str
|
Title of the plot. Defaults to ''. |
''
|
names |
Iterable[str]
|
Names of the fields . Defaults to |
('', '')
|
cmap |
str
|
Colormap to use. Defaults to 'seismic'. |
'seismic'
|
vmin |
float
|
Minimum value to use for the colormap. Defaults to None. |
None
|
vmax |
float
|
Maximum value to use for the colormap. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Figure |
Figure
|
Figure object. |
show_field(x, title='', figsize=(8, 6), vmax=None, aspect='auto')
Plots a real valued field. The colormap goes from -vmax
to vmax
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Field
|
Field to plot. |
required |
title |
str
|
Title of the plot. Defaults to "". |
''
|
figsize |
tuple
|
Figure size. Defaults to (8,6). |
(8, 6)
|
vmax |
float
|
Maximum value to display. Defaults to None. |
None
|
aspect |
str
|
Aspect ratio of the plot. Defaults to "auto". |
'auto'
|
Returns:
Type | Description |
---|---|
matplotlib.pyplot.figure: Figure object. |
|
matplotlib.pyplot.axes: Axes object. |