background pixels with contaminated=True are removed from background calculation

This commit is contained in:
Никита Тырин 2025-05-24 14:34:21 +03:00
parent fdc26bc4c4
commit ada05dd34b

View File

@ -209,7 +209,7 @@ class UpperLimitView(APIView):
) )
annulus_pixels = Pixel.objects.filter( 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 # check contamination
@ -218,9 +218,14 @@ class UpperLimitView(APIView):
or annulus_pixels.filter(contaminated=True).exists() 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( 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, status=status.HTTP_404_NOT_FOUND,
) )