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

Dipole broadcasting #76

Merged
merged 33 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ba5d0d6
simplify broadcasting operation.
jcapriot Oct 15, 2024
00460b5
fix em wholespace dipoles
jcapriot Oct 15, 2024
d9748f2
static wholespace checks
jcapriot Oct 16, 2024
3113e01
simplify some functions
jcapriot Oct 16, 2024
ce61771
make dipoles work with scalar time/frequency
jcapriot Oct 16, 2024
f6e3fea
improve gravity tests
jcapriot Oct 16, 2024
03c97d1
a few small gravity simplifications
jcapriot Oct 17, 2024
e65a0c0
make cart to cyl transforms broadcast
jcapriot Oct 17, 2024
066ad5b
make planewave broadcast
jcapriot Oct 17, 2024
91d864f
add a reference file for ward and hohmann's unaltered formulas
jcapriot Oct 17, 2024
f1c1d9e
add some tests
jcapriot Oct 17, 2024
1f9e325
add sympy to test environment
jcapriot Oct 17, 2024
4b06788
fix spatial test
jcapriot Oct 17, 2024
46b8c75
update prism tests
jcapriot Oct 17, 2024
fce5699
improve gravity and magnetic prism tests
jcapriot Oct 17, 2024
314dad0
fix up some more tests
jcapriot Oct 18, 2024
22bec11
Adds a LineSegment class for a wholespace
jcapriot Oct 18, 2024
cea3683
fix wholespace and add orientation tests
jcapriot Oct 19, 2024
f399142
fix sign for linecurrent
jcapriot Oct 19, 2024
fc4ce09
Improve circular loop tests.
jcapriot Oct 19, 2024
7589516
assert allclose instead of allequal
jcapriot Oct 19, 2024
cbd6082
fix for 3.10 syntax
jcapriot Oct 19, 2024
1a1e164
more 3.10 fixes
jcapriot Oct 19, 2024
8e6f342
add import
jcapriot Oct 19, 2024
9ddf838
loosen test slightly
jcapriot Oct 19, 2024
ff25b91
add some numerical accuracy protection for the circular loop B-field
jcapriot Oct 21, 2024
9b3ee89
update test
jcapriot Oct 21, 2024
b2b7431
add small rho approximations for circular loop
jcapriot Oct 21, 2024
3990a58
use k_sq to check for small argument.
jcapriot Oct 21, 2024
7cea582
update codecov upload version
jcapriot Oct 21, 2024
9d0564a
Make LineCurrentFreeSpace the same as LineCurrentWholeSpace
jcapriot Oct 22, 2024
89f779e
rename test files
jcapriot Oct 22, 2024
87af1b7
Revert "rename test files"
jcapriot Oct 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/environment_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
# testing
- pytest
- pytest-cov
- sympy

# Building
- pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_with_conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:

- name: "Upload coverage to Codecov"
if: matrix.python-version == '3.11'
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion geoana/earthquake/oksar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ def example():
# data=data
# )

data = np.fromstring(dinar_file.content, np.float32)
data = np.frombuffer(dinar_file.content, np.float32)
title = 'Dinar, Turkey'
location = [706216.0606, 4269238.9999]
location_UTM_zone = 35
Expand Down
24 changes: 23 additions & 1 deletion geoana/em/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@

self._sigma = value

@property
def rho(self):
"""Electrical resistivity in Ohm m

Returns
-------
float
Electrical resistivity in Ohm m
"""
return 1/self.sigma

@rho.setter
def rho(self, value):
try:
value = float(value)
except:
raise TypeError(f"resistivity must be a number, got {type(value)}")

Check warning on line 77 in geoana/em/base.py

View check run for this annotation

Codecov / codecov/patch

geoana/em/base.py#L76-L77

Added lines #L76 - L77 were not covered by tests

self.sigma = 1/value

@property
def mu(self):
"""Magnetic permeability in H/m
Expand Down Expand Up @@ -177,6 +197,8 @@
var = np.r_[0., 1., 0.]
elif var.upper() == 'Z':
var = np.r_[0., 0., 1.]
else:
raise ValueError("Orientation must be one of {'X','Y','Z'}")
else:
try:
var = np.asarray(var, dtype=float)
Expand All @@ -187,7 +209,7 @@
var = np.squeeze(var)
if var.shape != (3, ):
raise ValueError(
f"orientation must be array_like with shape (3,), got {len(var)}"
f"orientation must be array_like with shape (3,), got {var.shape}"
)

# Normalize the orientation
Expand Down
4 changes: 1 addition & 3 deletions geoana/em/fdem/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,11 @@ def frequency(self, value):
value = np.asarray(value, dtype=float)
except:
raise TypeError(f"frequencies are not a valid type")
value = np.atleast_1d(value)

# Enforce positivity and dimensions
if (value < 0.).any():
raise ValueError("All frequencies must be greater than 0")
if value.ndim > 1:
raise TypeError(f"frequencies must be ('*') array")
raise TypeError(f"frequencies must have at most 1 dimension.")

self._frequency = value

Expand Down
2 changes: 1 addition & 1 deletion geoana/em/fdem/halfspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def magnetic_field(self, xy, field="secondary"):

Returns
-------
(n_freq, ..., 3) numpy.array of complex
(n_freq, ..., 3) numpy.ndarray of complex
Magnetic field at all frequencies for the gridded
locations provided. Output array is squeezed when n_freq and/or
n_loc = 1.
Expand Down
2 changes: 1 addition & 1 deletion geoana/em/fdem/layered.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def magnetic_field(self, xyz, field="secondary"):

Returns
-------
(n_freq, n_loc, 3) numpy.array of complex
(n_freq, n_loc, 3) numpy.ndarray of complex
Magnetic field at all frequencies for the gridded
locations provided. Output array is squeezed when n_freq and/or
n_loc = 1.
Expand Down
Loading