Compare commits
No commits in common. "feature/fit-analysis" and "main" have entirely different histories.
feature/fi
...
main
@ -1,6 +1,3 @@
|
||||
import space.kscience.gradle.useApache2Licence
|
||||
import space.kscience.gradle.useSPCTeam
|
||||
|
||||
plugins {
|
||||
id("space.kscience.gradle.project")
|
||||
}
|
||||
@ -13,21 +10,17 @@ allprojects {
|
||||
}
|
||||
|
||||
group = "ru.inr.mass"
|
||||
version = "0.1.4-dev-2"
|
||||
version = "0.1.3"
|
||||
}
|
||||
|
||||
val dataforgeVersion by extra("0.6.2")
|
||||
val dataforgeVersion by extra("0.6.0-dev-15")
|
||||
val tablesVersion: String by extra("0.2.0-dev-3")
|
||||
val kmathVersion by extra("0.3.1")
|
||||
val visionForgeVersion: String by rootProject.extra("0.3.0-dev-6")
|
||||
val kmathVersion by extra("0.3.1-dev-6")
|
||||
val visionForgeVersion: String by rootProject.extra("0.3.0-dev-4")
|
||||
|
||||
|
||||
ksciencePublish {
|
||||
pom("https://spc.jetbrains.space/p/numass/repositories/numass/") {
|
||||
useApache2Licence()
|
||||
useSPCTeam()
|
||||
}
|
||||
space("https://maven.pkg.jetbrains.space/spc/p/numass/maven")
|
||||
ksciencePublish{
|
||||
space("https://maven.pkg.jetbrains.space/mipt-npm/p/numass/maven")
|
||||
}
|
||||
|
||||
apiValidation {
|
||||
|
@ -5,11 +5,11 @@
|
||||
|
||||
kotlin.code.style=official
|
||||
kotlin.mpp.stability.nowarn=true
|
||||
kotlin.js.compiler=ir
|
||||
|
||||
kotlin.jupyter.add.scanner=false
|
||||
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.parallel=true
|
||||
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G
|
||||
|
||||
toolsVersion=0.14.10-kotlin-1.9.0
|
||||
compose.version=1.5.1
|
||||
toolsVersion=0.13.3-kotlin-1.7.20
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -8,9 +8,7 @@ val dataforgeVersion: String by rootProject.extra
|
||||
val kmathVersion: String by rootProject.extra
|
||||
val tablesVersion: String by rootProject.extra
|
||||
|
||||
kscience {
|
||||
jvm()
|
||||
js()
|
||||
kotlin.sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api(projects.numass.numassDataModel)
|
||||
@ -22,7 +20,7 @@ kscience {
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
//kscience{
|
||||
// useAtomic()
|
||||
//}
|
||||
|
@ -6,11 +6,7 @@ plugins {
|
||||
|
||||
val dataforgeVersion: String by rootProject.extra
|
||||
|
||||
kscience{
|
||||
jvm()
|
||||
js()
|
||||
useSerialization()
|
||||
|
||||
kotlin.sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api("space.kscience:dataforge-context:$dataforgeVersion")
|
||||
@ -18,14 +14,15 @@ kscience{
|
||||
api("org.jetbrains.kotlinx:kotlinx-datetime:${space.kscience.gradle.KScienceVersions.dateTimeVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin.sourceSets{
|
||||
getByName("jvmMain"){
|
||||
jvmMain{
|
||||
dependencies{
|
||||
api("ch.qos.logback:logback-classic:1.2.3")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kscience{
|
||||
useSerialization()
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id("space.kscience.gradle.jvm")
|
||||
id("com.squareup.wire") version "4.9.1"
|
||||
id("com.squareup.wire") version "4.4.1"
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
|
@ -2,27 +2,10 @@
|
||||
// Source: ru.inr.mass.data.proto.Point in numass-proto.proto
|
||||
package ru.inr.mass.`data`.proto
|
||||
|
||||
import com.squareup.wire.FieldEncoding
|
||||
import com.squareup.wire.Message
|
||||
import com.squareup.wire.ProtoAdapter
|
||||
import com.squareup.wire.ProtoReader
|
||||
import com.squareup.wire.ProtoWriter
|
||||
import com.squareup.wire.ReverseProtoWriter
|
||||
import com.squareup.wire.*
|
||||
import com.squareup.wire.Syntax.PROTO_3
|
||||
import com.squareup.wire.WireField
|
||||
import com.squareup.wire.`internal`.JvmField
|
||||
import com.squareup.wire.`internal`.immutableCopyOf
|
||||
import com.squareup.wire.`internal`.redactElements
|
||||
import kotlin.Any
|
||||
import kotlin.AssertionError
|
||||
import kotlin.Boolean
|
||||
import kotlin.Deprecated
|
||||
import kotlin.DeprecationLevel
|
||||
import kotlin.Int
|
||||
import kotlin.Long
|
||||
import kotlin.Nothing
|
||||
import kotlin.String
|
||||
import kotlin.collections.List
|
||||
import com.squareup.wire.internal.immutableCopyOf
|
||||
import com.squareup.wire.internal.redactElements
|
||||
import okio.ByteString
|
||||
|
||||
public class Point(
|
||||
@ -36,7 +19,6 @@ public class Point(
|
||||
tag = 1,
|
||||
adapter = "ru.inr.mass.data.proto.Point${'$'}Channel#ADAPTER",
|
||||
label = WireField.Label.REPEATED,
|
||||
schemaIndex = 0,
|
||||
)
|
||||
public val channels: List<Channel> = immutableCopyOf("channels", channels)
|
||||
|
||||
@ -44,10 +26,10 @@ public class Point(
|
||||
message = "Shouldn't be used in Kotlin",
|
||||
level = DeprecationLevel.HIDDEN,
|
||||
)
|
||||
override fun newBuilder(): Nothing = throw
|
||||
public override fun newBuilder(): Nothing = throw
|
||||
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
public override fun equals(other: Any?): Boolean {
|
||||
if (other === this) return true
|
||||
if (other !is Point) return false
|
||||
if (unknownFields != other.unknownFields) return false
|
||||
@ -55,7 +37,7 @@ public class Point(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
public override fun hashCode(): Int {
|
||||
var result = super.hashCode
|
||||
if (result == 0) {
|
||||
result = unknownFields.hashCode()
|
||||
@ -65,7 +47,7 @@ public class Point(
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
public override fun toString(): String {
|
||||
val result = mutableListOf<String>()
|
||||
if (channels.isNotEmpty()) result += """channels=$channels"""
|
||||
return result.joinToString(prefix = "Point{", separator = ", ", postfix = "}")
|
||||
@ -84,23 +66,23 @@ public class Point(
|
||||
null,
|
||||
"numass-proto.proto"
|
||||
) {
|
||||
override fun encodedSize(`value`: Point): Int {
|
||||
public override fun encodedSize(`value`: Point): Int {
|
||||
var size = value.unknownFields.size
|
||||
size += Channel.ADAPTER.asRepeated().encodedSizeWithTag(1, value.channels)
|
||||
return size
|
||||
}
|
||||
|
||||
override fun encode(writer: ProtoWriter, `value`: Point) {
|
||||
public override fun encode(writer: ProtoWriter, `value`: Point): Unit {
|
||||
Channel.ADAPTER.asRepeated().encodeWithTag(writer, 1, value.channels)
|
||||
writer.writeBytes(value.unknownFields)
|
||||
}
|
||||
|
||||
override fun encode(writer: ReverseProtoWriter, `value`: Point) {
|
||||
public override fun encode(writer: ReverseProtoWriter, `value`: Point): Unit {
|
||||
writer.writeBytes(value.unknownFields)
|
||||
Channel.ADAPTER.asRepeated().encodeWithTag(writer, 1, value.channels)
|
||||
}
|
||||
|
||||
override fun decode(reader: ProtoReader): Point {
|
||||
public override fun decode(reader: ProtoReader): Point {
|
||||
val channels = mutableListOf<Channel>()
|
||||
val unknownFields = reader.forEachTag { tag ->
|
||||
when (tag) {
|
||||
@ -114,7 +96,7 @@ public class Point(
|
||||
)
|
||||
}
|
||||
|
||||
override fun redact(`value`: Point): Point = value.copy(
|
||||
public override fun redact(`value`: Point): Point = value.copy(
|
||||
channels = value.channels.redactElements(Channel.ADAPTER),
|
||||
unknownFields = ByteString.EMPTY
|
||||
)
|
||||
@ -134,7 +116,6 @@ public class Point(
|
||||
tag = 1,
|
||||
adapter = "com.squareup.wire.ProtoAdapter#UINT64",
|
||||
label = WireField.Label.OMIT_IDENTITY,
|
||||
schemaIndex = 0,
|
||||
)
|
||||
public val id: Long = 0L,
|
||||
blocks: List<Block> = emptyList(),
|
||||
@ -147,7 +128,6 @@ public class Point(
|
||||
tag = 2,
|
||||
adapter = "ru.inr.mass.data.proto.Point${'$'}Channel${'$'}Block#ADAPTER",
|
||||
label = WireField.Label.REPEATED,
|
||||
schemaIndex = 1,
|
||||
)
|
||||
public val blocks: List<Block> = immutableCopyOf("blocks", blocks)
|
||||
|
||||
@ -155,10 +135,10 @@ public class Point(
|
||||
message = "Shouldn't be used in Kotlin",
|
||||
level = DeprecationLevel.HIDDEN,
|
||||
)
|
||||
override fun newBuilder(): Nothing = throw
|
||||
public override fun newBuilder(): Nothing = throw
|
||||
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
public override fun equals(other: Any?): Boolean {
|
||||
if (other === this) return true
|
||||
if (other !is Channel) return false
|
||||
if (unknownFields != other.unknownFields) return false
|
||||
@ -167,7 +147,7 @@ public class Point(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
public override fun hashCode(): Int {
|
||||
var result = super.hashCode
|
||||
if (result == 0) {
|
||||
result = unknownFields.hashCode()
|
||||
@ -178,7 +158,7 @@ public class Point(
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
public override fun toString(): String {
|
||||
val result = mutableListOf<String>()
|
||||
result += """id=$id"""
|
||||
if (blocks.isNotEmpty()) result += """blocks=$blocks"""
|
||||
@ -201,26 +181,26 @@ public class Point(
|
||||
null,
|
||||
"numass-proto.proto"
|
||||
) {
|
||||
override fun encodedSize(`value`: Channel): Int {
|
||||
public override fun encodedSize(`value`: Channel): Int {
|
||||
var size = value.unknownFields.size
|
||||
if (value.id != 0L) size += ProtoAdapter.UINT64.encodedSizeWithTag(1, value.id)
|
||||
size += Block.ADAPTER.asRepeated().encodedSizeWithTag(2, value.blocks)
|
||||
return size
|
||||
}
|
||||
|
||||
override fun encode(writer: ProtoWriter, `value`: Channel) {
|
||||
public override fun encode(writer: ProtoWriter, `value`: Channel): Unit {
|
||||
if (value.id != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.id)
|
||||
Block.ADAPTER.asRepeated().encodeWithTag(writer, 2, value.blocks)
|
||||
writer.writeBytes(value.unknownFields)
|
||||
}
|
||||
|
||||
override fun encode(writer: ReverseProtoWriter, `value`: Channel) {
|
||||
public override fun encode(writer: ReverseProtoWriter, `value`: Channel): Unit {
|
||||
writer.writeBytes(value.unknownFields)
|
||||
Block.ADAPTER.asRepeated().encodeWithTag(writer, 2, value.blocks)
|
||||
if (value.id != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.id)
|
||||
}
|
||||
|
||||
override fun decode(reader: ProtoReader): Channel {
|
||||
public override fun decode(reader: ProtoReader): Channel {
|
||||
var id: Long = 0L
|
||||
val blocks = mutableListOf<Block>()
|
||||
val unknownFields = reader.forEachTag { tag ->
|
||||
@ -237,7 +217,7 @@ public class Point(
|
||||
)
|
||||
}
|
||||
|
||||
override fun redact(`value`: Channel): Channel = value.copy(
|
||||
public override fun redact(`value`: Channel): Channel = value.copy(
|
||||
blocks = value.blocks.redactElements(Block.ADAPTER),
|
||||
unknownFields = ByteString.EMPTY
|
||||
)
|
||||
@ -257,7 +237,6 @@ public class Point(
|
||||
tag = 1,
|
||||
adapter = "com.squareup.wire.ProtoAdapter#UINT64",
|
||||
label = WireField.Label.OMIT_IDENTITY,
|
||||
schemaIndex = 0,
|
||||
)
|
||||
public val time: Long = 0L,
|
||||
frames: List<Frame> = emptyList(),
|
||||
@ -268,7 +247,6 @@ public class Point(
|
||||
tag = 3,
|
||||
adapter = "ru.inr.mass.data.proto.Point${'$'}Channel${'$'}Block${'$'}Events#ADAPTER",
|
||||
label = WireField.Label.OMIT_IDENTITY,
|
||||
schemaIndex = 2,
|
||||
)
|
||||
public val events: Events? = null,
|
||||
/**
|
||||
@ -278,7 +256,6 @@ public class Point(
|
||||
tag = 4,
|
||||
adapter = "com.squareup.wire.ProtoAdapter#UINT64",
|
||||
label = WireField.Label.OMIT_IDENTITY,
|
||||
schemaIndex = 3,
|
||||
)
|
||||
public val length: Long = 0L,
|
||||
/**
|
||||
@ -289,7 +266,6 @@ public class Point(
|
||||
adapter = "com.squareup.wire.ProtoAdapter#UINT64",
|
||||
label = WireField.Label.OMIT_IDENTITY,
|
||||
jsonName = "binSize",
|
||||
schemaIndex = 4,
|
||||
)
|
||||
public val bin_size: Long = 0L,
|
||||
unknownFields: ByteString = ByteString.EMPTY,
|
||||
@ -301,7 +277,6 @@ public class Point(
|
||||
tag = 2,
|
||||
adapter = "ru.inr.mass.data.proto.Point${'$'}Channel${'$'}Block${'$'}Frame#ADAPTER",
|
||||
label = WireField.Label.REPEATED,
|
||||
schemaIndex = 1,
|
||||
)
|
||||
public val frames: List<Frame> = immutableCopyOf("frames", frames)
|
||||
|
||||
@ -309,10 +284,10 @@ public class Point(
|
||||
message = "Shouldn't be used in Kotlin",
|
||||
level = DeprecationLevel.HIDDEN,
|
||||
)
|
||||
override fun newBuilder(): Nothing = throw
|
||||
public override fun newBuilder(): Nothing = throw
|
||||
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
public override fun equals(other: Any?): Boolean {
|
||||
if (other === this) return true
|
||||
if (other !is Block) return false
|
||||
if (unknownFields != other.unknownFields) return false
|
||||
@ -324,7 +299,7 @@ public class Point(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
public override fun hashCode(): Int {
|
||||
var result = super.hashCode
|
||||
if (result == 0) {
|
||||
result = unknownFields.hashCode()
|
||||
@ -338,7 +313,7 @@ public class Point(
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
public override fun toString(): String {
|
||||
val result = mutableListOf<String>()
|
||||
result += """time=$time"""
|
||||
if (frames.isNotEmpty()) result += """frames=$frames"""
|
||||
@ -367,7 +342,7 @@ public class Point(
|
||||
null,
|
||||
"numass-proto.proto"
|
||||
) {
|
||||
override fun encodedSize(`value`: Block): Int {
|
||||
public override fun encodedSize(`value`: Block): Int {
|
||||
var size = value.unknownFields.size
|
||||
if (value.time != 0L) size += ProtoAdapter.UINT64.encodedSizeWithTag(1, value.time)
|
||||
size += Frame.ADAPTER.asRepeated().encodedSizeWithTag(2, value.frames)
|
||||
@ -378,7 +353,7 @@ public class Point(
|
||||
return size
|
||||
}
|
||||
|
||||
override fun encode(writer: ProtoWriter, `value`: Block) {
|
||||
public override fun encode(writer: ProtoWriter, `value`: Block): Unit {
|
||||
if (value.time != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.time)
|
||||
Frame.ADAPTER.asRepeated().encodeWithTag(writer, 2, value.frames)
|
||||
if (value.events != null) Events.ADAPTER.encodeWithTag(writer, 3, value.events)
|
||||
@ -387,7 +362,7 @@ public class Point(
|
||||
writer.writeBytes(value.unknownFields)
|
||||
}
|
||||
|
||||
override fun encode(writer: ReverseProtoWriter, `value`: Block) {
|
||||
public override fun encode(writer: ReverseProtoWriter, `value`: Block): Unit {
|
||||
writer.writeBytes(value.unknownFields)
|
||||
if (value.bin_size != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 5, value.bin_size)
|
||||
if (value.length != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 4, value.length)
|
||||
@ -396,7 +371,7 @@ public class Point(
|
||||
if (value.time != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.time)
|
||||
}
|
||||
|
||||
override fun decode(reader: ProtoReader): Block {
|
||||
public override fun decode(reader: ProtoReader): Block {
|
||||
var time: Long = 0L
|
||||
val frames = mutableListOf<Frame>()
|
||||
var events: Events? = null
|
||||
@ -422,7 +397,7 @@ public class Point(
|
||||
)
|
||||
}
|
||||
|
||||
override fun redact(`value`: Block): Block = value.copy(
|
||||
public override fun redact(`value`: Block): Block = value.copy(
|
||||
frames = value.frames.redactElements(Frame.ADAPTER),
|
||||
events = value.events?.let(Events.ADAPTER::redact),
|
||||
unknownFields = ByteString.EMPTY
|
||||
@ -443,7 +418,6 @@ public class Point(
|
||||
tag = 1,
|
||||
adapter = "com.squareup.wire.ProtoAdapter#UINT64",
|
||||
label = WireField.Label.OMIT_IDENTITY,
|
||||
schemaIndex = 0,
|
||||
)
|
||||
public val time: Long = 0L,
|
||||
/**
|
||||
@ -454,7 +428,6 @@ public class Point(
|
||||
adapter = "com.squareup.wire.ProtoAdapter#BYTES",
|
||||
label = WireField.Label.OMIT_IDENTITY,
|
||||
declaredName = "data",
|
||||
schemaIndex = 1,
|
||||
)
|
||||
public val data_: ByteString = ByteString.EMPTY,
|
||||
unknownFields: ByteString = ByteString.EMPTY,
|
||||
@ -463,10 +436,10 @@ public class Point(
|
||||
message = "Shouldn't be used in Kotlin",
|
||||
level = DeprecationLevel.HIDDEN,
|
||||
)
|
||||
override fun newBuilder(): Nothing = throw
|
||||
public override fun newBuilder(): Nothing = throw
|
||||
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
public override fun equals(other: Any?): Boolean {
|
||||
if (other === this) return true
|
||||
if (other !is Frame) return false
|
||||
if (unknownFields != other.unknownFields) return false
|
||||
@ -475,7 +448,7 @@ public class Point(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
public override fun hashCode(): Int {
|
||||
var result = super.hashCode
|
||||
if (result == 0) {
|
||||
result = unknownFields.hashCode()
|
||||
@ -486,7 +459,7 @@ public class Point(
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
public override fun toString(): String {
|
||||
val result = mutableListOf<String>()
|
||||
result += """time=$time"""
|
||||
result += """data_=$data_"""
|
||||
@ -509,7 +482,7 @@ public class Point(
|
||||
null,
|
||||
"numass-proto.proto"
|
||||
) {
|
||||
override fun encodedSize(`value`: Frame): Int {
|
||||
public override fun encodedSize(`value`: Frame): Int {
|
||||
var size = value.unknownFields.size
|
||||
if (value.time != 0L) size += ProtoAdapter.UINT64.encodedSizeWithTag(1, value.time)
|
||||
if (value.data_ != ByteString.EMPTY) size += ProtoAdapter.BYTES.encodedSizeWithTag(2,
|
||||
@ -517,21 +490,21 @@ public class Point(
|
||||
return size
|
||||
}
|
||||
|
||||
override fun encode(writer: ProtoWriter, `value`: Frame) {
|
||||
public override fun encode(writer: ProtoWriter, `value`: Frame): Unit {
|
||||
if (value.time != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.time)
|
||||
if (value.data_ != ByteString.EMPTY) ProtoAdapter.BYTES.encodeWithTag(writer, 2,
|
||||
value.data_)
|
||||
writer.writeBytes(value.unknownFields)
|
||||
}
|
||||
|
||||
override fun encode(writer: ReverseProtoWriter, `value`: Frame) {
|
||||
public override fun encode(writer: ReverseProtoWriter, `value`: Frame): Unit {
|
||||
writer.writeBytes(value.unknownFields)
|
||||
if (value.data_ != ByteString.EMPTY) ProtoAdapter.BYTES.encodeWithTag(writer, 2,
|
||||
value.data_)
|
||||
if (value.time != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.time)
|
||||
}
|
||||
|
||||
override fun decode(reader: ProtoReader): Frame {
|
||||
public override fun decode(reader: ProtoReader): Frame {
|
||||
var time: Long = 0L
|
||||
var data_: ByteString = ByteString.EMPTY
|
||||
val unknownFields = reader.forEachTag { tag ->
|
||||
@ -548,7 +521,7 @@ public class Point(
|
||||
)
|
||||
}
|
||||
|
||||
override fun redact(`value`: Frame): Frame = value.copy(
|
||||
public override fun redact(`value`: Frame): Frame = value.copy(
|
||||
unknownFields = ByteString.EMPTY
|
||||
)
|
||||
}
|
||||
@ -574,7 +547,6 @@ public class Point(
|
||||
tag = 1,
|
||||
adapter = "com.squareup.wire.ProtoAdapter#UINT64",
|
||||
label = WireField.Label.PACKED,
|
||||
schemaIndex = 0,
|
||||
)
|
||||
public val times: List<Long> = immutableCopyOf("times", times)
|
||||
|
||||
@ -585,7 +557,6 @@ public class Point(
|
||||
tag = 2,
|
||||
adapter = "com.squareup.wire.ProtoAdapter#UINT64",
|
||||
label = WireField.Label.PACKED,
|
||||
schemaIndex = 1,
|
||||
)
|
||||
public val amplitudes: List<Long> = immutableCopyOf("amplitudes", amplitudes)
|
||||
|
||||
@ -593,10 +564,10 @@ public class Point(
|
||||
message = "Shouldn't be used in Kotlin",
|
||||
level = DeprecationLevel.HIDDEN,
|
||||
)
|
||||
override fun newBuilder(): Nothing = throw
|
||||
public override fun newBuilder(): Nothing = throw
|
||||
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
public override fun equals(other: Any?): Boolean {
|
||||
if (other === this) return true
|
||||
if (other !is Events) return false
|
||||
if (unknownFields != other.unknownFields) return false
|
||||
@ -605,7 +576,7 @@ public class Point(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
public override fun hashCode(): Int {
|
||||
var result = super.hashCode
|
||||
if (result == 0) {
|
||||
result = unknownFields.hashCode()
|
||||
@ -616,7 +587,7 @@ public class Point(
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
public override fun toString(): String {
|
||||
val result = mutableListOf<String>()
|
||||
if (times.isNotEmpty()) result += """times=$times"""
|
||||
if (amplitudes.isNotEmpty()) result += """amplitudes=$amplitudes"""
|
||||
@ -639,61 +610,43 @@ public class Point(
|
||||
null,
|
||||
"numass-proto.proto"
|
||||
) {
|
||||
override fun encodedSize(`value`: Events): Int {
|
||||
public override fun encodedSize(`value`: Events): Int {
|
||||
var size = value.unknownFields.size
|
||||
size += ProtoAdapter.UINT64.asPacked().encodedSizeWithTag(1, value.times)
|
||||
size += ProtoAdapter.UINT64.asPacked().encodedSizeWithTag(2, value.amplitudes)
|
||||
return size
|
||||
}
|
||||
|
||||
override fun encode(writer: ProtoWriter, `value`: Events) {
|
||||
public override fun encode(writer: ProtoWriter, `value`: Events): Unit {
|
||||
ProtoAdapter.UINT64.asPacked().encodeWithTag(writer, 1, value.times)
|
||||
ProtoAdapter.UINT64.asPacked().encodeWithTag(writer, 2, value.amplitudes)
|
||||
writer.writeBytes(value.unknownFields)
|
||||
}
|
||||
|
||||
override fun encode(writer: ReverseProtoWriter, `value`: Events) {
|
||||
public override fun encode(writer: ReverseProtoWriter, `value`: Events): Unit {
|
||||
writer.writeBytes(value.unknownFields)
|
||||
ProtoAdapter.UINT64.asPacked().encodeWithTag(writer, 2, value.amplitudes)
|
||||
ProtoAdapter.UINT64.asPacked().encodeWithTag(writer, 1, value.times)
|
||||
}
|
||||
|
||||
override fun decode(reader: ProtoReader): Events {
|
||||
var times: MutableList<Long>? = null
|
||||
var amplitudes: MutableList<Long>? = null
|
||||
public override fun decode(reader: ProtoReader): Events {
|
||||
val times = mutableListOf<Long>()
|
||||
val amplitudes = mutableListOf<Long>()
|
||||
val unknownFields = reader.forEachTag { tag ->
|
||||
when (tag) {
|
||||
1 -> {
|
||||
if (times == null) {
|
||||
val minimumByteSize = 1
|
||||
val initialCapacity = (reader.nextFieldMinLengthInBytes() / minimumByteSize)
|
||||
.coerceAtMost(Int.MAX_VALUE.toLong())
|
||||
.toInt()
|
||||
times = ArrayList(initialCapacity)
|
||||
}
|
||||
times!!.add(ProtoAdapter.UINT64.decode(reader))
|
||||
}
|
||||
2 -> {
|
||||
if (amplitudes == null) {
|
||||
val minimumByteSize = 1
|
||||
val initialCapacity = (reader.nextFieldMinLengthInBytes() / minimumByteSize)
|
||||
.coerceAtMost(Int.MAX_VALUE.toLong())
|
||||
.toInt()
|
||||
amplitudes = ArrayList(initialCapacity)
|
||||
}
|
||||
amplitudes!!.add(ProtoAdapter.UINT64.decode(reader))
|
||||
}
|
||||
1 -> times.add(ProtoAdapter.UINT64.decode(reader))
|
||||
2 -> amplitudes.add(ProtoAdapter.UINT64.decode(reader))
|
||||
else -> reader.readUnknownField(tag)
|
||||
}
|
||||
}
|
||||
return Events(
|
||||
times = times ?: listOf(),
|
||||
amplitudes = amplitudes ?: listOf(),
|
||||
times = times,
|
||||
amplitudes = amplitudes,
|
||||
unknownFields = unknownFields
|
||||
)
|
||||
}
|
||||
|
||||
override fun redact(`value`: Events): Events = value.copy(
|
||||
public override fun redact(`value`: Events): Events = value.copy(
|
||||
unknownFields = ByteString.EMPTY
|
||||
)
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import java.nio.file.Path
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.io.path.isDirectory
|
||||
import kotlin.io.path.relativeTo
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public class NumassProtoPlugin : AbstractPlugin() {
|
||||
public val io: IOPlugin by require(IOPlugin)
|
||||
@ -34,6 +35,7 @@ public class NumassProtoPlugin : AbstractPlugin() {
|
||||
public companion object : PluginFactory<NumassProtoPlugin> {
|
||||
override fun build(context: Context, meta: Meta): NumassProtoPlugin = NumassProtoPlugin()
|
||||
override val tag: PluginTag = PluginTag("numass-proto", group = "ru.inr.mass")
|
||||
override val type: KClass<out NumassProtoPlugin> = NumassProtoPlugin::class
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,24 @@ public class TaggedNumassEnvelopeFormat(private val io: IOPlugin) : EnvelopeForm
|
||||
writeRawString(END_SEQUENCE)
|
||||
}
|
||||
|
||||
override fun writeObject(output: Output, obj: Envelope) {
|
||||
override fun writeEnvelope(
|
||||
output: Output,
|
||||
envelope: Envelope,
|
||||
metaFormatFactory: MetaFormatFactory,
|
||||
formatMeta: Meta,
|
||||
) {
|
||||
error("Don't write legacy formats")
|
||||
// val metaFormat = metaFormatFactory.invoke(formatMeta, io.context)
|
||||
// val metaBytes = metaFormat.toBinary(envelope.meta)
|
||||
// val actualSize: ULong = (envelope.data?.size ?: 0).toULong()
|
||||
// val tag = Tag(metaFormatFactory.key, metaBytes.size.toUInt() + 2u, actualSize)
|
||||
// output.writeBinary(tag.toBinary())
|
||||
// output.writeBinary(metaBytes)
|
||||
// output.writeRawString("\r\n")
|
||||
// envelope.data?.let {
|
||||
// output.writeBinary(it)
|
||||
// }
|
||||
// output.flush()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,30 +68,31 @@ public class TaggedNumassEnvelopeFormat(private val io: IOPlugin) : EnvelopeForm
|
||||
override fun readObject(input: Input): Envelope {
|
||||
val tag = input.readTag()
|
||||
|
||||
val metaFormat = io.resolveMetaFormat(tag.metaFormatKey) ?: JsonMetaFormat
|
||||
val metaFormat = io.resolveMetaFormat(tag.metaFormatKey)
|
||||
?: error("Meta format with key ${tag.metaFormatKey} not found")
|
||||
|
||||
val meta: Meta = metaFormat.readObjectFrom(input.readBinary(tag.metaSize.toInt()))
|
||||
|
||||
val data = input.readBinary(tag.dataSize.toInt())
|
||||
|
||||
return Envelope(meta, data)
|
||||
return SimpleEnvelope(meta, data)
|
||||
}
|
||||
|
||||
override fun readPartial(input: Input): PartialEnvelope {
|
||||
val tag = input.readTag()
|
||||
|
||||
val metaFormat = if (tag.metaFormatKey == 1.toShort()) {
|
||||
JsonMetaFormat
|
||||
} else {
|
||||
io.resolveMetaFormat(tag.metaFormatKey)
|
||||
?: error("Meta format with key ${tag.metaFormatKey} not found")
|
||||
}
|
||||
|
||||
val meta: Meta = metaFormat.readObjectFrom(input.readBinary(tag.metaSize.toInt()))
|
||||
|
||||
|
||||
return PartialEnvelope(meta, 30 + tag.metaSize.toInt(), tag.dataSize)
|
||||
}
|
||||
//
|
||||
// override fun readPartial(input: Input): PartialEnvelope {
|
||||
// val tag = input.readTag()
|
||||
//
|
||||
// val metaFormat = if (tag.metaFormatKey == 1.toShort()) {
|
||||
// JsonMetaFormat
|
||||
// } else {
|
||||
// io.resolveMetaFormat(tag.metaFormatKey)
|
||||
// ?: error("Meta format with key ${tag.metaFormatKey} not found")
|
||||
// }
|
||||
//
|
||||
// val meta: Meta = metaFormat.readObjectFrom(input.readBinary(tag.metaSize.toInt()))
|
||||
//
|
||||
//
|
||||
// return PartialEnvelope(meta, 30 + tag.metaSize.toInt(), tag.dataSize)
|
||||
// }
|
||||
|
||||
private data class Tag(
|
||||
val metaFormatKey: Short,
|
||||
@ -132,10 +149,22 @@ public class TaggedNumassEnvelopeFormat(private val io: IOPlugin) : EnvelopeForm
|
||||
|
||||
private val default by lazy { invoke() }
|
||||
|
||||
override fun writeObject(output: Output, obj: Envelope) {
|
||||
error("Don't write legacy formats")
|
||||
}
|
||||
override fun readPartial(input: Input): PartialEnvelope =
|
||||
default.run { readPartial(input) }
|
||||
|
||||
override fun writeEnvelope(
|
||||
output: Output,
|
||||
envelope: Envelope,
|
||||
metaFormatFactory: MetaFormatFactory,
|
||||
formatMeta: Meta,
|
||||
): Unit = default.run {
|
||||
writeEnvelope(
|
||||
output,
|
||||
envelope,
|
||||
metaFormatFactory,
|
||||
formatMeta
|
||||
)
|
||||
}
|
||||
|
||||
override fun readObject(input: Input): Envelope = default.readObject(input)
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
plugins {
|
||||
id("space.kscience.gradle.mpp")
|
||||
id("org.jetbrains.compose")
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
@ -8,41 +7,54 @@ val visionForgeVersion: String by rootProject.extra
|
||||
|
||||
val production: Boolean by rootProject.extra(true)
|
||||
|
||||
|
||||
kscience {
|
||||
fullStack("js/numass-web.js")
|
||||
|
||||
useSerialization {
|
||||
json()
|
||||
kotlin {
|
||||
js(IR) {
|
||||
browser {
|
||||
webpackTask {
|
||||
this.outputFileName = "js/numass-web.js"
|
||||
}
|
||||
}
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
useContextReceivers()
|
||||
useKtor()
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation(project(":numass-data-model"))
|
||||
implementation("space.kscience:visionforge-core:$visionForgeVersion")
|
||||
implementation("space.kscience:visionforge-plotly:$visionForgeVersion")
|
||||
}
|
||||
}
|
||||
jvmMain {
|
||||
dependencies {
|
||||
implementation(project(":numass-data-proto"))
|
||||
implementation("space.kscience:visionforge-server:$visionForgeVersion")
|
||||
}
|
||||
}
|
||||
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation(project(":numass-data-model"))
|
||||
implementation("space.kscience:visionforge-core:$visionForgeVersion")
|
||||
implementation("space.kscience:visionforge-plotly:$visionForgeVersion")
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
val distributionTask = if (production) {
|
||||
tasks.getByName("jsBrowserDistribution")
|
||||
} else {
|
||||
tasks.getByName("jsBrowserDevelopmentExecutableDistribution")
|
||||
}
|
||||
|
||||
tasks.getByName<ProcessResources>("jvmProcessResources") {
|
||||
dependsOn(distributionTask)
|
||||
from(distributionTask)
|
||||
include("**/*.js")
|
||||
if (production) {
|
||||
include("**/*.map")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin{
|
||||
sourceSets{
|
||||
getByName("jvmMain"){
|
||||
dependencies{
|
||||
implementation(compose.runtime)
|
||||
implementation(project(":numass-data-proto"))
|
||||
implementation("io.ktor:ktor-server-cio")
|
||||
implementation("io.ktor:ktor-server-html-builder")
|
||||
implementation("space.kscience:visionforge-plotly:$visionForgeVersion")
|
||||
}
|
||||
}
|
||||
getByName("jsMain"){
|
||||
dependencies{
|
||||
implementation(compose.html.core)
|
||||
}
|
||||
}
|
||||
kscience {
|
||||
useSerialization {
|
||||
json()
|
||||
}
|
||||
}
|
||||
withContextReceivers()
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import space.kscience.dataforge.context.PluginTag
|
||||
import space.kscience.dataforge.meta.Meta
|
||||
import space.kscience.visionforge.Vision
|
||||
import space.kscience.visionforge.VisionPlugin
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public class NumassCommonPlugin(meta: Meta = Meta.EMPTY) : VisionPlugin(meta) {
|
||||
override val tag: PluginTag get() = Companion.tag
|
||||
@ -17,6 +18,7 @@ public class NumassCommonPlugin(meta: Meta = Meta.EMPTY) : VisionPlugin(meta) {
|
||||
|
||||
public companion object : PluginFactory<NumassCommonPlugin> {
|
||||
override val tag: PluginTag = PluginTag("numass.common", "ru.inr.mass")
|
||||
override val type: KClass<NumassCommonPlugin> = NumassCommonPlugin::class
|
||||
|
||||
override fun build(context: Context, meta: Meta): NumassCommonPlugin = NumassCommonPlugin()
|
||||
|
||||
|
@ -18,6 +18,7 @@ import space.kscience.visionforge.ElementVisionRenderer
|
||||
import space.kscience.visionforge.Vision
|
||||
import space.kscience.visionforge.VisionClient
|
||||
import space.kscience.visionforge.plotly.PlotlyPlugin
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public class NumassJsPlugin : AbstractPlugin(), ElementVisionRenderer {
|
||||
public val client: VisionClient by require(VisionClient)
|
||||
@ -36,7 +37,7 @@ public class NumassJsPlugin : AbstractPlugin(), ElementVisionRenderer {
|
||||
else -> super.content(target)
|
||||
}
|
||||
|
||||
override fun render(element: Element, name: Name, vision: Vision, meta: Meta) {
|
||||
override fun render(element: Element, vision: Vision, meta: Meta) {
|
||||
when (vision) {
|
||||
is VisionOfNumassHv -> element.append {
|
||||
h1 { +"HV" }
|
||||
@ -63,7 +64,7 @@ public class NumassJsPlugin : AbstractPlugin(), ElementVisionRenderer {
|
||||
vision.spectra.forEach { (channel, spectrum) ->
|
||||
val pairs = spectrum.entries.sortedBy { it.key }
|
||||
scatter {
|
||||
this.name = channel
|
||||
name = channel
|
||||
mode = ScatterMode.lines
|
||||
line {
|
||||
shape = LineShape.hv
|
||||
@ -82,6 +83,8 @@ public class NumassJsPlugin : AbstractPlugin(), ElementVisionRenderer {
|
||||
|
||||
public companion object : PluginFactory<NumassJsPlugin> {
|
||||
override val tag: PluginTag = PluginTag("numass.js", "ru.inr.mass")
|
||||
override val type: KClass<NumassJsPlugin> = NumassJsPlugin::class
|
||||
|
||||
override fun build(context: Context, meta: Meta): NumassJsPlugin = NumassJsPlugin()
|
||||
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
package ru.inr.mass.data.server
|
||||
|
||||
import org.jetbrains.compose.web.dom.Div
|
||||
import org.jetbrains.compose.web.renderComposable
|
||||
import org.w3c.dom.Document
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.visionforge.Application
|
||||
|
||||
public class NumassViewerApplication : Application {
|
||||
private val context = Context("NumassViewer") {
|
||||
plugin(NumassJsPlugin)
|
||||
}
|
||||
|
||||
override fun start(document: Document, state: Map<String, Any>) {
|
||||
renderComposable(rootElementId = "application") {
|
||||
Div({ classes("container") }) {
|
||||
Div({ classes("row") })
|
||||
Div({ classes("col-md-3") }) {
|
||||
|
||||
}
|
||||
Div({ classes("col-md-9") }) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +1,15 @@
|
||||
package ru.inr.mass.data.server
|
||||
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.Application
|
||||
import io.ktor.http.URLBuilder
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.server.cio.CIO
|
||||
import io.ktor.server.engine.embeddedServer
|
||||
import io.ktor.server.html.respondHtml
|
||||
import io.ktor.server.http.content.resources
|
||||
import io.ktor.server.response.respondText
|
||||
import io.ktor.server.routing.get
|
||||
import io.ktor.server.routing.routing
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.html.*
|
||||
import ru.inr.mass.data.api.NumassPoint
|
||||
import ru.inr.mass.data.proto.NumassDirectorySet
|
||||
import ru.inr.mass.data.proto.NumassProtoPlugin
|
||||
@ -27,15 +22,12 @@ import space.kscience.dataforge.names.Name
|
||||
import space.kscience.dataforge.names.NameToken
|
||||
import space.kscience.dataforge.names.cutLast
|
||||
import space.kscience.dataforge.names.lastOrNull
|
||||
import space.kscience.visionforge.server.close
|
||||
import space.kscience.visionforge.server.openInBrowser
|
||||
import space.kscience.visionforge.server.visionServer
|
||||
|
||||
|
||||
public fun main() {
|
||||
val port = 7777
|
||||
val host = "localhost"
|
||||
embeddedServer(CIO, port, host, module = Application::numassModule).start()
|
||||
}
|
||||
|
||||
public fun Application.numassModule(repositoryName: String = "D:\\Work\\Numass\\data\\test") {
|
||||
public suspend fun main() {
|
||||
val context = Context("Numass") {
|
||||
plugin(NumassProtoPlugin)
|
||||
plugin(NumassCommonPlugin)
|
||||
@ -45,98 +37,96 @@ public fun Application.numassModule(repositoryName: String = "D:\\Work\\Numass\\
|
||||
val numassCommon = context.fetch(NumassCommonPlugin)
|
||||
|
||||
val visionManager = numassCommon.visionManager
|
||||
val repository: DataTree<NumassDirectorySet> = runBlocking { numassProto.readRepository(repositoryName) }
|
||||
|
||||
routing {
|
||||
resources()
|
||||
val repositroyName = "D:\\Work\\Numass\\data\\test"
|
||||
|
||||
get("/") {
|
||||
call.respondHtml {
|
||||
head {
|
||||
meta { charset = "utf-8" }
|
||||
meta {
|
||||
name = "viewport"
|
||||
content = "width=device-width, initial-scale=1"
|
||||
}
|
||||
title("Numass Data Viewer")
|
||||
link {
|
||||
href = "https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
|
||||
rel = "stylesheet"
|
||||
attributes["integrity"] =
|
||||
"sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65"
|
||||
attributes["crossorigin"] = "anonymous"
|
||||
}
|
||||
val port = 7777
|
||||
val host = "localhost"
|
||||
|
||||
val url = URLBuilder(host = host, port = port).build()
|
||||
|
||||
val repository: DataTree<NumassDirectorySet> = numassProto.readRepository(repositroyName)
|
||||
|
||||
val visionOfNumassRepository = VisionOfNumassRepository(Name.EMPTY, repository)
|
||||
|
||||
val server = context.embeddedServer(CIO, port, host) {
|
||||
routing {
|
||||
get("/repository") {
|
||||
call.respondText {
|
||||
visionManager.encodeToString(visionOfNumassRepository)
|
||||
}
|
||||
body {
|
||||
div {
|
||||
id = "application"
|
||||
}
|
||||
script {
|
||||
src = "js/numass-web.js"
|
||||
}
|
||||
script {
|
||||
src = "https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity = "sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
|
||||
attributes["crossorigin"] = "anonymous"
|
||||
}
|
||||
}
|
||||
|
||||
get("/sets/{name...}") {
|
||||
val setName: Name? = call.parameters.getAll("name")
|
||||
?.map { NameToken.parse(it) }?.let(::Name)
|
||||
|
||||
if (setName == null) {
|
||||
call.respondText(status = HttpStatusCode.BadRequest) { "Set name is empty" }
|
||||
return@get
|
||||
}
|
||||
|
||||
val set: NumassDirectorySet? = withContext(Dispatchers.IO) { repository[setName]?.await() }
|
||||
if (set == null) {
|
||||
call.respondText(status = HttpStatusCode.NotFound) { "A set with name $setName not found in the repository" }
|
||||
return@get
|
||||
}
|
||||
|
||||
call.respondText {
|
||||
visionManager.encodeToString(VisionOfNumassSet(setName, set))
|
||||
}
|
||||
}
|
||||
get("/points/{name...}") {
|
||||
val fullName: Name? = call.parameters.getAll("name")
|
||||
?.map { NameToken.parse(it) }?.let(::Name)
|
||||
|
||||
if (fullName == null) {
|
||||
call.respondText(status = HttpStatusCode.BadRequest) { "Point name is empty" }
|
||||
return@get
|
||||
}
|
||||
|
||||
val setName = fullName.cutLast()
|
||||
|
||||
val set: NumassDirectorySet? = withContext(Dispatchers.IO) { repository[setName]?.await() }
|
||||
if (set == null) {
|
||||
call.respondText(status = HttpStatusCode.NotFound) { "A set with name $setName not found in the repository" }
|
||||
return@get
|
||||
}
|
||||
|
||||
val pointIndex: Int? = fullName.lastOrNull()?.body?.toIntOrNull()
|
||||
|
||||
val point: NumassPoint? = set.points.find { it.index == pointIndex }
|
||||
|
||||
if (point == null) {
|
||||
call.respondText(status = HttpStatusCode.NotFound) { "A point with name $setName/$pointIndex not found in the repository" }
|
||||
return@get
|
||||
}
|
||||
call.respondText {
|
||||
visionManager.encodeToString(point.toVision())
|
||||
}
|
||||
}
|
||||
}
|
||||
visionServer(numassCommon.visionManager, url)
|
||||
}.start()
|
||||
|
||||
get("/repository") {
|
||||
call.respondText(ContentType.Application.Json) {
|
||||
visionManager.encodeToString(VisionOfNumassRepository(Name.EMPTY, repository))
|
||||
}
|
||||
}
|
||||
// val server = context.visionManager.serve {
|
||||
// header("numass", VisionPage.scriptHeader("js/numass-web.js"))
|
||||
// page {
|
||||
// div("flex-column") {
|
||||
// h1 { +"Visionforge file demo" }
|
||||
// vision { visionOfNumass }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
get("/sets/{name...}") {
|
||||
val setName: Name? = call.parameters.getAll("name")
|
||||
?.map { NameToken.parse(it) }?.let(::Name)
|
||||
server.openInBrowser()
|
||||
|
||||
if (setName == null) {
|
||||
call.respondText(status = HttpStatusCode.BadRequest) { "Set name is empty" }
|
||||
return@get
|
||||
}
|
||||
|
||||
val set: NumassDirectorySet? = withContext(Dispatchers.IO) { repository[setName]?.await() }
|
||||
if (set == null) {
|
||||
call.respondText(status = HttpStatusCode.NotFound) { "A set with name $setName not found in the repository" }
|
||||
return@get
|
||||
}
|
||||
|
||||
call.respondText(ContentType.Application.Json) {
|
||||
visionManager.encodeToString(VisionOfNumassSet(setName, set))
|
||||
}
|
||||
}
|
||||
get("/points/{name...}") {
|
||||
val fullName: Name? = call.parameters.getAll("name")
|
||||
?.map { NameToken.parse(it) }?.let(::Name)
|
||||
|
||||
if (fullName == null) {
|
||||
call.respondText(status = HttpStatusCode.BadRequest) { "Point name is empty" }
|
||||
return@get
|
||||
}
|
||||
|
||||
val setName = fullName.cutLast()
|
||||
|
||||
val set: NumassDirectorySet? = withContext(Dispatchers.IO) { repository[setName]?.await() }
|
||||
if (set == null) {
|
||||
call.respondText(status = HttpStatusCode.NotFound) { "A set with name $setName not found in the repository" }
|
||||
return@get
|
||||
}
|
||||
|
||||
val pointIndex: Int? = fullName.lastOrNull()?.body?.toIntOrNull()
|
||||
|
||||
val point: NumassPoint? = set.points.find { it.index == pointIndex }
|
||||
|
||||
if (point == null) {
|
||||
call.respondText(status = HttpStatusCode.NotFound) { "A point with name $setName/$pointIndex not found in the repository" }
|
||||
return@get
|
||||
}
|
||||
call.respondText(ContentType.Application.Json) {
|
||||
visionManager.encodeToString(point.toVision())
|
||||
}
|
||||
}
|
||||
println("Enter 'exit' to close server")
|
||||
while (readLine() != "exit") {
|
||||
//
|
||||
}
|
||||
//serveVisionData(VisionRoute("/visions", visionManager))
|
||||
|
||||
server.close()
|
||||
|
||||
}
|
@ -2,8 +2,11 @@ package ru.inr.mass.data.server
|
||||
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.dataforge.misc.DFExperimental
|
||||
import space.kscience.visionforge.html.*
|
||||
import space.kscience.visionforge.visionManager
|
||||
import space.kscience.visionforge.html.HtmlVisionFragment
|
||||
import space.kscience.visionforge.html.ResourceLocation
|
||||
import space.kscience.visionforge.html.VisionPage
|
||||
import space.kscience.visionforge.html.importScriptHeader
|
||||
import space.kscience.visionforge.makeFile
|
||||
import java.awt.Desktop
|
||||
import java.nio.file.Path
|
||||
|
||||
@ -16,7 +19,7 @@ public fun Context.makeNumassWebFile(
|
||||
show: Boolean = true,
|
||||
content: HtmlVisionFragment,
|
||||
): Unit {
|
||||
val actualPath = VisionPage(visionManager, content = content).makeFile(path) { actualPath: Path ->
|
||||
val actualPath = VisionPage(this, content = content).makeFile(path) { actualPath: Path ->
|
||||
mapOf(
|
||||
"title" to VisionPage.title(title),
|
||||
"numassWeb" to VisionPage.importScriptHeader("js/numass-web.js", resourceLocation, actualPath)
|
||||
|
@ -7,9 +7,7 @@ plugins {
|
||||
val dataforgeVersion: String by rootProject.extra
|
||||
val kmathVersion: String by rootProject.extra
|
||||
|
||||
kscience{
|
||||
jvm()
|
||||
js()
|
||||
kotlin.sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api("space.kscience:dataforge-context:$dataforgeVersion")
|
||||
@ -17,10 +15,7 @@ kscience{
|
||||
api("space.kscience:kmath-functions:$kmathVersion")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin.sourceSets{
|
||||
getByName("jvmMain"){
|
||||
jvmMain {
|
||||
dependencies {
|
||||
api("space.kscience:kmath-commons:$kmathVersion")
|
||||
api("ch.qos.logback:logback-classic:1.2.3")
|
||||
|
@ -15,10 +15,10 @@
|
||||
*/
|
||||
package ru.inr.mass.models
|
||||
|
||||
import space.kscience.kmath.UnstableKMathAPI
|
||||
import space.kscience.kmath.data.ColumnarData
|
||||
import space.kscience.kmath.expressions.Symbol
|
||||
import space.kscience.kmath.expressions.symbol
|
||||
import space.kscience.kmath.misc.UnstableKMathAPI
|
||||
import space.kscience.kmath.structures.Buffer
|
||||
|
||||
|
||||
|
@ -32,8 +32,8 @@ public class NBkgSpectrum(public val source: Spectrum) : DifferentiableSpectrum
|
||||
override fun derivativeOrNull(symbols: List<Symbol>): Spectrum? = when {
|
||||
symbols.isEmpty() -> this
|
||||
symbols.size == 1 -> when (symbols.first()) {
|
||||
norm -> Spectrum { x, arguments -> source(x, arguments) }
|
||||
bkg -> Spectrum { _, _ -> 1.0 }
|
||||
norm -> Spectrum { x, arguments -> source(x, arguments) + (arguments[bkg] ?: 0.0) }
|
||||
bkg -> Spectrum { x, arguments -> (arguments[norm] ?: 1.0) * source(x, arguments) }
|
||||
else -> (source as? DifferentiableSpectrum)?.derivativeOrNull(symbols)?.let { NBkgSpectrum(it) }
|
||||
}
|
||||
else -> null
|
||||
|
@ -3,8 +3,6 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
@file:Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE")
|
||||
|
||||
package ru.inr.mass.models
|
||||
|
||||
import space.kscience.kmath.expressions.Symbol
|
||||
|
@ -12,13 +12,10 @@ import kotlin.math.sqrt
|
||||
/**
|
||||
* @author [Alexander Nozik](mailto:altavir@gmail.com)
|
||||
*/
|
||||
|
||||
@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE")
|
||||
public class NumassResolution(
|
||||
public val resA: Double = 1.7e-4,
|
||||
public val resA: Double = 8.3e-5,
|
||||
public val resB: Double = 0.0,
|
||||
// Recent formula for adiabacity
|
||||
public val tailFunction: (Double, Double) -> Double = { e, u -> -1.75559e-13 * (e - u) * (e - u) * (e - u) - 5.97479e-11 * (e - u) * (e - u) + 3.26473e-7 * (e - u) + 1.0 },
|
||||
public val tailFunction: (Double, Double) -> Double = { _, _ -> 1.0 },
|
||||
) : DifferentiableKernel {
|
||||
|
||||
// private val tailFunction: Kernel = when {
|
||||
@ -46,12 +43,12 @@ public class NumassResolution(
|
||||
// else -> ResolutionFunction.getConstantTail()
|
||||
// }
|
||||
|
||||
private fun getValueFast(e: Double, u: Double): Double {
|
||||
val delta = resA * e
|
||||
private fun getValueFast(E: Double, U: Double): Double {
|
||||
val delta = resA * E
|
||||
return when {
|
||||
e - u < 0 -> 0.0
|
||||
e - u > delta -> tailFunction(e, u)
|
||||
else -> (e - u) / delta
|
||||
E - U < 0 -> 0.0
|
||||
E - U > delta -> tailFunction(E, U)
|
||||
else -> (E - U) / delta
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,15 +57,15 @@ public class NumassResolution(
|
||||
override val x: Symbol get() = e
|
||||
override val y: Symbol get() = u
|
||||
|
||||
override fun invoke(e: Double, u: Double, arguments: Map<Symbol, Double>): Double {
|
||||
override fun invoke(E: Double, U: Double, arguments: Map<Symbol, Double>): Double {
|
||||
if (resB <= 0) {
|
||||
return this.getValueFast(e, u)
|
||||
return this.getValueFast(E, U)
|
||||
}
|
||||
val delta = resA * e
|
||||
val delta = resA * E
|
||||
return when {
|
||||
e - u < 0 -> 0.0
|
||||
e - u > delta -> tailFunction(e, u)
|
||||
else -> (1 - sqrt(1 - (e - u) / e * resB)) / (1 - sqrt(1 - resA * resB))
|
||||
E - U < 0 -> 0.0
|
||||
E - U > delta -> tailFunction(E, U)
|
||||
else -> (1 - sqrt(1 - (E - U) / E * resB)) / (1 - sqrt(1 - resA * resB))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import kotlin.math.*
|
||||
* @author [Alexander Nozik](mailto:altavir@gmail.com)
|
||||
*/
|
||||
public class NumassTransmission(
|
||||
public val trapFunc: Kernel = trapFunction,
|
||||
public val trapFunc: Kernel = defaultTrapping,
|
||||
// private val adjustX: Boolean = false,
|
||||
) : DifferentiableKernel {
|
||||
// private val trapFunc: Kernel = if (meta.hasValue("trapping")) {
|
||||
@ -54,10 +54,8 @@ public class NumassTransmission(
|
||||
}
|
||||
sum
|
||||
}
|
||||
|
||||
else -> null
|
||||
}
|
||||
|
||||
else -> null
|
||||
}
|
||||
|
||||
@ -65,7 +63,6 @@ public class NumassTransmission(
|
||||
// loss part
|
||||
val thickness = arguments[thickness] ?: 0.0
|
||||
val loss = getTotalLossValue(thickness, ei, ef)
|
||||
//val loss = 0.0
|
||||
// double loss;
|
||||
//
|
||||
// if(eIn-eOut >= 300){
|
||||
@ -79,9 +76,7 @@ public class NumassTransmission(
|
||||
// }
|
||||
|
||||
//trapping part
|
||||
//
|
||||
val trap = (arguments[trap] ?: 1.0) * trapFunc(ei, ef, arguments)
|
||||
//val trap = 0.0
|
||||
return loss + trap
|
||||
}
|
||||
|
||||
@ -91,7 +86,7 @@ public class NumassTransmission(
|
||||
|
||||
private val cache = HashMap<Int, Function1D<Double>>()
|
||||
|
||||
private const val ION_POTENTIAL = 13.6//eV
|
||||
private const val ION_POTENTIAL = 15.4//eV
|
||||
|
||||
|
||||
private fun getX(arguments: Map<Symbol, Double>, eIn: Double, adjustX: Boolean = false): Double {
|
||||
@ -136,7 +131,6 @@ public class NumassTransmission(
|
||||
}
|
||||
|
||||
private fun getCachedSpectrum(order: Int): Function1D<Double> {
|
||||
//println("-------------------ORDER $order ------------------------")
|
||||
return when {
|
||||
order <= 0 -> error("Non-positive loss cache order")
|
||||
order == 1 -> singleScatterFunction
|
||||
@ -280,13 +274,13 @@ public class NumassTransmission(
|
||||
* Значение полной производной функции потерь с учетом всех неисчезающих
|
||||
* порядков
|
||||
*
|
||||
* @param thickness
|
||||
* @param X
|
||||
* @param eIn
|
||||
* @param eOut
|
||||
* @return
|
||||
*/
|
||||
private fun getTotalLossDeriv(thickness: Double, eIn: Double, eOut: Double): Double {
|
||||
val probs = getLossProbDerivs(thickness)
|
||||
private fun getTotalLossDeriv(X: Double, eIn: Double, eOut: Double): Double {
|
||||
val probs = getLossProbDerivs(X)
|
||||
|
||||
var sum = 0.0
|
||||
for (i in 1 until probs.size) {
|
||||
@ -337,7 +331,6 @@ public class NumassTransmission(
|
||||
val z = eps - pos1
|
||||
A1 * exp(-2.0 * z * z / w1 / w1)
|
||||
}
|
||||
|
||||
else -> {
|
||||
val z = 4.0 * (eps - pos2) * (eps - pos2)
|
||||
A2 / (1 + z / w2 / w2)
|
||||
@ -406,8 +399,8 @@ public class NumassTransmission(
|
||||
// return getSingleScatterFunction(exPos, ionPos, exW, ionW, exIonRatio)
|
||||
// }
|
||||
|
||||
public val trapFunction: Kernel = Kernel { ei: Double, ef: Double, _ ->
|
||||
val eps = ei - ef
|
||||
public val trapFunction: (Double, Double) -> Double = { Ei: Double, Ef: Double ->
|
||||
val eps = Ei - Ef
|
||||
if (eps > 10) {
|
||||
1.86e-04 * exp(-eps / 25.0) + 5.5e-05
|
||||
} else {
|
||||
|
@ -2,7 +2,6 @@ plugins {
|
||||
id("space.kscience.gradle.jvm")
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
`maven-publish`
|
||||
application
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@ -10,7 +9,7 @@ kotlin {
|
||||
}
|
||||
|
||||
val dataforgeVersion: String by rootProject.extra
|
||||
val plotlyKtVersion = "0.6.0"
|
||||
val visionForgeVersion: String by rootProject.extra
|
||||
val kmathVersion: String by rootProject.extra
|
||||
val tablesVersion: String by rootProject.extra
|
||||
|
||||
@ -22,15 +21,9 @@ dependencies {
|
||||
|
||||
implementation("space.kscience:kmath-jupyter:$kmathVersion")
|
||||
implementation("space.kscience:tables-kt:$tablesVersion")
|
||||
implementation("space.kscience:plotlykt-core:$plotlyKtVersion")
|
||||
|
||||
implementation("com.github.ajalt.clikt:clikt:4.2.1")
|
||||
implementation("space.kscience:visionforge-plotly:$visionForgeVersion")
|
||||
}
|
||||
|
||||
kscience{
|
||||
jupyterLibrary("ru.inr.mass.notebook.NumassJupyter")
|
||||
}
|
||||
|
||||
//application {
|
||||
// mainClass.set("ru.inr.mass.scripts.Get_spectrumKt")
|
||||
//}
|
||||
}
|
@ -1,196 +0,0 @@
|
||||
package ru.inr.mass.scripts
|
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand
|
||||
import com.github.ajalt.clikt.core.context
|
||||
import com.github.ajalt.clikt.output.MordantHelpFormatter
|
||||
import com.github.ajalt.clikt.parameters.arguments.argument
|
||||
import com.github.ajalt.clikt.parameters.arguments.help
|
||||
import com.github.ajalt.clikt.parameters.options.default
|
||||
import com.github.ajalt.clikt.parameters.options.help
|
||||
import com.github.ajalt.clikt.parameters.options.option
|
||||
import com.github.ajalt.clikt.parameters.options.prompt
|
||||
import com.github.ajalt.clikt.parameters.types.double
|
||||
import com.github.ajalt.clikt.parameters.types.int
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import ru.inr.mass.models.*
|
||||
import ru.inr.mass.workspace.buffer
|
||||
import ru.inr.mass.workspace.fitWith
|
||||
import space.kscience.kmath.UnstableKMathAPI
|
||||
import space.kscience.kmath.data.XYColumnarData
|
||||
import space.kscience.kmath.data.XYErrorColumnarData
|
||||
import space.kscience.kmath.data.indices
|
||||
import space.kscience.kmath.expressions.Symbol
|
||||
import space.kscience.kmath.expressions.derivative
|
||||
import space.kscience.kmath.operations.asSequence
|
||||
import space.kscience.kmath.optimization.*
|
||||
import space.kscience.kmath.real.step
|
||||
import space.kscience.kmath.structures.asBuffer
|
||||
import space.kscience.plotly.*
|
||||
import space.kscience.plotly.models.ScatterMode
|
||||
import java.io.File
|
||||
import kotlin.math.pow
|
||||
|
||||
@OptIn(UnstableKMathAPI::class)
|
||||
fun parse(filename: String): XYErrorColumnarData<Double, Double, Double> {
|
||||
val x: MutableList<Double> = mutableListOf()
|
||||
val y: MutableList<Double> = mutableListOf()
|
||||
val errors: MutableList<Double> = mutableListOf()
|
||||
|
||||
File(filename).forEachLine {
|
||||
val array = it.split("\t").map { it.toDouble() }
|
||||
x.add(array[0])
|
||||
y.add(array[1])
|
||||
errors.add(array[2])
|
||||
//errors.add(array[1] / 100)
|
||||
}
|
||||
return XYErrorColumnarData.of(
|
||||
x.asBuffer(),
|
||||
y.asBuffer(),
|
||||
errors.map { it }.asBuffer()
|
||||
)
|
||||
}
|
||||
class Args : CliktCommand() {
|
||||
|
||||
init {
|
||||
context {
|
||||
helpFormatter = { MordantHelpFormatter(it, showDefaultValues = true) }
|
||||
}
|
||||
}
|
||||
|
||||
val spectrum: String by argument().help("path to spectrum TSV file")
|
||||
|
||||
val norm: Double by option().double().default(8.311751921319484E8).help("NBkgSpectrum.norm")
|
||||
val bkg: Double by option().double().default(1612.626961212948).help("NBkgSpectrum.bkg")
|
||||
|
||||
val mnu2: Double by option().double().default(0.0).help("NumassBeta.mnu2")
|
||||
val e0: Double by option().double().default(18572.0).help("NumassBeta.e0")
|
||||
val msterile2: Double by option().double().default(0.0.pow(2)).help("NumassBeta.msterile2")
|
||||
val u2: Double by option().double().default(1e-2).help("NumassBeta.u2")
|
||||
|
||||
val thickness: Double by option().double().default(0.3).help("NumassTransmission.thickness")
|
||||
val trap: Double by option().double().default(1.0).help("NumassTransmission.trap")
|
||||
|
||||
@UnstableKMathAPI
|
||||
override fun run() {
|
||||
val fitParams: Map<Symbol, Double> = mapOf(
|
||||
NBkgSpectrum.norm to norm,
|
||||
NBkgSpectrum.bkg to bkg,
|
||||
NumassBeta.mnu2 to mnu2,
|
||||
NumassBeta.e0 to e0,
|
||||
NumassBeta.msterile2 to msterile2,
|
||||
NumassBeta.u2 to u2,
|
||||
NumassTransmission.thickness to thickness,
|
||||
NumassTransmission.trap to trap
|
||||
)
|
||||
|
||||
runBlocking {
|
||||
process(spectrum, fitParams)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) = Args().main(args)
|
||||
|
||||
suspend fun fitNumassSpectrum(data: XYErrorColumnarData<Double, Double, Double>, initial: Map<Symbol, Double>): XYFit {
|
||||
val spectrum: NBkgSpectrum = SterileNeutrinoSpectrum(
|
||||
// fss = FSS.default,
|
||||
transmission = NumassTransmission(NumassTransmission.trapFunction),
|
||||
// resolution = NumassResolution(1.7e-4)
|
||||
).withNBkg()
|
||||
|
||||
return data.fitWith(
|
||||
optimizer = QowOptimizer,
|
||||
modelExpression = spectrum,
|
||||
startingPoint = initial,
|
||||
OptimizationParameters(NumassBeta.e0, NBkgSpectrum.norm, NBkgSpectrum.bkg,
|
||||
// NumassTransmission.trap
|
||||
),
|
||||
OptimizationIterations(20)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@UnstableKMathAPI
|
||||
suspend fun process(spectrumFile: String, fitParams: Map<Symbol, Double>) {
|
||||
|
||||
val data = parse(spectrumFile)
|
||||
|
||||
val spectrum: NBkgSpectrum = SterileNeutrinoSpectrum(
|
||||
// fss = FSS.default,
|
||||
transmission = NumassTransmission(NumassTransmission.trapFunction),
|
||||
// resolution = NumassResolution(1.7e-4)
|
||||
).withNBkg()
|
||||
|
||||
val fit = fitNumassSpectrum(data, fitParams)
|
||||
|
||||
println(fit.resultPoint)
|
||||
|
||||
Plotly.page {
|
||||
plot {
|
||||
|
||||
scatter {
|
||||
name = "Data"
|
||||
mode = ScatterMode.markers
|
||||
x.buffer = data.x
|
||||
y.buffer = data.y
|
||||
}
|
||||
|
||||
|
||||
scatter {
|
||||
name = "Initial"
|
||||
mode = ScatterMode.lines
|
||||
x.buffer = data.x
|
||||
y.numbers = x.doubles.map { spectrum(it, fitParams + fit.resultPoint) }
|
||||
File(spectrumFile + "-fit").printWriter().use { out ->
|
||||
out.println("U_sp\tcounts\tresidials")
|
||||
|
||||
data.indices.map{
|
||||
val value = spectrum(data.x[it], fitParams + fit.resultPoint)
|
||||
val dif = data.y[it] - value
|
||||
out.println("${data.x[it]}\t${data.y[it]}\t${dif/data.yErr[it]}")
|
||||
}
|
||||
}
|
||||
}
|
||||
scatter {
|
||||
name = "Fit"
|
||||
mode = ScatterMode.lines
|
||||
x.buffer = 12000.0..18600.0 step 10.0
|
||||
y.numbers = x.doubles.map { spectrum(it, fitParams + fit.resultPoint) }
|
||||
}
|
||||
}
|
||||
plot{
|
||||
scatter {
|
||||
name = "Residuals"
|
||||
mode = ScatterMode.markers
|
||||
x.buffer = data.x
|
||||
y.numbers = data.indices.map{
|
||||
val value = spectrum(data.x[it], fitParams + fit.resultPoint)
|
||||
val dif = data.y[it] - value
|
||||
dif/data.yErr[it]
|
||||
}
|
||||
}
|
||||
}
|
||||
plot{
|
||||
histogram {
|
||||
x.numbers = data.indices.map{
|
||||
val value = spectrum(data.x[it], fitParams + fit.resultPoint)
|
||||
val dif = data.y[it] - value
|
||||
dif/data.yErr[it]
|
||||
}
|
||||
name = "Res histo"
|
||||
}
|
||||
}
|
||||
plot {
|
||||
scatter {
|
||||
name = "Residuals_lines"
|
||||
mode = ScatterMode.lines
|
||||
x.buffer = data.x
|
||||
y.numbers = data.indices.map {
|
||||
val value = spectrum(data.x[it], fitParams + fit.resultPoint)
|
||||
val dif = data.y[it] - value
|
||||
dif / data.yErr[it]
|
||||
}
|
||||
}
|
||||
}
|
||||
}.makeFile()
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
package ru.inr.mass.scripts
|
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand
|
||||
import com.github.ajalt.clikt.core.context
|
||||
import com.github.ajalt.clikt.output.MordantHelpFormatter
|
||||
import com.github.ajalt.clikt.parameters.arguments.argument
|
||||
import com.github.ajalt.clikt.parameters.arguments.help
|
||||
import com.github.ajalt.clikt.parameters.options.default
|
||||
import com.github.ajalt.clikt.parameters.options.help
|
||||
import com.github.ajalt.clikt.parameters.options.option
|
||||
import com.github.ajalt.clikt.parameters.types.double
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import ru.inr.mass.models.*
|
||||
import space.kscience.kmath.data.XYErrorColumnarData
|
||||
import space.kscience.kmath.UnstableKMathAPI
|
||||
import space.kscience.kmath.expressions.Symbol
|
||||
import space.kscience.kmath.operations.toTypedArray
|
||||
import space.kscience.kmath.real.plus
|
||||
import space.kscience.kmath.real.step
|
||||
import space.kscience.plotly.models.HoverMode
|
||||
import kotlin.math.pow
|
||||
|
||||
private class CalcSpectrum : CliktCommand() {
|
||||
|
||||
init {
|
||||
context {
|
||||
helpFormatter = { MordantHelpFormatter(it, showDefaultValues = true) }
|
||||
}
|
||||
}
|
||||
|
||||
val spectrum: String by argument().help("path to spectrum TSV file")
|
||||
|
||||
val norm: Double by option().double().default(8.84e8).help("NBkgSpectrum.norm")
|
||||
val bkg: Double by option().double().default(-1.702).help("NBkgSpectrum.bkg")
|
||||
|
||||
val mnu2: Double by option().double().default(0.0).help("NumassBeta.mnu2")
|
||||
val e0: Double by option().double().default(18572.0).help("NumassBeta.e0")
|
||||
val msterile2: Double by option().double().default(0.0.pow(2)).help("NumassBeta.msterile2")
|
||||
val u2: Double by option().double().default(1e-2).help("NumassBeta.u2")
|
||||
|
||||
val thickness: Double by option().double().default(0.3).help("NumassTransmission.thickness")
|
||||
val trap: Double by option().double().default(1.0).help("NumassTransmission.trap")
|
||||
|
||||
@UnstableKMathAPI
|
||||
override fun run() {
|
||||
val fitParams: Map<Symbol, Double> = mapOf(
|
||||
NBkgSpectrum.norm to norm,
|
||||
NBkgSpectrum.bkg to bkg,
|
||||
NumassBeta.mnu2 to mnu2,
|
||||
NumassBeta.e0 to e0,
|
||||
NumassBeta.msterile2 to msterile2,
|
||||
NumassBeta.u2 to u2,
|
||||
NumassTransmission.thickness to thickness,
|
||||
NumassTransmission.trap to trap
|
||||
)
|
||||
|
||||
runBlocking {
|
||||
calcSpectrum(spectrum, fitParams)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) = CalcSpectrum().main(args)
|
||||
|
||||
suspend fun calcSpectrum(spectrumFile: String, fitParams: Map<Symbol, Double>) {
|
||||
|
||||
val data = parse(spectrumFile)
|
||||
|
||||
val range = data.x.toTypedArray();
|
||||
|
||||
runBlocking(Dispatchers.Default) {
|
||||
|
||||
val handles = range.map {
|
||||
|
||||
async(Dispatchers.Default) {
|
||||
val spectrum: NBkgSpectrum = SterileNeutrinoSpectrum(
|
||||
transmission = NumassTransmission(NumassTransmission.trapFunction),
|
||||
).withNBkg()
|
||||
|
||||
val res = spectrum.invoke(it, fitParams)
|
||||
return@async res
|
||||
}
|
||||
}
|
||||
val out = handles.map { it.await() }
|
||||
println(out.joinToString("\n"))
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package ru.inr.mass.scripts
|
||||
|
||||
//import com.google.cloud.storage.contrib.nio.CloudStorageFileSystem
|
||||
//import ru.inr.mass.data.proto.NumassDirectorySet
|
||||
//import ru.inr.mass.workspace.Numass
|
||||
//import space.kscience.dataforge.data.DataTree
|
||||
//
|
||||
//// https://storage.cloud.google.com/numass-data/2020_12/Adiabaticity/16/set_3/p10(10s)(HV1%3D13750)
|
||||
//
|
||||
//suspend fun main() {
|
||||
// CloudStorageFileSystem.forBucket("numass-data").use { fs ->
|
||||
// val repo: DataTree<NumassDirectorySet> = Numass.readRepository(fs.getPath("2020_12/Adiabaticity"))
|
||||
// repo.items().forEach{ (key,item)->
|
||||
// println(key)
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -18,6 +18,7 @@ import space.kscience.dataforge.workspace.WorkspacePlugin
|
||||
import space.kscience.dataforge.workspace.pipeFrom
|
||||
import space.kscience.dataforge.workspace.task
|
||||
import space.kscience.tables.Table
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
class NumassWorkspacePlugin : WorkspacePlugin() {
|
||||
override val tag: PluginTag get() = Companion.tag
|
||||
@ -127,6 +128,7 @@ class NumassWorkspacePlugin : WorkspacePlugin() {
|
||||
|
||||
companion object : PluginFactory<NumassWorkspacePlugin> {
|
||||
override val tag: PluginTag = PluginTag("numass", "ru.mipt.npm")
|
||||
override val type: KClass<out NumassWorkspacePlugin> = NumassWorkspacePlugin::class
|
||||
override fun build(context: Context, meta: Meta): NumassWorkspacePlugin = NumassWorkspacePlugin()
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
@file:OptIn(UnstableKMathAPI::class)
|
||||
|
||||
package ru.inr.mass.workspace
|
||||
|
||||
import ru.inr.mass.models.Spectrum
|
||||
import space.kscience.kmath.UnstableKMathAPI
|
||||
import space.kscience.kmath.data.XYColumnarData
|
||||
import space.kscience.kmath.data.XYErrorColumnarData
|
||||
import space.kscience.kmath.expressions.DifferentiableExpression
|
||||
import space.kscience.kmath.expressions.Symbol
|
||||
import space.kscience.kmath.misc.FeatureSet
|
||||
import space.kscience.kmath.misc.Loggable
|
||||
import space.kscience.kmath.optimization.*
|
||||
import space.kscience.kmath.random.RandomGenerator
|
||||
import space.kscience.kmath.samplers.PoissonSampler
|
||||
import space.kscience.kmath.stat.next
|
||||
import space.kscience.kmath.structures.asBuffer
|
||||
import kotlin.math.sqrt
|
||||
|
||||
public suspend fun XYColumnarData<Double, Double, Double>.fitWith(
|
||||
optimizer: Optimizer<Double, XYFit>,
|
||||
modelExpression: DifferentiableExpression<Double>,
|
||||
startingPoint: Map<Symbol, Double>,
|
||||
vararg features: OptimizationFeature = emptyArray(),
|
||||
xSymbol: Symbol = Symbol.x,
|
||||
pointToCurveDistance: PointToCurveDistance = PointToCurveDistance.byY,
|
||||
pointWeight: PointWeight = PointWeight.byYSigma,
|
||||
): XYFit {
|
||||
var actualFeatures = FeatureSet.of(*features, OptimizationStartPoint(startingPoint))
|
||||
|
||||
if (actualFeatures.getFeature<OptimizationLog>() == null) {
|
||||
actualFeatures = actualFeatures.with(OptimizationLog(Loggable.console))
|
||||
}
|
||||
val problem = XYFit(
|
||||
this,
|
||||
modelExpression,
|
||||
actualFeatures,
|
||||
pointToCurveDistance,
|
||||
pointWeight,
|
||||
xSymbol
|
||||
)
|
||||
return optimizer.optimize(problem)
|
||||
}
|
||||
|
||||
public suspend fun Spectrum.generate(
|
||||
strategy: Map<Double, Double>,
|
||||
arguments: Map<Symbol, Double>,
|
||||
generator: RandomGenerator = RandomGenerator.default,
|
||||
): XYErrorColumnarData<Double, Double, Double> {
|
||||
val xs = mutableListOf<Double>()
|
||||
val ys = mutableListOf<Double>()
|
||||
val errors = mutableListOf<Double>()
|
||||
|
||||
strategy.forEach { (x, time) ->
|
||||
xs.add(x)
|
||||
val mu = invoke(x, arguments) * time
|
||||
val y = PoissonSampler(mu).next(generator) / time
|
||||
val error = sqrt(mu) / time
|
||||
ys.add(y)
|
||||
errors.add(error)
|
||||
}
|
||||
return XYErrorColumnarData.of(
|
||||
xs.toTypedArray().asBuffer(),
|
||||
ys.toTypedArray().asBuffer(),
|
||||
errors.toTypedArray().asBuffer()
|
||||
)
|
||||
}
|
@ -12,9 +12,9 @@ import ru.inr.mass.data.proto.HVData
|
||||
import ru.inr.mass.data.proto.NumassDirectorySet
|
||||
import space.kscience.dataforge.meta.asValue
|
||||
import space.kscience.dataforge.meta.double
|
||||
import space.kscience.kmath.UnstableKMathAPI
|
||||
import space.kscience.kmath.domains.center
|
||||
import space.kscience.kmath.histogram.Histogram1D
|
||||
import space.kscience.kmath.misc.UnstableKMathAPI
|
||||
import space.kscience.kmath.operations.asIterable
|
||||
import space.kscience.kmath.structures.Buffer
|
||||
import space.kscience.kmath.structures.DoubleBuffer
|
||||
|
@ -1,6 +1,7 @@
|
||||
rootProject.name = "numass"
|
||||
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
enableFeaturePreview("VERSION_CATALOGS")
|
||||
|
||||
pluginManagement {
|
||||
|
||||
@ -14,7 +15,6 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("org.jetbrains.compose").version(extra["compose.version"] as String)
|
||||
id("space.kscience.gradle.project") version toolsVersion
|
||||
id("space.kscience.gradle.mpp") version toolsVersion
|
||||
id("space.kscience.gradle.jvm") version toolsVersion
|
||||
|
Loading…
Reference in New Issue
Block a user