Skip to content

Commit

Permalink
Merge pull request #76 from jcapriot/dipole_broadcasting
Browse files Browse the repository at this point in the history
Dipole broadcasting
  • Loading branch information
jcapriot authored Oct 22, 2024
2 parents d72b4c1 + 87af1b7 commit 979cf23
Show file tree
Hide file tree
Showing 47 changed files with 2,483 additions and 2,908 deletions.
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 @@ def sigma(self, value):

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)}")

self.sigma = 1/value

@property
def mu(self):
"""Magnetic permeability in H/m
Expand Down Expand Up @@ -177,6 +197,8 @@ def orientation(self, var):
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 @@ def orientation(self, var):
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

0 comments on commit 979cf23

Please sign in to comment.