clophfit.utils ============== .. py:module:: clophfit.utils .. autoapi-nested-parse:: General utility helpers for clophfit. Functions --------- .. autoapisummary:: clophfit.utils.weights_from_sigma clophfit.utils.read_xls clophfit.utils.lookup_listoflines clophfit.utils.strip_lines Module Contents --------------- .. py:function:: weights_from_sigma(sigma) Convert standard deviations to ODR weights (1 / sigma**2). Returns None when sigma is empty to use odrpack defaults. .. py:function:: read_xls(path) Read first sheet of an xls file. :param path: Path to `.xls` file. :type path: Path :returns: Lines as list_of_lines. :rtype: list[list[str | int | float]] .. py:function:: lookup_listoflines(csvl: list[list[str]], pattern: str, col: int) -> list[int] lookup_listoflines(csvl: list[list[str | int | float]], pattern: str = 'Label: Label', col: int = 0) -> list[int] Lookup line numbers (row index) where given pattern occurs. :param csvl: Lines (list_of_lines) of a csv/xls file. :type csvl: list[list[str | int | float]] | list[list[str]] :param pattern: Pattern to be searched (default="Label: Label"). :type pattern: str :param col: Column to search (default=0). :type col: int :returns: Row/line index for all occurrences of pattern. Empty list for no occurrences. :rtype: list[int] .. py:function:: strip_lines(lines) Remove empty fields/cells from lines read from a csv file. :param lines: Lines (list_of_lines) that are a list of fields, typically from a csv/xls file. :type lines: list[list[str | int | float]] :returns: Lines (list_of_lines) removed from blank cells. :rtype: list[list[str | int | float]] .. rubric:: Examples >>> lines = [ ... ["Shaking (Linear) Amplitude:", "", "", "", 2, "mm", "", "", "", "", ""] ... ] >>> strip_lines(lines) [['Shaking (Linear) Amplitude:', 2, 'mm']]