From ada05dd34bea06b8a0c57fd79486d695a0778854 Mon Sep 17 00:00:00 2001 From: tyrin Date: Sat, 24 May 2025 14:34:21 +0300 Subject: [PATCH] background pixels with contaminated=True are removed from background calculation --- views.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/views.py b/views.py index 00f4bfa..867e03d 100644 --- a/views.py +++ b/views.py @@ -209,7 +209,7 @@ class UpperLimitView(APIView): ) annulus_pixels = Pixel.objects.filter( - hpid__in=annulus_pixel_list, survey__in=survey_numbers + hpid__in=annulus_pixel_list, survey__in=survey_numbers, contaminated=False ) # check contamination @@ -218,9 +218,14 @@ class UpperLimitView(APIView): or annulus_pixels.filter(contaminated=True).exists() ) - if not source_pixels.exists() and not annulus_pixels.exists(): + # exclude contaminated pixels from the background calculations + annulus_pixels = annulus_pixels.exclude(contaminated=True) + + if not source_pixels.exists() or not annulus_pixels.exists(): return Response( - {"detail": "No pixel data for the given survey selection."}, + { + "detail": "No background and/or source pixel data for the given survey selection." + }, status=status.HTTP_404_NOT_FOUND, )