Commit 7a653c9e authored by Kruyff,D.L.W. (Dylan)'s avatar Kruyff,D.L.W. (Dylan)
Browse files

Experiments update


Former-commit-id: 90bc7822
parent a06c8e37
......@@ -43,6 +43,7 @@ export interface State {
export interface StateNode {
id: number;
image: any;
state: State;
children: number[];
}
......
<div class="container">
<as-split direction="vertical">
<as-split-area [size]="30">
<as-split-area [size]="35">
<as-split direction="horizontal">
<as-split-area [size]="70">
......@@ -18,10 +18,10 @@
</as-split>
</as-split-area>
<as-split-area [size]="70">
<as-split-area [size]="65">
<as-split direction="horizontal">
<as-split-area [size]="60">
<as-split-area [size]="62">
<div class="channel_header">
Feedback
</div>
......@@ -29,7 +29,7 @@
<app-training-window></app-training-window>
</div>
</as-split-area>
<as-split-area [size]="40">
<as-split-area [size]="38">
<div class="channel_header">
Results
</div>
......
......@@ -250,7 +250,7 @@ export class ProgressViewComponent implements OnInit {
zeroline: false,
showticklabels: false,
},
height: 200 * this.state.selection.length,
height: 100 * this.state.selection.length,
width: 300,
};
this.state.selection.forEach((channelIndex, index) => {
......
......@@ -19,3 +19,21 @@
stroke: #f44336;
stroke-width: 2px;
}
.container {
display: flex;
justify-content: space-around;
}
.sub-container {
width: 45%
}
fieldset {
width: 100%;
min-width: 0;
}
.state {
overflow: scroll;
}
<div class="state">
<div class="container">
<div class="sub-container">
<fieldset>
<legend>States</legend>
<div class="state">
</div>
</fieldset>
</div>
<div class="sub-container">
<fieldset>
<legend>Prototype</legend>
<div *ngIf="plot" class="prototype">
<plotly-plot [data]="plot.data" [layout]="plot.layout"></plotly-plot>
</div>
</fieldset>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import * as d3 from 'd3';
import {StateService} from '../state.service';
import {style} from '@angular/animations';
import {State} from '../api.service';
import * as PlotlyJS from 'plotly.js/dist/plotly.js';
@Component({
selector: 'app-state-management',
......@@ -14,12 +14,16 @@ export class StateManagementComponent implements OnInit {
private treeCreated = false;
private selectedNode;
private treemap;
private svg;
private hoveredNode = 1;
public plot;
constructor(private state: StateService) { }
ngOnInit(): void {
if (this.state.lshData) {
this.createStateTree();
this.initializePlot();
}
this.state.onNewLshData.subscribe(() => {
if (!this.treeCreated) {
......@@ -27,17 +31,93 @@ export class StateManagementComponent implements OnInit {
} else {
this.update();
}
this.initializePlot();
});
}
initializePlot(): void {
console.log('creating plot');
console.log(this.hoveredNode);
console.log(this.state.states);
const subplots = [];
const data = [];
this.state.selection.forEach((channelIndex: number, index: number) => {
const channel = this.state.states[this.hoveredNode.toString()].state.queryWindow[channelIndex];
data.push({
x: [...Array(channel.length).keys()],
y: channel,
type: 'line',
xaxis: 'x',
yaxis: `y${index + 2}`,
line: {
color: this.state.colors[channelIndex],
}
});
subplots.push([`xy${index + 2}`]);
});
const plot = {
data: data,
layout: {
grid: {
rows: this.state.selection.length,
columns: 1,
subplots: subplots,
},
showlegend: false,
hovermode: 'closest',
autosize: true,
margin: {
l: 30,
r: 30,
t: 30,
b: 0,
pad: 4
},
height: 100 * this.state.selection.length,
width: 300,
titlefont: {
size: 9
},
xaxis: {
showgrid: false,
zeroline: false,
showticklabels: false,
},
yaxis: {
zeroline: false,
showticklabels: false,
}
}
};
this.state.selection.forEach((channel: number, index: number) => {
plot.layout[`yaxis${index + 2}`] = {
zeroline: false,
showticklabels: false,
annotations: [{
xref: 'paper',
yref: 'paper',
x: 0,
xanchor: 'right',
y: 1,
yanchor: 'bottom',
text: 'X axis label',
showarrow: false
}]
// title: this.state.rawData[channel].name
};
});
this.plot = plot;
}
createStateTree() {
console.log('Creating tree!');
const margin = {top: 20, right: 90, bottom: 30, left: 90};
const margin = {top: 20, right: 10, bottom: 30, left: 10};
const width = 960 - margin.left - margin.right;
const height = 500 - margin.top - margin.bottom;
const svg = d3.select('.state').append('svg')
this.svg = d3.select('.state').append('svg')
.attr("width", width + margin.right + margin.left)
.attr("height", height + margin.top + margin.bottom)
.append("g")
......@@ -47,14 +127,14 @@ export class StateManagementComponent implements OnInit {
let root;
const data = this.state.states;
this.selectedNode = d3.hierarchy(data[1], function(d) { return d.children ? d.children.map(function(child) {return data[child]}) : undefined });
this.selectedNode.x0 = height / 2;
this.selectedNode.y0 = 20;
this.selectedNode.x0 = width / 8;
this.selectedNode.y0 = 0;
this.treeCreated = true;
this.update();
}
update() {
async update() {
const margin = {top: 20, right: 90, bottom: 30, left: 90};
const width = 960 - margin.left - margin.right;
const height = 500 - margin.top - margin.bottom;
......@@ -65,17 +145,20 @@ export class StateManagementComponent implements OnInit {
let i = 0;
const duration = 750;
const svg = d3.select('.state').select('svg');
console.log(svg);
const data = this.state.states;
const currIndex = this.state.currStateIndex;
this.hoveredNode = currIndex;
const root = d3.hierarchy(data[1], function(d) { return d.children ? d.children.map(function(child) {return data[child]}) : undefined });
const source = this.selectedNode;
const loadState = (id) => {
this.state.loadState(id);
};
const setHover = (id) => {
this.hoveredNode = id;
this.initializePlot();
};
// // Assigns the x and y position for the nodes
// let root;
// const data = this.state.states;
......@@ -91,23 +174,18 @@ export class StateManagementComponent implements OnInit {
// Normalize for fixed-depth.
nodes.forEach(function(d) {
d.y = d.depth * 180
d.y = d.depth * 180;
});
// ****************** Nodes section ***************************
svg.selectAll('g.node').select('circle').style("fill", "#fff");
this.svg.selectAll('g.node').select('circle').style("fill", "#fff");
// Update the nodes...
const node = svg.selectAll('g.node')
const node = this.svg.selectAll('g.node')
.data(nodes, function(d: any) {
console.log('all-nodes');
console.log(d);
return d.id;
});
console.log('node');
console.log(node);
// Enter any new modes at the parent's previous position.
......@@ -152,7 +230,7 @@ export class StateManagementComponent implements OnInit {
nodeUpdate.transition()
.duration(duration)
.attr("transform", function(d: any) {
return "translate(" + d.y + "," + d.x + ")";
return "translate(" + d.x + "," + d.y + ")";
});
// Update the node attributes and style
......@@ -161,7 +239,18 @@ export class StateManagementComponent implements OnInit {
.style("fill", function(d:any) {
return d.data.id === currIndex ? "lightsteelblue" : "#fff";
})
.attr('cursor', 'pointer');
.attr('cursor', 'pointer')
.on("mouseover", function(d) {
d3.select(this).style("fill", function(d:any) {
return "orange";
});
setHover(d.data.id);
})
.on('mouseout', function(d) {
d3.select(this).style("fill", function(d:any) {
return d.data.id === currIndex ? "lightsteelblue" : "#fff";
});
});
// Remove any exiting nodes
......@@ -183,7 +272,7 @@ export class StateManagementComponent implements OnInit {
// ****************** links section ***************************
// Update the links...
const link = svg.selectAll('path.link')
const link = this.svg.selectAll('path.link')
.data(links, function(d: any) {
return d.id;
});
......@@ -224,15 +313,26 @@ export class StateManagementComponent implements OnInit {
// Creates a curved (diagonal) path from parent to the child nodes
function diagonal(s, d) {
const path = `M ${s.y} ${s.x}
C ${(s.y + d.y) / 2} ${s.x},
${(s.y + d.y) / 2} ${d.x},
${d.y} ${d.x}`;
const path = `M ${s.x} ${s.y}
C ${(s.x + d.x) / 2} ${s.y},
${(s.x + d.x) / 2} ${d.y},
${d.x} ${d.y}`;
return path;
}
// for (const state of Object.values(this.state.states)) {
// const trace ={x:[3,9,8,10,4,6,5],y:[5,7,6,7,8,9,8],type:"scatter"};
// const trace1 ={x:[3,4,1,6,8,9,5],y:[4,2,5,2,1,7,3],type:"scatter"};
// const dataa = [trace, trace1];
// const layout = {title : "Simple JavaScript Graph"};
// const gd = await PlotlyJS.newPlot('graph', dataa, layout);
// console.log(gd);
// const plot = d3.select('.cartesianlayer').node();
// console.log(plot);
// this.svg.node().appendChild(plot);
// // const image = await PlotlyJS.toImage(gd,{format: 'svg', height:300,width:300});
// }
}
// Toggle children on click
......
......@@ -136,7 +136,7 @@ export class StateService {
return await this.api.getWindowByIndices(indices);
}
public saveState() {
public async saveState() {
this.maxStateIndex++;
if (this.currStateIndex > 0) {
if (!this.states[this.currStateIndex].children) {
......@@ -147,8 +147,10 @@ export class StateService {
this.states[this.maxStateIndex] = {
id: this.maxStateIndex,
state: this.state,
image: undefined,
children: undefined
};
console.log(this.states[this.maxStateIndex]);
this.currStateIndex = this.maxStateIndex;
}
......
......@@ -20,14 +20,56 @@
</component>
<component name="ChangeListManager">
<list default="true" id="556080ba-825c-4b55-a92a-867a4df4fb32" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.css" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/query-window/query-window.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/query-window/query-window.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/api.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/api.service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/main/main.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/main/main.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/progress-view/progress-view.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/progress-view/progress-view.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/state-management/state-management.component.css" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/state-management/state-management.component.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/state-management/state-management.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/state-management/state-management.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/state-management/state-management.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/state-management/state-management.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/state.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/state.service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data/processed-data.npy" beforeDir="false" afterPath="$PROJECT_DIR$/data/processed-data.npy" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/preprocessing.py" beforeDir="false" afterPath="$PROJECT_DIR$/preprocessing.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pseudo.py" beforeDir="false" afterPath="$PROJECT_DIR$/pseudo.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/.ipynb_checkpoints/Compare Recall and Precision on EEG data, M=50.000, T=128, d=20-checkpoint.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/.ipynb_checkpoints/Compare Recall and Precision on EEG data, M=50.000, T=128, d=20-checkpoint.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/.ipynb_checkpoints/Compare Recall and Precision on EEG data, M=50.000, T=128, d=35-checkpoint.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/.ipynb_checkpoints/Compare Recall and Precision on EEG data, M=50.000, T=128, d=35-checkpoint.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/.ipynb_checkpoints/Compare Recall and Precision on EEG data, M=50.000, T=128, d=70-checkpoint.ipynb" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/.ipynb_checkpoints/Compare Recall and Precision on EEG data, M=50.000, T=256, d=35-Copy1-checkpoint.ipynb" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/.ipynb_checkpoints/Compare Recall and Precision on EEG data, M=50.000, T=256, d=35-checkpoint.ipynb" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/.ipynb_checkpoints/Compare Recall and Precision on Gas Sensor data, T=200, d=16-checkpoint.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/.ipynb_checkpoints/Compare Recall and Precision on Gas Sensor data, T=200, d=16-checkpoint.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/.ipynb_checkpoints/Compare Recall and Precision on Gas Sensor data, T=50, d=16-checkpoint.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/.ipynb_checkpoints/Compare Recall and Precision on Gas Sensor data, T=50, d=16-checkpoint.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=100.000, T=128, d=35.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=100.000, T=128, d=35.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=25.000, T=128, d=35.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=25.000, T=128, d=35.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=50.000, T=128, d=20.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=50.000, T=128, d=20.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=50.000, T=128, d=35.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=50.000, T=128, d=35.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=50.000, T=128, d=70.ipynb" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=50.000, T=256, d=35-Copy1.ipynb" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=50.000, T=256, d=35.ipynb" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=75.000, T=128, d=35.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on EEG data, M=75.000, T=128, d=35.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on Gas Sensor data, T=100, d=16.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on Gas Sensor data, T=100, d=16.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on Gas Sensor data, T=150, d=16.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on Gas Sensor data, T=150, d=16.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on Gas Sensor data, T=200, d=16.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on Gas Sensor data, T=200, d=16.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on Gas Sensor data, T=50, d=16.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/Compare Recall and Precision on Gas Sensor data, T=50, d=16.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/data/12kb-similarity-search.h5" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/data/12kb-similarity-search.h5" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/data/cae_12kb.h5" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/data/cae_12kb.h5" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_100000_128_35.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_100000_128_35.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_25000_128_35.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_25000_128_35.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_50000_128_20.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_50000_128_20.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_50000_128_35.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_50000_128_35.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_50000_256_20.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_50000_256_20.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_75000_128_35.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/accuracy_eeg_75000_128_35.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/accuracy_gas_200000_100_16.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/accuracy_gas_200000_100_16.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/accuracy_gas_200000_50_16.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/accuracy_gas_200000_50_16.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/time_eeg_100000_128_35.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/time_eeg_100000_128_35.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/time_eeg_25000_128_35.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/time_eeg_25000_128_35.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/time_eeg_50000_128_20.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/time_eeg_50000_128_20.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/time_eeg_50000_128_35.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/time_eeg_50000_128_35.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/time_eeg_50000_256_20.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/time_eeg_50000_256_20.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/time_eeg_75000_128_35.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/time_eeg_75000_128_35.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/time_gas_200000_100_16.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/time_gas_200000_100_16.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/images/time_gas_200000_50_16.png" beforeDir="false" afterPath="$PROJECT_DIR$/../experiments/images/time_gas_200000_50_16.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/old2/.ipynb_checkpoints/Compare similarity search strategies UTS on PEAX data-checkpoint.ipynb" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../experiments/old2/Compare similarity search strategies UTS on PEAX data.ipynb" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......
This source diff could not be displayed because it is stored in LFS. You can view the blob instead.
......@@ -30,7 +30,7 @@ Output: [{
@app.route('/read-data', methods=['GET'])
def read_data():
t0 = time()
response = preprocessing.read_eeg_data(10)
response = preprocessing.read_weather_data()
response = orjson.dumps(response)
print('Data read: ' + str(time()-t0))
return response
......@@ -184,8 +184,8 @@ def query():
window_indices = raw_data['indices']
if start_index is not None:
preprocessing.create_eeg_windows(query_size, 10)
window_indices = int(start_index / 100)
preprocessing.create_weather_windows(query_size)
window_indices = int(start_index)
data = np.load(data_path)
response = pseudo.query(data, window_indices)
......
......@@ -30,35 +30,6 @@ def read_data():
]
return response
def read_mts_data():
filename = 'data/data.pkl'
if (not os.path.isfile(filename)):
print("start")
df = dd.read_csv("NW_Ground_Stations_2016.csv", usecols=['number_sta', 'date', 't', 'hu', 'td'])
print("read file")
df = df.loc[df['number_sta'].isin([14066001, 14137001, 14216001, 14372001, 22092001, 22113006, 22135001])].fillna(0)
print("split rows")
df = df.compute()
df.to_pickle(filename)
print("to_pandas")
df = pd.read_pickle(filename)
df.dropna(subset=['t'], inplace=True)
response = [
{
"index": df.loc[df['number_sta'] == 14066001].loc[:, 'date'].values.astype(str).tolist(),
"values": df.loc[df['number_sta'] == 14066001].loc[:, 't'].values.tolist()
},
{
"index": df.loc[df['number_sta'] == 14066001].loc[:, 'date'].values.astype(str).tolist(),
"values": df.loc[df['number_sta'] == 14066001].loc[:, 'hu'].values.tolist()
},
{
"index": df.loc[df['number_sta'] == 14066001].loc[:, 'date'].values.astype(str).tolist(),
"values": df.loc[df['number_sta'] == 14066001].loc[:, 'td'].values.tolist()
}
]
return response
def create_peax_windows_12kb(window_size):
data = bigwig.chunk(
'test.bigWig',
......@@ -124,18 +95,80 @@ def create_eeg_windows(window_size, nr_of_channels):
np.save('data/processed-data', np.load(data_path))
return '1'
def create_weather_windows(window_size):
def read_eeg_data(nr_of_channels):
response = []
datafile = 'data/21.csv'
data = pd.read_csv(datafile, header=None)
npdata = np.array(data, dtype="float32")
del data
for i in range(4, 4+ nr_of_channels):
response.append(
{
'index': list(range(0, len(npdata), 100)),
'values': npdata[::100,i].tolist()
}
)
print(npdata.shape)
return response
def read_weather_data():
filename = 'data/data.pkl'
if (not os.path.isfile(filename)):
print("start")
df = dd.read_csv("data/ NW_Ground_Stations_2016.csv", usecols=['number_sta', 'date', 't', 'hu', 'td', 'dd', 'ff'])
print("read file")
df = df.loc[df['number_sta'].isin([14066001, 14137001, 14216001, 14372001, 22092001, 22113006, 22135001])].fillna(0)
print("split rows")
df = df.compute()
df.to_pickle(filename)
print("to_pandas")
df = pd.read_pickle(filename)
channels = list()
channels.append(df.loc[df['number_sta'] == 14066001].loc[:, 't'].fillna(0).values.tolist())
channels.append(df.loc[df['number_sta'] == 14066001].loc[:, 'hu'].fillna(0).values.tolist())
channels.append(df.loc[df['number_sta'] == 14066001].loc[:, 'td'].fillna(0).values.tolist())
data = [([values[i:i+window_size] for values in channels]) for i in range(0, len(channels[0]) - window_size, 1)]
windows = []
for i in range(len(data)):
if i % 5000 == 0: