From 9870ae408bb7f1a494b156d33b193173fd7d9e14 Mon Sep 17 00:00:00 2001 From: Peter Nemere Date: Mon, 11 Nov 2024 22:44:01 +1000 Subject: [PATCH] Fix generated HK file had no header/wrong file name read in lambda for EM import --- api/dataimport/internal/converters/pixlem/import.go | 2 +- api/dataimport/sdfToRSI/sdfToRSI.go | 13 +++++++++---- api/ws/handlers/scan.go | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/api/dataimport/internal/converters/pixlem/import.go b/api/dataimport/internal/converters/pixlem/import.go index b33dd1db..9a5066fe 100644 --- a/api/dataimport/internal/converters/pixlem/import.go +++ b/api/dataimport/internal/converters/pixlem/import.go @@ -137,7 +137,7 @@ func (p PIXLEM) Import(importPath string, pseudoIntensityRangesPath string, data beamPath := filepath.Join(importPath, beamName) // HK file should be here too... - hkPath := filepath.Join(importPath, "housekeeping-"+rttStr+".csv") + hkPath := filepath.Join(importPath, "HK-"+rttStr+".csv") data, err := importEMData(rttStr, beamPath, hkPath, imageList, bulkMaxList, msaList, &fs, log) if err != nil { log.Errorf("Import failed for %v: %v", beamName, err) diff --git a/api/dataimport/sdfToRSI/sdfToRSI.go b/api/dataimport/sdfToRSI/sdfToRSI.go index 843990c3..440b9a98 100644 --- a/api/dataimport/sdfToRSI/sdfToRSI.go +++ b/api/dataimport/sdfToRSI/sdfToRSI.go @@ -63,15 +63,20 @@ func sdfToRSI(sdfPath string, rtt int64, startLine int, endLine int, outPath str return fmt.Errorf("Failed to create output RSI CSV %v: %v", outPath, err) } + _, err = fout.WriteString(fmt.Sprintf("Spatial information from PIXL SDF or dat files %v for RTT: %v\n", sdfPath, rtt) + + "SCLK, RTT, PMC, PDP category, PDP name, PDP information (content varies)\n" + + "comment,,,, Housekeeping columns, Mtr1, Mtr2, Mtr3, Mtr4, Mtr5, Mtr6, SDD1_V, SDD2_V, Arm_R, SDD1_T, SDD2_T, SDD1_TEC_T, SDD2_TEC_T, Yellow_T, AFE_T, LVCM_T, HVMM_T, Fil_V, Fil_I, HV, Em_I\n") + + if err != nil { + return fmt.Errorf("Failed to write output CSV headers for %v: %v", outPath, err) + } + fout_hk, err := os.Create(outPath_Housekeeping) if err != nil { return fmt.Errorf("Failed to create output housekeeping CSV %v: %v", outPath, err) } - _, err = fout.WriteString(fmt.Sprintf("Spatial information from PIXL SDF or dat files %v for RTT: %v\n", sdfPath, rtt) + - "SCLK, RTT, PMC, PDP category, PDP name, PDP information (content varies)\n" + - "comment,,,, Housekeeping columns, Mtr1, Mtr2, Mtr3, Mtr4, Mtr5, Mtr6, SDD1_V, SDD2_V, Arm_R, SDD1_T, SDD2_T, SDD1_TEC_T, SDD2_TEC_T, Yellow_T, AFE_T, LVCM_T, HVMM_T, Fil_V, Fil_I, HV, Em_I\n") - + _, err = fout_hk.WriteString("SCLK,PMC,hk_fcnt,f_pixl_sdd_1_conv,f_pixl_sdd_2_conv,f_pixl_arm_resist_conv,f_head_sdd_1_conv,f_head_sdd_2_conv,f_hvps_fvmon_conv,f_hvps_fimon_conv,f_hvps_hvmon_conv,f_hvps_himon_conv,i_motor_1_conv,i_motor_2_conv,i_motor_3_conv,i_motor_4_conv,i_motor_5_conv,i_motor_6_conv\n") if err != nil { return fmt.Errorf("Failed to write output CSV headers for %v: %v", outPath, err) } diff --git a/api/ws/handlers/scan.go b/api/ws/handlers/scan.go index bb44c4b9..e819767c 100644 --- a/api/ws/handlers/scan.go +++ b/api/ws/handlers/scan.go @@ -586,11 +586,11 @@ func processEM(importId string, zipReader *zip.Reader, zippedData []byte, destBu // Upoad the output files (beam locations, log and surface) files := []string{filepath.Join(localTemp, hkFile), rxlPath, logPath, surfPath} name := []string{"housekeeping", "beam location", "log", "surface"} - for _, file := range files { + for i, file := range files { data, err := os.ReadFile(file) if err != nil { // Don't fail on errors for these - we may have run beam location tool on some incomplete scan, so failure isn't terrible! - logger.Errorf("Failed to read generated %v file: %v. Error: %v", name, file, err) + logger.Errorf("Failed to read generated %v file: %v. Error: %v", name[i], file, err) continue }