Ejemplo n.º 1
0
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)
	}
}
Ejemplo n.º 2
0
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)
	}
}
Ejemplo n.º 3
0
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)
	}
}
Ejemplo n.º 4
0
func Cross(args string) {
	if len(args) > 0 {
		io.Ff(&bb, "Cross(%s)\n", args)
	} else {
		io.Ff(&bb, "Cross()\n")
	}
}
Ejemplo n.º 5
0
// 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")
}
Ejemplo n.º 6
0
// 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")
}
Ejemplo n.º 7
0
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")
}
Ejemplo n.º 8
0
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)
}
Ejemplo n.º 9
0
// 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)
	}
}
Ejemplo n.º 10
0
// 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")
}
Ejemplo n.º 11
0
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)
	}
}
Ejemplo n.º 12
0
// 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")
}
Ejemplo n.º 13
0
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")
}
Ejemplo n.º 14
0
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)
	}
}
Ejemplo n.º 15
0
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)
}
Ejemplo n.º 16
0
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)
}
Ejemplo n.º 17
0
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)
}
Ejemplo n.º 18
0
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)
}
Ejemplo n.º 19
0
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)
}
Ejemplo n.º 20
0
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)
}
Ejemplo n.º 21
0
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)
}
Ejemplo n.º 22
0
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)
}
Ejemplo n.º 23
0
func PyFile(filename string) {
	b, err := io.ReadFile(filename)
	if err != nil {
		chk.Panic("PyFile failed:\n%v", err)
	}
	io.Ff(&bb, string(b))
}
Ejemplo n.º 24
0
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)
}
Ejemplo n.º 25
0
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)
}
Ejemplo n.º 26
0
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)
}
Ejemplo n.º 27
0
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)
}
Ejemplo n.º 28
0
// 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")
}
Ejemplo n.º 29
0
// 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))
}
Ejemplo n.º 30
0
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)
}