radon_conc_chain = A[:, parameters['nhyper']+parameters['nstate']:]

        b = sampler.chain[:, :, parameters['nhyper']+parameters['nstate']:]

        df_params_chain = pd.DataFrame(data = params_chain, columns=parameters['variable_parameter_names'])


        # calculate net eff and a to c ratio for each row in the chain
        net_effs = []
        a_to_c = []
        for ii in range(len(df_params_chain)):
            pm = {}
            pm.update(parameters)
            for k in df_params_chain.columns:
                pm[k] = df_params_chain.iloc[ii][k]
            ne = tm.calc_detector_efficiency(pm)
            ac = tm.calc_detector_activity_a_to_c_ratio(pm)
            net_effs.append(ne)
            a_to_c.append(ac)
        df_params_chain['net_eff'] = net_effs
        df_params_chain['a_to_c'] = a_to_c
        chains_list.append(df_params_chain)

        # how does the optimised solution look?
        p_mod = dict()
        p_mod.update(parameters)
        p_mod.update(df_params_chain.mean())
        deconv_radon_conc = radon_conc_chain.mean(axis=0)
        from scipy.stats import scoreatpercentile

        dfss['lldmod_opt'] = np.r_[np.NaN,
            
            parameters.pop('transform_radon_timeseries')
            parameters.pop('total_efficiency')
            parameters.pop('total_efficiency_frac_error')
            
            # calibration parameters
            parameters['cal_source_strength'] = source_strength
            parameters['cal_begin'] = cal_begin
            if not site == 'ri':
                parameters['cal_duration'] = (dfss.cal_radon_conc > 0).sum() * 1800.0
            else:
                parameters['cal_duration'] = cal_duration
            
            # check net sensitivity/efficiency
            ne = tm.calc_detector_efficiency(parameters)
            # set eff so that net eff equals expectation
            parameters['eff'] = parameters['eff'] * expected_net_eff / ne
            
            # times relative to injection
            times = dfss.index.to_pydatetime()
            tzero = times[0]
            t = np.array([ (itm-tzero).total_seconds() for itm in times])
            tres = t[1] - t[0]
            # priors on parameters
            variable_parameter_names = 'Q_external', 'Q', 'rs', 'lamp', 't_delay', 'eff'
            parameters['variable_parameter_lower_bounds'] = np.array([0.0, 0.0, 0.0, 0.0, -np.inf, 0.0])
            parameters['variable_parameter_upper_bounds'] = np.array([np.inf, np.inf, 2.0, np.inf, np.inf, np.inf])
            variable_parameters_mu_prior = np.array(
                                    [parameters[k] for k in variable_parameter_names])
            variable_parameters_sigma_prior = np.array([parameters['Q_external'] * 0.02,