In [8]:
import sys, os

import pandas as pd
import numpy as np

from glob import glob
from tqdm import tqdm

In [9]:
house3_c1 = np.loadtxt( 'datasets/REDD/high_freq/house_3/current_1.dat' )

In [7]:
house3_c1.shape


Out[7]:
(71202, 277)

In [6]:
house3_c1[:,1]


Out[6]:
array([ 1782.,  1782.,  2760., ...,  6802., 10603.,  3760.])

In [7]:
df_house3_c1 = pd.DataFrame(
    data = house3_c1, 
    columns=['utc_timestamp', 'cycle_count'] + ['wf_value_'+str(i) for i in range(0, 275)]
)
df_house3_c1.head()


Out[7]:
utc_timestamp cycle_count wf_value_0 wf_value_1 wf_value_2 wf_value_3 wf_value_4 wf_value_5 wf_value_6 wf_value_7 ... wf_value_265 wf_value_266 wf_value_267 wf_value_268 wf_value_269 wf_value_270 wf_value_271 wf_value_272 wf_value_273 wf_value_274
0 1.302922e+09 1782.0 -0.017231 -0.017167 -0.017059 -0.017008 -0.017104 -0.017163 -0.017450 -0.017587 ... -0.017431 -0.017421 -0.017433 -0.017398 -0.017257 -0.017344 -0.017262 -0.017277 -0.017192 -0.017232
1 1.302922e+09 1782.0 -0.017288 -0.017300 -0.017320 -0.017308 -0.017248 -0.017345 -0.017636 -0.017700 ... -0.017539 -0.017615 -0.017604 -0.017637 -0.017505 -0.017600 -0.017512 -0.017387 -0.017450 -0.017289
2 1.302931e+09 2760.0 0.002427 0.007893 0.020264 0.037044 0.059954 0.139391 0.195261 0.231653 ... -0.131324 -0.208694 -0.192772 -0.104762 -0.070186 -0.036816 -0.027137 -0.012471 -0.003119 0.002425
3 1.302931e+09 2065.0 0.004701 0.008471 0.022125 0.040235 0.063376 0.143110 0.198713 0.237631 ... -0.131911 -0.212030 -0.197415 -0.107624 -0.073997 -0.036811 -0.027118 -0.013915 -0.003341 0.004708
4 1.302931e+09 206.0 0.002921 0.006746 0.021267 0.042351 0.065329 0.144688 0.197718 0.238668 ... -0.216036 -0.261511 -0.158430 -0.126622 -0.074224 -0.036602 -0.027803 -0.014041 -0.005268 0.002964

5 rows × 277 columns


In [8]:
import matplotlib.pyplot as plt

%matplotlib inline

In [9]:
plt.plot(house3_c1[0,2:])


Out[9]:
[<matplotlib.lines.Line2D at 0x7f09320a6400>]

In [10]:
plt.plot(house3_c1[1,2:])


Out[10]:
[<matplotlib.lines.Line2D at 0x7f098ac25a20>]

In [12]:
!!pip install tqdm


Out[12]:
['Collecting tqdm',
 '  Using cached https://files.pythonhosted.org/packages/9f/3d/7a6b68b631d2ab54975f3a4863f3c4e9b26445353264ef01f465dc9b0208/tqdm-4.32.2-py2.py3-none-any.whl',
 'Installing collected packages: tqdm',
 'Successfully installed tqdm-4.32.2']

In [ ]:
xlabels = list(range(0, 275, 5))

for r in tqdm(range(0, house3_c1.shape[0])):

    name_fig = 'datasets/REDD/high_freq/{}/{}/wf_{}.png'.format( 'house_3', 'current_1', house3_c1[r,0] )
    
    if not os.path.isfile(name_fig):
        fig = plt.figure(figsize=(15,5))
        ax = fig.add_axes([0.1,0.1,0.8,0.8])

        ax.plot(house3_c1[r,2:])
        ax.grid()
        ax.set_xticks(xlabels )
        ax.set_xticklabels(xlabels, rotation=90)
        ax.set_xlim(0, 274)
        ax.set_title('Timestamp: {}'.format(house3_c1[r,0]))

        fig.savefig(name_fig)   # save the figure to file
        plt.close(fig)    # close the figure

#plt.plot(house3_c1[8,2:])


 21%|██▏       | 15268/71202 [27:39<2:23:03,  6.52it/s]  

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: