Fixed conversion script to include time

This commit is contained in:
Alexander Nozik 2022-04-11 11:50:28 +03:00
parent 03bf4f2d96
commit 5d3e6948db
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
2 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,7 @@
package ru.inr.mass.scripts package ru.inr.mass.scripts
import kotlinx.datetime.DateTimeUnit
import kotlinx.datetime.plus
import ru.inr.mass.data.api.NumassBlock import ru.inr.mass.data.api.NumassBlock
import ru.inr.mass.data.api.channels import ru.inr.mass.data.api.channels
import ru.inr.mass.workspace.Numass import ru.inr.mass.workspace.Numass
@ -12,7 +14,7 @@ import kotlin.io.path.writeText
fun main() { fun main() {
val point = Numass.readPoint("D:\\Work\\numass-data\\set_3\\p101(30s)(HV1=14150)") val point = Numass.readPoint("D:\\Work\\Numass\\data\\test\\set_7\\p59(30s)(HV1=14000)")
val channels: Map<Int, NumassBlock> = point.channels val channels: Map<Int, NumassBlock> = point.channels
//Initialize and create target directory //Initialize and create target directory
@ -22,9 +24,13 @@ fun main() {
//dumping meta //dumping meta
targetDir.resolve("meta").writeText(point.meta.toString()) targetDir.resolve("meta").writeText(point.meta.toString())
val pointTime = point.startTime
channels.forEach { (key, block) -> channels.forEach { (key, block) ->
targetDir.resolve("channel-$key.csv").write { targetDir.resolve("channel-$key.csv").write {
block.listFrames().forEach { frame -> block.listFrames().forEach { frame ->
val frameTime = pointTime.plus(frame.timeOffset, DateTimeUnit.NANOSECOND)
writeUtf8String("$frameTime,")
val line = frame.signal.joinToString(",", postfix = "\n" ) val line = frame.signal.joinToString(",", postfix = "\n" )
writeUtf8String(line) writeUtf8String(line)
} }

View File

@ -7,7 +7,7 @@ import space.kscience.plotly.makeFile
import space.kscience.plotly.scatter import space.kscience.plotly.scatter
fun main() { fun main() {
val directory = Numass.readDirectory("D:\\Work\\numass-data\\set_3\\") val directory = Numass.readDirectory("D:\\Work\\Numass\\data\\test\\set_7\\")
val monitorPoints: List<NumassPoint> = directory.filter { it.voltage == 14000.0 }.sortedBy { it.startTime } val monitorPoints: List<NumassPoint> = directory.filter { it.voltage == 14000.0 }.sortedBy { it.startTime }