11
"github.com/RB-PRO/ssa/internal/ssaApp"
12
"github.com/xuri/excelize/v2"
13
"gonum.org/v1/gonum/mat"
17
func TestInstantaneous_frequency_of_normalized_ACF_sET12(t *testing.T) {
22
pic8_test_txt, pic8_test_txt_Error := OpenVarStr("pic8_test.txt")
23
if pic8_test_txt_Error != nil {
24
t.Error(pic8_test_txt_Error)
27
float64Dense, float64Dense_Error := Str2FloatArr(pic8_test_txt)
28
if float64Dense_Error != nil {
29
t.Error(float64Dense_Error)
32
AcfNrm_sET12 := mat.NewDense(102, 200, float64Dense)
36
lag := int(math.Floor(float64(win) / 10.0))
38
dt := 1 / float64(cad)
39
lgl := make([]float64, lag)
40
for m := 0; m < len(lgl); m++ {
41
lgl[m] = float64(m + 1)
44
insFrc_AcfNrm, insFrc_AcfNrm_Error := ssaApp.Instantaneous_frequency_of_normalized_ACF_sET12(*AcfNrm_sET12, S, lag, dt, lgl)
45
if insFrc_AcfNrm_Error != nil {
46
t.Error(insFrc_AcfNrm_Error)
49
SaveVarStr("insFrc_AcfNrm.txt", fmt.Sprintf("%v", insFrc_AcfNrm))
54
func xlsx2floatArr(filename string, sSheet string) (output string, errorFile error) {
55
xlsxFile, errorFile := excelize.OpenFile(filename, excelize.Options{})
59
defer xlsxFile.Close()
62
rows, errorFile := xlsxFile.GetRows(sSheet)
66
for _, row := range rows {
67
for _, colCell := range row {
68
output += colCell + ","
71
return output[:len(output)-1], nil
75
func SaveVarStr(filename, data string) error {
76
f, err := os.Create(filename)
82
_, err = f.WriteString(data)
90
func OpenVarStr(filename string) (string, error) {
91
b, err := os.ReadFile(filename)
99
func Str2FloatArr(data string) ([]float64, error) {
100
strs := strings.Split(data, ",")
101
outputArray := make([]float64, len(strs))
102
for indexStrs, valueStr := range strs {
104
if n, err := strconv.ParseFloat(valueStr, 64); err == nil {
105
outputArray[indexStrs] = n
107
fmt.Println(">>>", valueStr)
112
return outputArray, nil