/
filtering.py
126 lines (102 loc) · 3.5 KB
/
filtering.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
'''Functions for filtering and subsetting PV system data.'''
import numpy as np
def normalized_filter(energy_normalized, energy_normalized_low=0.01,
energy_normalized_high=None):
'''
Select normalized yield between ``low_cutoff`` and ``high_cutoff``
Parameters
----------
energy_normalized : pd.Series
Normalized energy measurements.
energy_normalized_low : float, default 0.01
The lower bound of acceptable values.
energy_normalized_high : float, optional
The upper bound of acceptable values.
Returns
-------
pd.Series
Boolean Series of whether the given measurement is within acceptable
bounds.
'''
if energy_normalized_low is None:
energy_normalized_low = -np.inf
if energy_normalized_high is None:
energy_normalized_high = np.inf
return ((energy_normalized > energy_normalized_low) &
(energy_normalized < energy_normalized_high))
def poa_filter(poa_global, poa_global_low=200, poa_global_high=1200):
'''
Filter POA irradiance readings outside acceptable measurement bounds.
Parameters
----------
poa_global : pd.Series
POA irradiance measurements.
poa_global_low : float, default 200
The lower bound of acceptable values.
poa_global_high : float, default 1200
The upper bound of acceptable values.
Returns
-------
pd.Series
Boolean Series of whether the given measurement is within acceptable
bounds.
'''
return (poa_global > poa_global_low) & (poa_global < poa_global_high)
def tcell_filter(temperature_cell, temperature_cell_low=-50,
temperature_cell_high=110):
'''
Filter temperature readings outside acceptable measurement bounds.
Parameters
----------
temperature_cell : pd.Series
Cell temperature measurements.
temperature_cell_low : float, default -50
The lower bound of acceptable values.
temperature_cell_high : float, default 110
The upper bound of acceptable values.
Returns
-------
pd.Series
Boolean Series of whether the given measurement is within acceptable
bounds.
'''
return ((temperature_cell > temperature_cell_low) &
(temperature_cell < temperature_cell_high))
def clip_filter(power_ac, quantile=0.98):
'''
Filter data points likely to be affected by clipping
with power greater than or equal to 99% of the `quant`
quantile.
Parameters
----------
power_ac : pd.Series
AC power in Watts
quantile : float, default 0.98
Value for upper threshold quantile
Returns
-------
pd.Series
Boolean Series of whether the given measurement is below 99% of the
quantile filter.
'''
v = power_ac.quantile(quantile)
return (power_ac < v * 0.99)
def csi_filter(poa_global_measured, poa_global_clearsky, threshold=0.15):
'''
Filtering based on clear-sky index (csi)
Parameters
----------
poa_global_measured : pd.Series
Plane of array irradiance based on measurments
poa_global_clearsky : pd.Series
Plane of array irradiance based on a clear sky model
threshold : float, default 0.15
threshold for filter
Returns
-------
pd.Series
Boolean Series of whether the clear-sky index is within the threshold
around 1.
'''
csi = poa_global_measured / poa_global_clearsky
return (csi >= 1.0 - threshold) & (csi <= 1.0 + threshold)