Changes:增加了自动生成修改数据变csv的格式
This commit is contained in:
3
cycle.py
3
cycle.py
@@ -1,8 +1,9 @@
|
|||||||
from algorithm import algorithm
|
from algorithm import algorithm
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
|
import ray
|
||||||
|
|
||||||
|
@ray.remote
|
||||||
class cycle(algorithm):
|
class cycle(algorithm):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.config_dict_ = None
|
self.config_dict_ = None
|
||||||
|
|||||||
@@ -1,25 +1,29 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from cycle import cycle
|
from cycle import cycle
|
||||||
|
import ray
|
||||||
|
|
||||||
|
ray.init()
|
||||||
filepath = "D:/python_project_data/1.csv"
|
filepath = "D:/python_project_data/1.csv"
|
||||||
origin_data = pd.read_csv(filepath)
|
origin_data = pd.read_csv(filepath)
|
||||||
row_len = origin_data.shape[0]
|
row_len = origin_data.shape[0]
|
||||||
cow_len = origin_data.shape[1]
|
cow_len = origin_data.shape[1]
|
||||||
disturb_data = origin_data
|
disturb_data = origin_data
|
||||||
algorithm_step = cycle()
|
algorithm_step = cycle.remote()
|
||||||
|
|
||||||
cow_name = "G1.TTXD1_3"
|
cow_name = "G1.TTXD1_3"
|
||||||
contrast_data = pd.DataFrame()
|
contrast_data = pd.DataFrame()
|
||||||
contrast_data[cow_name+'_origin'] = origin_data[cow_name]
|
contrast_data[cow_name+'_origin'] = origin_data[cow_name]
|
||||||
algorithm_step.set_config('{"CYCLE_AMPLITUDE_BASE": 200 , "CYCLE_TIME_BASE": 5 ,"CYCLE_START_ANGLE_BASE": 3.14}')
|
algorithm_step.set_config.remote('{"CYCLE_AMPLITUDE_BASE": 200 , "CYCLE_TIME_BASE": 5 ,"CYCLE_START_ANGLE_BASE": 3.14}')
|
||||||
# algorithm_step.set_config('{"CYCLE_TIME_BASE": 5 }')
|
# algorithm_step.set_config('{"CYCLE_TIME_BASE": 5 }')
|
||||||
for i in range(0,row_len):
|
for i in range(0,row_len):
|
||||||
disturb_data.loc[i,cow_name]=algorithm_step.eval(origin_data.loc[i,cow_name],i)
|
futures=algorithm_step.eval.remote(origin_data.loc[i,cow_name],i)
|
||||||
print(disturb_data)
|
disturb_data.loc[i,cow_name]=ray.get(futures)
|
||||||
|
|
||||||
|
print(disturb_data.loc[:,cow_name])
|
||||||
contrast_data[cow_name+'_disturb'] = disturb_data[cow_name]
|
contrast_data[cow_name+'_disturb'] = disturb_data[cow_name]
|
||||||
disturb_data.to_csv("D:/python_project_data/1_disturb.csv", index=False)
|
disturb_data.to_csv("D:/python_project_data/1_disturb.csv", index=False)
|
||||||
contrast_data.to_csv("D:/python_project_data/contrast_data.csv", index=False)
|
contrast_data.to_csv("D:/python_project_data/contrast_data.csv", index=False)
|
||||||
|
|
||||||
|
|
||||||
# 以下均为测试性能用
|
# 以下均为测试性能用
|
||||||
print(algorithm_step.config_)
|
# print(algorithm_step.config_)
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
from algorithm import algorithm
|
from algorithm import algorithm
|
||||||
import json
|
import json
|
||||||
|
import ray
|
||||||
|
|
||||||
|
@ray.remote
|
||||||
class excursion(algorithm):
|
class excursion(algorithm):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.config_dict_ = None
|
self.config_dict_ = None
|
||||||
|
|||||||
18
ray_example.py
Normal file
18
ray_example.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import ray
|
||||||
|
ray.init()
|
||||||
|
|
||||||
|
@ray.remote
|
||||||
|
class Counter(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.n = 0
|
||||||
|
|
||||||
|
def increment(self):
|
||||||
|
self.n += 1
|
||||||
|
|
||||||
|
def read(self):
|
||||||
|
return self.n
|
||||||
|
|
||||||
|
counters = [Counter.remote() for i in range(4)]
|
||||||
|
[c.increment.remote() for c in counters]
|
||||||
|
futures = [c.read.remote() for c in counters]
|
||||||
|
print(ray.get(futures))
|
||||||
3
step.py
3
step.py
@@ -1,7 +1,8 @@
|
|||||||
from algorithm import algorithm
|
from algorithm import algorithm
|
||||||
import json
|
import json
|
||||||
|
import ray
|
||||||
|
|
||||||
|
@ray.remote
|
||||||
class step(algorithm):
|
class step(algorithm):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.config_dict_ = None
|
self.config_dict_ = None
|
||||||
|
|||||||
17
step_test.py
17
step_test.py
@@ -1,14 +1,17 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from step import step
|
from step import step
|
||||||
|
import ray
|
||||||
|
ray.init()
|
||||||
|
|
||||||
filepath = "D:/python_project/TurbineExhaustTemperatureTheromcouple-FourWorkingCondition.xlsx"
|
filepath = "D:/python_project_data/1.csv"
|
||||||
origin_data = pd.read_excel(filepath,sheet_name='s4_ttxd')
|
origin_data = pd.read_csv(filepath)
|
||||||
row_len = origin_data.shape[0]
|
row_len = origin_data.shape[0]
|
||||||
cow_len = origin_data.shape[1]
|
cow_len = origin_data.shape[1]
|
||||||
disturb_data = origin_data
|
disturb_data = origin_data
|
||||||
algorithm_step = step()
|
algorithm_step = step.remote()
|
||||||
cow_name = "ttxd_12_1"
|
cow_name = "G1.TTXD1_3"
|
||||||
algorithm_step.set_config('{"STEP_AMPLITUDE_BASE": 1.3}')
|
algorithm_step.set_config.remote('{"STEP_AMPLITUDE_BASE": 1.3}')
|
||||||
for i in range(0,row_len):
|
for i in range(0,row_len):
|
||||||
disturb_data.loc[i,cow_name]=algorithm_step.eval(origin_data.loc[i,cow_name])
|
futures=algorithm_step.eval.remote(origin_data.loc[i,cow_name])
|
||||||
print(disturb_data)
|
disturb_data.loc[i, cow_name] = ray.get(futures)
|
||||||
|
print(disturb_data.loc[:,cow_name])
|
||||||
@@ -2,8 +2,9 @@ from random import random
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from algorithm import algorithm
|
from algorithm import algorithm
|
||||||
import json
|
import json
|
||||||
|
import ray
|
||||||
|
|
||||||
|
@ray.remote
|
||||||
class white_noise(algorithm):
|
class white_noise(algorithm):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.config_dict_ = None
|
self.config_dict_ = None
|
||||||
|
|||||||
Reference in New Issue
Block a user