From a66721be2bf99be1f331637b8540770b8b7e0292 Mon Sep 17 00:00:00 2001 From: Iqbal Date: Sun, 5 Oct 2025 15:52:04 +0530 Subject: [PATCH 1/7] Add example script demonstrating CDPpy usage for Hacktoberfest --- cdippy/example_script.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 cdippy/example_script.py diff --git a/cdippy/example_script.py b/cdippy/example_script.py new file mode 100644 index 0000000..c812e22 --- /dev/null +++ b/cdippy/example_script.py @@ -0,0 +1,21 @@ +# example_script.py +# Demonstrating basic usage of CDPpy for analyzing cell culture data + +from cdippy import CDPpy # Import the CDPpy library + +# Initialize the CDPpy object +cdp = CDPpy() + +# Sample data representing cell culture measurements +data = { + 'time': [0, 1, 2, 3, 4], + 'cell_density': [1.0, 1.2, 1.5, 1.8, 2.0], + 'glucose_concentration': [5.0, 4.8, 4.5, 4.2, 4.0] +} + +# Analyze the data using CDPpy's built-in methods +analysis_results = cdp.analyze(data) + +# Print the analysis results +print("Analysis Results:") +print(analysis_results) From f045973da29791bcc943946e57ce205fa1247708 Mon Sep 17 00:00:00 2001 From: Iqbal Date: Mon, 6 Oct 2025 22:22:42 +0530 Subject: [PATCH 2/7] Add documentation for plotting and data visualization methods (#23) --- examples/plotting_docs.py | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 examples/plotting_docs.py diff --git a/examples/plotting_docs.py b/examples/plotting_docs.py new file mode 100644 index 0000000..0232aaf --- /dev/null +++ b/examples/plotting_docs.py @@ -0,0 +1,65 @@ +""" +CDPpy: Plotting and Data Visualization Documentation +----------------------------------------------------- + +This script demonstrates how to use CDPpy's built-in plotting and +data visualization methods to explore and analyze cell culture data. +""" + +from cdippy import CDPpy + +# Initialize CDPpy object +cdp = CDPpy() + +# Sample cell culture data +data = { + 'time': [0, 1, 2, 3, 4, 5], + 'cell_density': [1.0, 1.2, 1.5, 1.9, 2.2, 2.5], + 'glucose_concentration': [5.0, 4.8, 4.5, 4.2, 4.0, 3.8] +} + +# ----------------------------- +# Basic Analysis +# ----------------------------- +results = cdp.analyze(data) +print("Analysis Results:") +print(results) + +# ----------------------------- +# Plotting Methods +# ----------------------------- + +# 1. Plot a single variable against time +cdp.plot( + data, + x='time', + y='cell_density', + title='Cell Density Over Time', + xlabel='Time (hours)', + ylabel='Cell Density (cells/mL)' +) + +# 2. Plot another variable +cdp.plot( + data, + x='time', + y='glucose_concentration', + title='Glucose Concentration Over Time', + xlabel='Time (hours)', + ylabel='Glucose Concentration (mM)' +) + +# 3. Plot multiple variables together (if supported) +cdp.plot_multiple( + data, + y=['cell_density', 'glucose_concentration'], + title='Cell & Glucose Dynamics Over Time', + xlabel='Time (hours)' +) + +# ----------------------------- +# Notes: +# ----------------------------- +# - `plot()` is used for a single variable. +# - `plot_multiple()` is used to compare multiple variables in one figure. +# - Always include descriptive titles and axis labels for clarity. From 7f0480037ac47445db78210ef8aca23e9d0449bd Mon Sep 17 00:00:00 2001 From: Iqbal Date: Mon, 6 Oct 2025 22:51:37 +0530 Subject: [PATCH 3/7] Enhanced documentation for plotting and visualization functions #23 --- cdippy/plotting.py | 92 +++++++++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 29 deletions(-) diff --git a/cdippy/plotting.py b/cdippy/plotting.py index f0c893a..d4953fc 100644 --- a/cdippy/plotting.py +++ b/cdippy/plotting.py @@ -4,35 +4,57 @@ def make_annual_hs_boxplot(stn: str, year: int) -> Figure: """ - Create a boxplot of annual significant wave heights for a station. - - Args: - stn (str): A 5-char station identifier, e.g. '100p1'. - year (int): The year to plot. - - Returns: - fig (Figure): A matplotlib.pyplot.Figure object for the created plot. + Create a boxplot of annual significant wave heights for a given station and year. + + Parameters + ---------- + stn : str + A 5-character station identifier, e.g., '100p1'. + year : int + The year for which the boxplot is generated. + + Returns + ------- + fig : Figure + A matplotlib Figure object representing the annual wave height boxplot. + + Example + ------- + >>> fig = make_annual_hs_boxplot('100p1', 2023) + >>> fig.show() """ - return plots.annual_hs_boxplot.make_plot(stn, year) def make_compendium_plot( stns: str, start: str, end: str, params: str, x_inch: int ) -> Figure: - """CDIP's classic compendium plot for multiple stations and parameters. - - Args: - stns (str): A comma-delimited list of 5-char station identifiers, e.g. '100p1,201p1'. - start (str): Start time of data series formatted as 'yyyymm[ddHHMMss]' where 'ddHHMMss' are optional components. - end (str): End time of data series ('yyyymm[ddHHMMss]') If 'None' is provided, defaults to the current date and time. - params (str): A comma-delimited string of parameter names, e.g. 'waveHs,waveTp'. - - Returns: - fig (Figure): A matplotlib.pyplot.Figure object for the created plot. - """ - + Generate CDIP's classic compendium plot for multiple stations and parameters over a time range. + + Parameters + ---------- + stns : str + Comma-delimited list of 5-character station identifiers, e.g., '100p1,201p1'. + start : str + Start time formatted as 'yyyymm[ddHHMMss]'; optional components default to zero. + end : str + End time formatted as 'yyyymm[ddHHMMss]'. If None, defaults to current date/time. + params : str + Comma-delimited string of parameter names, e.g., 'waveHs,waveTp'. + x_inch : int + Width of the figure in inches. + + Returns + ------- + fig : Figure + A matplotlib Figure object representing the compendium plot. + + Example + ------- + >>> fig = make_compendium_plot('100p1,201p1', '202301', '202312', 'waveHs,waveTp', 10) + >>> fig.show() + """ return plots.compendium.make_plot(stns, start, end, params, x_inch) @@ -40,13 +62,25 @@ def make_sst_climatology_plot( stn: str, x_inch: int = None, y_inch: int = None ) -> Figure: """ - Create a plot of yearly climatology of sea surface temperature at a station for all years of available data. - - Args: - stn (str): A 5-char station identifier, e.g. '100p1'. - - Returns: - fig (Figure): A matplotlib.pyplot.Figure object for the created plot. + Plot the yearly climatology of sea surface temperature for a given station over all available years. + + Parameters + ---------- + stn : str + A 5-character station identifier, e.g., '100p1'. + x_inch : int, optional + Width of the figure in inches. Default is None. + y_inch : int, optional + Height of the figure in inches. Default is None. + + Returns + ------- + fig : Figure + A matplotlib Figure object representing the SST climatology plot. + + Example + ------- + >>> fig = make_sst_climatology_plot('100p1', x_inch=8, y_inch=6) + >>> fig.show() """ - return plots.sst_climatology.make_plot(stn, x_inch, y_inch) From 7c6c918b3eae1c947faa71094c9ae670d9aa8b74 Mon Sep 17 00:00:00 2001 From: Iqbal Nawab <132881057+Iqbal-dev12@users.noreply.github.com> Date: Tue, 7 Oct 2025 01:27:45 +0530 Subject: [PATCH 4/7] docs: remove example sections from plotting.py The docstrings for plotting functions previously included example sections that referenced external libraries and interactive code (e.g., matplotlib usage with fig.show()). These examples were removed to keep the documentation clean, consistent, and focused only on parameters and return values. This improves clarity and avoids confusion for users while maintaining a standard NumPy-style docstring format across the module. --- cdippy/plotting.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/cdippy/plotting.py b/cdippy/plotting.py index d4953fc..b6b959b 100644 --- a/cdippy/plotting.py +++ b/cdippy/plotting.py @@ -17,11 +17,6 @@ def make_annual_hs_boxplot(stn: str, year: int) -> Figure: ------- fig : Figure A matplotlib Figure object representing the annual wave height boxplot. - - Example - ------- - >>> fig = make_annual_hs_boxplot('100p1', 2023) - >>> fig.show() """ return plots.annual_hs_boxplot.make_plot(stn, year) @@ -30,7 +25,7 @@ def make_compendium_plot( stns: str, start: str, end: str, params: str, x_inch: int ) -> Figure: """ - Generate CDIP's classic compendium plot for multiple stations and parameters over a time range. + Generate CDIP's compendium plot for multiple stations and parameters over a time range. Parameters ---------- @@ -49,11 +44,6 @@ def make_compendium_plot( ------- fig : Figure A matplotlib Figure object representing the compendium plot. - - Example - ------- - >>> fig = make_compendium_plot('100p1,201p1', '202301', '202312', 'waveHs,waveTp', 10) - >>> fig.show() """ return plots.compendium.make_plot(stns, start, end, params, x_inch) @@ -77,10 +67,5 @@ def make_sst_climatology_plot( ------- fig : Figure A matplotlib Figure object representing the SST climatology plot. - - Example - ------- - >>> fig = make_sst_climatology_plot('100p1', x_inch=8, y_inch=6) - >>> fig.show() """ return plots.sst_climatology.make_plot(stn, x_inch, y_inch) From 13bd42dff6243eebcf72f103a07e7c56ba6de243 Mon Sep 17 00:00:00 2001 From: Iqbal Nawab <132881057+Iqbal-dev12@users.noreply.github.com> Date: Tue, 7 Oct 2025 01:41:10 +0530 Subject: [PATCH 5/7] Delete examples/plotting_docs.py --- examples/plotting_docs.py | 65 --------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 examples/plotting_docs.py diff --git a/examples/plotting_docs.py b/examples/plotting_docs.py deleted file mode 100644 index 0232aaf..0000000 --- a/examples/plotting_docs.py +++ /dev/null @@ -1,65 +0,0 @@ -""" -CDPpy: Plotting and Data Visualization Documentation ------------------------------------------------------ - -This script demonstrates how to use CDPpy's built-in plotting and -data visualization methods to explore and analyze cell culture data. -""" - -from cdippy import CDPpy - -# Initialize CDPpy object -cdp = CDPpy() - -# Sample cell culture data -data = { - 'time': [0, 1, 2, 3, 4, 5], - 'cell_density': [1.0, 1.2, 1.5, 1.9, 2.2, 2.5], - 'glucose_concentration': [5.0, 4.8, 4.5, 4.2, 4.0, 3.8] -} - -# ----------------------------- -# Basic Analysis -# ----------------------------- -results = cdp.analyze(data) -print("Analysis Results:") -print(results) - -# ----------------------------- -# Plotting Methods -# ----------------------------- - -# 1. Plot a single variable against time -cdp.plot( - data, - x='time', - y='cell_density', - title='Cell Density Over Time', - xlabel='Time (hours)', - ylabel='Cell Density (cells/mL)' -) - -# 2. Plot another variable -cdp.plot( - data, - x='time', - y='glucose_concentration', - title='Glucose Concentration Over Time', - xlabel='Time (hours)', - ylabel='Glucose Concentration (mM)' -) - -# 3. Plot multiple variables together (if supported) -cdp.plot_multiple( - data, - y=['cell_density', 'glucose_concentration'], - title='Cell & Glucose Dynamics Over Time', - xlabel='Time (hours)' -) - -# ----------------------------- -# Notes: -# ----------------------------- -# - `plot()` is used for a single variable. -# - `plot_multiple()` is used to compare multiple variables in one figure. -# - Always include descriptive titles and axis labels for clarity. From d55e09c439647896640c9461d9ebc62a817934ec Mon Sep 17 00:00:00 2001 From: Iqbal Nawab <132881057+Iqbal-dev12@users.noreply.github.com> Date: Tue, 7 Oct 2025 01:41:37 +0530 Subject: [PATCH 6/7] Delete cdippy/example_script.py --- cdippy/example_script.py | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 cdippy/example_script.py diff --git a/cdippy/example_script.py b/cdippy/example_script.py deleted file mode 100644 index c812e22..0000000 --- a/cdippy/example_script.py +++ /dev/null @@ -1,21 +0,0 @@ -# example_script.py -# Demonstrating basic usage of CDPpy for analyzing cell culture data - -from cdippy import CDPpy # Import the CDPpy library - -# Initialize the CDPpy object -cdp = CDPpy() - -# Sample data representing cell culture measurements -data = { - 'time': [0, 1, 2, 3, 4], - 'cell_density': [1.0, 1.2, 1.5, 1.8, 2.0], - 'glucose_concentration': [5.0, 4.8, 4.5, 4.2, 4.0] -} - -# Analyze the data using CDPpy's built-in methods -analysis_results = cdp.analyze(data) - -# Print the analysis results -print("Analysis Results:") -print(analysis_results) From a9b712ae5495c95bda86c7ec605882c3e83e9916 Mon Sep 17 00:00:00 2001 From: Iqbal Nawab <132881057+Iqbal-dev12@users.noreply.github.com> Date: Tue, 7 Oct 2025 08:53:32 +0530 Subject: [PATCH 7/7] Reformat docstrings in plotting.py to Google style Updated all function docstrings in plotting.py to follow Google-style formatting for consistency with the rest of the project. Removed the previous NumPy-style section headers ("Parameters", "Returns") and replaced them with "Args" and "Returns" blocks. Also ensured that no external or unrelated library references remain. --- cdippy/plotting.py | 57 ++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/cdippy/plotting.py b/cdippy/plotting.py index b6b959b..20a016c 100644 --- a/cdippy/plotting.py +++ b/cdippy/plotting.py @@ -6,17 +6,12 @@ def make_annual_hs_boxplot(stn: str, year: int) -> Figure: """ Create a boxplot of annual significant wave heights for a given station and year. - Parameters - ---------- - stn : str - A 5-character station identifier, e.g., '100p1'. - year : int - The year for which the boxplot is generated. + Args: + stn (str): A 5-character station identifier, e.g., '100p1'. + year (int): The year for which the boxplot is generated. - Returns - ------- - fig : Figure - A matplotlib Figure object representing the annual wave height boxplot. + Returns: + Figure: A matplotlib Figure object representing the annual wave height boxplot. """ return plots.annual_hs_boxplot.make_plot(stn, year) @@ -27,23 +22,15 @@ def make_compendium_plot( """ Generate CDIP's compendium plot for multiple stations and parameters over a time range. - Parameters - ---------- - stns : str - Comma-delimited list of 5-character station identifiers, e.g., '100p1,201p1'. - start : str - Start time formatted as 'yyyymm[ddHHMMss]'; optional components default to zero. - end : str - End time formatted as 'yyyymm[ddHHMMss]'. If None, defaults to current date/time. - params : str - Comma-delimited string of parameter names, e.g., 'waveHs,waveTp'. - x_inch : int - Width of the figure in inches. + Args: + stns (str): Comma-delimited list of 5-character station identifiers, e.g., '100p1,201p1'. + start (str): Start time formatted as 'yyyymm[ddHHMMss]'; optional components default to zero. + end (str): End time formatted as 'yyyymm[ddHHMMss]'. If None, defaults to current date/time. + params (str): Comma-delimited string of parameter names, e.g., 'waveHs,waveTp'. + x_inch (int): Width of the figure in inches. - Returns - ------- - fig : Figure - A matplotlib Figure object representing the compendium plot. + Returns: + Figure: A matplotlib Figure object representing the compendium plot. """ return plots.compendium.make_plot(stns, start, end, params, x_inch) @@ -54,18 +41,12 @@ def make_sst_climatology_plot( """ Plot the yearly climatology of sea surface temperature for a given station over all available years. - Parameters - ---------- - stn : str - A 5-character station identifier, e.g., '100p1'. - x_inch : int, optional - Width of the figure in inches. Default is None. - y_inch : int, optional - Height of the figure in inches. Default is None. + Args: + stn (str): A 5-character station identifier, e.g., '100p1'. + x_inch (int, optional): Width of the figure in inches. Defaults to None. + y_inch (int, optional): Height of the figure in inches. Defaults to None. - Returns - ------- - fig : Figure - A matplotlib Figure object representing the SST climatology plot. + Returns: + Figure: A matplotlib Figure object representing the SST climatology plot. """ return plots.sst_climatology.make_plot(stn, x_inch, y_inch)