Ticket 684: "Analyze only" with bropo creates invalid DBZH datafield mats_featurebranch jenkins-bRopo-46
authorMats Vernersson <mats.vernersson@smhi.se>
Tue, 21 Feb 2017 12:20:26 +0000 (13:20 +0100)
committerMats Vernersson <mats.vernersson@smhi.se>
Tue, 21 Feb 2017 12:20:26 +0000 (13:20 +0100)
The function PadNrays in ropo_realtime.py (accidentally?) modified the input scan, instead of just applying the change to the newscan-parameter that is returned from the function. This change caused the the DBZH datafield of the original scan to be modified. The only caused problems with the use of "analyze only", since the modified datafield was otherwise overwritten again with a corrected one.

The solve this, a clone of the datafield is used instead of the original field when making the modification.

pyropo/ropo_realtime.py
test/pytest/ropo_quality_plugin_test.py

index 7133ea5..d06e145 100644 (file)
@@ -264,7 +264,7 @@ def PadNrays(scan, options):
 
     newscan = _polarscan.new()
 
-    dbzh = scan.getParameter("DBZH")
+    dbzh = scan.getParameter("DBZH").clone()
     data = dbzh.getData()
     toprays = data[0:gates, ]
     botrays = data[scan.nrays - gates:, ]
index 4062dfa..09f4a5f 100644 (file)
@@ -27,10 +27,8 @@ import unittest
 
 import _raveio
 import ropo_quality_plugin
-import rave_quality_plugin
-import os, string
-import _rave
-import numpy
+
+from rave_quality_plugin import QUALITY_CONTROL_MODE_ANALYZE_AND_APPLY, QUALITY_CONTROL_MODE_ANALYZE
 
 class ropo_quality_plugin_test(unittest.TestCase):
   SCAN_FIXTURE = "fixtures/scan_sevil_20100702T113200Z.h5"
@@ -78,11 +76,13 @@ class ropo_quality_plugin_test(unittest.TestCase):
   def test_process_volume(self):
     volume = _raveio.open(self.VOLUME_FIXTURE).object
 
-    result = self.classUnderTest.process(volume)
+    result = self.classUnderTest.process(volume, quality_control_mode=QUALITY_CONTROL_MODE_ANALYZE_AND_APPLY)
     
     for i in range(result.getNumberOfScans()):
       scan = result.getScan(i)
       self.assertTrue(scan.getQualityFieldByHowTask("fi.fmi.ropo.detector.classification") != None)
+      self.assertEquals(result.getScanWithMaxDistance().getParameter('DBZH').getData().shape[0], 361, "Wrong size of data field")
+      self.assertEquals(result.getScanWithMaxDistance().getParameter('DBZH').getData().shape[1], 500, "Wrong size of data field")
 
   def test_process_volume_reprocess_true(self):
     volume = _raveio.open(self.VOLUME_FIXTURE).object
@@ -123,4 +123,15 @@ class ropo_quality_plugin_test(unittest.TestCase):
     self.assertEquals(len(fields), len(fields2))
     for i in range(len(fields)):
       self.assertTrue(fields[i] == fields2[i])
+      
+  def test_process_volume_analyze_only(self):
+    volume = _raveio.open(self.VOLUME_FIXTURE).object
+
+    result = self.classUnderTest.process(volume, quality_control_mode=QUALITY_CONTROL_MODE_ANALYZE)
+    
+    for i in range(result.getNumberOfScans()):
+      scan = result.getScan(i)
+      self.assertTrue(scan.getQualityFieldByHowTask("fi.fmi.ropo.detector.classification") != None)
+      self.assertEquals(result.getScanWithMaxDistance().getParameter('DBZH').getData().shape[0], 361, "Wrong size of data field")
+      self.assertEquals(result.getScanWithMaxDistance().getParameter('DBZH').getData().shape[1], 500, "Wrong size of data field")