def process(self, obj, reprocess_quality_flag=True, quality_control_mode=QUALITY_CONTROL_MODE_ANALYZE_AND_APPLY, arguments=None): if obj != None and _polarvolume.isPolarVolume(obj): import _detectionrange ascending = obj.isAscendingScans() drgenerator = _detectionrange.new() maxscan = obj.getScanWithMaxDistance() if reprocess_quality_flag or not maxscan.findQualityFieldByHowTask( "se.smhi.detector.poo"): # We want to have same resolution as maxdistance scan since we are going to add the poo-field to it # The second argument is dbz threshold, modify it accordingly topfield = drgenerator.top(obj, maxscan.rscale, -40.0) # Topfield is a scan filterfield = drgenerator.filter( topfield) # filterfield is a scan poofield = drgenerator.analyze( filterfield, 60, 0.1, 0.35) # poofield is a quality field, add it to maxscan maxscan.addOrReplaceQualityField(poofield) if ascending: obj.sortByElevations(1) return obj, self.getQualityFields()
def test_top(self): dr = _detectionrange.new() o = _raveio.open(self.FIXTURE_VOLUME) result = dr.top(o.object, 2000, -40.0) os = _raveio.new() os.filename = self.TEMPORARY_FILE os.object = result os.save()
def test_analyze_and_write(self): dr = _detectionrange.new() o = _raveio.open(self.FIXTURE_VOLUME) topfield = dr.top(o.object, 2000, -40.0) filterfield = dr.filter(topfield) result = dr.analyze(filterfield, 60, 0.1, 0.5) param = _polarscanparam.fromField(result) scan = _polarscan.new() scan.addParameter(param) os = _raveio.new() os.filename = self.TEMPORARY_FILE os.object = scan os.save()
def test_analyze(self): dr = _detectionrange.new() o = _raveio.open(self.FIXTURE_VOLUME) topfield = dr.top(o.object, 2000, -40.0) filterfield = dr.filter(topfield) result = dr.analyze(filterfield, 60, 0.1, 0.5) self.assertNotEqual(-1, str(type(result)).find("RaveFieldCore")) self.assertEqual(120, result.xsize) self.assertEqual(420, result.ysize) self.assertEqual("se.smhi.detector.poo", result.getAttribute("how/task")) self.assertAlmostEqual(1.0, result.getAttribute("what/offset"), 4) self.assertAlmostEqual(-1.0 / 255.0, result.getAttribute("what/gain"), 4) self.assertAlmostEqual(255.0, result.getAttribute("what/nodata"), 4) self.assertAlmostEqual(255.0, result.getAttribute("what/undetect"), 4) self.assertEqual("DR", result.getAttribute("what/quantity"))
def test_analysis_maxrange(self): obj = _detectionrange.new() self.assertAlmostEqual(240000.0, obj.analysis_maxrange, 4) obj.analysis_maxrange = 250000.0 self.assertAlmostEqual(250000.0, obj.analysis_maxrange, 4)
def test_analysis_minrange(self): obj = _detectionrange.new() self.assertAlmostEqual(10000.0, obj.analysis_minrange, 4) obj.analysis_minrange = 12000.0 self.assertAlmostEqual(12000.0, obj.analysis_minrange, 4)
def test_lookupPath(self): obj = _detectionrange.new() self.assertEqual("/tmp", obj.lookupPath) obj.lookupPath = "/tmp/that" self.assertEqual("/tmp/that", obj.lookupPath)
def test_new(self): obj = _detectionrange.new() self.assertNotEqual(-1, str(type(obj)).find("DetectionRangeCore"))