-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from jngaravitoc/devel
Devel
- Loading branch information
Showing
8 changed files
with
729 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def remove_terms(original_coefficients, n, l, m): | ||
""" | ||
Remove coefficients | ||
""" | ||
|
||
assert len(l) == len(m) == len(n) | ||
copy_coeffcients = original_coefficients.deepcopy() | ||
coefs_matrix = original_coefficients.getAllCoefs() | ||
t_snaps = original_coefficients.Times() | ||
|
||
|
||
for t in range(len(t_snaps)): | ||
for i in range(len(l)): | ||
lm_idx = int(l[i]*(l[i]+1) / 2) + m[i] | ||
print(n[i],l[i],m[i],lm_idx) | ||
try: coefs_matrix[n[i], lm_idx, t] = np.complex128(0) | ||
except IndexError: continue | ||
copy_coeffcients.setMatrix(mat=coefs_matrix[:,:, t], time=t_snaps[t]) | ||
|
||
return copy_coeffcients |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
|
||
import numpy as np | ||
import k3d | ||
|
||
def field3Dcontour(field, contour_range, contour_name, size, **kwargs): | ||
""" | ||
field: numpy.ndarray | ||
shape(t, N, N, N), where t is the time axis, N are the spatial axis. | ||
contour_ranges: list | ||
values in percentage of the contour levels. e.g [0.5, 0.75] means | ||
contours at the 50% and 75% level. | ||
volume_names | ||
kwargs: | ||
color map | ||
""" | ||
|
||
field_max = np.max(np.abs(field)) | ||
#field_min = np.min(field) | ||
|
||
|
||
volume = k3d.volume(field.astype(np.float32), | ||
alpha_coef=1.0, | ||
color_range=contour_range, #*field_max, | ||
color_map=(np.array(k3d.colormaps.paraview_color_maps.Cool_to_Warm_Extended).reshape(-1,4) | ||
* np.array([1,1.0,1.0,1.0])).astype(np.float32), | ||
name=contour_name) | ||
|
||
# Where this values come from? | ||
volume.opacity_function = [0. , 0. , 0.21327923, 0.98025 , 0.32439035, | ||
0. , 0.5 , 0. , 0.67560965, 0. , | ||
0.74537706, 0.9915 , 1. , 0. ] | ||
|
||
|
||
volume.transform.bounds = [-size[0], size[0], | ||
-size[1], size[1], | ||
-size[2], size[2]] | ||
|
||
if 'alpha' in kwargs.keys(): | ||
volume.alpha_coef = kwargs['alpha'] | ||
|
||
return volume | ||
|
||
def orbit3D(orbit, orbit_name, **kwargs): | ||
""" | ||
# TODO: Add time-dependent | ||
orbit: numpy.array | ||
(3, N) shape | ||
orbit_name | ||
color | ||
kwargs: | ||
color map | ||
""" | ||
|
||
orbit_trayectory = k3d.line(orbit.astype(np.float32), | ||
width=1, | ||
color_range=[0, 0.1], color=0x3e3a3a, name=orbit_name) | ||
|
||
|
||
|
||
if 'alpha' in kwargs.keys(): | ||
orbit_trayectory.alpha_coef = kwargs['alpha'] | ||
|
||
return orbit_trayectory | ||
|
||
|
||
|
||
def field3Drender(volumes, contour_ranges, size, contour_names=['Inner', 'Outter'], | ||
contour_alphas=[8,1], **kwargs): | ||
""" | ||
volumes: numpy.ndarray | ||
shape: t, gridx, gridy, gridz | ||
orbit | ||
""" | ||
render = k3d.plot(height=800) | ||
|
||
for vol in range(len(contour_ranges)): | ||
v = field3Dcontour(volumes[0], | ||
contour_range=contour_ranges[vol], | ||
contour_name=contour_names[vol], | ||
alpha=contour_alphas[vol], size=size) | ||
render += v | ||
v_t = {} | ||
for t in range(volumes.shape[0]): | ||
v_t[str(float(t))] = volumes[t].astype(np.float32) | ||
v.volume = v_t | ||
|
||
# Implement 3d orbit | ||
if 'orbits' in kwargs.keys(): | ||
|
||
for orb in range(len(kwargs['orbits_names'])): | ||
o = orbit3D(kwargs['orbits'][orb], | ||
orbit_name=kwargs['orbits_names'][orb], width=10) | ||
render += o | ||
|
||
|
||
return render |
Oops, something went wrong.