<jupyter_start><jupyter_text>This script tests the performance of the interpolation function in `data_impute()` on a sample day. The plots show before and after data imputation. The missing data here are for couple of hours.<jupyter_code>import os
import sys
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
module_path = os.path.abspath(os.path.join('..', 'demand_acep'))
if module_path not in sys.path:
    sys.path.append(module_path)
from demand_acep import extract_data
from demand_acep import data_impute
from demand_acep import data_resample
dirpath = os.path.join(module_path, 'data/measurements/test_data')
filename = 'PokerFlatResearchRange-PokerFlat-PkFltM3SciPTot@2019-01-03T093004Z@P1D@PT179F.nc'
test_df = extract_data(dirpath, filename)
sample_time = '1S' # 1 second sampling time
test_resampled = data_resample(test_df, sample_time)
test_resampled.set_index(np.arange(1, len(test_resampled)+1), inplace=True)
sns.set_context('poster')
fig, ax = plt.subplots(1, 1, figsize=(15, 10))
plt.sca(ax)
plt.plot(test_resampled)
plt.title('Sample Day Total Load Profile (PTot) for PkFltM3Sci Meter with Missing Data')
plt.xlabel('Time (seconds)')
plt.ylabel('Total Active Power (kW)')
plt.grid(linewidth=0.75, alpha=0.25)
plt.autoscale(enable=True, axis='x', tight=True)
plt.xticks(rotation=45)
plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
ax.xaxis.major.formatter._useMathText = True
plt.show()
test_filled = data_impute(test_resampled)
sns.set_context('poster')
fig, ax = plt.subplots(1, 1, figsize=(15, 10))
plt.sca(ax)
plt.plot(test_filled)
plt.title('Sample Day Total Load Profile (PTot) for PkFltM3Sci Meter \n with Missing Data Filled Using Interpolation')
plt.xlabel('Time (seconds)')
plt.ylabel('Total Active Power (kW)')
plt.grid(linewidth=0.75, alpha=0.25)
plt.autoscale(enable=True, axis='x', tight=True)
plt.xticks(rotation=45)
plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
ax.xaxis.major.formatter._useMathText = True
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12907939600584512, 'fraction_numerical': 0.027764247442766683, 'mean_word_length': 7.118577075098814, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '602136', 'license': 'MIT', 'n_tokens_mistral': 815, 'n_tokens_neox': 757, 'n_words': 176, 'path': 'scripts/test_data_impute.ipynb', 'repo_name': 'reconjohn/demand_acep', 'size': '2053'}