rgbs = [(16, 200, 209), (140, 255, 255), (215, 255, 255), (234, 255, 255), (255, 255, 255), (252, 237, 244), (250, 201, 222), (240, 125, 171), (160, 37, 96)]

import numpy
rgbas = [numpy.array(list(rgb) + [255], dtype=numpy.uint8) for rgb in rgbs]

from chimerax.atomic import AtomicStructure
for model in session.models:
	if not isinstance(model, AtomicStructure):
		continue

	for r in model.residues:
		if not r.chain:
			continue
		res_bfactors = r.atoms.bfactors
		bf = res_bfactors.min()
		if res_bfactors.max() != bf:
			continue
		int_bf = int(bf)
		if int_bf != bf or int_bf < 0 or int_bf > 9:
			continue
		r.atoms.colors = rgbas[int_bf-1]

