Esempio n. 1
0
def main(argv):
    print('starting....')

    para_dict = init_data_para()
    para_dict = fc.deal_argv(argv, para_dict)
    mode = para_dict['run_mode']

    print('starting processing the data...')
    bat_list = rwd.get_bat_list(para_dict, mode)
    if bat_list is not None:
        for bat_name in bat_list:

            para_dict['bat_config'] = fc.get_bat_config(
                para_dict['bat_info_config'][mode], bat_name, fuzzy=False)

            if 'pro_info' in para_dict['mission'] or 'all' in para_dict[
                    'mission']:
                pro_info = rwd.get_pro_info(para_dict, mode, bat_name)
                rwd.save_pro_info(pro_info,
                                  para_dict['log_info'] + '_' + bat_name,
                                  para_dict, mode)

            if 'cell_v_drop' in para_dict['mission'] or 'all' in para_dict[
                    'mission']:
                #获得cell_v_drop
                pro_info = rwd.read_bat_data(
                    para_dict, mode, para_dict['log_info'] + '_' + bat_name)
                feature = cvd.get_feature_vdrop(para_dict, mode, bat_name,
                                                pro_info)
                rwd.save_pro_info(feature, 'cell_v_drop_' + bat_name,
                                  para_dict, mode)

            if 'cell_stdv' in para_dict['mission'] or 'all' in para_dict[
                    'mission']:
                #获得cell_v_drop
                pro_info = rwd.read_bat_data(
                    para_dict, mode, para_dict['log_info'] + '_' + bat_name)
                feature = cs.get_feature_stdv(para_dict, mode, bat_name,
                                              pro_info)
                rwd.save_pro_info(feature, 'cell_stdv_' + bat_name, para_dict,
                                  mode)

            if 'soh_feature' in para_dict['mission'] or 'all' in para_dict[
                    'mission']:
                pro_info = rwd.read_bat_data(
                    para_dict, mode, para_dict['log_info'] + '_' + bat_name)
                feature = sf.get_feature_soh(para_dict, mode, bat_name,
                                             pro_info)
                rwd.save_pro_info(feature, 'cell_soh_' + bat_name, para_dict,
                                  mode)

            if 'dqdv_calc' in para_dict['mission'] or 'all' in para_dict[
                    'mission']:
                pro_info = rwd.read_bat_data(
                    para_dict, mode, para_dict['log_info'] + '_' + bat_name)
                feature = dc.get_dqdv_data(para_dict, mode, bat_name, pro_info)
                rwd.save_pro_info(feature, 'cell_dqdv_' + bat_name, para_dict,
                                  mode)
    else:
        print('there is no bat!')
Esempio n. 2
0
def get_1_pro_data(para_dict, mode, table_name, pro_info, pro_no, condition1='start_time', condition2='end_time', t_keywords='stime'):
    str_value1 = pro_info[condition1].iloc[pro_no] 
    str_value1 = str_value1.strftime("%Y-%m-%d %H:%M:%S")
    str_value2 = pro_info[condition2].iloc[pro_no] 
    str_value2 = str_value2.strftime("%Y-%m-%d %H:%M:%S")
    df = rwd.read_bat_data(para_dict, mode, table_name, start_time=str_value1, end_time=str_value2)
    return df
Esempio n. 3
0
def main(argv):
    sys.path.append(app_dir)
    import rw_bat_data as rwd
    import preprocess_data as ppd
    import func as fc
    import scale_data as sd

    para_dict = init_data_para()
    para_dict = fc.deal_argv(argv, para_dict)
    mode = para_dict['run_mode']

    #读取所需的数据,并进行处理后存储到指定位置
    print('starting processing the data...')
    bat_list = rwd.get_bat_list(para_dict, mode)
    regx, mask_filename = fc.get_filename_regx(para_dict['log_pro'],
                                               **para_dict)

    if bat_list is not None:
        for bat_name in bat_list:
            raw_data = rwd.read_bat_data(para_dict,
                                         mode,
                                         bat_name,
                                         limit=para_dict['data_limit'][mode])
            data = ppd.preprocess_data(bat_name, raw_data)
            rwd.save_bat_data(data, para_dict['log_pro'] + '_' + bat_name,
                              para_dict, mode)  #存储处理后的数据
    else:
        print('there is no bat!')

    #将处理好的数据按工作状态划分后存储到指定位置
    print('save the processed data...')

    result = fc.save_workstate_data(regx, mask_filename,
                                    para_dict['processed_data_dir'][mode],
                                    para_dict['processed_data_dir'][mode])
    if not result:
        print(
            'there is not any files included the data which would been scaled.'
        )
        return
    else:
        #进行扩充
        print('to be scaled...')

        for state in para_dict['states']:
            file_name = r'%s_' % state + mask_filename
            processed_data = sd.get_processed_data(
                os.path.join(para_dict['processed_data_dir'][mode], file_name))
            scale_data = sd.generate_data(processed_data, **para_dict)
            sd.save_scale_data(scale_data,
                               para_dict['log_scale'] + '_' + file_name,
                               para_dict['scale_data_dir'][mode])
            print('finished scaling the %s data' % state)

    #训练模型
    print('starting training the model...')
    for state in para_dict['states']:
        file_name = r'%s_%s_%s' % (para_dict['log_scale'], state,
                                   mask_filename)
        para_dict['pkl_dir'] = {
            'run':
            os.path.normpath('/raid/data/processed_data/pkl/' + save_dir +
                             '/%s_pkl' % state),
            'debug':
            os.path.normpath(app_dir + '/%s_pkl' % state)
        }
        import build_model as bm
        bm.train_model(file_name, state, **para_dict)
Esempio n. 4
0
        'db': 'test_bat',
        'port': 3306
    }
}
para_dict['processed_data_dir'] = {'debug': './data'}
mode = 'debug'
table_list = rwd.get_bat_list(para_dict, mode)
if 'cell_v_drop' in table_list[0]:
    file_name = 'cell_v_drop'
    cut = 12
elif 'cell_stdv' in table_list[0]:
    file_name = 'cell_stdv'
    cut = 10
elif 'cell_soh' in table_list[0]:
    file_name = 'cell_soh'
    cut = 9
if table_list is not None:
    data = []
    data_dir = para_dict['processed_data_dir'][mode]
    if not os.path.exists(data_dir):
        os.mkdir(data_dir)
    writer = pd.ExcelWriter(os.path.join(data_dir, file_name + '.xlsx'))
    for table_name in table_list:
        v = rwd.read_bat_data(para_dict, mode, table_name)
        v['bat_id'] = table_name[cut:]
        v = v.drop(columns='index')
        v.to_excel(writer, table_name[cut:])
        rwd.save_bat_data(v, table_name, para_dict, mode)
        data.append(v)
    df = pd.concat(tuple(data))
    rwd.save_bat_data(df, file_name, para_dict, mode)