Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Build docs #319

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs-source/source/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# Changelog
## v8.5.0 (2024-09-09)

### Feat

- functions operating on all elements in the time series (#274)
- interpolation based on sequence data (#277)
- mock scatter plot functionality (#279)

### Fix

- Add example units to guide users (#253)
- **deps**: update dependency scikit-image to ^0.24.0 (#215)
- **deps**: update dependency numba to ^0.60.0 (#261)
- disable oscillation detection in charts (#240)
- **deps**: update dependency scikit-image to ^0.22.0 (#42)

## v8.4.0 (2024-03-22)

### Feat
Expand Down
586 changes: 306 additions & 280 deletions docs/CHANGELOG.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def abs_diff(a: pd.Series, b: pd.Series) -> pd.Series:
# Next, we implement the new version of the `abs_diff` and mark it as version 1.1.
#

from indsl.resample import reindex # noqa
from indsl.resample import reindex_v1 # noqa


@versioning.register(version="1.1") # type: ignore
def abs_diff(a: pd.Series, b: pd.Series) -> pd.Series:
a, b = reindex(a, b)
a, b = reindex_v1.reindex(a, b)
return (a - b).abs()


Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -26,7 +15,7 @@
},
"outputs": [],
"source": [
"import os\n\nimport matplotlib.pyplot as plt\nimport pandas as pd\n\nfrom indsl.sustainability.co2_emissions_calculations import (\n cumulative_co2_cost,\n cumulative_co2_production,\n rate_of_emissions,\n)\n\n\n# Load and pre-process data\nbase_path = os.path.dirname(\"\")\ndata = pd.read_csv(os.path.join(base_path, \"../../datasets/data/compressor_power_output.csv\"), index_col=0)\ndata.index = pd.to_datetime(data.index)\npower = data[data.columns[0]].resample(\"1h\").mean().ffill() # Unit is in kW\n\n# Specify factors\nco2_cost_factor = 0.5 # NOK/kg CO2\nemissions_factor = 0.21 # kg CO2/kWh\n\n# Perform emissions calculations\nrate_co2_produced = rate_of_emissions(power, emissions_factor)\nco2_produced = cumulative_co2_production(rate_co2_produced)\nco2_cost = cumulative_co2_cost(power, co2_cost_factor=co2_cost_factor, emissions_factor=emissions_factor)\n\n\n# Plotting\nplt.subplots(2, 2, figsize=(10, 10))\n\nax = plt.subplot(2, 2, 1)\n(power).plot(ax=ax)\nplt.ylabel(\"Power (kW)\")\nplt.xlabel(\"Date\")\nplt.title(\"Compressor Power Output\")\n\nax = plt.subplot(2, 2, 2)\n(rate_co2_produced).plot(ax=ax)\nplt.ylabel(\"CO2 Production Rate (kg CO2/hr)\")\nplt.xlabel(\"Date\")\nplt.title(\"Rate of CO2 Production\")\n\n\nax = plt.subplot(2, 2, 3)\n(co2_produced / 1000).plot(ax=ax)\nplt.ylabel(\"Mass CO2 Emitted (tonnes)\")\nplt.xlabel(\"Date\")\nplt.title(\"Cumulative Sum of CO2 Production\")\n\n\nax = plt.subplot(2, 2, 4)\n(co2_cost / 1e6).plot(ax=ax)\nplt.ylabel(\"Cost (MNOK)\")\nplt.xlabel(\"Date\")\nplt.title(\"Cumulative Cost of CO2\")\n\nplt.show()"
"import os\n\nimport matplotlib.pyplot as plt\nimport pandas as pd\n\nfrom indsl.sustainability.co2_emissions_calculations import (\n cumulative_co2_cost,\n cumulative_co2_production,\n rate_of_emissions,\n)\n\n\n# Load and pre-process data\nbase_path = os.path.dirname(\"\")\ndata = pd.read_csv(os.path.join(base_path, \"../../datasets/data/compressor_power_output.csv\"), index_col=0)\ndata.index = pd.to_datetime(data.index)\npower = data[data.columns[0]].resample(\"1h\").mean().ffill() # Unit is in kW\n\n# Specify factors\nco2_cost_factor = 0.5 # NOK/kg CO2\nemissions_factor = 0.21 # kg CO2/kWh\n\n# Perform emissions calculations\nrate_co2_produced = rate_of_emissions(power, emissions_factor)\nco2_produced = cumulative_co2_production(rate_co2_produced, start_date=data.index[0])\nco2_cost = cumulative_co2_cost(\n power, co2_cost_factor=co2_cost_factor, emissions_factor=emissions_factor, start_date=data.index[0]\n)\n\n# Plotting\nplt.subplots(2, 2, figsize=(10, 10))\n\nax = plt.subplot(2, 2, 1)\n(power).plot(ax=ax)\nplt.ylabel(\"Power (kW)\")\nplt.xlabel(\"Date\")\nplt.title(\"Compressor Power Output\")\n\nax = plt.subplot(2, 2, 2)\n(rate_co2_produced).plot(ax=ax)\nplt.ylabel(\"CO2 Production Rate (kg CO2/hr)\")\nplt.xlabel(\"Date\")\nplt.title(\"Rate of CO2 Production\")\n\n\nax = plt.subplot(2, 2, 3)\n(co2_produced / 1000).plot(ax=ax)\nplt.ylabel(\"Mass CO2 Emitted (tonnes)\")\nplt.xlabel(\"Date\")\nplt.title(\"Cumulative Sum of CO2 Production\")\n\n\nax = plt.subplot(2, 2, 4)\n(co2_cost / 1e6).plot(ax=ax)\nplt.ylabel(\"Cost (MNOK)\")\nplt.xlabel(\"Date\")\nplt.title(\"Cumulative Cost of CO2\")\n\nplt.show()"
]
}
],
Expand All @@ -46,7 +35,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -46,7 +35,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"# Threshold breach check for difference between two data points over a period of time\n",
"\n",
"Example of visualizing breach of threshold in hour count in a time series representing running hours of a piece of\n",
"equipment.\n"
"\n# Threshold breach check for difference between two data points over a period of time\n\nExample of visualizing breach of threshold in hour count in a time series representing running hours of a piece of\nequipment.\n"
]
},
{
Expand All @@ -19,63 +15,7 @@
},
"outputs": [],
"source": [
"import os\n",
"\n",
"from datetime import datetime, timedelta\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"from indsl.data_quality.datapoint_diff import datapoint_diff_over_time_period\n",
"\n",
"\n",
"# import generated data\n",
"base_path = \"\" if __name__ == \"__main__\" else os.path.dirname(__file__)\n",
"data = pd.read_csv(os.path.join(base_path, \"../../datasets/data/hour_count.csv\"), index_col=0)\n",
"data = data.squeeze()\n",
"data.index = pd.to_datetime(data.index)\n",
"\n",
"# apply function to calculate difference between datapoint over a period of 1 day\n",
"hour_count_default_threshold = datapoint_diff_over_time_period(data, pd.Timedelta(\"1d\"), 24, pd.Timedelta(\"1h\"))\n",
"\n",
"# Resample and forward fill generated step series\n",
"resampled_step_series_default_threshold = hour_count_default_threshold.resample(\"60min\")\n",
"default_threshold_forward_filled = resampled_step_series_default_threshold.ffill()\n",
"\n",
"# Plot unchanged signal identification series against actual data\n",
"fig, ax1 = plt.subplots(figsize=(15, 5))\n",
"ax1.plot(data.index, data, label=\"Time series\", marker=\".\", color=\"blue\")\n",
"\n",
"values = np.arange(data.index[0], data.index[-1], timedelta(minutes=120)).astype(datetime)\n",
"\n",
"ax1.set_xticks(values)\n",
"ax1.set_xticklabels([ts.strftime(\"%d-%m \\n %H:%M\") for ts in values], fontsize=8)\n",
"\n",
"ax2 = ax1.twinx()\n",
"ax2.plot(\n",
" data.index,\n",
" default_threshold_forward_filled,\n",
" label=\"Threshold breach indicator for datapoint diff over last 24 hours\",\n",
" marker=\".\",\n",
" color=\"red\",\n",
")\n",
"\n",
"lines1, labels1 = ax1.get_legend_handles_labels()\n",
"lines2, labels2 = ax2.get_legend_handles_labels()\n",
"ax2.legend(lines1 + lines2, labels1 + labels2, loc=0)\n",
"\n",
"plt.xlabel(\"Timestamp\")\n",
"ax1.set_ylabel(\"Timeseries value\")\n",
"ax2.set_ylabel(\"Hour count threshold breach\")\n",
"\n",
"fig.suptitle(\n",
" \"Check if difference between two datapoints at a distance of 24 hours exceeds the threshold\",\n",
" fontsize=14,\n",
")\n",
"fig.tight_layout()\n",
"\n",
"plt.show()"
"import os\n\nfrom datetime import datetime, timedelta\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\n\nfrom indsl.data_quality.datapoint_diff import datapoint_diff_over_time_period\n\n\n# import generated data\nbase_path = \"\" if __name__ == \"__main__\" else os.path.dirname(__file__)\ndata = pd.read_csv(os.path.join(base_path, \"../../datasets/data/hour_count.csv\"), index_col=0)\ndata = data.squeeze()\ndata.index = pd.to_datetime(data.index)\n\n# apply function to calculate difference between datapoint over a period of 1 day\nhour_count_default_threshold = datapoint_diff_over_time_period(data, pd.Timedelta(\"1d\"), 24, pd.Timedelta(\"1h\"))\n\n# Resample and forward fill generated step series\nresampled_step_series_default_threshold = hour_count_default_threshold.resample(\"60min\")\ndefault_threshold_forward_filled = resampled_step_series_default_threshold.ffill()\n\n# Plot unchanged signal identification series against actual data\nfig, ax1 = plt.subplots(figsize=(15, 5))\nax1.plot(data.index, data, label=\"Time series\", marker=\".\", color=\"blue\")\n\nvalues = np.arange(data.index[0], data.index[-1], timedelta(minutes=120)).astype(datetime)\n\nax1.set_xticks(values)\nax1.set_xticklabels([ts.strftime(\"%d-%m \\n %H:%M\") for ts in values], fontsize=8)\n\nax2 = ax1.twinx()\nax2.plot(\n data.index,\n default_threshold_forward_filled,\n label=\"Threshold breach indicator for datapoint diff over last 24 hours\",\n marker=\".\",\n color=\"red\",\n)\n\nlines1, labels1 = ax1.get_legend_handles_labels()\nlines2, labels2 = ax2.get_legend_handles_labels()\nax2.legend(lines1 + lines2, labels1 + labels2, loc=0)\n\nplt.xlabel(\"Timestamp\")\nax1.set_ylabel(\"Timeseries value\")\nax2.set_ylabel(\"Hour count threshold breach\")\n\nfig.suptitle(\n \"Check if difference between two datapoints at a distance of 24 hours exceeds the threshold\",\n fontsize=14,\n)\nfig.tight_layout()\n\nplt.show()"
]
}
],
Expand All @@ -95,9 +35,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -46,7 +35,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@

# Perform emissions calculations
rate_co2_produced = rate_of_emissions(power, emissions_factor)
co2_produced = cumulative_co2_production(rate_co2_produced)
co2_cost = cumulative_co2_cost(power, co2_cost_factor=co2_cost_factor, emissions_factor=emissions_factor)

co2_produced = cumulative_co2_production(rate_co2_produced, start_date=data.index[0])
co2_cost = cumulative_co2_cost(
power, co2_cost_factor=co2_cost_factor, emissions_factor=emissions_factor, start_date=data.index[0]
)

# Plotting
plt.subplots(2, 2, figsize=(10, 10))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
Loading
Loading