diff --git a/views.py b/views.py index 5f99b17..6cf1b62 100644 --- a/views.py +++ b/views.py @@ -412,7 +412,6 @@ class UpperLimitView(APIView): .values("hpid") .annotate( counts=Sum("counts"), - contaminated=Max("contaminated"), ) .order_by("hpid") ) @@ -423,7 +422,14 @@ class UpperLimitView(APIView): # get lists of healpix indices and count values map_healpix_list = [d["hpid"] for d in map_pixels_list] map_counts_list = [d["counts"] for d in map_pixels_list] - map_contaminated_list = [d["contaminated"] for d in map_pixels_list] + + cont_dict = dict( + Pixel.objects.filter(hpid__in=map_healpix_list, survey__in=survey_numbers) + .values_list("hpid", "contaminated") + .distinct() + ) + + map_contaminated_list = [cont_dict[h] for h in map_healpix_list] # set map nside map_nside = 4096