-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
151eab2
commit 1859915
Showing
8 changed files
with
295 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
|
||
# 3rd party imports | ||
import numpy as np | ||
import xarray as xr | ||
|
||
# Local imports | ||
from .ts_scalar import ts_scalar | ||
|
||
__author__ = "Louis Richard" | ||
__email__ = "[email protected]" | ||
|
@@ -67,9 +71,16 @@ def calc_ag(p_xyz): | |
""" | ||
|
||
# Check input type | ||
assert isinstance(p_xyz, xr.DataArray), "p_xyz must be a xarray.DataArray" | ||
|
||
# Check import shape | ||
message = "p_xyz must be a time series of a tensor" | ||
assert p_xyz.data.ndim == 3 and p_xyz.shape[1] == 3 and p_xyz.shape[2] == 3, message | ||
|
||
# Diagonal and off-diagonal terms | ||
p_11, p_22, _ = [p_xyz[:, 0, 0], p_xyz[:, 1, 1], p_xyz[:, 2, 2]] | ||
p_12, p_13, p_23 = [p_xyz[:, 0, 1], p_xyz[:, 0, 2], p_xyz[:, 1, 2]] | ||
p_11, p_22, _ = [p_xyz.data[:, 0, 0], p_xyz.data[:, 1, 1], p_xyz.data[:, 2, 2]] | ||
p_12, p_13, p_23 = [p_xyz.data[:, 0, 1], p_xyz.data[:, 0, 2], p_xyz.data[:, 1, 2]] | ||
|
||
det_p = p_11 * (p_22**2 - p_23**2) | ||
det_p -= p_12 * (p_12 * p_22 - p_23 * p_13) | ||
|
@@ -78,5 +89,6 @@ def calc_ag(p_xyz): | |
det_g = p_11 * p_22**2 | ||
|
||
agyrotropy = np.abs(det_p - det_g) / (det_p + det_g) | ||
agyrotropy = ts_scalar(p_xyz.time.data, agyrotropy) | ||
|
||
return agyrotropy |
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 |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
|
||
# 3rd party imports | ||
import numpy as np | ||
import xarray as xr | ||
|
||
# Local imports | ||
from .ts_scalar import ts_scalar | ||
|
||
__author__ = "Louis Richard" | ||
__email__ = "[email protected]" | ||
|
@@ -58,9 +62,17 @@ def calc_agyro(p_xyz): | |
""" | ||
|
||
# Check input type | ||
assert isinstance(p_xyz, xr.DataArray), "p_xyz must be a xarray.DataArray" | ||
|
||
# Check import shape | ||
message = "p_xyz must be a time series of a tensor" | ||
assert p_xyz.data.ndim == 3 and p_xyz.shape[1] == 3 and p_xyz.shape[2] == 3, message | ||
|
||
# Parallel and perpendicular components | ||
p_perp_1, p_perp_2 = [p_xyz[:, 1, 1], p_xyz[:, 2, 2]] | ||
p_perp_1, p_perp_2 = [p_xyz.data[:, 1, 1], p_xyz.data[:, 2, 2]] | ||
|
||
agyro = np.abs(p_perp_1 - p_perp_2) / (p_perp_1 + p_perp_2) | ||
agyrotropy = np.abs(p_perp_1 - p_perp_2) / (p_perp_1 + p_perp_2) | ||
agyrotropy = ts_scalar(p_xyz.time.data, agyrotropy) | ||
|
||
return agyro | ||
return agyrotropy |
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 |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
|
||
# 3rd party imports | ||
import numpy as np | ||
import xarray as xr | ||
|
||
# Local imports | ||
from .ts_scalar import ts_scalar | ||
|
||
__author__ = "Louis Richard" | ||
__email__ = "[email protected]" | ||
|
@@ -65,13 +69,22 @@ def calc_dng(p_xyz): | |
""" | ||
|
||
# Check input type | ||
assert isinstance(p_xyz, xr.DataArray), "p_xyz must be a xarray.DataArray" | ||
|
||
# Check import shape | ||
message = "p_xyz must be a time series of a tensor" | ||
assert p_xyz.data.ndim == 3 and p_xyz.shape[1] == 3 and p_xyz.shape[2] == 3, message | ||
|
||
# Parallel and perpendicular components | ||
p_para, p_perp = [p_xyz[:, 0, 0], (p_xyz[:, 1, 1] + p_xyz[:, 2, 2]) / 2] | ||
p_para = p_xyz.data[:, 0, 0] | ||
p_perp = (p_xyz.data[:, 1, 1] + p_xyz.data[:, 2, 2]) / 2 | ||
|
||
# Off-diagonal terms | ||
p_12, p_13, p_23 = [p_xyz[:, 0, 1], p_xyz[:, 0, 2], p_xyz[:, 1, 2]] | ||
p_12, p_13, p_23 = [p_xyz.data[:, 0, 1], p_xyz.data[:, 0, 2], p_xyz.data[:, 1, 2]] | ||
|
||
d_ng = np.sqrt(8 * (p_12**2 + p_13**2 + p_23**2)) | ||
d_ng /= p_para + 2 * p_perp | ||
d_ng = ts_scalar(p_xyz.time.data, d_ng) | ||
|
||
return d_ng |
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 |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
|
||
# 3rd party imports | ||
import numpy as np | ||
import xarray as xr | ||
|
||
# Local imports | ||
from .ts_scalar import ts_scalar | ||
|
||
__author__ = "Louis Richard" | ||
__email__ = "[email protected]" | ||
|
@@ -64,13 +68,22 @@ def calc_sqrtq(p_xyz): | |
""" | ||
|
||
# Check input type | ||
assert isinstance(p_xyz, xr.DataArray), "p_xyz must be a xarray.DataArray" | ||
|
||
# Check import shape | ||
message = "p_xyz must be a time series of a tensor" | ||
assert p_xyz.data.ndim == 3 and p_xyz.shape[1] == 3 and p_xyz.shape[2] == 3, message | ||
|
||
# Parallel and perpendicular components | ||
p_para, p_perp = [p_xyz[:, 0, 0], (p_xyz[:, 1, 1] + p_xyz[:, 2, 2]) / 2] | ||
p_para = p_xyz.data[:, 0, 0] | ||
p_perp = (p_xyz.data[:, 1, 1] + p_xyz.data[:, 2, 2]) / 2 | ||
|
||
# Off-diagonal terms | ||
p_12, p_13, p_23 = [p_xyz[:, 0, 1], p_xyz[:, 0, 2], p_xyz[:, 1, 2]] | ||
p_12, p_13, p_23 = [p_xyz.data[:, 0, 1], p_xyz.data[:, 0, 2], p_xyz.data[:, 1, 2]] | ||
|
||
sqrt_q = np.sqrt(p_12**2 + p_13**2 + p_23**2) | ||
sqrt_q /= np.sqrt(p_perp**2 + 2 * p_perp * p_para) | ||
sqrt_q = ts_scalar(p_xyz.time.data, sqrt_q) | ||
|
||
return sqrt_q |
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
Oops, something went wrong.