1- import { For , Match , Switch , createMemo , createUniqueId } from "solid-js" ;
1+ import { For , Match , Show , Switch , createMemo , createUniqueId } from "solid-js" ;
22import { getVerticalProfiles } from "~/lib/profiles" ;
3- import { analyses , experiments , setAnalyses } from "~/lib/store" ;
4- import type { Experiment } from "~/lib/store" ;
3+ import { type Analysis , deleteAnalysis , experiments } from "~/lib/store" ;
54import LinePlot from "./LinePlot" ;
65import { MdiCog , MdiContentCopy , MdiDelete , MdiDownload } from "./icons" ;
76import { Button } from "./ui/button" ;
@@ -24,54 +23,30 @@ const colors = [
2423
2524const linestyles = [ "none" , "5,5" , "10,10" , "15,5,5,5" , "20,10,5,5,5,10" ] ;
2625
27- export interface Analysis {
28- name : string ;
29- description : string ;
30- id : string ;
31- experiments : Experiment [ ] | undefined ;
32- type : string ;
33- }
34-
35- export function addAnalysis ( type = "default" ) {
36- const name = {
37- default : "Final height" ,
38- timeseries : "Timeseries" ,
39- profiles : "Vertical profiles" ,
40- } [ type ] ;
41-
42- setAnalyses ( analyses . length , {
43- name : name ,
44- id : createUniqueId ( ) ,
45- experiments : experiments ,
46- type : type ,
47- } ) ;
48- }
49-
50- function deleteAnalysis ( analysis : Analysis ) {
51- setAnalyses ( analyses . filter ( ( ana ) => ana . id !== analysis . id ) ) ;
52- }
53-
5426/** Very rudimentary plot showing time series of each experiment globally available
5527 * It only works if the time axes are equal
5628 */
5729export function TimeSeriesPlot ( ) {
5830 const chartData = createMemo ( ( ) => {
5931 return experiments
60- . filter ( ( e ) => e . reference . output )
32+ . filter ( ( e ) => e . running === false ) // Skip running experiments
6133 . flatMap ( ( e , i ) => {
62- const permutationRuns = e . permutations . map ( ( perm , j ) => {
63- return {
64- label : `${ e . name } /${ perm . name } ` ,
65- y : perm . output === undefined ? [ ] : perm . output . h ,
66- x : perm . output === undefined ? [ ] : perm . output . t ,
67- color : colors [ ( j + 1 ) % 10 ] ,
68- linestyle : linestyles [ i % 5 ] ,
69- } ;
70- } ) ;
34+ const experimentOutput = e . reference . output ;
35+ const permutationRuns = e . permutations
36+ . filter ( ( perm ) => perm . output !== undefined )
37+ . map ( ( perm , j ) => {
38+ return {
39+ label : `${ e . name } /${ perm . name } ` ,
40+ y : perm . output ?. h ?? [ ] ,
41+ x : perm . output ?. t ?? [ ] ,
42+ color : colors [ ( j + 1 ) % 10 ] ,
43+ linestyle : linestyles [ i % 5 ] ,
44+ } ;
45+ } ) ;
7146 return [
7247 {
73- y : e . reference . output === undefined ? [ ] : e . reference . output . h ,
74- x : e . reference . output === undefined ? [ ] : e . reference . output . t ,
48+ y : experimentOutput ?. h ?? [ ] ,
49+ x : experimentOutput ?. t ?? [ ] ,
7550 label : e . name ,
7651 color : colors [ 0 ] ,
7752 linestyle : linestyles [ i ] ,
@@ -94,33 +69,40 @@ export function VerticalProfilePlot() {
9469 const variable = "theta" ;
9570 const time = - 1 ;
9671 const profileData = createMemo ( ( ) => {
97- return experiments . flatMap ( ( e , i ) => {
98- const permutations = e . permutations . map ( ( p , j ) => {
99- // TODO get additional config info from reference
100- // permutations probably usually don't have gammaq/gammatetha set?
101- return {
102- color : colors [ ( j + 1 ) % 10 ] ,
103- linestyle : linestyles [ i % 5 ] ,
104- label : `${ e . name } /${ p . name } ` ,
105- ...getVerticalProfiles ( p . output , p . config , variable , time ) ,
106- } ;
107- } ) ;
72+ return experiments
73+ . filter ( ( e ) => e . running === false ) // Skip running experiments
74+ . flatMap ( ( e , i ) => {
75+ const permutations = e . permutations . map ( ( p , j ) => {
76+ // TODO get additional config info from reference
77+ // permutations probably usually don't have gammaq/gammatetha set?
78+ return {
79+ color : colors [ ( j + 1 ) % 10 ] ,
80+ linestyle : linestyles [ i % 5 ] ,
81+ label : `${ e . name } /${ p . name } ` ,
82+ ...getVerticalProfiles ( p . output , p . config , variable , time ) ,
83+ } ;
84+ } ) ;
10885
109- return [
110- {
111- label : e . name ,
112- color : colors [ 0 ] ,
113- linestyle : linestyles [ i ] ,
114- ...getVerticalProfiles (
115- e . reference . output ,
116- e . reference . config ,
117- variable ,
118- time ,
119- ) ,
120- } ,
121- ...permutations ,
122- ] ;
123- } ) ;
86+ return [
87+ {
88+ label : e . name ,
89+ color : colors [ 0 ] ,
90+ linestyle : linestyles [ i ] ,
91+ ...getVerticalProfiles (
92+ e . reference . output ?? {
93+ t : [ ] ,
94+ h : [ ] ,
95+ theta : [ ] ,
96+ dtheta : [ ] ,
97+ } ,
98+ e . reference . config ,
99+ variable ,
100+ time ,
101+ ) ,
102+ } ,
103+ ...permutations ,
104+ ] ;
105+ } ) ;
124106 } ) ;
125107 return (
126108 < LinePlot
@@ -137,26 +119,31 @@ function FinalHeights() {
137119 < ul >
138120 < For each = { experiments } >
139121 { ( experiment ) => {
140- const h = ( ) =>
141- experiment . reference . output ?. h [
142- experiment . reference . output . h . length - 1
143- ] || 0 ;
122+ const h = ( ) => {
123+ const experimentOutput = experiment . reference . output ;
124+ return experimentOutput ?. h [ experimentOutput ?. h . length - 1 ] || 0 ;
125+ } ;
144126 return (
145- < >
127+ < Show when = { ! experiment . running } >
146128 < li class = "mb-2" title = { experiment . name } >
147129 { experiment . name } : { h ( ) . toFixed ( ) } m
148130 </ li >
149131 < For each = { experiment . permutations } >
150132 { ( perm ) => {
151- const h = ( ) => perm . output ?. h [ perm . output . h . length - 1 ] || 0 ;
133+ const h = ( ) => {
134+ const permOutput = perm . output ;
135+ return permOutput ?. h ?. length
136+ ? permOutput . h [ permOutput . h . length - 1 ]
137+ : 0 ;
138+ } ;
152139 return (
153140 < li title = { `${ experiment . name } /${ perm . name } ` } >
154141 { experiment . name } /{ perm . name } : { h ( ) . toFixed ( ) } m
155142 </ li >
156143 ) ;
157144 } }
158145 </ For >
159- </ >
146+ </ Show >
160147 ) ;
161148 } }
162149 </ For >
@@ -196,7 +183,7 @@ export function AnalysisCard(analysis: Analysis) {
196183 </ CardHeader >
197184 < CardContent class = "min-h-[450px]" >
198185 < Switch fallback = { < p > Unknown analysis type</ p > } >
199- < Match when = { analysis . type === "default " } >
186+ < Match when = { analysis . type === "finalheight " } >
200187 < FinalHeights />
201188 </ Match >
202189 < Match when = { analysis . type === "timeseries" } >
0 commit comments