Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post mortem debugging of adaptive decisions #2259

Open
t-b opened this issue Sep 13, 2024 · 0 comments
Open

Post mortem debugging of adaptive decisions #2259

t-b opened this issue Sep 13, 2024 · 0 comments

Comments

@t-b
Copy link
Collaborator

t-b commented Sep 13, 2024

Needs PSQ_DS_DAScaleParams to be made public.

#define AUTOMATED_TESTING

/// @name Type constants for PSQ_DS_GetLabnotebookData
/// @anchor PSQDAScaleAdaptiveLBNTypeConstants
///@{
static Constant PSQ_DS_FI_SLOPE              = 0x1
static Constant PSQ_DS_FI_SLOPE_REACHED_PASS = 0x2
static Constant PSQ_DS_FI_OFFSET             = 0x3
static Constant PSQ_DS_SWEEP_PASS            = 0x4
static Constant PSQ_DS_SWEEP                 = 0x5
static Constant PSQ_DS_APFREQ                = 0x6
static Constant PSQ_DS_DASCALE               = 0x7
///@}

Function dostuff()

	variable sweepNo = 34
	variable headstage = 0
	string sweepbrowser = "SweepBrowser"
	string device 
	string anaFuncParams, key
	variable daScaleStepMinNorm, daScaleStepMaxNorm, emptySCi, dascale, fromRhSuAd

	WAVE/Z numericalValues = BSP_GetLogbookWave(sweepbrowser, LBT_LABNOTEBOOK, LBN_NUMERICAL_VALUES, sweepNumber = sweepNo)
	WAVE/Z textualValues   = BSP_GetLogbookWave(sweepbrowser, LBT_LABNOTEBOOK, LBN_TEXTUAL_VALUES, sweepNumber = sweepNo)

	WAVE/T/Z settings = GetLastSetting(textualValues, sweepNo, ANALYSIS_FUNCTION_PARAMS_LBN, DATA_ACQUISITION_MODE)

	anaFuncParams = settings[headstage]
	
	STRUCT PSQ_DS_DAScaleParams cdp

	cdp.slopePercentage = AFH_GetAnalysisParamNumerical("SlopePercentage", anaFunCParams)
	cdp.maxFrequencyChangePercent = AFH_GetAnalysisParamNumerical("maxFrequencyChangePercent", anaFunCParams)
	cdp.AbsFrequencyMinDistance = AFH_GetAnalysisParamNumerical("AbsFrequencyMinDistance", anaFunCParams)

	key                = CreateAnaFuncLBNKey(PSQ_DA_SCALE, PSQ_FMT_LBN_DA_AT_MIN_DASCALE_NORM, query = 1)
	cdp.daScaleStepMinNorm = GetLastSettingIndepSCI(numericalValues, sweepNo, key, headstage, UNKNOWN_MODE)

	key                = CreateAnaFuncLBNKey(PSQ_DA_SCALE, PSQ_FMT_LBN_DA_AT_MAX_DASCALE_NORM, query = 1)
	cdp.daScaleStepMaxNorm = GetLastSettingIndepSCI(numericalValues, sweepNo, key, headstage, UNKNOWN_MODE)

	ASSERT(MIES_PSQ#PSQ_DS_DAScaleParamsAreFinite(cdp), "Invalid cdp values")
	
	print cdp

	fromRhSuAd = 0

	[WAVE DAScales, emptySCI] = MIES_PSQ#PSQ_DS_GetLabnotebookData(numericalValues, textualValues, sweepNo, headstage, PSQ_DS_DASCALE, filterPassing = 1, fromRhSuAd = fromRhSuAd)
	[WAVE apfreq, emptySCI] = MIES_PSQ#PSQ_DS_GetLabnotebookData(numericalValues, textualValues, sweepNo, headstage, PSQ_DS_APFREQ, filterPassing = 1, fromRhSuAd = fromRhSuAd)
	[WAVE fiSlope, emptySCI] = MIES_PSQ#PSQ_DS_GetLabnotebookData(numericalValues, textualValues, sweepNo, headstage, PSQ_DS_FI_SLOPE, filterPassing = 1, fromRhSuAd = fromRhSuAd)
	[WAVE fiOffset, emptySCI] = MIES_PSQ#PSQ_DS_GetLabnotebookData(numericalValues, textualValues, sweepNo, headstage, PSQ_DS_FI_OFFSET, filterPassing = 1, fromRhSuAd = fromRhSuAd)

	variable numEntriesToKeep = 9 // RhSuAdd

	Redimension/N=(numEntriesToKeep) apfreq, DAScales

	Redimension/N=(numEntriesToKeep - 1) fiSlope, fiOffset

	print apfreq, DAScales, fiSlope, fiOffset

	WAVE/Z futureDASCales = MIES_PSQ#PSQ_DS_GatherOvershootCorrection(cdp, apFreq, DAScales, $"")
	
	print futureDASCales
	
	dascale = MIES_PSQ#PSQ_DS_CalculateDAScale(cdp, fiOffset[Inf], fiSlope[Inf], DAScales[Inf], apfreq[Inf])
	
	print dascale
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant