Column tables to kotlin
This commit is contained in:
parent
4fd269e8ff
commit
9e3dcd08d1
@ -7,9 +7,7 @@ import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.names.Name
|
||||
import hep.dataforge.storage.Storage
|
||||
import hep.dataforge.storage.StorageElement
|
||||
import hep.dataforge.storage.StorageManager
|
||||
import inr.numass.data.api.NumassSet
|
||||
import inr.numass.data.storage.NumassDirectory.Companion.NUMASS_DIRECTORY_TYPE
|
||||
import kotlinx.coroutines.experimental.runBlocking
|
||||
import kotlin.coroutines.experimental.buildSequence
|
||||
|
||||
@ -37,9 +35,8 @@ class NumassDataFactory : DataFactory<NumassSet>(NumassSet::class.java) {
|
||||
}
|
||||
|
||||
override fun fill(builder: DataNodeEditor<NumassSet>, context: Context, meta: Meta) {
|
||||
val newMeta = meta.builder.setValue("type", NUMASS_DIRECTORY_TYPE)
|
||||
runBlocking {
|
||||
val storage = context.load(StorageManager::class.java, Meta.empty()).create(newMeta) as Storage
|
||||
val storage = NumassDirectory.read(context,meta.getString("path")) as Storage
|
||||
storage.sequence().forEach { pair ->
|
||||
val value = pair.second
|
||||
if (value is NumassSet) {
|
||||
|
@ -39,6 +39,8 @@ object TransformDataAction : OneToOneAction<Table, Table>("numass.transform", Ta
|
||||
|
||||
override fun execute(context: Context, name: String, input: Table, meta: Laminate): Table {
|
||||
|
||||
var table = ColumnTable.copy(input)
|
||||
|
||||
val corrections = ArrayList<Correction>()
|
||||
|
||||
meta.optMeta("corrections").ifPresent { cors ->
|
||||
@ -59,19 +61,17 @@ object TransformDataAction : OneToOneAction<Table, Table>("numass.transform", Ta
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
var table = ColumnTable.copy(input)
|
||||
|
||||
for (correction in corrections) {
|
||||
//adding correction columns
|
||||
if (!correction.isAnonymous) {
|
||||
table = table.buildColumn(ColumnFormat.build(correction.name, NUMBER)) { correction.corr(it) }
|
||||
table = table.buildColumn(ColumnFormat.build(correction.name, NUMBER)) { correction.corr(this) }
|
||||
if (correction.hasError()) {
|
||||
table = table.buildColumn(ColumnFormat.build(correction.name + ".err", NUMBER)) { correction.corrErr(it) }
|
||||
table = table.buildColumn(ColumnFormat.build(correction.name + ".err", NUMBER)) { correction.corrErr(this) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// adding original count rate and error columns
|
||||
table = table.addColumn(ListColumn(ColumnFormat.build("$COUNT_RATE_KEY.orig", NUMBER), table.getColumn(COUNT_RATE_KEY).stream()))
|
||||
table = table.addColumn(ListColumn(ColumnFormat.build("$COUNT_RATE_ERROR_KEY.orig", NUMBER), table
|
||||
|
Loading…
Reference in New Issue
Block a user