Skip to content

Commit

Permalink
Update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed Jun 5, 2024
1 parent 6841233 commit d537d98
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 76 deletions.
2 changes: 1 addition & 1 deletion disdrodb/api/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def check_valid_campaign_dir(campaign_dir):
Used to check validity of ``raw_dir`` and ``processed_dir``.
The path must be ``*/DISDRODB/<Raw/Processed>/<DATA_SOURCE>/<CAMPAIGN_NAME>``
The path must be ``/DISDRODB/<Raw/Processed>/<DATA_SOURCE>/<CAMPAIGN_NAME>``.
"""
last_component = os.path.basename(campaign_dir)
tree_components = infer_disdrodb_tree_path_components(campaign_dir)
Expand Down
2 changes: 1 addition & 1 deletion disdrodb/api/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def read_config_file(sensor_name: str, product: str, filename: str) -> dict:
return dictionary


def available_sensor_names(product: str = "L0A") -> sorted:
def available_sensor_names(product: str = "L0A") -> list:
"""Get available names of sensors.
Returns
Expand Down
8 changes: 4 additions & 4 deletions disdrodb/api/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def define_l0a_filename(df, processed_dir, station_name: str) -> str:
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
L0A DataFrame
processed_dir : str
Path of the processed directory
Expand Down Expand Up @@ -425,7 +425,7 @@ def define_l0b_filename(ds, processed_dir, station_name: str) -> str:
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
L0B xarray Dataset
processed_dir : str
Path of the processed directory
Expand Down Expand Up @@ -454,7 +454,7 @@ def define_l0a_filepath(df: pd.DataFrame, processed_dir: str, station_name: str)
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
L0A DataFrame.
processed_dir : str
Path of the processed directory.
Expand All @@ -477,7 +477,7 @@ def define_l0b_filepath(ds: xr.Dataset, processed_dir: str, station_name: str, l
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
L0B xarray Dataset.
processed_dir : str
Path of the processed directory.
Expand Down
6 changes: 3 additions & 3 deletions disdrodb/l0/check_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _check_raw_fields_available(df: pd.DataFrame, sensor_name: str, verbose: boo
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Dataframe
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -124,7 +124,7 @@ def check_l0a_column_names(df: pd.DataFrame, sensor_name: str) -> None:
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe.
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -165,7 +165,7 @@ def check_l0a_standards(df: pd.DataFrame, sensor_name: str, verbose: bool = True
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
L0A dataframe.
sensor_name : str
Name of the sensor.
Expand Down
17 changes: 1 addition & 16 deletions disdrodb/l0/l0_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,38 +385,29 @@ def run_l0a(
The path should have the following structure: ``<...>/DISDRODB/Processed/<DATA_SOURCE>/<CAMPAIGN_NAME>``.
For testing purposes, this function exceptionally accepts also a directory path simply ending
with ``<CAMPAIGN_NAME>`` (e.g., ``/tmp/<CAMPAIGN_NAME>``).
station_name : str
The name of the station.
The name of the station.
glob_patterns : str
Glob pattern to search for data files in ``<raw_dir>/data/<station_name>``.
column_names : list
Column names of the raw text file.
reader_kwargs : dict
Arguments for Pandas ``read_csv`` function to open the text file.
df_sanitizer_fun : callable, optional
Sanitizer function to format the DataFrame into DISDRODB L0A standard.
Default is ``None``.
parallel : bool, optional
If ``True``, process the files simultaneously in multiple processes.
The number of simultaneous processes can be customized using the ``dask.distributed.LocalCluster``.
If ``False``, process the files sequentially in a single process.
Default is ``False``.
verbose : bool, optional
If ``True``, print detailed processing information to the terminal.
Default is ``False``.
force : bool, optional
If ``True``, overwrite existing data in destination directories.
If ``False``, raise an error if data already exists in destination directories.
Default is ``False``.
debugging_mode : bool, optional
If ``True``, reduce the amount of data to process.
Processes only the first 100 rows of 3 raw data files.
Expand Down Expand Up @@ -519,33 +510,27 @@ def run_l0b(
- The ``<CAMPAIGN_NAME>`` must semantically match between:
- the ``raw_dir`` and ``processed_dir`` directory paths;
- with the key ``campaign_name`` within the metadata YAML files.
processed_dir : str
The desired directory path for the processed DISDRODB L0A and L0B products.
The path should have the following structure: ``<...>/DISDRODB/Processed/<DATA_SOURCE>/<CAMPAIGN_NAME>``.
For testing purposes, this function exceptionally accepts also a directory path simply ending
with ``<CAMPAIGN_NAME>`` (e.g., ``/tmp/<CAMPAIGN_NAME>``).
station_name : str
The name of the station.
force : bool, optional
If ``True``, overwrite existing data in destination directories.
If ``False``, raise an error if data already exists in destination directories.
Default is ``False``.
verbose : bool, optional
If ``True``, print detailed processing information to the terminal.
Default is ``True``.
parallel : bool, optional
If ``True``, process the files simultaneously in multiple processes.
The number of simultaneous processes can be customized using the ``dask.distributed.LocalCluster``.
Ensure that the ``threads_per_worker`` (number of thread per process) is set to 1 to avoid HDF errors.
Also, ensure to set the ``HDF5_USE_FILE_LOCKING`` environment variable to ``False``.
If ``False``, process the files sequentially in a single process.
Default is ``False``.
debugging_mode : bool, optional
If ``True``, reduce the amount of data to process.
Only the first 3 raw data files will be processed.
Expand Down
20 changes: 10 additions & 10 deletions disdrodb/l0/l0a_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def remove_rows_with_missing_time(df: pd.DataFrame, verbose: bool = False):
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe.
verbose : bool
Whether to verbose the processing. The default is ``False``.
Expand Down Expand Up @@ -193,7 +193,7 @@ def remove_duplicated_timesteps(df: pd.DataFrame, verbose: bool = False):
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe.
verbose : bool
Whether to verbose the processing. The default is ``False``.
Expand Down Expand Up @@ -251,7 +251,7 @@ def remove_issue_timesteps(df, issue_dict, verbose=False):
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe.
issue_dict : dict
Issue dictionary.
Expand Down Expand Up @@ -293,7 +293,7 @@ def cast_column_dtypes(df: pd.DataFrame, sensor_name: str) -> pd.DataFrame:
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe.
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -330,7 +330,7 @@ def coerce_corrupted_values_to_nan(df: pd.DataFrame, sensor_name: str) -> pd.Dat
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe.
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -361,7 +361,7 @@ def strip_string_spaces(df: pd.DataFrame, sensor_name: str) -> pd.DataFrame:
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe.
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -456,7 +456,7 @@ def replace_nan_flags(df, sensor_name, verbose=False):
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe.
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -491,7 +491,7 @@ def set_nan_outside_data_range(df, sensor_name, verbose=False):
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe.
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -530,7 +530,7 @@ def set_nan_invalid_values(df, sensor_name, verbose=False):
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe.
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -679,7 +679,7 @@ def write_l0a(
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe.
filepath : str
Output file path.
Expand Down
14 changes: 7 additions & 7 deletions disdrodb/l0/l0b_nc_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def preprocess_raw_netcdf(ds, dict_names, sensor_name):
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
Raw netCDF to be converted to DISDRODB standards.
dict_names : dict
Dictionary mapping raw netCDF variables/coordinates/dimension names
Expand All @@ -151,7 +151,7 @@ def preprocess_raw_netcdf(ds, dict_names, sensor_name):
Returns
-------
ds : xr.Dataset
ds : xarray.Dataset
xarray Dataset with variables compliant to DISDRODB conventions.
"""
Expand Down Expand Up @@ -185,7 +185,7 @@ def replace_custom_nan_flags(ds, dict_nan_flags, verbose=False):
Parameters
----------
df : xr.Dataset
df : xarray.Dataset
Input xarray dataset
dict_nan_flags : dict
Dictionary with nan flags value to set as ``np.nan``.
Expand Down Expand Up @@ -218,7 +218,7 @@ def replace_nan_flags(ds, sensor_name, verbose):
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
Input xarray dataset
dict_nan_flags : dict
Dictionary with nan flags value to set as np.nan
Expand All @@ -242,7 +242,7 @@ def set_nan_outside_data_range(ds, sensor_name, verbose):
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
Input xarray dataset
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -280,7 +280,7 @@ def set_nan_invalid_values(ds, sensor_name, verbose):
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
Input xarray dataset
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -323,7 +323,7 @@ def create_l0b_from_raw_nc(
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
Raw xarray dataset
dict_names : dict
Dictionary mapping raw netCDF variables/coordinates/dimension names
Expand Down
16 changes: 8 additions & 8 deletions disdrodb/l0/l0b_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def retrieve_l0b_arrays(
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
Input dataframe
sensor_name : str
Name of the sensor
Expand Down Expand Up @@ -287,7 +287,7 @@ def _convert_object_variables_to_string(ds: xr.Dataset) -> xr.Dataset:
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
Input dataset.
Returns
Expand All @@ -306,7 +306,7 @@ def _set_variable_attributes(ds: xr.Dataset, sensor_name: str) -> xr.Dataset:
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
Input dataset.
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -431,7 +431,7 @@ def create_l0b_from_l0a(
Parameters
----------
df : pd.DataFrame
df : pandas.DataFrame
DISDRODB L0A dataframe.
attrs : dict
Station metadata.
Expand Down Expand Up @@ -503,7 +503,7 @@ def sanitize_encodings_dict(encoding_dict: dict, ds: xr.Dataset) -> dict:
----------
encoding_dict : dict
Dictionary containing the encoding to write DISDRODB L0B netCDFs.
ds : xr.Dataset
ds : xarray.Dataset
Input dataset.
Returns
Expand All @@ -525,7 +525,7 @@ def rechunk_dataset(ds: xr.Dataset, encoding_dict: dict) -> xr.Dataset:
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
Input xarray dataset
encoding_dict : dict
Dictionary containing the encoding to write the xarray dataset as a netCDF.
Expand All @@ -549,7 +549,7 @@ def set_encodings(ds: xr.Dataset, sensor_name: str) -> xr.Dataset:
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
Input xarray dataset.
sensor_name : str
Name of the sensor.
Expand Down Expand Up @@ -585,7 +585,7 @@ def write_l0b(ds: xr.Dataset, filepath: str, force=False) -> None:
Parameters
----------
ds : xr.Dataset
ds : xarray.Dataset
Input xarray dataset.
filepath : str
Output file path.
Expand Down
Loading

0 comments on commit d537d98

Please sign in to comment.