func Title(txt, args string) { if len(args) > 0 { io.Ff(&bb, "title('%s',%s)\n", txt, args) } else { io.Ff(&bb, "title('%s')\n", txt) } }
func PlotOne(x, y float64, args string) { if len(args) > 0 { io.Ff(&bb, "plot(%23.15e,%23.15e,%s)\n", x, y, args) } else { io.Ff(&bb, "plot(%23.15e,%23.15e)\n", x, y) } }
func Text(x, y float64, txt, args string) { if len(args) > 0 { io.Ff(&bb, "text(%g,%g,'%s',%s)\n", x, y, txt, args) } else { io.Ff(&bb, "text(%g,%g,'%s')\n", x, y, txt) } }
func Cross(args string) { if len(args) > 0 { io.Ff(&bb, "Cross(%s)\n", args) } else { io.Ff(&bb, "Cross()\n") } }
// GenArray generates the NumPy text in 'b' corresponding to an array of float point numbers func GenArray(b *bytes.Buffer, name string, u []float64) { io.Ff(b, "%s=array([", name) for i, _ := range u { io.Ff(b, "%g,", u[i]) } io.Ff(b, "],dtype=float)\n") }
// GenStrArray generates the NumPy text in 'b' corresponding to an array of strings func GenStrArray(b *bytes.Buffer, name string, u []string) { io.Ff(b, "%s=[", name) for i, _ := range u { io.Ff(b, "%q,", u[i]) } io.Ff(b, "]\n") }
func write_python_array(buf *bytes.Buffer, name string, x []float64) { io.Ff(buf, "%s=np.array([", name) for i := 0; i < len(x); i++ { io.Ff(buf, "%g,", x[i]) } io.Ff(buf, "])\n") }
func SupTitle(txt, args string) { n := bb.Len() if len(args) > 0 { io.Ff(&bb, "st%d = suptitle('%s',%s)\n", n, txt, args) } else { io.Ff(&bb, "st%d = suptitle('%s')\n", n, txt) } io.Ff(&bb, "ea.append(st%d)\n", n) }
// xResRow adds row to table with X results func (o *TexReport) xResRow(opt *Optimiser) { if !o.singleObj { return } io.Ff(o.bxres, "%s &\n", opt.RptName) io.Ff(o.bxres, " $x_{best} = $"+opt.RptFmtX+" \\\\ \n", opt.BestOfBestFlt) if len(opt.RptXref) == opt.Nflt { io.Ff(o.bxres, "& $x_{ref.} = $"+opt.RptFmtX+" \\\\ \n", opt.RptXref) } }
// GenList generates list func GenList(buf *bytes.Buffer, name string, a [][]float64) { io.Ff(buf, "%s=[", name) for i, _ := range a { io.Ff(buf, "[") for j, _ := range a[i] { io.Ff(buf, "%g,", a[i][j]) } io.Ff(buf, "],") } io.Ff(buf, "]\n") }
func Plot(x, y []float64, args string) { n := bb.Len() sx := io.Sf("x%d", n) sy := io.Sf("y%d", n) Gen2Arrays(&bb, sx, sy, x, y) if len(args) > 0 { io.Ff(&bb, "plot(%s,%s,%s)\n", sx, sy, args) } else { io.Ff(&bb, "plot(%s,%s)\n", sx, sy) } }
// GenMat generates matrix func GenMat(buf *bytes.Buffer, name string, a [][]float64) { io.Ff(buf, "%s=array([", name) for i, _ := range a { io.Ff(buf, "[") for j, _ := range a[i] { io.Ff(buf, "%g,", a[i][j]) } io.Ff(buf, "],") } io.Ff(buf, "],dtype=float)\n") }
func write_python_matrix(buf *bytes.Buffer, name string, xy [][]float64) { io.Ff(buf, "%s=np.array([", name) for i := 0; i < len(xy); i++ { io.Ff(buf, "[") for j := 0; j < len(xy[i]); j++ { io.Ff(buf, "%g,", xy[i][j]) } io.Ff(buf, "],\n") } io.Ff(buf, "])\n") }
func Hist(x [][]float64, labels []string, args string) { n := bb.Len() sx := io.Sf("x%d", n) sy := io.Sf("y%d", n) GenList(&bb, sx, x) GenStrArray(&bb, sy, labels) if len(args) > 0 { io.Ff(&bb, "hist(%s,label=%s,%s)\n", sx, sy, args) } else { io.Ff(&bb, "hist(%s,label=%s)\n", sx, sy) } }
func vtu_write(geo, dat *bytes.Buffer) { if geo == nil || dat == nil { return } nv := len(verts) nc := len(cells) var hdr, foo bytes.Buffer io.Ff(&hdr, "<?xml version=\"1.0\"?>\n<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n<UnstructuredGrid>\n") io.Ff(&hdr, "<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", nv, nc) io.Ff(&foo, "</Piece>\n</UnstructuredGrid>\n</VTKFile>\n") io.WriteFileVD(dirout, fnkey+".vtu", &hdr, geo, dat, &foo) }
func Wireframe(x, y, z [][]float64, args string) { n := bb.Len() sx := io.Sf("x%d", n) sy := io.Sf("y%d", n) sz := io.Sf("z%d", n) GenMat(&bb, sx, x) GenMat(&bb, sy, y) GenMat(&bb, sz, z) cmd := io.Sf("ax%d = Wireframe(%s,%s,%s", n, sx, sy, sz) if len(args) > 0 { cmd += io.Sf(",%s", args) } io.Ff(&bb, "%s)\n", cmd) io.Ff(&bb, "ea.append(ax%d)\n", n) }
func Plot3dPoints(x, y, z []float64, args string) { n := bb.Len() sx := io.Sf("x%d", n) sy := io.Sf("y%d", n) sz := io.Sf("z%d", n) GenArray(&bb, sx, x) GenArray(&bb, sy, y) GenArray(&bb, sz, z) cmd := io.Sf("ax%d = Plot3dPoints(%s,%s,%s", n, sx, sy, sz) if len(args) > 0 { cmd += io.Sf(",%s", args) } io.Ff(&bb, "%s)\n", cmd) io.Ff(&bb, "ea.append(ax%d)\n", n) }
func Camera(elev, azim float64, args string) { cmd := io.Sf("gca().view_init(elev=%g, azim=%g", elev, azim) if len(args) > 0 { cmd += io.Sf(",%s", args) } io.Ff(&bb, "%s)\n", cmd) }
func Circle(xc, yc, r float64, args string) { cmd := io.Sf("Circle(%g,%g,%g", xc, yc, r) if len(args) > 0 { cmd += io.Sf(",%s", args) } io.Ff(&bb, "%s)\n", cmd) }
func pvd_write(buf *bytes.Buffer, label string) { if buf == nil { return } io.Ff(buf, "</Collection>\n</VTKFile>") io.WriteFileV(io.Sf("%s/%s_%s.pvd", dirout, fnkey, label), buf) }
func vtu_write(geo, dat *bytes.Buffer, tidx int, label string) { if geo == nil || dat == nil { return } nv := len(verts) nc := len(elems) if label == "ips" { nv = len(out.Ipoints) nc = nv } var hdr, foo bytes.Buffer io.Ff(&hdr, "<?xml version=\"1.0\"?>\n<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n<UnstructuredGrid>\n") io.Ff(&hdr, "<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", nv, nc) io.Ff(&foo, "</Piece>\n</UnstructuredGrid>\n</VTKFile>\n") io.WriteFile(io.Sf("%s/%s_%06d_%s.vtu", dirout, fnkey, tidx, label), &hdr, geo, dat, &foo) }
func AnnotateXlabels(x float64, txt string, args string) { cmd := io.Sf("AnnotateXlabels(%g, %s", x, txt) if len(args) > 0 { cmd += io.Sf(",%s", args) } io.Ff(&bb, "%s)\n", cmd) }
func PyFile(filename string) { b, err := io.ReadFile(filename) if err != nil { chk.Panic("PyFile failed:\n%v", err) } io.Ff(&bb, string(b)) }
func AxVline(x float64, args string) { cmd := io.Sf("axvline(%g", x) if len(args) > 0 { cmd += io.Sf(",%s", args) } io.Ff(&bb, "%s)\n", cmd) }
func Annotate(x, y float64, txt string, args string) { cmd := io.Sf("annotate(%s, xy=(%g,%g)", txt, x, y) if len(args) > 0 { cmd += io.Sf(",%s", args) } io.Ff(&bb, "%s)\n", cmd) }
func AxHline(y float64, args string) { cmd := io.Sf("axhline(%g", y) if len(args) > 0 { cmd += io.Sf(",%s", args) } io.Ff(&bb, "%s)\n", cmd) }
func Arrow(xi, yi, xf, yf float64, args string) { cmd := io.Sf("Arrow(%g,%g, %g,%g", xi, yi, xf, yf) if len(args) > 0 { cmd += io.Sf(",%s", args) } io.Ff(&bb, "%s)\n", cmd) }
// inputFooter adds foote to input data table func (o *TexReport) inputFooter() { io.Ff(o.binp, ` \bottomrule \end{tabular} \label{tab:%s} \end{table*} `, o.RefLabel+"Inp") }
// tableFooter add table footer func (o *TexReport) tableFooter(idxtab int) { io.Ff(o.buf, ` \bottomrule \end{tabular} \label{tab:%s} \end{table*} `, io.Sf("%s%d", o.RefLabel, idxtab)) }
func Gll(xl, yl string, args string) { n := bb.Len() cmd := io.Sf("lg%d = Gll(r'%s',r'%s'", n, xl, yl) if len(args) > 0 { cmd += io.Sf(",%s", args) } io.Ff(&bb, "%s)\nea.append(lg%d)\n", cmd, n) }