From 893f8cad8726abb61d3fcd26789ec5954094adf8 Mon Sep 17 00:00:00 2001 From: Omesh37 Date: Thu, 2 Jul 2026 19:36:52 +0530 Subject: [PATCH 1/6] shading: use morphology.footprint_rectangle((1, 3)) for 1x3 structuring element --- pvanalytics/features/shading.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvanalytics/features/shading.py b/pvanalytics/features/shading.py index 08ea73ed..cd595a3e 100644 --- a/pvanalytics/features/shading.py +++ b/pvanalytics/features/shading.py @@ -365,7 +365,7 @@ def fixed(ghi, daytime, clearsky, interval=None, min_gradient=2): threshold = gradient > min_gradient # binary image of wire candidates # From here we CAN use skimage because we are working with binary images. - three_minute_mask = morphology.rectangle(1, 3) + three_minute_mask = morphology.footprint_rectangle((1, 3)) wires = morphology.remove_small_objects( morphology.binary_closing(threshold, three_minute_mask), min_size=200, From cfd31c9a448ada605fc01f53b413719b330ab8da Mon Sep 17 00:00:00 2001 From: Omesh37 Date: Sat, 4 Jul 2026 13:53:00 +0530 Subject: [PATCH 2/6] Fix read-only array error in _prepare_images by copying to_numpy() output --- pvanalytics/features/shading.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvanalytics/features/shading.py b/pvanalytics/features/shading.py index cd595a3e..d76977ea 100644 --- a/pvanalytics/features/shading.py +++ b/pvanalytics/features/shading.py @@ -113,7 +113,7 @@ def _prepare_images(ghi, clearsky, daytime, interval): ghi_image = pd.DataFrame(cloudless_image).interpolate( axis=0, limit_direction='both' - ).to_numpy() + ).to_numpy().copy() # set night to nan ghi_image[~_to_image(daytime.to_numpy(), image_width)] = np.nan return ( From 553b9d57d3a82e1f41ba98f066c11fefd4598ad0 Mon Sep 17 00:00:00 2001 From: Omesh37 Date: Wed, 8 Jul 2026 18:32:41 +0530 Subject: [PATCH 3/6] Move footprint_rectangle import to module level with version fallback for skimage < 0.23 --- pvanalytics/features/shading.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pvanalytics/features/shading.py b/pvanalytics/features/shading.py index d76977ea..34853d6a 100644 --- a/pvanalytics/features/shading.py +++ b/pvanalytics/features/shading.py @@ -5,7 +5,8 @@ from skimage import morphology, measure import pvlib from pvanalytics import util - +from skimage.morphology import footprint_rectangle +from skimage.morphology import rectangle as footprint_rectangle def _to_image(data, width): """Convert data to an image. @@ -365,7 +366,7 @@ def fixed(ghi, daytime, clearsky, interval=None, min_gradient=2): threshold = gradient > min_gradient # binary image of wire candidates # From here we CAN use skimage because we are working with binary images. - three_minute_mask = morphology.footprint_rectangle((1, 3)) + three_minute_mask = footprint_rectangle(1, 3) wires = morphology.remove_small_objects( morphology.binary_closing(threshold, three_minute_mask), min_size=200, From 394267b57b3968980b2d829e6a24b06382662363 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 8 Jul 2026 08:08:03 -0600 Subject: [PATCH 4/6] Apply suggestion from @cwhanse --- pvanalytics/features/shading.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pvanalytics/features/shading.py b/pvanalytics/features/shading.py index 34853d6a..c930ea32 100644 --- a/pvanalytics/features/shading.py +++ b/pvanalytics/features/shading.py @@ -5,7 +5,6 @@ from skimage import morphology, measure import pvlib from pvanalytics import util -from skimage.morphology import footprint_rectangle from skimage.morphology import rectangle as footprint_rectangle def _to_image(data, width): From e976c1f5d7241a0c3357d87f288f1e8fba3e9f82 Mon Sep 17 00:00:00 2001 From: Omesh37 Date: Wed, 8 Jul 2026 20:02:19 +0530 Subject: [PATCH 5/6] fixed flake8 error --- pvanalytics/features/shading.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pvanalytics/features/shading.py b/pvanalytics/features/shading.py index c930ea32..74c82971 100644 --- a/pvanalytics/features/shading.py +++ b/pvanalytics/features/shading.py @@ -7,6 +7,7 @@ from pvanalytics import util from skimage.morphology import rectangle as footprint_rectangle + def _to_image(data, width): """Convert data to an image. From f3e8713b03879d0d1bbe276b629362e63d8bdbc6 Mon Sep 17 00:00:00 2001 From: Omesh37 Date: Wed, 8 Jul 2026 21:05:45 +0530 Subject: [PATCH 6/6] Fix DatetimeIndex.diff() AttributeError in completeness_score --- pvanalytics/quality/gaps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvanalytics/quality/gaps.py b/pvanalytics/quality/gaps.py index 2e16d83e..4441149f 100644 --- a/pvanalytics/quality/gaps.py +++ b/pvanalytics/quality/gaps.py @@ -274,7 +274,7 @@ def completeness_score(series, keep_index=True): (fraction of the day for which `series` has data). """ - seconds_per_sample = series.index.diff().total_seconds()[1] + seconds_per_sample = (series.index[1] - series.index[0]).total_seconds() daily_counts = series.resample('D').count() daily_completeness = (daily_counts * seconds_per_sample) / (1440*60) if keep_index: