def GetData(coll_prefix):
    fdata = []
    for date, value in coll_prefix.items():
        if ("traffic" in value):
            traflist = value["traffic"]
        else:
            traflist = [""]

        if ("ID" in value):
            IDlist = value["ID"]
        else:
            IDlist = [""]

        for t in traflist:
            for i in IDlist:
                W_coll = date + t + i
                if (W_coll in coll_prefix["Exception"]):
                    continue
                W_coll = W_coll + '-ProcessData'
                mW = mongodb_api(user='******',
                                 pwd='ubuntu',
                                 database='wifi_diagnosis',
                                 collection=W_coll)
                found = mW.find(key_value={}, ftype='many')
                c_print(W_coll + ' : ' + str(len(found)))
                fdata = fdata + found

    return fdata
    SkipFirstN = 0

    iptable = {
        "AP": "10.144.24.24",
        "STA": "10.144.24.23",
        "10.144.24.24": "AP",
        "10.144.24.23": "STA"
    }

    R_coll = date + '-TestData'
    W_coll = date + '-ProcessData'
    ML_coll = date + '-MLData'
    ML_coll_pair = date + 'MLData-Pair'

    mR = mongodb_api(user='******',
                     pwd='ubuntu',
                     database='wifi_diagnosis',
                     collection=R_coll)
    mW = mongodb_api(user='******',
                     pwd='ubuntu',
                     database='wifi_diagnosis',
                     collection=W_coll)
    mdb_ML = mongodb_api(user='******',
                         pwd='ubuntu',
                         database='wifi_diagnosis',
                         collection=ML_coll)
    mdb_ML_pair = mongodb_api(user='******',
                              pwd='ubuntu',
                              database='wifi_diagnosis',
                              collection=ML_coll_pair)

    #    sorted_data = Testdata_sort(mR)
        scanlist.append(tmp)
        
    new_data_payload["Scan"] = scanlist
    
    return new_data_payload    
    #new_data_payload["Time"] = Time
    #return new_data_payload
    
if __name__ == '__main__': 
    
    date='1070207small-t1'
    
    R_coll = date + '-RawData'
    W_coll = date + '-TestData' 
    
    m = mongodb_api(user='******', pwd='ubuntu', database='wifi_diagnosis', collection=R_coll)    
    
    
#    find_reg = {"Topic":"CwmData/DumpAth9kAni"}
    find_reg = {}
    found_data = m.find(key_value = find_reg, ftype='many')
    print(len(found_data))    
    
    
    
    m = mongodb_api(user='******', pwd='ubuntu', database='wifi_diagnosis', collection=W_coll)
    m.remove(key_value = {}, justone=False)
    
    casetype = "Start"
    for data in found_data:
        out, casetype = data_process(data,casetype)
import mongodb_api as db
import pandas as pd
import sys
import numpy as np
from sklearn.svm import SVR

from matplotlib import pyplot as plt

m = db.mongodb_api(user='******', pwd='ubuntu', collection="TestData1213")
found_data = m.find(ftype='many')
_found_data = {}

idx = 0

survey_dict = {
    "survey_data": [],
    "survey_mean": [],
    "survey_std": [],
    "survey_FER": []
}

spectralscan_data_dict = {
    "Spectralscan_data": [],
    "Spectralscan_mean": [],
    "Spectralscan_std": [],
    "Spectralscan_FER": []
}

survey_label = []
Spectralscan_label = []
survey_station_info = []
device = 'AP'
AP_data = []
                 
for i in range(len(db_collections['collection'])):

    collection_name = db_collections['collection'][i]
    
    for j in range(db_collections['number'][i]):
        
        
        if j==0:
            db_collection = db_collections['collection'][i] + '-ProcessData'
        else:
            db_collection = db_collections['collection'][i] + '-'+ str(j+1) + '-ProcessData'
        
        mW = db.mongodb_api(user='******', pwd='ubuntu', database='wifi_diagnosis',collection=db_collection)
        fdata = mW.find(key_value = {}, ftype='many')


        for k in range(len(fdata)):
            AP_data.append(pd.Series(fdata[k]['AP']))
            #tmp = pd.Series.transpose(tmp)
    
AP_data = pd.concat(AP_data, axis=1).transpose()


#Drop data with no delay values 
AP_data = AP_data[AP_data.astype(str)['Delay']!='[]'].reset_index(drop='True')
AP_data = AP_data[AP_data.astype(str)['SS_Subval']!='[]'].reset_index(drop='True')

Esempio n. 6
0
                
    return train_data
        


output_folder = '../data/ProcessData1070208'
collections = ['1070222-clear-ProcessData']
"""
collections = ['1070208small-t1', '1070208small-t1-2', 
               '1070208small-t2', '1070208small-t2-2',
               '1070208small-t3', '1070208small-t3-2'
               ]
"""
for c in collections:
    
    m = db.mongodb_api(user='******', pwd='ubuntu', database='wifi_diagnosis', collection=c+'-MLData')
    found_data = m.find(ftype='many')
    output_file = c +'.h5'
    output_path = os.path.join(output_folder,output_file)
    
    if not os.path.isdir(output_folder):
        os.mkdir(output_folder)
    
    time_step = 1
    time_stride = 1
    
    train_data = gnerate_data_and_label(found_data, data_dict) 
    processed_data  = pd.DataFrame.from_dict(train_data)
    processed_data.to_hdf(output_path, 'raw_data', mode='w')
    
    
Esempio n. 7
0
                #label
                "Ping_mean":[],
                "Ping_std":[],
                "FER":[],
                
                          }


train_data = {'AP':copy.deepcopy(data_dict), 'STA':copy.deepcopy(data_dict)}
test_data = {'AP':copy.deepcopy(data_dict), 'STA':copy.deepcopy(data_dict)}
devices_type = ['AP','STA']



#m = db.mongodb_api(user='******', pwd='ubuntu', collection="ProcessData1061228")
m = db.mongodb_api(user='******', pwd='ubuntu', collection="1070208small-t1")
found_data = m.find(ftype='many')
output_folder = '../data/ProcessData1070208'
output_file = 'training_data_mid_5.h5'
output_path = os.path.join(output_folder,output_file)

if not os.path.isdir(output_folder):
    os.mkdir(output_folder)


training_portion = 0.0 #Portion for training data

time_step = 1
time_stride = 1
train_pairs = []
test_pairs = []
            if rawdata[key] != test[key]: return False

        return True

    def test(self):

        for idx in range(len(self.found_data)):

            self.issucess = self.sucess_create_data(idx) and self.issucess

        return self.issucess


#Init mogodb connection and find data
m = db.mongodb_api(user='******',
                   pwd='ubuntu',
                   collection='Fingerprint_171101')
found_data = m.find(ftype='many')
"""
#Simple function test
test = test_create_data(found_data)
print("Data test Result: ", test)     
"""
#Create data dimensions to fix input dimensions
#Create label table for one got encode

key_pair = []
label_pair = {}
label_count = 0
for i in range(len(found_data)):
    for key in found_data[i]["key"].keys():