Commit e5793362 authored by Camilla Dodge Koslowsky Harris's avatar Camilla Dodge Koslowsky Harris
Browse files

Formatting docstrings so they work with pydocs

parent e90d39d3
...@@ -571,7 +571,7 @@ Some useful references: ...@@ -571,7 +571,7 @@ Some useful references:
apply_equations(eqn_path: str, verbose: bool = False) -> None apply_equations(eqn_path: str, verbose: bool = False) -> None
``` ```
Apply an equations file in the Tecplot macro format to the active dataset Apply a Tecplot-formatted equations file to the active dataset.
Please reference the Tecplot User's Manual for more details on Please reference the Tecplot User's Manual for more details on
equation files and syntax. It is recommended to use this function with eqn equation files and syntax. It is recommended to use this function with eqn
...@@ -580,11 +580,9 @@ See [TECPLOT](TECPLOT.markdown) for tips on using pytecplot. ...@@ -580,11 +580,9 @@ See [TECPLOT](TECPLOT.markdown) for tips on using pytecplot.
**Arguments**: **Arguments**:
eqn_file_path (str): - `eqn_file_path` _str_ - The path to the equation macro file (typically with
The path to the equation macro file extension `.eqn`).
(typically with extension `.eqn`). - `verbose` _bool_ - (Optional) Whether or not to print the equations as they
verbose (bool):
(Optional) Whether or not to print the equations as they
are applied. Default behavior is silent. are applied. Default behavior is silent.
...@@ -630,8 +628,8 @@ This is helpful for accessing Tecplot variables. ...@@ -630,8 +628,8 @@ This is helpful for accessing Tecplot variables.
**Arguments**: **Arguments**:
variable_name (str): - `variable_name` _str_ - A string which may contain the meta-characters * ?
A string which may contain the meta-characters * ? [ or ]. [ or ].
**Examples**: **Examples**:
...@@ -645,8 +643,8 @@ This is helpful for accessing Tecplot variables. ...@@ -645,8 +643,8 @@ This is helpful for accessing Tecplot variables.
```python ```python
print(dataset.variable('X [R]').name) print(dataset.variable('X [R]').name)
# TecplotPatternMatchWarning: no variables found matching: "X [R]" For # TecplotPatternMatchWarning: no variables found matching: "X [R]" For
# a literal match, the meta-characters: * ? [ ] must be wrapped in square- # a literal match, the meta-characters: * ? [ ] must be wrapped in
# For example, "[?]" matches the character "?"... # square-brackets. For example, "[?]" matches the character "?"...
``` ```
However, However,
```python ```python
...@@ -665,21 +663,16 @@ Writes a tecplot zone to various formats. ...@@ -665,21 +663,16 @@ Writes a tecplot zone to various formats.
**Arguments**: **Arguments**:
tecplot_dataset (tecplot.data.dataset.Dataset): - `tecplot_dataset` _tecplot.data.dataset.Dataset_ - The dataset to save.
The dataset to save. - `tecplot_zone` _tecplot.data.dataset.Zone_ - The zone to save.
tecplot_zone (tecplot.data.dataset.Zone): - `write_as` _str_ - Type of file to write to. Supported options are `hdf5`,
The zone to save. `csv`, `tecplot_ascii`, and `tecplot_plt`.
write_as (str): - `filename` _str_ - Name of the file to write to.
Type of file to write to. Supported options are 'hdf5', variables : (Optional) Specify a subset of the dataset variables to
'csv', 'tecplot_ascii', and 'tecplot_plt'. save. This option may decrease the size of the
filename (str): output. Default behavior is to save all
Name of the file to write to. variables.
variables (list(tecplot.data.dataset.Variable)): - `verbose` - (Optional) Print diagnostic information. Defaults to False.
(Optional) Specify a subset of the dataset variables to
save. This option may decrease the size of the output. Default
behavior is to save all variables.
verbose:
(Optional) Print diagnostic information. Defaults to False.
**Examples**: **Examples**:
...@@ -728,50 +721,52 @@ Interpolates Tecplot binary data onto various geometries. ...@@ -728,50 +721,52 @@ Interpolates Tecplot binary data onto various geometries.
**Arguments**: **Arguments**:
dataset: - `dataset` - The loaded Tecplot dataset.
The loaded Tecplot dataset. - `source_zone` - The Tecplot zone to interpolate onto the geometry.
source_zone: - `geometry` _str_ - Type of geometry for interpolation. Supported geometries
The Tecplot zone to interpolate onto the geometry. are `shell`, `line`, `rectprism`, or `trajectory`. See
geometry (str): below for the required keyword arguments for each
Type of geometry for interpolation. Supported geometries geometry.
are 'shell', 'line', 'rectprism', or 'trajectory'. See below for the - `variables` _list_ - (Optional) Subset of variables to interpolate. Default
required keyword arguments for each geometry.
variables (list):
(Optional) Subset of variables to interpolate. Default
behavior is to interpolate all variables. behavior is to interpolate all variables.
verbose: - `verbose` - (Optional) Print diagnostic information. Defaults to False.
(Optional) Print diagnostic information. Defaults to False.
**kwargs: **kwargs:
- `center` _array-like_ - Argument for the 'shell' geometry. Contains the X, - `center` _array-like_ - Argument for the `shell` geometry. Contains the X,
Y, and Z positions of the shell. Defaults to (0,0,0). Y, and Z positions of the shell. Defaults to
- `radius` _float_ - Argument for the 'shell' geometry. Required. (0,0,0).
- `npoints` _array-like_ - Argument for the 'shell' geometry. Contains the - `radius` _float_ - Argument for the `shell` geometry. Required.
number of points in the azimuthal and polar directions to - `npoints` _array-like_ - Argument for the `shell` geometry. Contains the
interpolate onto, excluding the north and south polar points. number of points in the azimuthal and polar
Defaults to (360,179). directions to interpolate onto, excluding the
- `r1` _array-like_ - Argument for the 'line' geometry. Contains the X, Y, north and south polar points. Defaults to
and Z positions of the point where the line starts. Required. (360,179).
- `r2` _array-like_ - Argument for the 'line' geometry. Contains the X, Y, - `r1` _array-like_ - Argument for the `line` geometry. Contains the X, Y,
and Z positions of the point where the line ends. Required. and Z positions of the point where the line starts.
- `npoints` _int_ - Argument for the 'line' geometry. The number of points Required.
- `r2` _array-like_ - Argument for the `line` geometry. Contains the X, Y,
and Z positions of the point where the line ends.
Required.
- `npoints` _int_ - Argument for the `line` geometry. The number of points
along the line to interpolate onto. Required. along the line to interpolate onto. Required.
- `center` _array-like_ - Argument for the 'rectprism' geometry. Contains the - `center` _array-like_ - Argument for the `rectprism` geometry. Contains the
X, Y, and Z positions of the center of the rectangular prism. X, Y, and Z positions of the center of the
Defaults to (0,0,0). rectangular prism. Defaults to (0,0,0).
- `halfwidths` _array-like_ - Argument for the 'rectprism' geometry. Contains - `halfwidths` _array-like_ - Argument for the `rectprism` geometry. Contains
the half widths of the rectangular prism in the X, Y, and Z the half widths of the rectangular prism in the
directions. Required. X, Y, and Z directions. Required.
- `npoints` _array-like_ - Argument for the 'rectprism' geometry. Contains - `npoints` _array-like_ - Argument for the `rectprism` geometry. Contains
the number of points in the X, Y, and Z directions to interpolate the number of points in the X, Y, and Z directions
onto. Required. to interpolate onto. Required.
- `trajectory_data` _str_ - Argument for the 'trajectory' geometry. The path - `trajectory_data` _str_ - Argument for the `trajectory` geometry. The path
to the ASCII trajectory data file. Required. to the ASCII trajectory data file. Required.
- `trajectory_format` _str_ - Argument for the 'trajectory' geometry. The - `trajectory_format` _str_ - Argument for the `trajectory` geometry. The
format of the trajectory data file. Supported formats are 'tecplot' format of the trajectory data file. Supported
(data is a tecplot zone with 3D positional variables and 'time') and formats are `tecplot` (data is a tecplot zone
'batsrus' (data is formatted as described for the `SATELLITE` with 3D positional variables) and `batsrus`
command, see SWMF documentation). Required. (data is formatted as described for the
``SATELLITE`` command, see SWMF documentation).
Required.
**Examples**: **Examples**:
......
#!/usr/bin/env bash
# Script to make the docs for swmfpy.
# Requires pydoc-markdown
# run `pip install pydoc-markdown --user`
# then run this script in the project root directory
pydoc-markdown --py3 -v -I. --render-toc -m swmfpy -m swmfpy.web -m swmfpy.io -m swmfpy.paramin -m swmfpy.tools -m swmfpy.tecplottools $@ | sed 's/\\043/#/g' > DOCUMENTATION.markdown
...@@ -28,14 +28,13 @@ import numpy as np ...@@ -28,14 +28,13 @@ import numpy as np
import tecplot import tecplot
def _get_variable_names(variables): def _get_variable_names(variables) -> list:
"""For getting the names of a group of Tecplot variables""" """For getting the names of a group of Tecplot variables."""
return [var.name for var in variables] return [var.name for var in variables]
def _shell_geometry(geometry_params: dict) -> dict: def _shell_geometry(geometry_params: dict) -> dict:
"""Returns a dict containing points for the described shell geometry. """Returns a dict containing points for the described shell geometry."""
"""
nlon = geometry_params['npoints'][0] # 360 nlon = geometry_params['npoints'][0] # 360
nlat = geometry_params['npoints'][1] # 179 nlat = geometry_params['npoints'][1] # 179
lons = np.linspace(0, 360, nlon, endpoint=False) lons = np.linspace(0, 360, nlon, endpoint=False)
...@@ -63,8 +62,7 @@ def _shell_geometry(geometry_params: dict) -> dict: ...@@ -63,8 +62,7 @@ def _shell_geometry(geometry_params: dict) -> dict:
def _line_geometry(geometry_params: dict) -> dict: def _line_geometry(geometry_params: dict) -> dict:
"""Returns a dict containing points for the described line geometry. """Returns a dict containing points for the described line geometry."""
"""
geometry_points = { geometry_points = {
'npoints': geometry_params['npoints'], 'npoints': geometry_params['npoints'],
'X': np.linspace( 'X': np.linspace(
...@@ -84,8 +82,7 @@ def _line_geometry(geometry_params: dict) -> dict: ...@@ -84,8 +82,7 @@ def _line_geometry(geometry_params: dict) -> dict:
def _rectprism_geometry(geometry_params: dict) -> dict: def _rectprism_geometry(geometry_params: dict) -> dict:
"""Returns a dict containing points for the described rectprism geometry. """Returns a dict containing points for the described rectprism geometry."""
"""
npoints = (geometry_params['npoints'][0] npoints = (geometry_params['npoints'][0]
* geometry_params['npoints'][1] * geometry_params['npoints'][1]
* geometry_params['npoints'][2]) * geometry_params['npoints'][2])
...@@ -157,8 +154,7 @@ def _trajectory_geometry(geometry_params: dict) -> dict: ...@@ -157,8 +154,7 @@ def _trajectory_geometry(geometry_params: dict) -> dict:
def _save_hdf5(filename, geometry_params, new_zone, variables) -> None: def _save_hdf5(filename, geometry_params, new_zone, variables) -> None:
"""Save the aux data and a subset of the variables in hdf5 format. """Save the aux data and a subset of the variables in hdf5 format."""
"""
column_names = _get_variable_names(variables) column_names = _get_variable_names(variables)
tp_data = [] tp_data = []
for var in variables: for var in variables:
...@@ -171,8 +167,7 @@ def _save_hdf5(filename, geometry_params, new_zone, variables) -> None: ...@@ -171,8 +167,7 @@ def _save_hdf5(filename, geometry_params, new_zone, variables) -> None:
def _save_csv(filename, geometry_params, new_zone, variables) -> None: def _save_csv(filename, geometry_params, new_zone, variables) -> None:
"""Save the aux data and a subset of the variables in plain-text format. """Save the aux data and a subset of the variables in plain-text format."""
"""
aux_data = geometry_params.__repr__() + '\n' aux_data = geometry_params.__repr__() + '\n'
column_names = variables[0].name.__repr__() column_names = variables[0].name.__repr__()
for var in variables[1:]: for var in variables[1:]:
...@@ -197,7 +192,7 @@ def _add_variable_value(dataset, variable_name: str, zone, values): ...@@ -197,7 +192,7 @@ def _add_variable_value(dataset, variable_name: str, zone, values):
def apply_equations(eqn_path: str, verbose: bool = False) -> None: def apply_equations(eqn_path: str, verbose: bool = False) -> None:
"""Apply an equations file in the Tecplot macro format to the active dataset """Apply a Tecplot-formatted equations file to the active dataset.
Please reference the Tecplot User's Manual for more details on Please reference the Tecplot User's Manual for more details on
equation files and syntax. It is recommended to use this function with eqn equation files and syntax. It is recommended to use this function with eqn
...@@ -205,12 +200,10 @@ def apply_equations(eqn_path: str, verbose: bool = False) -> None: ...@@ -205,12 +200,10 @@ def apply_equations(eqn_path: str, verbose: bool = False) -> None:
See [TECPLOT](TECPLOT.markdown) for tips on using pytecplot. See [TECPLOT](TECPLOT.markdown) for tips on using pytecplot.
Args: Args:
eqn_file_path (str): eqn_file_path (str): The path to the equation macro file (typically with
The path to the equation macro file extension `.eqn`).
(typically with extension `.eqn`). verbose (bool): (Optional) Whether or not to print the equations as they
verbose (bool): are applied. Default behavior is silent.
(Optional) Whether or not to print the equations as they
are applied. Default behavior is silent.
Examples: Examples:
```python ```python
...@@ -266,8 +259,8 @@ def bracketify(variable_name: str) -> str: ...@@ -266,8 +259,8 @@ def bracketify(variable_name: str) -> str:
This is helpful for accessing Tecplot variables. This is helpful for accessing Tecplot variables.
Args: Args:
variable_name (str): variable_name (str): A string which may contain the meta-characters * ?
A string which may contain the meta-characters * ? [ or ]. [ or ].
Examples: Examples:
In a dataset which contains the variable 'X [R]', In a dataset which contains the variable 'X [R]',
...@@ -279,8 +272,8 @@ def bracketify(variable_name: str) -> str: ...@@ -279,8 +272,8 @@ def bracketify(variable_name: str) -> str:
```python ```python
print(dataset.variable('X [R]').name) print(dataset.variable('X [R]').name)
# TecplotPatternMatchWarning: no variables found matching: "X [R]" For # TecplotPatternMatchWarning: no variables found matching: "X [R]" For
# a literal match, the meta-characters: * ? [ ] must be wrapped in square- # a literal match, the meta-characters: * ? [ ] must be wrapped in
# For example, "[?]" matches the character "?"... # square-brackets. For example, "[?]" matches the character "?"...
``` ```
However, However,
```python ```python
...@@ -308,21 +301,16 @@ def write_zone( ...@@ -308,21 +301,16 @@ def write_zone(
"""Writes a tecplot zone to various formats. """Writes a tecplot zone to various formats.
Args: Args:
tecplot_dataset (tecplot.data.dataset.Dataset): tecplot_dataset (tecplot.data.dataset.Dataset): The dataset to save.
The dataset to save. tecplot_zone (tecplot.data.dataset.Zone): The zone to save.
tecplot_zone (tecplot.data.dataset.Zone): write_as (str): Type of file to write to. Supported options are `hdf5`,
The zone to save. `csv`, `tecplot_ascii`, and `tecplot_plt`.
write_as (str): filename (str): Name of the file to write to.
Type of file to write to. Supported options are 'hdf5', variables : (Optional) Specify a subset of the dataset variables to
'csv', 'tecplot_ascii', and 'tecplot_plt'. save. This option may decrease the size of the
filename (str): output. Default behavior is to save all
Name of the file to write to. variables.
variables (list(tecplot.data.dataset.Variable)): verbose: (Optional) Print diagnostic information. Defaults to False.
(Optional) Specify a subset of the dataset variables to
save. This option may decrease the size of the output. Default
behavior is to save all variables.
verbose:
(Optional) Print diagnostic information. Defaults to False.
Examples: Examples:
```python ```python
...@@ -413,12 +401,10 @@ def _assign_geometry_defaults( ...@@ -413,12 +401,10 @@ def _assign_geometry_defaults(
If the parameters are already set nothing will change. If the parameters are already set nothing will change.
Args: Args:
geometry (str): geometry (str): String identifying the geometry to look for.
String identifying the geometry to look for. default_params (dict): Dictionary of the default parameters.
default_params (dict): geomatry_params (dict): Dictionary in which to look for and set
Dictionary of the default parameters. parameters.
geomatry_params (dict):
Dictionary in which to look for and set parameters.
""" """
if geometry in geometry_params['geometry']: if geometry in geometry_params['geometry']:
for key, value in default_params.items(): for key, value in default_params.items():
...@@ -474,50 +460,52 @@ def interpolate_zone_to_geometry( ...@@ -474,50 +460,52 @@ def interpolate_zone_to_geometry(
"""Interpolates Tecplot binary data onto various geometries. """Interpolates Tecplot binary data onto various geometries.
Args: Args:
dataset: dataset: The loaded Tecplot dataset.
The loaded Tecplot dataset. source_zone: The Tecplot zone to interpolate onto the geometry.
source_zone: geometry (str): Type of geometry for interpolation. Supported geometries
The Tecplot zone to interpolate onto the geometry. are `shell`, `line`, `rectprism`, or `trajectory`. See
geometry (str): below for the required keyword arguments for each
Type of geometry for interpolation. Supported geometries geometry.
are 'shell', 'line', 'rectprism', or 'trajectory'. See below for the variables (list): (Optional) Subset of variables to interpolate. Default
required keyword arguments for each geometry. behavior is to interpolate all variables.
variables (list): verbose: (Optional) Print diagnostic information. Defaults to False.
(Optional) Subset of variables to interpolate. Default
behavior is to interpolate all variables.
verbose:
(Optional) Print diagnostic information. Defaults to False.
**kwargs: **kwargs:
center (array-like): Argument for the 'shell' geometry. Contains the X, center (array-like): Argument for the `shell` geometry. Contains the X,
Y, and Z positions of the shell. Defaults to (0,0,0). Y, and Z positions of the shell. Defaults to
radius (float): Argument for the 'shell' geometry. Required. (0,0,0).
npoints (array-like): Argument for the 'shell' geometry. Contains the radius (float): Argument for the `shell` geometry. Required.
number of points in the azimuthal and polar directions to npoints (array-like): Argument for the `shell` geometry. Contains the
interpolate onto, excluding the north and south polar points. number of points in the azimuthal and polar
Defaults to (360,179). directions to interpolate onto, excluding the
r1 (array-like): Argument for the 'line' geometry. Contains the X, Y, north and south polar points. Defaults to
and Z positions of the point where the line starts. Required. (360,179).
r2 (array-like): Argument for the 'line' geometry. Contains the X, Y, r1 (array-like): Argument for the `line` geometry. Contains the X, Y,
and Z positions of the point where the line ends. Required. and Z positions of the point where the line starts.
npoints (int): Argument for the 'line' geometry. The number of points Required.
along the line to interpolate onto. Required. r2 (array-like): Argument for the `line` geometry. Contains the X, Y,
center (array-like): Argument for the 'rectprism' geometry. Contains the and Z positions of the point where the line ends.
X, Y, and Z positions of the center of the rectangular prism. Required.
Defaults to (0,0,0). npoints (int): Argument for the `line` geometry. The number of points
halfwidths (array-like): Argument for the 'rectprism' geometry. Contains along the line to interpolate onto. Required.
the half widths of the rectangular prism in the X, Y, and Z center (array-like): Argument for the `rectprism` geometry. Contains the
directions. Required. X, Y, and Z positions of the center of the
npoints (array-like): Argument for the 'rectprism' geometry. Contains rectangular prism. Defaults to (0,0,0).
the number of points in the X, Y, and Z directions to interpolate halfwidths (array-like): Argument for the `rectprism` geometry. Contains
onto. Required. the half widths of the rectangular prism in the
trajectory_data (str): Argument for the 'trajectory' geometry. The path X, Y, and Z directions. Required.
to the ASCII trajectory data file. Required. npoints (array-like): Argument for the `rectprism` geometry. Contains
trajectory_format (str): Argument for the 'trajectory' geometry. The the number of points in the X, Y, and Z directions
format of the trajectory data file. Supported formats are 'tecplot' to interpolate onto. Required.
(data is a tecplot zone with 3D positional variables and 'time') and trajectory_data (str): Argument for the `trajectory` geometry. The path
'batsrus' (data is formatted as described for the #SATELLITE to the ASCII trajectory data file. Required.
command, see SWMF documentation). Required. trajectory_format (str): Argument for the `trajectory` geometry. The
format of the trajectory data file. Supported
formats are `tecplot` (data is a tecplot zone
with 3D positional variables) and `batsrus`
(data is formatted as described for the
`#SATELLITE` command, see SWMF documentation).
Required.
Examples: Examples:
```python ```python
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment