Skip to content

Commit

Permalink
Fix docstring bugs (JCSDA-internal#151)
Browse files Browse the repository at this point in the history
* fix bugs in transforms

* data api

* one line miss from last PR

* utils

* pycodestyle
  • Loading branch information
kevindougherty-noaa authored Aug 18, 2023
1 parent 2fd6d19 commit 315d954
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 101 deletions.
4 changes: 2 additions & 2 deletions src/eva/data/cubed_sphere_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def read_fms_tiles(files, variable, logger):
Args:
files (list): List of netCDF file paths.
variable (str): Name of the variable to extract.
logger: Logger object for logging messages.
logger (Logger): Logger object for logging messages.
Returns:
np.ndarray: Combined variable array from input files.
Expand Down Expand Up @@ -77,7 +77,7 @@ def execute(self, dataset_config, data_collections, timing):
Args:
dataset_config (dict): Configuration dictionary for the dataset.
data_collections: Object for managing data collections.
data_collections (DataCollections): Object for managing data collections.
timing: Timing object for tracking execution time.
"""

Expand Down
2 changes: 1 addition & 1 deletion src/eva/data/gsi_obs_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def subset_channels(ds, channels, logger, add_channels_variable=False):
Args:
ds (Dataset): The xarray Dataset to subset.
channels (list): List of channel numbers to keep.
logger: Logger instance for logging messages.
logger (Logger): Logger instance for logging messages.
add_channels_variable (bool, optional): Whether to add 'channelNumber' variable. Default is
False.
"""
Expand Down
41 changes: 25 additions & 16 deletions src/eva/data/ioda_obs_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ def subset_channels(ds, channels):
the dataset, the function will perform the subset operation.
Example:
# Subset the dataset 'data' to include only channels 1, 5 and 10:
subset_ds = subset_channels(data, [1, 5, 10])
::
# Subset the dataset 'data' to include only channels 1, 5 and 10:
subset_ds = subset_channels(data, [1, 5, 10])
"""

if 'Channel' in list(ds.dims):
Expand Down Expand Up @@ -97,14 +99,16 @@ class IodaObsSpace(EvaDatasetBase):
- (Additional notes, if applicable)
Example:
# Instantiate the class
ioda_instance = IodaObsSpace()
::
# Instantiate the class
ioda_instance = IodaObsSpace()
# Execute data collection processing using IODA observation space
ioda_instance.execute(dataset_config, data_collections, timing)
# Execute data collection processing using IODA observation space
ioda_instance.execute(dataset_config, data_collections, timing)
# Generate a default configuration dictionary for IODA observation space
default_config = ioda_instance.generate_default_config(filenames, collection_name)
# Generate a default configuration dictionary for IODA observation space
default_config = ioda_instance.generate_default_config(filenames, collection_name)
"""

def execute(self, dataset_config, data_collections, timing):
Expand All @@ -127,11 +131,13 @@ def execute(self, dataset_config, data_collections, timing):
- This method operates on instance-specific attributes.
Example:
# Instantiate the class
ioda_instance = IodaObsSpace()
::
# Execute data collection processing using IODA observation space
ioda_instance.execute(dataset_config, data_collections, timing)
# Instantiate the class
ioda_instance = IodaObsSpace()
# Execute data collection processing using IODA observation space
ioda_instance.execute(dataset_config, data_collections, timing)
"""

# Get channels for radiances
Expand Down Expand Up @@ -293,11 +299,14 @@ def generate_default_config(self, filenames, collection_name):
- This method operates on instance-specific attributes.
Example:
# Instantiate the class
ioda_instance = IodaObsSpace()
::
# Instantiate the class
ioda_instance = IodaObsSpace()
# Generate a default configuration dictionary for IODA observation space
default_config = ioda_instance.generate_default_config(filenames, collection_name)
# Generate a default configuration dictionary for IODA observation space
default_config = ioda_instance.generate_default_config(filenames,
collection_name)
"""

eva_dict = {'filenames': filenames,
Expand Down
4 changes: 2 additions & 2 deletions src/eva/data/jedi_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def execute(self, dataset_config, data_collections, timing):
Args:
dataset_config (dict): Configuration dictionary for the dataset.
data_collections: Object for managing data collections.
timing: Timing object for tracking execution time.
data_collections (DataCollections): Object for managing data collections.
timing (Timing): Timing object for tracking execution time.
"""

# Get name of the log file to parse
Expand Down
4 changes: 2 additions & 2 deletions src/eva/data/lat_lon.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def execute(self, dataset_config, data_collections, timing):
Args:
dataset_config (dict): Configuration dictionary for the dataset.
data_collections: Object for managing data collections.
timing: Timing object for tracking execution time.
data_collections (DataCollections): Object for managing data collections.
timing (Timing): Timing object for tracking execution time.
"""

# Filename to be read into this collection
Expand Down
4 changes: 2 additions & 2 deletions src/eva/data/mon_data_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def execute(self, dataset_config, data_collections, timing):
Args:
dataset_config (dict): Configuration dictionary for the dataset.
data_collections: Object for managing data collections.
timing: Timing object for tracking execution time.
data_collections (DataCollections): Object for managing data collections.
timing (Timing): Timing object for tracking execution time.
"""

# Set the collection name
Expand Down
2 changes: 1 addition & 1 deletion src/eva/data/soca_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def read_soca(file, variable, logger):
Args:
file (str): Path to the SOCA data file.
variable (str): Name of the variable to read.
logger: Logger for logging messages.
logger (Logger): Logger for logging messages.
Returns:
tuple: A tuple containing dimensions (list) and data (numpy.ndarray) for the specified
Expand Down
2 changes: 1 addition & 1 deletion src/eva/plotting/emcpy/plot_tools/figure_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def figure_driver(config, data_collections, timing, logger):
config (dict): A dictionary containing the configuration for generating figures.
data_collections (DataCollections): An instance of the DataCollections class containing
input data.
timing: A timing instance to measure the execution time.
timing (Timing): A timing instance to measure the execution time.
logger (Logger): An instance of the logger for logging messages.
This function generates and saves multiple figures based on the provided configuration. It
Expand Down
37 changes: 20 additions & 17 deletions src/eva/transforms/accept_where.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def accept_where(config, data_collections):
Args:
config (dict): A configuration dictionary containing transformation parameters.
data_collections (DataCollections): An instance of the DataCollections class containing
input data.
input data.
Returns:
None
Expand All @@ -40,15 +40,17 @@ def accept_where(config, data_collections):
The resulting filtered variables are added to the data collections.
Example:
config = {
'collections': [...],
'groups': [...],
'variables': [...],
'new name': 'filtered_variable',
'starting field': 'original_variable',
'where': ['${collection}::${group}::${variable} >= 0.0']
}
accept_where(config, data_collections)
::
config = {
'collections': [...],
'groups': [...],
'variables': [...],
'new name': 'filtered_variable',
'starting field': 'original_variable',
'where': ['${collection}::${group}::${variable} >= 0.0']
}
accept_where(config, data_collections)
"""

# Create a logger
Expand Down Expand Up @@ -126,13 +128,14 @@ def generate_accept_where_config(new_name, starting_field, where, collection, va
'for' dictionary to apply the transformation to the specified variables.
Example:
new_name = 'filtered_variable'
starting_field = 'original_variable'
where = ['group1 >= 0', 'group2 < 10']
collection = 'my_collection'
var_list = ['variable1', 'variable2']
config = generate_accept_where_config(new_name, starting_field, where, collection,
var_list)
::
new_name = 'filtered_variable'
starting_field = 'original_variable'
where = ['group1 >= 0', 'group2 < 10']
collection = 'my_collection'
var_list = ['variable1', 'variable2']
config = generate_accept_where_config(new_name, starting_field, where,
collection, var_list)
"""

# Update new_name
Expand Down
37 changes: 22 additions & 15 deletions src/eva/transforms/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def isfloat(a_string):
floating-point number.
Example:
result = isfloat("3.14")
::
result = isfloat("3.14")
"""

try:
Expand All @@ -60,7 +62,7 @@ def arithmetic(config, data_collections):
Args:
config (dict): A configuration dictionary containing transformation parameters.
data_collections (DataCollections): An instance of the DataCollections class containing
input data.
input data.
Returns:
None
Expand All @@ -71,14 +73,17 @@ def arithmetic(config, data_collections):
resulting variables are added to the data collections.
Example:
config = {
'collections': [...],
'groups': [...],
'variables': [...],
'new name': 'result_variable',
'equals': '(${collection}::${group}::${var1} + ${collection}::${group}::${var2}) / 2'
}
arithmetic(config, data_collections)
::
config = {
'collections': [...],
'groups': [...],
'variables': [...],
'new name': 'result_variable',
'equals': '(${collection}::${group}::${var1} + ${collection}::${group}::${var2})
/ 2'
}
arithmetic(config, data_collections)
"""

# Create a logger
Expand Down Expand Up @@ -154,11 +159,13 @@ def generate_arithmetic_config(new_name, expression, collection, var_list):
the transformation to the specified variables.
Example:
new_name = 'result_variable'
expression = '(${group1} + ${group2}) / 2'
collection = 'my_collection'
var_list = ['variable1', 'variable2']
config = generate_arithmetic_config(new_name, expression, collection, var_list)
::
new_name = 'result_variable'
expression = '(${group1} + ${group2}) / 2'
collection = 'my_collection'
var_list = ['variable1', 'variable2']
config = generate_arithmetic_config(new_name, expression, collection, var_list)
"""

# Update new_name
Expand Down
20 changes: 11 additions & 9 deletions src/eva/transforms/channel_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ def channel_stats(config, data_collections):
configuration. The resulting variables are added to the data collections.
Example:
config = {
'collections': [...],
'groups': [...],
'variables': [...],
'variable_name': 'data_variable',
'statistic list': ['Mean', 'Std', 'Count'],
'statistic_dimension': 'Location'
}
channel_stats(config, data_collections)
::
config = {
'collections': [...],
'groups': [...],
'variables': [...],
'variable_name': 'data_variable',
'statistic list': ['Mean', 'Std', 'Count'],
'statistic_dimension': 'Location'
}
channel_stats(config, data_collections)
"""

# Create a logger
Expand Down
28 changes: 15 additions & 13 deletions src/eva/transforms/select_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def select_time(config, data_collections):
Args:
config (dict): A configuration dictionary containing transformation parameters.
data_collections (DataCollections): An instance of the DataCollections class containing
input data.
input data.
Returns:
None
Expand All @@ -44,18 +44,20 @@ def select_time(config, data_collections):
for a single time point. The resulting processed variables are added to the data collections.
Example:
config = {
'collections': [...],
'groups': [...],
'variables': [...],
'new name': 'time_selected_variable',
'starting field': 'original_variable',
'cycle': 'YYYYMMDDHH',
# OR
'start cycle': 'YYYYMMDDHH',
'end cycle': 'YYYYMMDDHH'
}
select_time(config, data_collections)
::
config = {
'collections': [...],
'groups': [...],
'variables': [...],
'new name': 'time_selected_variable',
'starting field': 'original_variable',
'cycle': 'YYYYMMDDHH',
# OR
'start cycle': 'YYYYMMDDHH',
'end cycle': 'YYYYMMDDHH'
}
select_time(config, data_collections)
"""

# Create a logger
Expand Down
2 changes: 1 addition & 1 deletion src/eva/transforms/transform_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def transform_driver(config, data_collections, timing, logger):
Args:
config (dict): A configuration dictionary containing transformation parameters.
data_collections (DataCollections): An instance of the DataCollections class containing
input data.
input data.
timing (Timing): An instance of the Timing class for tracking execution times.
logger (Logger): An instance of the logger for logging messages.
Expand Down
Loading

0 comments on commit 315d954

Please sign in to comment.