Plots update
This commit is contained in:
parent
2f3e9357ff
commit
014628f2fd
@ -4,10 +4,11 @@ import inr.numass.models.sterile.NumassBeta.e0
|
|||||||
import inr.numass.models.sterile.NumassBeta.mnu2
|
import inr.numass.models.sterile.NumassBeta.mnu2
|
||||||
import inr.numass.models.sterile.NumassBeta.msterile2
|
import inr.numass.models.sterile.NumassBeta.msterile2
|
||||||
import inr.numass.models.sterile.NumassBeta.u2
|
import inr.numass.models.sterile.NumassBeta.u2
|
||||||
|
import inr.numass.models.sterile.NumassTransmission.Companion.thickness
|
||||||
import inr.numass.models.sterile.SterileNeutrinoSpectrum
|
import inr.numass.models.sterile.SterileNeutrinoSpectrum
|
||||||
|
import ru.inr.mass.workspace.buffer
|
||||||
import space.kscience.kmath.misc.Symbol
|
import space.kscience.kmath.misc.Symbol
|
||||||
import space.kscience.kmath.real.step
|
import space.kscience.kmath.real.step
|
||||||
import space.kscience.kmath.structures.asIterable
|
|
||||||
import space.kscience.plotly.Plotly
|
import space.kscience.plotly.Plotly
|
||||||
import space.kscience.plotly.makeFile
|
import space.kscience.plotly.makeFile
|
||||||
import space.kscience.plotly.models.ScatterMode
|
import space.kscience.plotly.models.ScatterMode
|
||||||
@ -19,12 +20,13 @@ fun main() {
|
|||||||
mnu2 to 0.0,
|
mnu2 to 0.0,
|
||||||
e0 to 18575.0,
|
e0 to 18575.0,
|
||||||
msterile2 to 1e6,
|
msterile2 to 1e6,
|
||||||
u2 to 1e-2
|
u2 to 1e-2,
|
||||||
|
thickness to 0.2
|
||||||
)
|
)
|
||||||
Plotly.plot {
|
Plotly.plot {
|
||||||
scatter {
|
scatter {
|
||||||
mode = ScatterMode.lines
|
mode = ScatterMode.lines
|
||||||
x.numbers = (14000.0..18600.0 step 1.0).asIterable()
|
x.buffer = 14000.0..18600.0 step 10.0
|
||||||
y.numbers = x.numbers.map { spectrum(it.toDouble(), args) }
|
y.numbers = x.numbers.map { spectrum(it.toDouble(), args) }
|
||||||
}
|
}
|
||||||
}.makeFile()
|
}.makeFile()
|
||||||
|
@ -5,11 +5,17 @@ import kotlinx.html.h2
|
|||||||
import ru.inr.mass.data.api.NumassPoint
|
import ru.inr.mass.data.api.NumassPoint
|
||||||
import ru.inr.mass.data.proto.HVEntry
|
import ru.inr.mass.data.proto.HVEntry
|
||||||
import ru.inr.mass.data.proto.NumassDirectorySet
|
import ru.inr.mass.data.proto.NumassDirectorySet
|
||||||
|
import space.kscience.dataforge.values.asValue
|
||||||
|
import space.kscience.dataforge.values.double
|
||||||
import space.kscience.kmath.histogram.UnivariateHistogram
|
import space.kscience.kmath.histogram.UnivariateHistogram
|
||||||
import space.kscience.kmath.histogram.center
|
import space.kscience.kmath.histogram.center
|
||||||
import space.kscience.kmath.misc.UnstableKMathAPI
|
import space.kscience.kmath.misc.UnstableKMathAPI
|
||||||
|
import space.kscience.kmath.structures.Buffer
|
||||||
|
import space.kscience.kmath.structures.DoubleBuffer
|
||||||
|
import space.kscience.kmath.structures.asIterable
|
||||||
import space.kscience.plotly.*
|
import space.kscience.plotly.*
|
||||||
import space.kscience.plotly.models.Trace
|
import space.kscience.plotly.models.Trace
|
||||||
|
import space.kscience.plotly.models.TraceValues
|
||||||
|
|
||||||
@OptIn(UnstableKMathAPI::class)
|
@OptIn(UnstableKMathAPI::class)
|
||||||
fun Trace.fromSpectrum(histogram: UnivariateHistogram) {
|
fun Trace.fromSpectrum(histogram: UnivariateHistogram) {
|
||||||
@ -40,7 +46,8 @@ fun Plot.hvData(data: List<HVEntry>): Trace = scatter {
|
|||||||
y.numbers = data.map { it.value }
|
y.numbers = data.map { it.value }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Plotly.numassDirectory(set: NumassDirectorySet, binSize: Int = 20, range: IntRange = 0..2000): PlotlyPage = Plotly.page {
|
fun Plotly.numassDirectory(set: NumassDirectorySet, binSize: Int = 20, range: IntRange = 0..2000): PlotlyPage =
|
||||||
|
Plotly.page {
|
||||||
h1 {
|
h1 {
|
||||||
+"Numass point set ${set.path}"
|
+"Numass point set ${set.path}"
|
||||||
}
|
}
|
||||||
@ -61,3 +68,12 @@ fun Plotly.numassDirectory(set: NumassDirectorySet, binSize: Int = 20, range: In
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a number buffer accessor for Plotly trace values
|
||||||
|
*/
|
||||||
|
public var TraceValues.buffer: Buffer<Number>
|
||||||
|
get() = value?.list?.let { list -> DoubleBuffer(list.size) { list[it].double } } ?: DoubleBuffer()
|
||||||
|
set(value) {
|
||||||
|
this.value = value.asIterable().map { it.asValue() }.asValue()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user