redplanet.analysis.radial_profile.get_profile
get_profile(
ring_coords__per_ring: tuple[numpy.ndarray],
accessor: collections.abc.Callable[
[float, float], float
],
return_stats: bool = False,
) -> (
numpy.ndarray
| tuple[
numpy.ndarray, numpy.ndarray, tuple[numpy.ndarray]
]
)
Compute a radial profile using data extracted from concentric rings.
This function computes a one-dimensional radial profile by applying an accessor function to a set of coordinates along each ring. For each ring, it averages the values returned by the accessor function. Optionally, the function can also return additional statistical information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ring_coords__per_ring
|
tuple[np.ndarray]
|
A tuple where each element is a numpy array containing (longitude, latitude) coordinate pairs for a ring. This corresponds to the second output of |
required |
accessor
|
Callable[[float, float], float]
|
A function that accepts two arguments (longitude and latitude), then returns a numerical value corresponding to a data point at those coordinates. See Notes for more information. |
required |
return_stats
|
bool
|
If True, the function returns additional statistical data (standard deviation and raw values for each ring) along with the averaged values. Default is False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
avg_vals__per_ring |
np.ndarray
|
Averaged values per ring (starting with the smallest). |
sigma__per_ring |
np.ndarray
|
Only returned if Standard deviations (sigma) per ring. |
vals__per_ring |
tuple[np.ndarray]
|
Only returned if A tuple of 1D numpy arrays, each containing the data values extracted from each ring (shape is |
Notes
The input for the accessor
parameter must be a function, which might be confusing. Here are two examples (assume datasets have already been loaded):
- Example 1: For functions which only take longitude and latitude as arguments (e.g., topography), you can simply pass
accessor = redplanet.Crust.topo.get
. - Example 2: For functions which require additional arguments (e.g., vector components of the magnetic field or custom calculations), you should define a separate function that will only require longitude and latitude as arguments. There are two ways to do this:
- Directly supply a lambda function like
accessor = lambda lon, lat: redplanet.Mag.sh.get(lon, lat, quantity='radial')
— this is ideal for simple one-line accessors. - Define a function separately like
def get_value(lon, lat): return redplanet.Mag.sh.get(lon, lat, quantity='radial')
, and then passaccessor = get_value
— this is ideal when your implementation of theget_value
function involves multiple steps, e.g. querying multiple datasets, performing calculations, conditional/loop blocks, etc.
- Directly supply a lambda function like