コード例 #1
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
	}
}
コード例 #2
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
	}
}
コード例 #3
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
	}
}
コード例 #4
0
ファイル: mplotlib.go プロジェクト: PaddySchmidt/gosl
func Cross(args string) {
	if len(args) > 0 {
		io.Ff(&bb, "Cross(%s)\n", args)
	} else {
		io.Ff(&bb, "Cross()\n")
	}
}
コード例 #5
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
// 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")
}
コード例 #6
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
// 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")
}
コード例 #7
0
ファイル: t_pareto_test.go プロジェクト: yunpeng1/gosl
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")
}
コード例 #8
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
}
コード例 #9
0
ファイル: report.go プロジェクト: cpmech/goga
// 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)
	}
}
コード例 #10
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
// 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")
}
コード例 #11
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
	}
}
コード例 #12
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
// 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")
}
コード例 #13
0
ファイル: t_pareto_test.go プロジェクト: yunpeng1/gosl
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")
}
コード例 #14
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
	}
}
コード例 #15
0
ファイル: Msh2vtu.go プロジェクト: PaddySchmidt/gofem
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)
}
コード例 #16
0
ファイル: mplotlib.go プロジェクト: yunpeng1/gosl
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)
}
コード例 #17
0
ファイル: mplotlib.go プロジェクト: yunpeng1/gosl
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)
}
コード例 #18
0
ファイル: mplotlib.go プロジェクト: yunpeng1/gosl
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)
}
コード例 #19
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
}
コード例 #20
0
ファイル: GenVtu.go プロジェクト: PaddySchmidt/gofem
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)
}
コード例 #21
0
ファイル: GenVtu.go プロジェクト: PaddySchmidt/gofem
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)
}
コード例 #22
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
}
コード例 #23
0
ファイル: mplotlib.go プロジェクト: yunpeng1/gosl
func PyFile(filename string) {
	b, err := io.ReadFile(filename)
	if err != nil {
		chk.Panic("PyFile failed:\n%v", err)
	}
	io.Ff(&bb, string(b))
}
コード例 #24
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
}
コード例 #25
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
}
コード例 #26
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
}
コード例 #27
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
}
コード例 #28
0
ファイル: report.go プロジェクト: cpmech/goga
// 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")
}
コード例 #29
0
ファイル: report.go プロジェクト: cpmech/goga
// 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))
}
コード例 #30
0
ファイル: mplotlib.go プロジェクト: PatrickSchm/gosl
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)
}