solarops 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- solarops-0.1.0/CHANGELOG.md +15 -0
- solarops-0.1.0/CONTRIBUTING.md +29 -0
- solarops-0.1.0/LICENSE +21 -0
- solarops-0.1.0/MANIFEST.in +13 -0
- solarops-0.1.0/PKG-INFO +150 -0
- solarops-0.1.0/README.md +123 -0
- solarops-0.1.0/docs/detection.md +164 -0
- solarops-0.1.0/docs/metrics.md +204 -0
- solarops-0.1.0/docs/preprocessing.md +223 -0
- solarops-0.1.0/docs/real_data_evaluation.md +265 -0
- solarops-0.1.0/docs/releasing.md +86 -0
- solarops-0.1.0/docs/reporting.md +186 -0
- solarops-0.1.0/docs/user_guide.md +409 -0
- solarops-0.1.0/docs/visualization.md +186 -0
- solarops-0.1.0/examples/detect_synthetic.py +34 -0
- solarops-0.1.0/examples/download_real_data.ps1 +20 -0
- solarops-0.1.0/examples/evaluate_real_data.py +249 -0
- solarops-0.1.0/examples/metrics_synthetic.py +50 -0
- solarops-0.1.0/examples/preprocess_synthetic.py +40 -0
- solarops-0.1.0/examples/report_synthetic.py +45 -0
- solarops-0.1.0/examples/synthetic_solar.csv +6 -0
- solarops-0.1.0/examples/validate_synthetic.py +22 -0
- solarops-0.1.0/examples/visualize_synthetic.py +57 -0
- solarops-0.1.0/pyproject.toml +40 -0
- solarops-0.1.0/setup.cfg +4 -0
- solarops-0.1.0/src/solarops/__init__.py +5 -0
- solarops-0.1.0/src/solarops/dataset.py +144 -0
- solarops-0.1.0/src/solarops/detection.py +179 -0
- solarops-0.1.0/src/solarops/exceptions.py +19 -0
- solarops-0.1.0/src/solarops/metrics.py +266 -0
- solarops-0.1.0/src/solarops/preprocessing.py +285 -0
- solarops-0.1.0/src/solarops/quality.py +230 -0
- solarops-0.1.0/src/solarops/reporting.py +298 -0
- solarops-0.1.0/src/solarops/visualization.py +249 -0
- solarops-0.1.0/src/solarops.egg-info/PKG-INFO +150 -0
- solarops-0.1.0/src/solarops.egg-info/SOURCES.txt +45 -0
- solarops-0.1.0/src/solarops.egg-info/dependency_links.txt +1 -0
- solarops-0.1.0/src/solarops.egg-info/requires.txt +10 -0
- solarops-0.1.0/src/solarops.egg-info/top_level.txt +1 -0
- solarops-0.1.0/tests/test_dataset.py +145 -0
- solarops-0.1.0/tests/test_detection.py +217 -0
- solarops-0.1.0/tests/test_metrics.py +259 -0
- solarops-0.1.0/tests/test_preprocessing.py +311 -0
- solarops-0.1.0/tests/test_quality.py +169 -0
- solarops-0.1.0/tests/test_real_data_evaluation.py +61 -0
- solarops-0.1.0/tests/test_reporting.py +266 -0
- solarops-0.1.0/tests/test_visualization.py +252 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 — first release candidate
|
|
4
|
+
|
|
5
|
+
- CSV/DataFrame loading and explicit interval-average power metadata.
|
|
6
|
+
- Structured timestamp, value, duplicate, grid and completeness checks.
|
|
7
|
+
- Non-mutating preprocessing with history and row provenance.
|
|
8
|
+
- Neutral flatline and configured-range observations.
|
|
9
|
+
- Coverage-aware period/daily energy and peak interval-average power.
|
|
10
|
+
- Optional Matplotlib plots and standalone JSON/HTML reports.
|
|
11
|
+
- Reproducible real-data evaluation and clearly labeled controlled experiments.
|
|
12
|
+
- Stable ambiguous/nonexistent-time diagnostics across pandas 2 and 3.
|
|
13
|
+
|
|
14
|
+
This is an initial alpha API. Publication status is tracked separately; this
|
|
15
|
+
changelog does not claim the candidate has been uploaded to GitHub or PyPI.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Use Python 3.10 or newer. From a source checkout:
|
|
4
|
+
|
|
5
|
+
```console
|
|
6
|
+
python -m venv .venv
|
|
7
|
+
# Activate .venv for your shell, then:
|
|
8
|
+
python -m pip install -e ".[dev,visualization]"
|
|
9
|
+
python -m pytest
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Keep changes focused and add deterministic tests for changed behavior. Automated
|
|
13
|
+
tests must not download datasets or require private data, network services or
|
|
14
|
+
credentials. Plot tests use a non-interactive backend. No formatter or linter is
|
|
15
|
+
currently configured; follow the surrounding code and run the full suite.
|
|
16
|
+
|
|
17
|
+
Preserve the interval-start, interval-average-power contract and explicit timezone,
|
|
18
|
+
units and cadence. Never silently clean inputs, infer equipment faults, or treat
|
|
19
|
+
missing production as zero. Keep configuration failures distinct from data blockers.
|
|
20
|
+
Document public API changes and record user-visible changes in CHANGELOG.md.
|
|
21
|
+
|
|
22
|
+
Synthetic examples must be labeled. Real-data examples require documented source
|
|
23
|
+
semantics, attribution, licence, checksum and reproducible access. Keep source
|
|
24
|
+
datasets, generated reports, virtual environments, credentials and personal assets
|
|
25
|
+
out of commits. Do not paste credentials or confidential measurement data in issues.
|
|
26
|
+
|
|
27
|
+
Contributions are distributed under this project's MIT licence. Preserve existing
|
|
28
|
+
copyright/licence notices and give credit for third-party material. See
|
|
29
|
+
[release procedures](docs/releasing.md) for packaging and publication checks.
|
solarops-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) SolarOps contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
include README.md LICENSE pyproject.toml CHANGELOG.md CONTRIBUTING.md
|
|
2
|
+
recursive-include src/solarops *.py
|
|
3
|
+
recursive-include docs *.md
|
|
4
|
+
recursive-include tests *.py
|
|
5
|
+
include examples/*.py examples/*.ps1 examples/synthetic_solar.csv
|
|
6
|
+
global-exclude __pycache__ *.py[cod]
|
|
7
|
+
prune linkedin-assets
|
|
8
|
+
prune .evaluation-data
|
|
9
|
+
prune .venv-evaluation
|
|
10
|
+
prune .release-checks
|
|
11
|
+
prune examples/generated_plots
|
|
12
|
+
prune examples/generated_reports
|
|
13
|
+
prune examples/generated_real_evaluation
|
solarops-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: solarops
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Offline quality checks, preprocessing, metrics and reports for solar PV power time series
|
|
5
|
+
Maintainer-email: Junaid Bashir <junaidbashir392@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/Junaid-Bashir/solarops
|
|
8
|
+
Project-URL: Documentation, https://github.com/Junaid-Bashir/solarops/tree/main/docs
|
|
9
|
+
Project-URL: Issues, https://github.com/Junaid-Bashir/solarops/issues
|
|
10
|
+
Keywords: solar,photovoltaic,time-series,data-quality,energy
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: pandas<4,>=2.2
|
|
21
|
+
Requires-Dist: tzdata>=2024.1; platform_system == "Windows"
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
24
|
+
Provides-Extra: visualization
|
|
25
|
+
Requires-Dist: matplotlib<4,>=3.8; extra == "visualization"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# SolarOps
|
|
29
|
+
|
|
30
|
+
SolarOps is an open-source Python library for validating and analyzing one site's
|
|
31
|
+
historical solar photovoltaic power data. It works offline without AI, weather
|
|
32
|
+
services or an account.
|
|
33
|
+
|
|
34
|
+
## What it does
|
|
35
|
+
|
|
36
|
+
- Load CSV files and pandas DataFrames with explicitly declared units, timezone and cadence.
|
|
37
|
+
- Report malformed timestamps, DST ambiguity, duplicates, missing intervals and unavailable values.
|
|
38
|
+
- Measure timestamp presence and usable-value coverage over explicit periods.
|
|
39
|
+
- Explicitly sort, resolve duplicates, convert units/timezones, regularize and downsample data.
|
|
40
|
+
- Identify neutral flatline and configured-range observations, with evidence.
|
|
41
|
+
- Calculate coverage-aware period/daily energy and recorded peak interval-average power.
|
|
42
|
+
- Create structured JSON and standalone HTML reports, with optional Matplotlib plots.
|
|
43
|
+
|
|
44
|
+
Original datasets remain unchanged; transformations return new datasets with
|
|
45
|
+
history and provenance. Missing production is never silently counted as zero.
|
|
46
|
+
Patterns are observations to investigate, not confirmed equipment faults.
|
|
47
|
+
|
|
48
|
+
## Install from source
|
|
49
|
+
|
|
50
|
+
Python 3.10+ is required. From a downloaded source tree or repository checkout:
|
|
51
|
+
|
|
52
|
+
```console
|
|
53
|
+
python -m venv .venv
|
|
54
|
+
# Windows: .venv\Scripts\Activate.ps1
|
|
55
|
+
# Linux/macOS: source .venv/bin/activate
|
|
56
|
+
python -m pip install .
|
|
57
|
+
# Optional plots:
|
|
58
|
+
python -m pip install ".[visualization]"
|
|
59
|
+
# Contributors:
|
|
60
|
+
python -m pip install -e ".[dev,visualization]"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The distribution name and import name are both `solarops`, version **0.1.0**.
|
|
64
|
+
The candidate is being prepared for first publication; the source installation
|
|
65
|
+
above is usable before PyPI publication is complete. Runtime dependencies are
|
|
66
|
+
pandas and, on Windows, tzdata. Matplotlib is optional; pytest is a development extra.
|
|
67
|
+
|
|
68
|
+
## Quick start
|
|
69
|
+
|
|
70
|
+
This self-contained example uses **synthetic** measurements:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import pandas as pd
|
|
74
|
+
from solarops import SolarDataset
|
|
75
|
+
from solarops.metrics import calculate_energy
|
|
76
|
+
from solarops.reporting import create_report
|
|
77
|
+
|
|
78
|
+
site = SolarDataset.from_dataframe(
|
|
79
|
+
pd.DataFrame({
|
|
80
|
+
"timestamp": pd.date_range("2026-06-01 10:00", periods=4, freq="15min"),
|
|
81
|
+
"power_kw": [4.0, 4.0, 4.0, 4.0],
|
|
82
|
+
}),
|
|
83
|
+
timestamp_col="timestamp", power_col="power_kw",
|
|
84
|
+
timezone="Europe/Brussels", interval="15min", unit="kW",
|
|
85
|
+
)
|
|
86
|
+
period = dict(start="2026-06-01 10:00", end="2026-06-01 11:00")
|
|
87
|
+
energy = calculate_energy(site, **period)
|
|
88
|
+
assert energy.values["accepted_energy_kwh"] == 4.0
|
|
89
|
+
print(energy.summary())
|
|
90
|
+
|
|
91
|
+
report = create_report(site, **period)
|
|
92
|
+
report.to_json("solar_report.json")
|
|
93
|
+
report.to_html("solar_report.html")
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Exports refuse existing files unless `overwrite=True`. Flatline/range detection
|
|
97
|
+
is opt-in and requires explicit caller parameters; reports never infer thresholds.
|
|
98
|
+
|
|
99
|
+
## Data contract and limitations
|
|
100
|
+
|
|
101
|
+
Only **interval-average power**, declared as W or kW, is supported. Timestamps
|
|
102
|
+
mark interval starts; analysis periods are `[start, end)`. The fixed sampling
|
|
103
|
+
interval and IANA site timezone are required. Naive times are localized strictly;
|
|
104
|
+
ambiguous/nonexistent DST times are never guessed. Aware times preserve their
|
|
105
|
+
represented instants. Daily metrics use actual local calendar-day durations.
|
|
106
|
+
|
|
107
|
+
Energy is observed over usable covered durations. A relaxed acceptance threshold
|
|
108
|
+
does not recover unknown production or convert partial energy into a complete total.
|
|
109
|
+
Peaks are maxima of recorded interval averages, not instantaneous maxima. Do not
|
|
110
|
+
load instantaneous samples, interval energy, cumulative meters or household net
|
|
111
|
+
import/export as if they were PV interval-average production. No forecasting,
|
|
112
|
+
automatic repairs or equipment-fault diagnosis is provided. The initial alpha API
|
|
113
|
+
may evolve. The current release has been tested locally on Windows/Python 3.12;
|
|
114
|
+
the included CI matrix expands verification after the repository is published.
|
|
115
|
+
|
|
116
|
+
## Documentation and examples
|
|
117
|
+
|
|
118
|
+
- [Detailed user guide](docs/user_guide.md)
|
|
119
|
+
- [Preprocessing and provenance](docs/preprocessing.md)
|
|
120
|
+
- [Detection](docs/detection.md)
|
|
121
|
+
- [Coverage-aware metrics](docs/metrics.md)
|
|
122
|
+
- [Visualization](docs/visualization.md)
|
|
123
|
+
- [Reporting and export privacy](docs/reporting.md)
|
|
124
|
+
- [Real-data evaluation and attribution](docs/real_data_evaluation.md)
|
|
125
|
+
- [Contributing](CONTRIBUTING.md) and [changelog](CHANGELOG.md)
|
|
126
|
+
|
|
127
|
+
From a source checkout, run:
|
|
128
|
+
|
|
129
|
+
```console
|
|
130
|
+
python -m pytest
|
|
131
|
+
python examples/validate_synthetic.py
|
|
132
|
+
python examples/preprocess_synthetic.py
|
|
133
|
+
python examples/detect_synthetic.py
|
|
134
|
+
python examples/metrics_synthetic.py
|
|
135
|
+
python examples/report_synthetic.py --output-dir examples/generated_reports --overwrite
|
|
136
|
+
python examples/visualize_synthetic.py --output-dir examples/generated_plots
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Examples ship in the source distribution/repository. Generated files, downloaded
|
|
140
|
+
real datasets, local environments and personal assets are excluded from publication.
|
|
141
|
+
Real-data evaluation downloads are separate and documented; automated tests are offline.
|
|
142
|
+
|
|
143
|
+
## Licence and acknowledgement
|
|
144
|
+
|
|
145
|
+
MIT licensed; see [LICENSE](LICENSE). SolarOps is an independent project inspired
|
|
146
|
+
by the general problem space of Solar Data Tools. It does not copy that project's
|
|
147
|
+
source, is not affiliated with it, and does not imply endorsement. Solar Data Tools
|
|
148
|
+
already offers established PV data-quality analysis and diagnostics; see the
|
|
149
|
+
[comparison and attribution](docs/real_data_evaluation.md). Third-party evaluation
|
|
150
|
+
data retains its own licence and attribution, separate from the SolarOps MIT licence.
|
solarops-0.1.0/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# SolarOps
|
|
2
|
+
|
|
3
|
+
SolarOps is an open-source Python library for validating and analyzing one site's
|
|
4
|
+
historical solar photovoltaic power data. It works offline without AI, weather
|
|
5
|
+
services or an account.
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
- Load CSV files and pandas DataFrames with explicitly declared units, timezone and cadence.
|
|
10
|
+
- Report malformed timestamps, DST ambiguity, duplicates, missing intervals and unavailable values.
|
|
11
|
+
- Measure timestamp presence and usable-value coverage over explicit periods.
|
|
12
|
+
- Explicitly sort, resolve duplicates, convert units/timezones, regularize and downsample data.
|
|
13
|
+
- Identify neutral flatline and configured-range observations, with evidence.
|
|
14
|
+
- Calculate coverage-aware period/daily energy and recorded peak interval-average power.
|
|
15
|
+
- Create structured JSON and standalone HTML reports, with optional Matplotlib plots.
|
|
16
|
+
|
|
17
|
+
Original datasets remain unchanged; transformations return new datasets with
|
|
18
|
+
history and provenance. Missing production is never silently counted as zero.
|
|
19
|
+
Patterns are observations to investigate, not confirmed equipment faults.
|
|
20
|
+
|
|
21
|
+
## Install from source
|
|
22
|
+
|
|
23
|
+
Python 3.10+ is required. From a downloaded source tree or repository checkout:
|
|
24
|
+
|
|
25
|
+
```console
|
|
26
|
+
python -m venv .venv
|
|
27
|
+
# Windows: .venv\Scripts\Activate.ps1
|
|
28
|
+
# Linux/macOS: source .venv/bin/activate
|
|
29
|
+
python -m pip install .
|
|
30
|
+
# Optional plots:
|
|
31
|
+
python -m pip install ".[visualization]"
|
|
32
|
+
# Contributors:
|
|
33
|
+
python -m pip install -e ".[dev,visualization]"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The distribution name and import name are both `solarops`, version **0.1.0**.
|
|
37
|
+
The candidate is being prepared for first publication; the source installation
|
|
38
|
+
above is usable before PyPI publication is complete. Runtime dependencies are
|
|
39
|
+
pandas and, on Windows, tzdata. Matplotlib is optional; pytest is a development extra.
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
This self-contained example uses **synthetic** measurements:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import pandas as pd
|
|
47
|
+
from solarops import SolarDataset
|
|
48
|
+
from solarops.metrics import calculate_energy
|
|
49
|
+
from solarops.reporting import create_report
|
|
50
|
+
|
|
51
|
+
site = SolarDataset.from_dataframe(
|
|
52
|
+
pd.DataFrame({
|
|
53
|
+
"timestamp": pd.date_range("2026-06-01 10:00", periods=4, freq="15min"),
|
|
54
|
+
"power_kw": [4.0, 4.0, 4.0, 4.0],
|
|
55
|
+
}),
|
|
56
|
+
timestamp_col="timestamp", power_col="power_kw",
|
|
57
|
+
timezone="Europe/Brussels", interval="15min", unit="kW",
|
|
58
|
+
)
|
|
59
|
+
period = dict(start="2026-06-01 10:00", end="2026-06-01 11:00")
|
|
60
|
+
energy = calculate_energy(site, **period)
|
|
61
|
+
assert energy.values["accepted_energy_kwh"] == 4.0
|
|
62
|
+
print(energy.summary())
|
|
63
|
+
|
|
64
|
+
report = create_report(site, **period)
|
|
65
|
+
report.to_json("solar_report.json")
|
|
66
|
+
report.to_html("solar_report.html")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Exports refuse existing files unless `overwrite=True`. Flatline/range detection
|
|
70
|
+
is opt-in and requires explicit caller parameters; reports never infer thresholds.
|
|
71
|
+
|
|
72
|
+
## Data contract and limitations
|
|
73
|
+
|
|
74
|
+
Only **interval-average power**, declared as W or kW, is supported. Timestamps
|
|
75
|
+
mark interval starts; analysis periods are `[start, end)`. The fixed sampling
|
|
76
|
+
interval and IANA site timezone are required. Naive times are localized strictly;
|
|
77
|
+
ambiguous/nonexistent DST times are never guessed. Aware times preserve their
|
|
78
|
+
represented instants. Daily metrics use actual local calendar-day durations.
|
|
79
|
+
|
|
80
|
+
Energy is observed over usable covered durations. A relaxed acceptance threshold
|
|
81
|
+
does not recover unknown production or convert partial energy into a complete total.
|
|
82
|
+
Peaks are maxima of recorded interval averages, not instantaneous maxima. Do not
|
|
83
|
+
load instantaneous samples, interval energy, cumulative meters or household net
|
|
84
|
+
import/export as if they were PV interval-average production. No forecasting,
|
|
85
|
+
automatic repairs or equipment-fault diagnosis is provided. The initial alpha API
|
|
86
|
+
may evolve. The current release has been tested locally on Windows/Python 3.12;
|
|
87
|
+
the included CI matrix expands verification after the repository is published.
|
|
88
|
+
|
|
89
|
+
## Documentation and examples
|
|
90
|
+
|
|
91
|
+
- [Detailed user guide](docs/user_guide.md)
|
|
92
|
+
- [Preprocessing and provenance](docs/preprocessing.md)
|
|
93
|
+
- [Detection](docs/detection.md)
|
|
94
|
+
- [Coverage-aware metrics](docs/metrics.md)
|
|
95
|
+
- [Visualization](docs/visualization.md)
|
|
96
|
+
- [Reporting and export privacy](docs/reporting.md)
|
|
97
|
+
- [Real-data evaluation and attribution](docs/real_data_evaluation.md)
|
|
98
|
+
- [Contributing](CONTRIBUTING.md) and [changelog](CHANGELOG.md)
|
|
99
|
+
|
|
100
|
+
From a source checkout, run:
|
|
101
|
+
|
|
102
|
+
```console
|
|
103
|
+
python -m pytest
|
|
104
|
+
python examples/validate_synthetic.py
|
|
105
|
+
python examples/preprocess_synthetic.py
|
|
106
|
+
python examples/detect_synthetic.py
|
|
107
|
+
python examples/metrics_synthetic.py
|
|
108
|
+
python examples/report_synthetic.py --output-dir examples/generated_reports --overwrite
|
|
109
|
+
python examples/visualize_synthetic.py --output-dir examples/generated_plots
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Examples ship in the source distribution/repository. Generated files, downloaded
|
|
113
|
+
real datasets, local environments and personal assets are excluded from publication.
|
|
114
|
+
Real-data evaluation downloads are separate and documented; automated tests are offline.
|
|
115
|
+
|
|
116
|
+
## Licence and acknowledgement
|
|
117
|
+
|
|
118
|
+
MIT licensed; see [LICENSE](LICENSE). SolarOps is an independent project inspired
|
|
119
|
+
by the general problem space of Solar Data Tools. It does not copy that project's
|
|
120
|
+
source, is not affiliated with it, and does not imply endorsement. Solar Data Tools
|
|
121
|
+
already offers established PV data-quality analysis and diagnostics; see the
|
|
122
|
+
[comparison and attribution](docs/real_data_evaluation.md). Third-party evaluation
|
|
123
|
+
data retains its own licence and attribution, separate from the SolarOps MIT licence.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Deterministic pattern detection
|
|
2
|
+
|
|
3
|
+
Detection describes data observations. A finding does **not** establish an
|
|
4
|
+
equipment fault, cause, severity or lost energy. No daylight calculation,
|
|
5
|
+
weather, clipping/low-production diagnosis, AI, forecasting, repair or network
|
|
6
|
+
service is used.
|
|
7
|
+
|
|
8
|
+
```python
|
|
9
|
+
from solarops.detection import DetectionResult, detect_flatlines, detect_out_of_range
|
|
10
|
+
|
|
11
|
+
flatlines = detect_flatlines(dataset, min_duration="2h", tolerance=0.01)
|
|
12
|
+
ranges = detect_out_of_range(dataset, minimum=0, maximum=100)
|
|
13
|
+
print(flatlines.summary())
|
|
14
|
+
print(ranges.findings)
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
payload = json.dumps(flatlines.to_dict(), allow_nan=False)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Both functions return `DetectionResult`, a neutral result type distinct from
|
|
21
|
+
`ValidationResult` and its quality-check severities. Input must be a
|
|
22
|
+
`SolarDataset` with the existing interval-average-power contract, declared W
|
|
23
|
+
or kW, site timezone and fixed sampling interval. Detection reads the **current
|
|
24
|
+
dataset snapshot**, including explicitly transformed values. It never modifies
|
|
25
|
+
data, metadata, provenance or transformation history, and never interpolates.
|
|
26
|
+
|
|
27
|
+
## Exact flatline rule
|
|
28
|
+
|
|
29
|
+
`min_duration` and `tolerance` are required keyword arguments. Minimum duration
|
|
30
|
+
is a positive fixed duration, such as `"2h"`; numeric durations are rejected.
|
|
31
|
+
Tolerance is a finite nonnegative number in the declared power unit. For example,
|
|
32
|
+
0.01 kW equals 10 W. Changing dataset units does not rescale later caller parameters.
|
|
33
|
+
|
|
34
|
+
Candidates are formed **greedily, without overlap**:
|
|
35
|
+
|
|
36
|
+
1. Strictly parse timestamps, then inspect rows chronologically, retaining their
|
|
37
|
+
current positional references. This ordering does not transform the dataset.
|
|
38
|
+
2. Start with the first usable reading. Extend only if the next start is exactly
|
|
39
|
+
one declared interval later and the candidate's total
|
|
40
|
+
`maximum - minimum <= tolerance`, including the new reading.
|
|
41
|
+
3. If the range exceeds tolerance, finish the previous candidate and start anew
|
|
42
|
+
with the new reading. A gap also finishes the candidate and starts another.
|
|
43
|
+
4. Missing, nonnumeric, boolean or non-finite measurements finish a candidate
|
|
44
|
+
and do not start another. Numeric strings and finite negative values are
|
|
45
|
+
usable, consistently with quality checks.
|
|
46
|
+
5. Emit finished candidates meeting minimum duration, including at end of input.
|
|
47
|
+
Short candidates are discarded; their rows are not reconsidered in overlapping
|
|
48
|
+
windows. No globally optimal partition or exhaustive window search is attempted.
|
|
49
|
+
|
|
50
|
+
Thus tolerance 1 and readings `[0, 0.75, 1.5, 2.25]` form two two-reading candidates,
|
|
51
|
+
not a single long flatline. Gradual pairwise drift cannot extend a run indefinitely.
|
|
52
|
+
|
|
53
|
+
With interval-start semantics, N consecutive readings cover **N × declared
|
|
54
|
+
interval**. Findings use `[first start, last start + interval)`. Two quarter-hour
|
|
55
|
+
readings cover 30 minutes. Duration comparisons are inclusive and use elapsed
|
|
56
|
+
time across DST. A nonintegral duration threshold is allowed; the next whole run
|
|
57
|
+
meeting it qualifies. A single reading can qualify if the selected duration is
|
|
58
|
+
no longer than one interval; select a longer duration to require repetition.
|
|
59
|
+
|
|
60
|
+
Malformed/missing timestamps, ambiguous/nonexistent naive times, duplicate
|
|
61
|
+
instants and off-grid starts raise actionable errors. They are never silently
|
|
62
|
+
dropped or assigned arbitrary times. Resolve duplicates explicitly first using
|
|
63
|
+
preprocessing. As in unbounded quality checks, the earliest valid instant anchors
|
|
64
|
+
the declared-interval grid: an entire series offset from midnight is not itself
|
|
65
|
+
off-grid. Missing slots break runs and are never filled. Repeated fall-back clock
|
|
66
|
+
times with different UTC offsets remain distinct instants. Leading/trailing
|
|
67
|
+
completeness beyond observed boundaries is unknown.
|
|
68
|
+
|
|
69
|
+
Nighttime zero periods are **included by default as neutral observations**.
|
|
70
|
+
Zero production at night is common and can be normal. The detector does not
|
|
71
|
+
calculate daylight, exclude zeros automatically, or infer a cause for repetition.
|
|
72
|
+
|
|
73
|
+
## Configured range observations
|
|
74
|
+
|
|
75
|
+
`detect_out_of_range(dataset, minimum=None, maximum=None)` requires at least
|
|
76
|
+
one finite numeric limit in the dataset's declared unit. Boundaries are inclusive:
|
|
77
|
+
equal values are in range. With two limits, minimum must not exceed maximum.
|
|
78
|
+
Boolean/string/NaN/infinite limits raise errors.
|
|
79
|
+
|
|
80
|
+
The detector reuses `solarops.quality.range_checks`, preserving its numeric and
|
|
81
|
+
limit rules. Missing, nonnumeric, boolean and non-finite values are counted
|
|
82
|
+
separately, never labeled out of range. Use quality `missing_values` or
|
|
83
|
+
`invalid_values` for their complete row findings. Negative readings are numeric
|
|
84
|
+
and are only range findings if caller limits exclude them.
|
|
85
|
+
|
|
86
|
+
All input records are checked independently, including duplicates and off-grid
|
|
87
|
+
records; no time grid or analysis period is needed. An affected record with an
|
|
88
|
+
unparseable/unlocalizable timestamp remains a finding with `timestamp=None`,
|
|
89
|
+
`raw_timestamp`, current row, root provenance and an explicit `timestamp_limitation`.
|
|
90
|
+
It is never assigned an invented time or silently discarded.
|
|
91
|
+
|
|
92
|
+
## Evidence and serialization
|
|
93
|
+
|
|
94
|
+
`DetectionResult` fields:
|
|
95
|
+
|
|
96
|
+
| Field | Content |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `metadata` | Detector, timezone, unit, interval, measurement type, timestamp convention, current-value source and copied transformation history; flatlines also include grid origin |
|
|
99
|
+
| `parameters` | Normalized duration/tolerance/candidate policy, or inclusive range limits |
|
|
100
|
+
| `counts` | Input-wide record, missing/invalid value and detector-specific counts |
|
|
101
|
+
| `findings` | All neutral findings and complete evidence in deterministic order |
|
|
102
|
+
| `notes` | Interpretation rules and limitations |
|
|
103
|
+
|
|
104
|
+
Flatline counts include `flatline_periods`, `flatline_measurements` and
|
|
105
|
+
`gap_breaks`. The latter counts gaps breaking an active usable candidate, not
|
|
106
|
+
every absent interval or gaps across already unavailable values. Each finding
|
|
107
|
+
contains start/end with offsets, duration string/seconds, count, minimum/maximum,
|
|
108
|
+
tolerance, unit, description, notes and an `evidence` list. Each supporting entry
|
|
109
|
+
includes current positional `row`, aware timestamp, numeric value, available
|
|
110
|
+
`provenance` and `is_derived`. `contains_derived_values` summarizes that flag.
|
|
111
|
+
|
|
112
|
+
Range counts include `out_of_range_values` and
|
|
113
|
+
`unparseable_finding_timestamps` (affected finding rows only). Findings contain
|
|
114
|
+
current row, normalized/raw timestamp, numeric value, unit, limits, description,
|
|
115
|
+
provenance, derived flag and timestamp limitation.
|
|
116
|
+
|
|
117
|
+
Root `source_rows` refer to positional rows at the start of the preprocessing
|
|
118
|
+
chain, not global file IDs. Unit-converted, duplicate-mean and resampled values
|
|
119
|
+
retain available lineage. Partial resampled means are analyzed as current numeric
|
|
120
|
+
values; their source coverage remains in evidence provenance. Detection does not
|
|
121
|
+
reinterpret that coverage or replace it with a completeness claim. Findings may
|
|
122
|
+
reflect the chosen preprocessing, so inspect source history and coverage.
|
|
123
|
+
|
|
124
|
+
`to_dict()` returns an independent JSON-compatible copy with full evidence.
|
|
125
|
+
`summary()` displays at most five findings plus accurate totals and notes; stored
|
|
126
|
+
findings are not truncated. No severity score is assigned. Results have no random
|
|
127
|
+
IDs or execution times, making repeated runs deterministic. Full evidence is
|
|
128
|
+
retained in memory. As with the existing result type, the frozen dataclass holds
|
|
129
|
+
ordinary mutable nested containers; use `to_dict()` for an independent copy.
|
|
130
|
+
|
|
131
|
+
## Optional quality-summary integration
|
|
132
|
+
|
|
133
|
+
Default quality/validation behavior is unchanged. Explicitly opt in:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from solarops.quality import quality_summary
|
|
137
|
+
|
|
138
|
+
report = quality_summary(
|
|
139
|
+
dataset, start="2026-06-01", end="2026-06-02",
|
|
140
|
+
flatline_options={"min_duration": "2h", "tolerance": 0.01},
|
|
141
|
+
)
|
|
142
|
+
observations = report.detections["flatlines"] # DetectionResult.to_dict() form
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Detection scans the **entire input**, consistent with input-wide quality value
|
|
146
|
+
checks. Start/end continue to restrict only timestamp completeness, not pattern
|
|
147
|
+
evidence. Detection errors propagate when opted in. Results stay separate from
|
|
148
|
+
quality `checks`; `ValidationResult.to_dict()` adds `detections` only when populated.
|
|
149
|
+
`dataset.validate()` does not automatically run detection. Range observations
|
|
150
|
+
remain available through existing quality limits, or the standalone detector for
|
|
151
|
+
provenance-enriched evidence.
|
|
152
|
+
|
|
153
|
+
## Synthetic example
|
|
154
|
+
|
|
155
|
+
```console
|
|
156
|
+
python examples/detect_synthetic.py
|
|
157
|
+
python -m pytest
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The fabricated example includes varying normal readings, a daytime flatline,
|
|
161
|
+
nighttime zeros, an out-of-range value and missing power separating two shorter
|
|
162
|
+
candidates. It prints summaries/evidence and verifies data/history preservation.
|
|
163
|
+
Daylight context, physical diagnostics and interpretation of causes remain
|
|
164
|
+
outside this stage. No automatic repair follows detection.
|