diff --git a/pvanalytics/features/shading.py b/pvanalytics/features/shading.py index 08ea73ed..74c82971 100644 --- a/pvanalytics/features/shading.py +++ b/pvanalytics/features/shading.py @@ -5,6 +5,7 @@ from skimage import morphology, measure import pvlib from pvanalytics import util +from skimage.morphology import rectangle as footprint_rectangle def _to_image(data, width): @@ -113,7 +114,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 ( @@ -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.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, 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: