density = np.load(densityCache)['density'] with open(PHOTROOT, 'rb') as f: HUGSPhotometry = pkl.load(f)[1] color = HUGSPhotometry["F275W"] - HUGSPhotometry["F814W"] mag = HUGSPhotometry["F814W"] HUGSPhotometry['density'] = normalize_density_magBin(color, mag, density, binSize=0.3)