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

Better display of multiple channels

parent b224f361
<zingchart-angular #chart [id]="id" [config]="config" (dblclick)="doubleClick($event)" (mousewheel)="zoom($event)" (click)="clicked($event)" [height]="300"></zingchart-angular>
<zingchart-angular #chart [id]="id" [config]="config" (mousewheel)="zoom($event)" (click)="clicked($event)" [height]="300"></zingchart-angular>
<div id="test"></div>
......@@ -34,49 +34,12 @@ export class OverviewWindowComponent implements OnInit {
}
async initializePlot() {
// Initialize channels
for (const channel of this.service.rawValues) {
const data = [];
for (let i = 0; i < channel.length; i++) {
data.push([i, channel[i]]);
}
this.graphset.push({
type: 'line',
// zoom: {
// shared: true
// },
plotarea: {
"margin-top": "10px",
"margin-bottom": "0px",
height: '50px',
},
scaleX: {
zooming: true,
zoomTo: [0, this.service.windowSize],
markers: []
},
'scale-y': {
zooming: false,
'auto-fit': true
},
series: [{
type: 'line',
values: data,
text: 'Raw Values',
zIndex: 5,
marker: {
alpha: 0.0,
zIndex: 10
}
}]
});
}
// Initialize label chart
this.graphset.push({
id: 'preview',
type: "scatter",
// plot: {
// visible: false,
// },
x: 0,
y: 0,
scaleX: {
zooming: true,
minValue: 0,
......@@ -88,6 +51,7 @@ export class OverviewWindowComponent implements OnInit {
visible: false
}
},
height: '30px',
scaleY: {
maxValue: 1,
minValue: -1,
......@@ -97,8 +61,9 @@ export class OverviewWindowComponent implements OnInit {
}
},
preview: {
height: "30px",
position: "0% 20%",
x: 50,
y: 10,
height: '30px',
},
series: [
{
......@@ -130,11 +95,49 @@ export class OverviewWindowComponent implements OnInit {
}
]
});
// Initialize channels
this.service.rawValues.forEach((channel, index) => {
const data = [];
for (let i = 0; i < channel.length; i++) {
data.push([i, channel[i]]);
}
this.graphset.push({
id: index,
x: 0,
y: `${75 * index + 50}px`,
type: 'line',
height: '50px',
scaleX: {
zooming: true,
zoomTo: [0, this.service.windowSize],
markers: []
},
'scale-y': {
zooming: false,
'auto-fit': true
},
plotarea: {
height: '50px',
'margin-top': '0px',
'margin-bot': '0px'
},
series: [{
type: 'line',
values: data,
text: 'Raw Values',
zIndex: 5,
marker: {
alpha: 0.0,
zIndex: 10
}
}]
});
});
zingchart.bind('zingchart-ng-1', 'zoom', (e) => {
if (e.graphid !== 'zingchart-ng-1-graph-id2') {
if (e.graphid !== `zingchart-ng-1-graph-preview`) {
return;
}
for (let i = 0; i < this.graphset.length - 1; i ++) {
for (let i = 1; i < this.graphset.length; i ++) {
this.chart.zoomto({
graphid: i,
xmin: e.xmin,
......@@ -143,7 +146,7 @@ export class OverviewWindowComponent implements OnInit {
}
});
this.config = {
layout: '3x1',
layout: `${this.graphset.length}x1`,
graphset: this.graphset
};
console.log(this.config);
......@@ -160,9 +163,7 @@ export class OverviewWindowComponent implements OnInit {
y: clickData.y
}));
console.log(xyInformation);
console.log(xyInformation[2]);
const index = Math.floor(xyInformation[2].nodeidx / this.service.stepSize);
console.log(index);
const index = Math.floor(xyInformation[8].nodeidx / this.service.stepSize);
await this.service.getQueryWindow(this.service.rawValues[0].slice(index, index + this.service.windowSize));
const temp = {};
temp[index] = true;
......@@ -209,7 +210,6 @@ export class OverviewWindowComponent implements OnInit {
data: this.config
});
await this.service.getSimilarWindows();
console.log('done');
}
async updateCandidates(sliderIndex) {
......@@ -259,8 +259,4 @@ export class OverviewWindowComponent implements OnInit {
});
} }
}
doubleClick(e) {
this.chart.viewall();
}
}
......@@ -2,9 +2,10 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="556080ba-825c-4b55-a92a-867a4df4fb32" name="Default Changelist" comment="">
<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/cache.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/cache.service.ts" 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$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data.pkl" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
......@@ -18,8 +19,8 @@
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-3340">
<caret line="62" column="36" selection-start-line="62" selection-start-column="36" selection-end-line="62" selection-end-column="36" />
<state relative-caret-position="431">
<caret line="68" column="5" lean-forward="true" selection-start-line="68" selection-start-column="5" selection-end-line="68" selection-end-column="5" />
<folding>
<element signature="e#0#41#0" expanded="true" />
</folding>
......@@ -59,7 +60,7 @@
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="7">
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-11" />
<option name="y" value="-11" />
<option name="width" value="1890" />
......@@ -144,18 +145,18 @@
<workItem from="1599487808817" duration="1192000" />
<workItem from="1599578907139" duration="8436000" />
<workItem from="1599661275060" duration="1249000" />
<workItem from="1600001984238" duration="8284000" />
<workItem from="1600001984238" duration="10447000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="102340000" />
<option name="totallyTimeSpent" value="104503000" />
</component>
<component name="ToolWindowManager">
<frame x="-7" y="-7" width="1295" height="695" extended-state="7" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.28698465" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.28698465" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
......@@ -211,8 +212,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-3340">
<caret line="62" column="36" selection-start-line="62" selection-start-column="36" selection-end-line="62" selection-end-column="36" />
<state relative-caret-position="431">
<caret line="68" column="5" lean-forward="true" selection-start-line="68" selection-start-column="5" selection-end-line="68" selection-end-column="5" />
<folding>
<element signature="e#0#41#0" expanded="true" />
</folding>
......
This source diff could not be displayed because it is stored in LFS. You can view the blob instead.
......@@ -44,7 +44,7 @@ def read_mts_data():
filename = 'data.pkl'
if (not os.path.isfile(filename)):
print("start")
df = dd.read_csv("NW_Ground_Stations_2016.csv", usecols=['number_sta', 'date', 't'])
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'] == 14066001]
print("split rows")
......@@ -55,12 +55,16 @@ def read_mts_data():
df.dropna(subset=['t'], inplace=True)
response = [
{
"index": df.loc[:, 'date'].iloc[0:int(len(df.index)/2)].values.astype(str).tolist(),
"values": df.loc[:, 't'].iloc[0:int(len(df.index)/2)].values.tolist()
"index": df.loc[:, 'date'].values.astype(str).tolist(),
"values": df.loc[:, 't'].values.tolist()
},
{
"index": df.loc[:, 'date'].values.astype(str).tolist(),
"values": df.loc[:, 'hu'].values.tolist()
},
{
"index": df.loc[:, 'date'].iloc[int(len(df.index)/2):len(df.index)].values.astype(str).tolist(),
"values": df.loc[:, 't'].iloc[int(len(df.index)/2):len(df.index)].values.tolist()
"index": df.loc[:, 'date'].values.astype(str).tolist(),
"values": df.loc[:, 'td'].values.tolist()
}
]
print("response ready")
......@@ -85,6 +89,24 @@ def create_windows():
print("Sending response: " + str(time()-t0))
return '1'
@app.route('/create-mts-windows', methods=['POST'])
def create_mts_windows():
t0 = time()
if (not os.path.isfile('processed-data.npy')):
filename = 'data.pkl'
df = pd.read_pickle(filename)
values = df.loc[:, 't'].values.astype(str).tolist()
print("Data read: " + str(time()-t0))
raw_data = request.json
window_size = int(raw_data['parameters']["windowsize"])
print("Processing: " + str(time()-t0))
data = [values[i:i+window_size] for i in range(len(values) - window_size)]
data = preprocessing.minmax_scale(data, (-1, 1), axis=1)
print("Preprocessed: " + str(time()-t0))
np.save('processed-data', data)
print("Sending response: " + str(time()-t0))
return '1'
@app.route('/create-tables', methods=['POST'])
def create_tables():
t0 = time()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment