func TestSecondPass(t *testing.T) {

	var ncTest lib.Nc
	var m config.Map
	var cfg toml.Configtoml
	var optDebug *bool
	filetoml := "../configfile/configtoml.toml"
	cfg = toml.InitToml(filetoml)

	m = config.InitMap()

	ncTest.Extras_s = make(map[string]string)
	ncTest.Extras_f = make(map[string]float64)
	ncTest.Variables_1D = make(map[string]interface{})
	ncTest.Variables_1D["TIME"] = []float64{}
	ncTest.Variables_1D["LATITUDE"] = []float64{}
	ncTest.Variables_1D["LONGITUDE"] = []float64{}
	ncTest.Variables_1D["PROFILE"] = []float64{}

	TestFile := []string{"../data/csp00201.lad"}

	secondPassLADCP(&ncTest, &m, cfg, TestFile, optDebug)

	fmt.Println("Time :", ncTest.Variables_1D["TIME"])
	fmt.Println("Latitude :", ncTest.Variables_1D["LATITUDE"])
	fmt.Println("Longitude :", ncTest.Variables_1D["LONGITUDE"])

}
func TestSecondPass(t *testing.T) {

	var ncTest lib.Nc
	var m config.Map
	var cfg toml.Configtoml
	var optDebug *bool
	filetoml := "../configfile/configtoml.toml"
	cfg = toml.InitToml(filetoml)

	m = config.InitMap()

	ncTest.Dimensions = make(map[string]int)
	ncTest.Attributes = make(map[string]string)
	ncTest.Extras_f = make(map[string]float64)
	ncTest.Extras_s = make(map[string]string)
	ncTest.Variables_1D = make(map[string]interface{})

	// initialize map entry from nil interface to empty slice of float64
	ncTest.Variables_1D["PROFILE"] = []float64{}
	ncTest.Variables_1D["TIME"] = []float64{}
	ncTest.Variables_1D["LATITUDE"] = []float64{}
	ncTest.Variables_1D["LONGITUDE"] = []float64{}
	ncTest.Variables_1D["BATH"] = []float64{}
	ncTest.Variables_1D["TYPECAST"] = []float64{}

	TestFile := []string{"../data/csp00101.btl"}

	secondPassBTL(&ncTest, &m, cfg, TestFile, optDebug)

	fmt.Println("Time :", ncTest.Variables_1D["TIME"])
	fmt.Println("Latitude :", ncTest.Variables_1D["LATITUDE"])
	fmt.Println("Longitude :", ncTest.Variables_1D["LONGITUDE"])

}
Example #3
0
// main body
func main() {

	//init variable cfg with config file in TOML
	cfg = toml.InitToml(filetoml)
	//init variable m with empty map
	m = config.InitMap()

	var files []string
	// to change the flags on the default logger
	log.SetFlags(log.LstdFlags | log.Lshortfile)

	files, optCfgfile := GetOptions(filetoml)

	//analyse the file to know contructor, instrument and instrument type
	filestruct = analyze.AnalyzeFile(cfg, files)

	switch {

	//case constructor == seabird
	case filestruct.Constructeur.Number == 0:
		seabird.ReadSeabird(&nc, &m, filestruct, cfg, files, optCfgfile, optAll, optDebug, prefixAll)
	//case constructor == IFM-GEOMAR
	case filestruct.Constructeur.Number == 1:
		ifm.Read(&nc, &m, filestruct, cfg, files, optCfgfile, optAll, optDebug, prefixAll)
	//case constructor == THECSAS
	case filestruct.Constructeur.Number == 2:
		thecsas.Read(&nc, &m, filestruct, cfg, files, optCfgfile, optAll, optDebug, prefixAll)
	//case constructor == MK21
	case filestruct.Constructeur.Number == 3:
		mk21.Read(&nc, &m, filestruct, cfg, files, optCfgfile, optAll, optDebug, prefixAll)
	}

}
func TestSecondPass(t *testing.T) {

	var ncTest lib.Nc
	var m config.Map
	var cfg toml.Configtoml
	var optDebug *bool
	filetoml := "../configfile/configtoml.toml"
	cfg = toml.InitToml(filetoml)

	m = config.InitMap()

	ncTest.Extras_s = make(map[string]string)
	ncTest.Extras_f = make(map[string]float64)
	ncTest.Variables_1D = make(map[string]interface{})
	ncTest.Variables_1D["TIME"] = []float64{}
	ncTest.Variables_1D["LATITUDE"] = []float64{}
	ncTest.Variables_1D["LONGITUDE"] = []float64{}
	ncTest.Variables_1D["PROFILE"] = []float64{}

	profile := GetProfileNumber(&ncTest, 0)

	TestFile := []string{"../data/20150718-114047-AT_COLCOR.COLCOR"}

	secondPassTHERMO(&ncTest, &m, cfg, TestFile, optDebug)

	fmt.Println("Time start :", ncTest.Extras_s[fmt.Sprintf("Starttime:%d", int(profile))])
	fmt.Println("Latitude start :", ncTest.Extras_s[fmt.Sprintf("Startlatpos:%d", int(profile))])
	fmt.Println("Longitude start :", ncTest.Extras_s[fmt.Sprintf("Startlongpos:%d", int(profile))])

}
//function for testing GetProfileNumber
func TestGetProfile(t *testing.T) {
	// variable for test

	fileconfigTest := "../configfile/configtoml.toml"
	var cfg toml.Configtoml
	var ncTest lib.Nc

	cfg = toml.InitToml(fileconfigTest)

	ncTest.Extras_s = make(map[string]string)

	TestFile := "../data/csp00201.cnv"
	Profile := GetProfileNumber(&ncTest, cfg, TestFile)
	fmt.Println("Profile CTD Number : ", Profile)

}
func TestDecodeHeader(t *testing.T) {

	// variable for test

	var cfg toml.Configtoml
	var fileconfig string
	var ncTest lib.Nc
	var optDebug *bool
	fileconfigTest := "../configfile/configtoml.toml"

	cfg = toml.InitToml(fileconfigTest)

	fmt.Println("fileconfig ", fileconfig)

	ncTest.Dimensions = make(map[string]int)
	ncTest.Attributes = make(map[string]string)
	ncTest.Extras_f = make(map[string]float64)
	ncTest.Extras_s = make(map[string]string)
	ncTest.Variables_1D = make(map[string]interface{})

	// initialize map entry from nil interface to empty slice of float64
	ncTest.Variables_1D["TIME"] = []float64{}
	ncTest.Variables_1D["LATITUDE"] = []float64{}
	ncTest.Variables_1D["LONGITUDE"] = []float64{}

	var profileTest float64 = 00001

	//var StringTest string = "Date        = 2015/07/24"
	//var StringTest string = "Start_Time  = 06:11:23"
	//var StringTest string = "Latitude    = -10.9877"
	var StringTest string = "Longitude     :  24 12.78809W"

	temp := regexp.MustCompile(cfg.Mk21.Longitude)

	fmt.Println(cfg.Mk21.Longitude)
	fmt.Println(StringTest)

	if temp.MatchString(StringTest) {
		fmt.Println("same")
	} else {
		fmt.Println("not same")
	}
	DecodeHeader(&ncTest, cfg, StringTest, profileTest, optDebug)

}
//function for testing Decodeheader
func TestDecodeHeader(t *testing.T) {
	// variable for test

	var cfg toml.Configtoml
	var ncTest lib.Nc
	var optDebug *bool
	fileconfigTest := "../configfile/configtoml.toml"

	cfg = toml.InitToml(fileconfigTest)

	ncTest.Dimensions = make(map[string]int)
	ncTest.Attributes = make(map[string]string)
	ncTest.Extras_f = make(map[string]float64)
	ncTest.Extras_s = make(map[string]string)
	ncTest.Variables_1D = make(map[string]interface{})

	// initialize map entry from nil interface to empty slice of float64
	ncTest.Variables_1D["PROFILE"] = []float64{}
	ncTest.Variables_1D["TIME"] = []float64{}
	ncTest.Variables_1D["LATITUDE"] = []float64{}
	ncTest.Variables_1D["LONGITUDE"] = []float64{}
	ncTest.Variables_1D["BATH"] = []float64{}
	ncTest.Variables_1D["TYPECAST"] = []float64{}

	var profileTest float64 = 00101

	var StringTest string = "* System UpLoad Time = Jul 20 2015 06:15:13"
	//var StringTest string = "* NMEA Latitude = 19 58.55 S"
	//var StringTest string = "* NMEA Longitude = 168 00.45 E"
	//var StringTest string = "** Cruise : CASSIOPEE"
	//var StringTest string = "** Station : 00101"
	//var StringTest string = "** Bottom Depth: 4937"
	//var StringTest string = "** Operator:  JG-GE-ESL"
	//var StringTest string = "** Type: PHY"
	fmt.Println(cfg.Seabird.SystemTime)

	temp := regexp.MustCompile(cfg.Seabird.SystemTime)

	if temp.MatchString(StringTest) {
		fmt.Println("same")
	} else {
		fmt.Println("not same")
	}
	DecodeHeader(&ncTest, cfg, StringTest, profileTest, optDebug)
}
func TestFirstPass(t *testing.T) {

	var ncTest lib.Nc
	var m config.Map
	var cfg toml.Configtoml
	filetoml := "../configfile/configtoml.toml"
	cfg = toml.InitToml(filetoml)

	m = config.InitMap()

	ncTest.Extras_s = make(map[string]string)
	ncTest.Extras_f = make(map[string]float64)

	TestFile := []string{"../data/csp00201.lad"}

	time, depth := firstPassLADCP(&ncTest, &m, cfg, TestFile)

	fmt.Println("Time : ", time)
	fmt.Println("Depth : ", depth)

}
func TestFirstPass(t *testing.T) {

	var ncTest lib.Nc
	var m config.Map
	var cfg toml.Configtoml
	filetoml := "../configfile/configtoml.toml"
	cfg = toml.InitToml(filetoml)

	m = config.InitMap()

	ncTest.Extras_s = make(map[string]string)
	ncTest.Extras_f = make(map[string]float64)

	TestFile := []string{"../data/20150718-114047-AT_COLCOR.COLCOR"}

	time, depth := firstPassTHERMO(&ncTest, &m, cfg, TestFile)

	fmt.Println("Time : ", time)
	fmt.Println("Depth : ", depth)

}
//function for testing ReadGlobal
func TestAnalyzeType(t *testing.T) {

	var cfg toml.Configtoml
	filetoml := "../configfile/configtoml.toml"
	cfg = toml.InitToml(filetoml)

	TestFile := []string{"../data/csp00101.cnv"}

	Type := AnalyzeType(cfg, TestFile)

	fmt.Println(cfg.Instrument.Type)
	fmt.Println(cfg.Instrument.Decodetype)
	fmt.Println("Type = " + Type)

	TestFile2 := []string{"../data/csp00101.btl"}

	Type2 := AnalyzeType(cfg, TestFile2)

	fmt.Println("Type = " + Type2)

	TestFile3 := []string{"../data/csp00201.lad"}

	Type3 := AnalyzeType(cfg, TestFile3)

	fmt.Println("Type = " + Type3)

	TestFile4 := []string{"../data/20150718-114047-AT_COLCOR.COLCOR"}

	Type4 := AnalyzeType(cfg, TestFile4)

	fmt.Println("Type = " + Type4)

	TestFile5 := []string{"../data/T7_00001.EDF"}

	Type5 := AnalyzeType(cfg, TestFile5)

	fmt.Println("Type = " + Type5)

}
//function for testing ReadGlobal
func TestAnalyzeConstructor(t *testing.T) {

	var cfg toml.Configtoml
	filetoml := "../configfile/configtoml.toml"
	cfg = toml.InitToml(filetoml)
	//init variable m with empty map

	TestFile := []string{"../data/csp00101.cnv"}

	Construct := AnalyzeConstructor(cfg, TestFile)

	fmt.Println("Numero Constructeur = ", Construct)

	TestFile2 := []string{"../data/csp00101.btl"}

	Construct2 := AnalyzeConstructor(cfg, TestFile2)

	fmt.Println("Numero Constructeur = ", Construct2)

	TestFile3 := []string{"../data/csp00201.lad"}

	Construct3 := AnalyzeConstructor(cfg, TestFile3)

	fmt.Println("Numero Constructeur = ", Construct3)

	TestFile4 := []string{"../data/20150718-114047-AT_COLCOR.COLCOR"}

	Construct4 := AnalyzeConstructor(cfg, TestFile4)

	fmt.Println("Numero Constructeur = ", Construct4)

	TestFile5 := []string{"../data/T7_00001.EDF"}

	Construct5 := AnalyzeConstructor(cfg, TestFile5)

	fmt.Println("Numero Constructeur = ", Construct5)

}