本文整理汇总了Golang中github.com/js-arias/evs/cmdapp.Command.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.Name方法的具体用法?Golang Command.Name怎么用?Golang Command.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/js-arias/evs/cmdapp.Command
的用法示例。
在下文中一共展示了Command.Name方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: evTreeRun
func evTreeRun(c *cmdapp.Command, args []string) {
d, err := loadData()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
r := raster.Rasterize(d, numCols, numFill)
ts, err := loadTrees()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
f := os.Stdin
if len(inFile) > 0 {
f, err = os.Open(inFile)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
defer f.Close()
}
recs, err := events.Read(f, r, ts, szExtra)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
err = treesvg.SVG(ts, recs, stepX, stepY)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
}
示例2: txLsRun
func txLsRun(c *cmdapp.Command, args []string) {
d, err := loadData()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
for _, tx := range d.Ls {
fmt.Printf("%s\n", tx.Name)
}
}
示例3: trLsRun
func trLsRun(c *cmdapp.Command, args []string) {
ls, err := loadTrees()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
for _, t := range ls {
fmt.Printf("%s\n", t.ID)
}
}
示例4: rBayRun
func rBayRun(c *cmdapp.Command, args []string) {
if len(args) == 0 {
fmt.Fprintf(os.Stderr, "%s: expecting output file\n", c.Name())
os.Exit(1)
}
d, err := loadData()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
ras := raster.Rasterize(d, numCols, 0)
geo, err := os.Create(args[0] + ".geo.txt")
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
defer geo.Close()
fmt.Fprintf(geo, "# 0.0\n")
var pxls []int
for y := 0; y < ((numCols / 2) + 1); y++ {
lat := 90 - ((float64(y) * ras.Resol) + (ras.Resol / 2))
for x := 0; x < numCols; x++ {
px := (y * numCols) + x
if _, ok := ras.Pixel[px]; ok {
pxls = append(pxls, px)
lon := ((float64(x) * ras.Resol) + (ras.Resol / 2)) - 180
fmt.Fprintf(geo, "%.4f %.4f\n", lat, lon)
}
}
}
areas, err := os.Create(args[0] + ".areas.txt")
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
defer areas.Close()
fmt.Fprintf(areas, "%d %d\n", len(ras.Names), len(pxls))
for _, tx := range ras.Names {
fmt.Fprintf(areas, "%s\t", tx.Name)
for _, v := range pxls {
px := ras.Pixel[v]
if tx.Obs.IsOn(px) {
fmt.Fprintf(areas, "1")
} else {
fmt.Fprintf(areas, "0")
}
}
fmt.Fprintf(areas, "\n")
}
}
示例5: evFlipRun
func evFlipRun(c *cmdapp.Command, args []string) {
if noVic && noSymp && noPoint && noFound {
fmt.Fprintf(os.Stderr, "%s: at least one event must be allowed\n", c.Name())
os.Exit(1)
}
o := os.Stdout
if len(outFile) > 0 {
var err error
o, err = os.Create(outFile)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
defer o.Close()
}
d, err := loadData()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
r := raster.Rasterize(d, numCols, numFill)
ts, err := loadTrees()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
best := make(chan []*events.Recons)
if numReps <= 0 {
numReps = 100
}
if numProc <= 0 {
numProc = runtime.NumCPU() * 2
}
for _, t := range ts {
out := make(chan []*events.Recons)
or := events.OR(r, t, szExtra)
// modify or to take into account the prohibited events
if (noVic) && (noSymp) {
for i := range or.Rec {
if (or.Rec[i].Flag == events.Vic) || (or.Rec[i].Flag == events.SympU) {
if noFound {
or.Rec[i].Flag = events.PointR
} else {
or.Rec[i].Flag = events.FoundR
}
or.DownPass(i)
}
}
} else if noVic {
for i := range or.Rec {
if or.Rec[i].Flag == events.Vic {
or.Rec[i].Flag = events.SympU
or.DownPass(i)
}
}
} else if noSymp {
for i := range or.Rec {
if or.Rec[i].Flag == events.SympU {
or.Rec[i].Flag = events.Vic
or.DownPass(i)
}
}
}
go doFlip(or, out)
go getBestFlip(or, out, best)
}
head := true
for _ = range ts {
recs := <-best
if verbose {
fmt.Printf("Tree %s best: %.3f recs found: %d\n", recs[0].Tree.ID, recs[0].Cost(), len(recs))
}
for _, b := range recs {
err := b.Write(o, head)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
head = false
}
}
}
示例6: evMapRun
func evMapRun(c *cmdapp.Command, args []string) {
d, err := loadData()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
r := raster.Rasterize(d, numCols, numFill)
ts, err := loadTrees()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
f := os.Stdin
if len(inFile) > 0 {
f, err = os.Open(inFile)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
defer f.Close()
}
recs, err := events.Read(f, r, ts, szExtra)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
err = treesvg.SVG(ts, nil, 0, 0)
// determines the boudaries of the geography
minLat := float64(biogeo.MaxLat)
maxLat := float64(biogeo.MinLat)
minLon := float64(biogeo.MaxLon)
maxLon := float64(biogeo.MinLon)
for _, tx := range d.Ls {
for _, g := range tx.Recs {
if g.Lat < minLat {
minLat = g.Lat
}
if g.Lat > maxLat {
maxLat = g.Lat
}
if g.Lon < minLon {
minLon = g.Lon
}
if g.Lon > maxLon {
maxLon = g.Lon
}
}
}
maxLat += 10
if maxLat > biogeo.MaxLat {
maxLat = biogeo.MaxLat
}
minLat -= 10
if minLat < biogeo.MinLat {
minLat = biogeo.MinLat
}
maxLon += 10
if maxLon > biogeo.MaxLon {
maxLon = biogeo.MaxLon
}
minLon -= 10
if minLon < biogeo.MinLon {
minLon = biogeo.MinLon
}
// loads the map
var imgmap image.Image
if len(args) == 0 {
imgmap = image.NewRGBA(image.Rect(0, 0, 360, 180))
} else {
im, err := os.Open(args[0])
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
imgmap, _, err = image.Decode(im)
im.Close()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
}
sizeX := imgmap.Bounds().Max.X
sizeY := imgmap.Bounds().Max.Y
scaleX := float64(sizeX) / 360
scaleY := float64(sizeY) / 180
szX := (maxLon - minLon) * scaleX
szY := (maxLat - minLat) * scaleY
originX := int((180 + minLon) * scaleX)
originY := int((90 - maxLat) * scaleY)
imgPump := make(chan *image.RGBA64, 10)
go func() {
ln := 0
for _, rc := range recs {
for i := range rc.Rec {
if rc.Rec[i].Node.First == nil {
//.........这里部分代码省略.........
示例7: trInRun
func trInRun(c *cmdapp.Command, args []string) {
if len(args) == 0 {
fmt.Fprintf(os.Stderr, "%s: expecting tree ID\n", c.Name())
os.Exit(1)
}
var ts []*tree.Tree
if _, err := os.Stat(treeFileName); err == nil {
ts, err = loadTrees()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
}
f := os.Stdin
if len(inFile) != 0 {
var err error
f, err = os.Open(inFile)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
defer f.Close()
}
for _, t := range ts {
if t.ID == args[0] {
fmt.Fprintf(os.Stderr, "%s: tree ID already used\n", c.Name())
os.Exit(1)
}
}
// reads the tree
in := os.Stdin
if len(inFile) != 0 {
var err error
in, err = os.Open(inFile)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
defer in.Close()
}
t, err := tree.ReadParenthetic(in, args[0])
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
ts = append(ts, t)
// writes the trees into the database
out, err := os.Create(treeFileName)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
defer out.Close()
head := true
for _, v := range ts {
err = v.Write(out, head)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", c.Name(), err)
os.Exit(1)
}
head = false
}
}