Save IR plot in same directory as IR file with matching filename
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"math"
|
||||
"math/cmplx"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"image/png"
|
||||
|
||||
@@ -642,8 +643,13 @@ func PlotIR(ir []float64, sampleRate int, irFileName string) error {
|
||||
p2.Draw(canvases[1][0])
|
||||
dc.DrawImage(vg.Rectangle{Min: vg.Point{X: 0, Y: 0}, Max: vg.Point{X: width, Y: height}}, imgPlots.Image())
|
||||
|
||||
// Save as PNG
|
||||
f, err = os.Create("ir_plot.png")
|
||||
// Save as PNG in the same directory as the IR file
|
||||
irDir := filepath.Dir(irFileName)
|
||||
irBase := filepath.Base(irFileName)
|
||||
irNameWithoutExt := strings.TrimSuffix(irBase, filepath.Ext(irBase))
|
||||
plotFileName := filepath.Join(irDir, irNameWithoutExt+".png")
|
||||
|
||||
f, err = os.Create(plotFileName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user