Skip to content
Snippets Groups Projects
Commit 2d1ba09f authored by Nico Vermaas's avatar Nico Vermaas
Browse files

bugfix, didn't consider rfi_percent = 0 a valid RFI (I'm not sure why)

parent 98a0b6e9
No related branches found
No related tags found
1 merge request!326bugfix, didn't consider rfi_percent = 0 a valid RFI
Pipeline #64015 passed
...@@ -13,7 +13,7 @@ DATABASES = { ...@@ -13,7 +13,7 @@ DATABASES = {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'atdb_admin', 'USER': 'atdb_admin',
'PASSWORD': 'atdb123', 'PASSWORD': 'atdb123',
'NAME': 'atdb_ldv_5oct2023', 'NAME': 'atdb_ldv_20nov2023',
'HOST': 'localhost', 'HOST': 'localhost',
'PORT': '5432', 'PORT': '5432',
}, },
......
...@@ -36,7 +36,7 @@ def calculate_qualities(task, tasks_for_this_sasid, quality_thresholds): ...@@ -36,7 +36,7 @@ def calculate_qualities(task, tasks_for_this_sasid, quality_thresholds):
rfi_percent = float(record['rfi_percent']) rfi_percent = float(record['rfi_percent'])
if rfi_percent > 0: if rfi_percent >= 0:
quality = "good" quality = "good"
if rfi_percent >= quality_thresholds['moderate']: if rfi_percent >= quality_thresholds['moderate']:
quality = "moderate" quality = "moderate"
...@@ -96,11 +96,12 @@ def calculate_qualities(task, tasks_for_this_sasid, quality_thresholds): ...@@ -96,11 +96,12 @@ def calculate_qualities(task, tasks_for_this_sasid, quality_thresholds):
return quality_sasid return quality_sasid
except Exception as error: except Exception as error:
logger.info(error) logger.error(error)
# --- main function body --- # --- main function body ---
# calculate the quality for this task # calculate the quality for this task
try:
calculated_quality_task = calculate_quality_task(task) calculated_quality_task = calculate_quality_task(task)
# store the result in task.calculated_qualities (not yet saved in the database) # store the result in task.calculated_qualities (not yet saved in the database)
...@@ -116,4 +117,7 @@ def calculate_qualities(task, tasks_for_this_sasid, quality_thresholds): ...@@ -116,4 +117,7 @@ def calculate_qualities(task, tasks_for_this_sasid, quality_thresholds):
# store the result in task.calculated_qualities (not yet saved in the database) # store the result in task.calculated_qualities (not yet saved in the database)
qualities['per_sasid'] = calculated_quality_sasid qualities['per_sasid'] = calculated_quality_sasid
except Exception as error:
logger.error(error)
return qualities return qualities
\ No newline at end of file
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
{% include 'taskdatabase/pagination.html' %} {% include 'taskdatabase/pagination.html' %}
</div> </div>
</div> </div>
<p class="footer"> Version 17 Oct 2023 <p class="footer"> Version 20 Nov 2023
</div> </div>
{% include 'taskdatabase/refresh.html' %} {% include 'taskdatabase/refresh.html' %}
......
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
data-popup-url="{% url 'inspection-plots-sasid' task.id False %}"> data-popup-url="{% url 'inspection-plots-sasid' task.id False %}">
<img src="{% static 'taskdatabase/surfsara.jpg' %}" height="20" alt="inspection plots"> <img src="{% static 'taskdatabase/surfsara.jpg' %}" height="20" alt="inspection plots">
</a>&nbsp; </a>&nbsp;
<!--
<!-- <a class="open-modal btn btn-warning btn-sm" <a class="open-modal btn btn-warning btn-sm"
data-popup-url="{% url 'inspection-plots-sasid' task.id True %}"> data-popup-url="{% url 'inspection-plots-sasid' task.id True %}">
<i class="fas fa-images"></i> <i class="fas fa-images"></i>
</a>&nbsp;--> </a>&nbsp;
-->
</td> </td>
{% else %} {% else %}
<td>-</td> <td>-</td>
......
...@@ -33,7 +33,7 @@ class TestCalculatedQualities(TestCase): ...@@ -33,7 +33,7 @@ class TestCalculatedQualities(TestCase):
workflow_requantisation = Workflow(workflow_uri="psrfits_requantisation") workflow_requantisation = Workflow(workflow_uri="psrfits_requantisation")
workflow_requantisation.save() workflow_requantisation.save()
# rfi_percent=0, this task should be skipped in the quality calculations # rfi_percent=0
Task.objects.get_or_create(sas_id=54321, status='processed', outputs=outputs.default_summary_flavour_with_rfi_percent_zero_1, workflow=workflow_requantisation) Task.objects.get_or_create(sas_id=54321, status='processed', outputs=outputs.default_summary_flavour_with_rfi_percent_zero_1, workflow=workflow_requantisation)
# rfi_percent 11,22,31,52 # rfi_percent 11,22,31,52
...@@ -74,7 +74,7 @@ class TestCalculatedQualities(TestCase): ...@@ -74,7 +74,7 @@ class TestCalculatedQualities(TestCase):
if task.calculated_qualities['per_sasid']: if task.calculated_qualities['per_sasid']:
count += 1 count += 1
self.assertEqual(count,5) self.assertEqual(count,6)
def test_calculated_qualities(self): def test_calculated_qualities(self):
...@@ -113,7 +113,7 @@ class TestCalculatedQualities(TestCase): ...@@ -113,7 +113,7 @@ class TestCalculatedQualities(TestCase):
# ignore the tasks that have no calculated quality. # ignore the tasks that have no calculated quality.
pass pass
self.assertEqual(quality_values,{'poor': 1, 'moderate': 2, 'good': 1}) self.assertEqual(quality_values,{'poor': 1, 'moderate': 2, 'good': 2})
# not 90% = good, and not >50% = poor so 'moderate' # not 90% = good, and not >50% = poor so 'moderate'
self.assertEqual(quality_per_sasid,'moderate') self.assertEqual(quality_per_sasid,'moderate')
...@@ -163,7 +163,7 @@ class TestCalculatedQualities(TestCase): ...@@ -163,7 +163,7 @@ class TestCalculatedQualities(TestCase):
# rfi_percentages are 11,22,31,52 for the tasks of this sasid # rfi_percentages are 11,22,31,52 for the tasks of this sasid
# with the optimistic parameters that means that the first 3 are 'good', and last one is moderate. No poor # with the optimistic parameters that means that the first 3 are 'good', and last one is moderate. No poor
self.assertEqual(quality_values,{'poor': 0, 'moderate': 1, 'good': 3}) self.assertEqual(quality_values,{'poor': 0, 'moderate': 1, 'good': 4})
# 3 out of 4 are 'good', 75% is above the 50% threshold, so 'good' # 3 out of 4 are 'good', 75% is above the 50% threshold, so 'good'
self.assertEqual(quality_per_sasid,'good') self.assertEqual(quality_per_sasid,'good')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment