Skip to content

Commit

Permalink
Fix doc headers to end with colons
Browse files Browse the repository at this point in the history
  • Loading branch information
bdestombe committed Nov 4, 2023
1 parent 62816f1 commit 2c8469f
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 262 deletions.
49 changes: 20 additions & 29 deletions src/dtscalibration/calibrate_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@


def parse_st_var(st, st_var):
"""
Utility function to check the st_var input and to return in DataArray
"""Utility function to check the st_var input and to return in DataArray
format.
Parameters
Expand All @@ -24,7 +23,7 @@ def parse_st_var(st, st_var):
distributed) define a DataArray of the shape as ds.st, where the
variance can be a function of time and/or x.
Returns
Returns:
-------
st_var_sec : DataArray
The variance of the noise from the Stokes detector.
Expand Down Expand Up @@ -57,7 +56,7 @@ def calibration_single_ended_helper(
trans_att,
solver,
):
"""Only used in `calibration_single_ended()`"""
"""Only used in `calibration_single_ended()`."""
nt = self.dts.nt
nx = self.dts.nx
nta = len(trans_att)
Expand Down Expand Up @@ -203,8 +202,7 @@ def calibration_single_ended_solver( # noqa: MC0001
trans_att=[],
verbose=False,
):
"""
The solver for single-ended setups. Assumes `ds` is pre-configured with
"""The solver for single-ended setups. Assumes `ds` is pre-configured with
`sections` and `trans_att`.
Parameters
Expand Down Expand Up @@ -237,7 +235,7 @@ def calibration_single_ended_solver( # noqa: MC0001
verbose : bool
Returns
Returns:
-------
"""
Expand Down Expand Up @@ -1131,8 +1129,7 @@ def calibrate_double_ended_solver( # noqa: MC0001
nta=None,
verbose=False,
):
"""
The solver for double-ended setups. Assumes `ds` is pre-configured with
"""The solver for double-ended setups. Assumes `ds` is pre-configured with
`sections` and `trans_att`.
The construction of X differs a bit from what is presented in the
Expand Down Expand Up @@ -1183,7 +1180,7 @@ def calibrate_double_ended_solver( # noqa: MC0001
locations. This array is produced by `matching_sections()`.
verbose : bool
Returns
Returns:
-------
"""
Expand Down Expand Up @@ -1592,11 +1589,10 @@ def matching_section_location_indices(ix_sec, hix, tix):


def construct_submatrices_matching_sections(x, ix_sec, hix, tix, nt, trans_att):
"""
For all matching indices, where subscript 1 refers to the indices in
"""For all matching indices, where subscript 1 refers to the indices in
`hix` and subscript 2 refers to the indices in `tix`.
F1 - F2 = E2 - E1 + TAF2 - TAF1 # EQ1
B1 - B2 = E1 - E2 + TAB2 - TAB1 # EQ2
B1 - B2 = E1 - E2 + TAB2 - TAB1 # EQ2.
For matching indices (`hix` and `tix`) that are outside of the reference
sections an additional equation is needed for `E` per time step.
Expand Down Expand Up @@ -1628,7 +1624,7 @@ def construct_submatrices_matching_sections(x, ix_sec, hix, tix, nt, trans_att):
tix : array-like of int
nt : int
Returns
Returns:
-------
"""
Expand Down Expand Up @@ -1835,12 +1831,11 @@ def construct_submatrices(sections, nt, nx, ds, trans_att, x_sec):
Zero_gamma (nt * nx, 1)
zero_d (nt * nx, nt)
Z_TA_fw (nt * nx, nta * 2 * nt) minus ones
Z_TA_bw (nt * nx, nta * 2 * nt) minus ones
Z_TA_bw (nt * nx, nta * 2 * nt) minus ones.
I_fw = 1/Tref*gamma - D_fw - E - TA_fw
I_bw = 1/Tref*gamma - D_bw + E - TA_bw
"""

# Z \gamma # Eq.47
cal_ref = np.array(
ds.dts.ufunc_per_section(
Expand Down Expand Up @@ -1937,13 +1932,12 @@ def wls_sparse(
return_werr=False,
**solver_kwargs,
):
"""
If some initial estimate x0 is known and if damp == 0, one could proceed as follows:
"""If some initial estimate x0 is known and if damp == 0, one could proceed as follows:
- Compute a residual vector r0 = b - A*x0.
- Use LSQR to solve the system A*dx = r0.
- Add the correction dx to obtain a final solution x = x0 + dx.
from: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.
linalg.lsqr.html
linalg.lsqr.html.
Parameters
----------
Expand All @@ -1954,7 +1948,7 @@ def wls_sparse(
verbose
kwargs
Returns
Returns:
-------
"""
Expand Down Expand Up @@ -2051,17 +2045,15 @@ def wls_sparse(


def wls_stats(X, y, w=1.0, calc_cov=False, x0=None, return_werr=False, verbose=False):
"""
Parameters
"""Parameters
----------
X
y
w
calc_cov
verbose
Returns
Returns:
-------
"""
Expand Down Expand Up @@ -2114,8 +2106,8 @@ def calc_alpha_double(
talpha_bw_var=None,
):
"""Eq.50 if weighted least squares. Assumes ds has `trans_att`
pre-configured."""

pre-configured.
"""
assert ix_alpha_is_zero >= 0, "Define ix_alpha_is_zero" + str(ix_alpha_is_zero)

if st_var is not None:
Expand Down Expand Up @@ -2235,8 +2227,7 @@ def calc_df_db_double_est(ds, sections, ix_alpha_is_zero, gamma_est):


def match_sections(ds, matching_sections):
"""
Matches location indices of two sections.
"""Matches location indices of two sections.
Parameters
----------
ds
Expand All @@ -2246,7 +2237,7 @@ def match_sections(ds, matching_sections):
that are matched. The third item is a boolean and is True if the two
sections have a reverse direction ("J-configuration"), most common.
Returns
Returns:
-------
matching_indices : array-like
Is an array of size (np, 2), where np is the number of paired
Expand Down
35 changes: 15 additions & 20 deletions src/dtscalibration/calibration/section_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@ def set_matching_sections(ds: xr.Dataset, matching_sections: dict[str, list[slic


def validate_no_overlapping_sections(sections: dict[str, list[slice]]):
"""
Check if the sections do not overlap.
"""Check if the sections do not overlap.
Parameters
----------
sections : dict[str, list[slice]]
The keys of the dictionary are the names of the sections.
The values are lists of slice objects.
Returns
Returns:
-------
None
Raises
Raises:
------
AssertionError
If the sections overlap.
Expand All @@ -50,23 +49,22 @@ def validate_no_overlapping_sections(sections: dict[str, list[slice]]):


def validate_sections_definition(sections: dict[str, list[slice]]):
"""
Check if the sections are defined correctly. The sections are defined
"""Check if the sections are defined correctly. The sections are defined
correctly if:
- The keys of the sections-dictionary are strings (assertion)
- The values of the sections-dictionary are lists (assertion)
- The values of the sections-dictionary are lists (assertion).
Parameters
----------
sections : dict[str, list[slice]]
The keys of the dictionary are the names of the sections.
The values are lists of slice objects.
Returns
Returns:
-------
None
Raises
Raises:
------
AssertionError
If the sections are not defined correctly.
Expand All @@ -84,14 +82,13 @@ def validate_sections_definition(sections: dict[str, list[slice]]):


def validate_sections(ds: xr.Dataset, sections: dict[str, list[slice]]):
"""
Check if the sections are valid. The sections are valid if:
"""Check if the sections are valid. The sections are valid if:
- The keys of the sections-dictionary refer to a valid timeserie
already stored in ds.data_vars (assertion)
- The values of the sections-dictionary are lists of slice objects.
(assertion)
- The slices are within the x-dimension (assertion)
- The slices do not overlap (assertion)
- The slices do not overlap (assertion).
Parameters
----------
Expand All @@ -102,11 +99,11 @@ def validate_sections(ds: xr.Dataset, sections: dict[str, list[slice]]):
The keys of the dictionary are the names of the sections.
The values are lists of slice objects.
Returns
Returns:
-------
None
Raises
Raises:
------
AssertionError
If the sections are not valid.
Expand Down Expand Up @@ -143,8 +140,7 @@ def ufunc_per_section(
calc_per="stretch",
**func_kwargs,
):
"""
User function applied to parts of the cable. Super useful,
"""User function applied to parts of the cable. Super useful,
many options and slightly
complicated.
Expand Down Expand Up @@ -183,12 +179,11 @@ def ufunc_per_section(
to a list and concatenating after.
Returns
Returns:
-------
Examples
Examples:
--------
1. Calculate the variance of the residuals in the along ALL the\
reference sections wrt the temperature of the water baths
Expand Down Expand Up @@ -249,7 +244,7 @@ def ufunc_per_section(
>>> ix_loc = d.ufunc_per_section(sections, x_indices=True)
Note
Note:
----
If `self[label]` or `self[subtract_from_label]` is a Dask array, a Dask
array is returned else a numpy array is returned
Expand Down
Loading

0 comments on commit 2c8469f

Please sign in to comment.