feat: update get-spectrum.kt for Pluto
This commit is contained in:
@@ -3,20 +3,18 @@ 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.flag
|
||||
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.UnstableKMathAPI
|
||||
import space.kscience.kmath.expressions.Symbol
|
||||
import space.kscience.kmath.operations.toTypedArray
|
||||
import space.kscience.kmath.real.map
|
||||
import space.kscience.kmath.real.step
|
||||
import kotlin.math.pow
|
||||
|
||||
private class CalcSpectrum : CliktCommand() {
|
||||
@@ -27,15 +25,10 @@ private class CalcSpectrum : CliktCommand() {
|
||||
}
|
||||
}
|
||||
|
||||
val spectrum: String by argument().help("path to spectrum TSV file")
|
||||
val full: String? by option().help("path to full spectrum (for test)")
|
||||
|
||||
val postfix: String? by option().help("save file postfix")
|
||||
|
||||
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 fixBkg: Boolean by option().flag().help("Don't fit bkg variable")
|
||||
|
||||
val mnu2: Double by option().double().default(0.0).help("NumassBeta.mnu2")
|
||||
val e0: Double by option().double().default(18572.0).help("NumassBeta.e0")
|
||||
@@ -67,17 +60,15 @@ private class CalcSpectrum : CliktCommand() {
|
||||
)
|
||||
|
||||
runBlocking {
|
||||
calcSpectrum(spectrum, fitParams, getTrapByName(trapFunc), getWallByName(wallFunc))
|
||||
calcSpectrum(fitParams, getTrapByName(trapFunc), getWallByName(wallFunc))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) = CalcSpectrum().main(args)
|
||||
|
||||
suspend fun calcSpectrum(spectrumFile: String, fitParams: Map<Symbol, Double>, trapFunc: ITrap, wallFunc: (u: Double) -> Double) {
|
||||
|
||||
val data = parse(spectrumFile)
|
||||
val range = data.x.toTypedArray();
|
||||
suspend fun calcSpectrum(fitParams: Map<Symbol, Double>, trapFunc: ITrap, wallFunc: (u: Double) -> Double) {
|
||||
val range = 2000.0..18000.0 step 50.0
|
||||
|
||||
runBlocking(Dispatchers.Default) {
|
||||
|
||||
@@ -90,7 +81,7 @@ suspend fun calcSpectrum(spectrumFile: String, fitParams: Map<Symbol, Double>, t
|
||||
},
|
||||
adjustX = false,
|
||||
),
|
||||
resolution = NumassResolution(1.7e-4, tailFunction = {e,u -> adiabacity(e,u) })
|
||||
resolution = NumassResolution(1.7e-4, tailFunction = {e,u -> adiabacity_2024_11(e,u) })
|
||||
).withNBkg()
|
||||
|
||||
val out = range.map {
|
||||
@@ -103,6 +94,6 @@ suspend fun calcSpectrum(spectrumFile: String, fitParams: Map<Symbol, Double>, t
|
||||
res
|
||||
}
|
||||
// val out = handles.map { it.await() }
|
||||
println(out.joinToString("\n"))
|
||||
println(out.toTypedArray().joinToString("\n"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user