Skip to content

Commit

Permalink
Docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneDu-GA committed Sep 27, 2024
1 parent ca30903 commit 0d1599a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
7 changes: 6 additions & 1 deletion gnssanalysis/gn_io/clk.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ def read_clk(clk_path):


def get_sv_clocks(clk_df: _pd.DataFrame) -> _pd.Series:
"""Retrieve satellite clocks from a CLK or SP3 dataframe"""
"""Retrieve satellite clocks from a CLK or SP3 dataframe
:param _pd.DataFrame clk_df: CLK or SP3 dataframe where to retreive satellite clocks from
:raises IndexError: Raise error if the dataframe is not indexed correctly
:return _pd.Series: Retrieved satellite clocks
"""
if clk_df.index.names == ['A', 'J2000', 'CODE']:
# fastest method to grab a specific category!, same as clk_df.EST.loc['AS'] but >6 times faster
AS_cat_code = clk_df.index.levels[0].categories.get_loc("AS")
Expand Down
4 changes: 0 additions & 4 deletions gnssanalysis/gn_io/sp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ def _process_sp3_block(
) -> _pd.DataFrame:
"""Process a single block of SP3 data.
:param str date: The date of the SP3 data block.
:param str data: The SP3 data block.
:param List[int] widths: The widths of the columns in the SP3 data block.
Expand Down Expand Up @@ -251,7 +250,6 @@ def read_sp3(
) -> _pd.DataFrame:
"""Reads an SP3 file and returns the data as a pandas DataFrame.
:param str sp3_path: The path to the SP3 file.
:param bool pOnly: If True, only P* values (positions) are included in the DataFrame. Defaults to True.
:param bool nodata_to_nan: If True, converts 0.000000 (indicating nodata) to NaN in the SP3 POS column
Expand Down Expand Up @@ -474,7 +472,6 @@ def getVelPoly(sp3Df: _pd.DataFrame, deg: int = 35) -> _pd.DataFrame:
:param DataFrame sp3Df: A pandas DataFrame containing the sp3 data.
:param int deg: Degree of the polynomial fit. Default is 35.
:return DataFrame: A pandas DataFrame with the interpolated velocities added as a new column.
"""
est = sp3Df.unstack(1).EST[["X", "Y", "Z"]]
x = est.index.get_level_values("J2000").values
Expand Down Expand Up @@ -580,7 +577,6 @@ def gen_sp3_content(
Organises, formats (including nodata values), then writes out SP3 content to a buffer if provided, or returns
it otherwise.
Args:
:param pandas.DataFrame sp3_df: The DataFrame containing the SP3 data.
:param bool sort_outputs: Whether to sort the outputs. Defaults to False.
:param io.TextIOBase buf: The buffer to write the SP3 content to. Defaults to None.
Expand Down
39 changes: 29 additions & 10 deletions gnssanalysis/gn_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@
from . import gn_const as _gn_const


def gen_helm_aux(pt1, pt2, dropna = True):
"""aux function for helmert values inversion."""
def gen_helm_aux(
pt1: _np.ndarray,
pt2: _np.ndarray,
dropna: bool = True,
) -> Tuple[_np.ndarray, _np.ndarray]:
"""Aux function for helmert values inversion.
:param _np.ndarray pt1: The first set of points.
:param _np.ndarray pt2: The second set of points.
:param bool dropna: Whether to drop NaN values in input data, defaults to True.
:return Tuple[_np.ndarray, _np.ndarray]: A tuple containing the design matrix and right hand side of the equation for least square estimation.
"""
if dropna:
mask = ~_np.isnan(pt1).any(axis=1) & ~_np.isnan(pt2).any(axis=1)
pt1 = pt1[mask]
Expand Down Expand Up @@ -37,14 +47,19 @@ def gen_helm_aux(pt1, pt2, dropna = True):
return A, rhs


def get_helmert7(pt1: _np.ndarray, pt2: _np.ndarray, scale_in_ppm: bool = True, dropna: bool = True) -> Tuple[_np.ndarray, _np.ndarray]:
def get_helmert7(
pt1: _np.ndarray,
pt2: _np.ndarray,
scale_in_ppm: bool = True,
dropna: bool = True,
) -> list:
"""Inversion of 7 Helmert parameters between 2 sets of points.
:param numpy.ndarray pt1: The first set of points.
:param numpy.ndarray pt2: The second set of points.
:param bool scale_in_ppm: Whether the scale parameter is in parts per million (ppm).
:param bool dropna: Whether to drop NaN values in input data.
:returns uple[np.ndarray, np.ndarray]: A tuple containing the Helmert parameters and the residuals.
:param bool dropna: Whether to drop NaN values in input data, defaults to True.
:returns list: A list containing the Helmert parameters and the residuals.
"""
A, rhs = gen_helm_aux(pt1, pt2, dropna)
sol = list(_np.linalg.lstsq(A, rhs, rcond=-1)) # parameters
Expand All @@ -67,14 +82,18 @@ def gen_rot_matrix(v):
return mat + _np.eye(3)


def transform7(xyz_in: _np.ndarray, hlm_params: _np.ndarray, scale_in_ppm: bool = True) -> _np.ndarray:
def transform7(
xyz_in: _np.ndarray,
hlm_params: _np.ndarray,
scale_in_ppm: bool = True,
) -> _np.ndarray:
"""
Transformation of xyz vector with 7 helmert parameters.
:param xyz_in: The input xyz vector.
:param hlm_params: The 7 helmert parameters: [Tx, Ty, Tz, Rx, Ry, Rz, Scale].
:param scale_in_ppm: Whether the scale parameter is in parts per million (ppm).
:return: The transformed xyz vector.
:param _np.ndarray xyz_in: The input xyz vector.
:param _np.ndarray hlm_params: The 7 helmert parameters: [Tx, Ty, Tz, Rx, Ry, Rz, Scale].
:param bool scale_in_ppm: Whether the scale parameter is in parts per million (ppm).
:return _np.ndarray: The transformed xyz vector.
"""
assert hlm_params.size == 7, "There must be exactly seven parameters"

Expand Down

0 comments on commit 0d1599a

Please sign in to comment.