ssa
1package pmtm_test2
3import (4"fmt"5"log"6"os"7"strconv"8"testing"9
10"github.com/RB-PRO/ssa/pkg/oss"11"github.com/RB-PRO/ssa/pkg/pmtm"12"github.com/xuri/excelize/v2"13)
14
15func TestPmtm(t *testing.T) {16x, _ := oss.Make_singnal_xn("pmtm")17y := pmtm.Pmtm(x, 1024)18saveTXT2("test222.txt", y)19safeToXlsx(x, y)20}
21
22// Сохранить в xlsx для дебага
23func safeToXlsx(x, y []float64) {24
25file_graph := excelize.NewFile()26file_graph.NewSheet("main")27file_graph.NewSheet("golang")28file_graph.DeleteSheet("Sheet1")29lenFor := len(x)30for ind := 0; ind < lenFor; ind++ {31file_graph.SetCellValue("golang", "A"+strconv.Itoa(ind+1), x[ind])32}33lenFor = len(y)34for ind := 0; ind < lenFor; ind++ {35file_graph.SetCellValue("golang", "B"+strconv.Itoa(ind+1), y[ind])36}37if err := file_graph.SaveAs("save_pmtm" + ".xlsx"); err != nil {38fmt.Println(err)39}40}
41
42func saveTXT2(FileName string, data []float64) {43filePW, ErrOpenFile := os.Create(FileName)44if ErrOpenFile != nil {45panic(ErrOpenFile)46}47defer filePW.Close()48for i := range data {49if _, err := filePW.WriteString(fmt.Sprintf("%.8f\n", data[i])); err != nil {50log.Println(err)51}52}53}
54