feat: fit-custom.kt add adiab to cli + extend report
This commit is contained in:
@@ -10,6 +10,7 @@ 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 com.github.ajalt.clikt.parameters.types.enum
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.html.*
|
||||
import ru.inr.mass.models.*
|
||||
@@ -98,9 +99,16 @@ class CustomArgs : CliktCommand() {
|
||||
|
||||
val fixRwall: Boolean by option().flag().help("Don't fit rwall variable")
|
||||
|
||||
val noAdiabacity: Boolean by option().flag().help("Use const 1 instead of adiabacity function")
|
||||
|
||||
// TODO: convert to enum
|
||||
val adiabacityFunc: String by option().default("2024_11").help(
|
||||
"adiabacity type (one of 2024_11, shifted, vasya)"
|
||||
)
|
||||
|
||||
@UnstableKMathAPI
|
||||
override fun run() {
|
||||
|
||||
val fitParams: Map<Symbol, Double> = mapOf(
|
||||
NBkgSpectrum.norm to norm,
|
||||
NBkgSpectrum.bkg to bkg,
|
||||
@@ -124,7 +132,10 @@ class CustomArgs : CliktCommand() {
|
||||
fixTrap,
|
||||
getTrapByName(trapFunc),
|
||||
fixRwall,
|
||||
getWallByName(wallFunc)
|
||||
noAdiabacity,
|
||||
getWallByName(wallFunc),
|
||||
cliArgs=this@CustomArgs,
|
||||
adiabacityFunc=getAdiabByName(adiabacityFunc)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -163,8 +174,12 @@ suspend fun processCustom(
|
||||
fixTrap: Boolean,
|
||||
trapFunc: ITrap,
|
||||
fixRwall: Boolean,
|
||||
wallFunc: (u: Double) -> Double
|
||||
noAdiabacity: Boolean,
|
||||
wallFunc: (u: Double) -> Double,
|
||||
cliArgs: Any?=null,
|
||||
adiabacityFunc: (e: Double, u: Double) -> Double
|
||||
) {
|
||||
println(cliArgs)
|
||||
|
||||
val data = parse(spectrumFile)
|
||||
val testData = if (full != null) parse(full) else data
|
||||
@@ -180,7 +195,13 @@ suspend fun processCustom(
|
||||
},
|
||||
adjustX = false,
|
||||
),
|
||||
resolution = NumassResolution(1.7e-4, tailFunction = {e,u -> adiabacity(e,u) })
|
||||
resolution = NumassResolution(1.7e-4, tailFunction = { e,u ->
|
||||
if (noAdiabacity) {
|
||||
1.0
|
||||
} else {
|
||||
adiabacityFunc(e,u)
|
||||
}
|
||||
})
|
||||
).withNBkg()
|
||||
|
||||
val logMessages = emptyList<String>().toMutableList()
|
||||
@@ -283,6 +304,10 @@ suspend fun processCustom(
|
||||
name = "Res histo"
|
||||
}
|
||||
}
|
||||
p {
|
||||
+"command args = $cliArgs"
|
||||
}
|
||||
br()
|
||||
p {
|
||||
+"initial params = $fitParams"
|
||||
}
|
||||
@@ -290,6 +315,14 @@ suspend fun processCustom(
|
||||
p {
|
||||
+"fit result = ${fit.result}"
|
||||
}
|
||||
br()
|
||||
p {
|
||||
+"chi^2 = ${fit.chiSquaredOrNull}"
|
||||
}
|
||||
br()
|
||||
p {
|
||||
+"dof = ${fit.dof}"
|
||||
}
|
||||
h4 {
|
||||
+"Fit log:"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user