in lab/app_ggv2/windfarm.py [0:0]
def __init__(self, n_turbines):
self.artifacts_path = os.environ.get("ARTIFACTS_PATH")
self.raw_data = pd.read_csv(f'{self.artifacts_path}/dataset_wind.csv.gz', compression="gzip", sep=',', low_memory=False).values
self.n_turbines = n_turbines
self.turbines = [WindTurbine(i, self.raw_data) for i in range(self.n_turbines)]
self.data_buffer = [[] for i in range(self.n_turbines)]
## launch edge agent clients
self.edge_agent = EdgeAgentClient('/tmp/aws.greengrass.SageMakerEdgeManager.sock')
self.model_meta = [{'model_name':None} for i in range(self.n_turbines)]
# we need to load the statistics computed in the data prep notebook
# these statistics will be used to compute normalize the input
self.raw_std = np.load(f'{self.artifacts_path}/raw_std.npy')
self.mean = np.load(f'{self.artifacts_path}/mean.npy')
self.std = np.load(f'{self.artifacts_path}/std.npy')
# then we load the thresholds computed in the training notebook
# for more info, take a look on the Notebook #2
self.thresholds = np.load(f'{self.artifacts_path}/thresholds.npy')
# configurations to format the time based data for the anomaly detection model
# If you change these parameters you need to retrain your model with the new parameters
self.INTERVAL = 5 # seconds
self.TIME_STEPS = 20 * self.INTERVAL # 50ms -> seg: 50ms * 20
self.STEP = 10
# these are the features used in this application
self.feature_ids = [8, 9, 10, 7, 22, 5, 6] # qX,qy,qz,qw ,wind_seed_rps, rps, voltage
self.n_features = 6 # roll, pitch, yaw, wind_speed, rotor_speed, voltage
self.running = False # running status
# minimal buffer length for denoising. We need to accumulate some sample before denoising
self.min_num_samples = 500
self.max_buffer_size = 500
for idx in range(n_turbines):
for j in range(self.max_buffer_size):
self.__read_next_turbine_sample__(idx)