The macro below is from Dimitry Chernyshov et al, Acta A77, 2021, 497 https://journals.iucr.org/paper?S2053273321007506 for flat plate area detectors. There's a minor modification relative to the published macro to avoid Sqrt of negative numbers.
macro pkshape_DC1(pka, pkav, pkb, pkbv, pkc, pkcv) 'Chernyshov Acta A77, 2021, 497 https://journals.iucr.org/paper?S2053273321007506 'Modified so fwhm stays positive, changed parameter names to avoid names restricted for cell parameters { #m_argu pka #m_argu pkb #m_argu pkc If_Prm_Eqn_Rpt(pka, pkav, min -1 max 2 val_on_continue = Rand(-0.01, 0.01);) If_Prm_Eqn_Rpt(pkb, pkbv, min -1 max 2 val_on_continue = Rand(-0.01, 0.01);) If_Prm_Eqn_Rpt(pkc, pkcv, min -1 max 2 val_on_continue = Rand(0.001, 0.01);) gauss_fwhm = Sqrt(Max(CeV(pka,pkav)*Cos(2*Th)^4 + CeV(pkb,pkbv)*Cos(2*Th)^2+CeV(pkc,pkcv),0.0001)); }