Пример #1
0
    def test_read_radolan_binary_array(self):
        filename = 'radolan/misc/raa01-rw_10000-1408030950-dwd---bin.gz'
        rw_file = wrl.util.get_wradlib_data_file(filename)
        rw_fid = radolan.get_radolan_filehandle(rw_file)
        header = radolan.read_radolan_header(rw_fid)
        attrs = radolan.parse_DWD_quant_composite_header(header)
        data = radolan.read_radolan_binary_array(rw_fid, attrs['datasize'])
        self.assertEqual(len(data), attrs['datasize'])

        rw_fid = radolan.get_radolan_filehandle(rw_file)
        header = radolan.read_radolan_header(rw_fid)
        attrs = radolan.parse_DWD_quant_composite_header(header)
        self.assertRaises(
            IOError, lambda: radolan.read_radolan_binary_array(
                rw_fid, attrs['datasize'] + 10))
Пример #2
0
 def test_decode_radolan_runlength_array(self):
     filename = 'radolan/misc/raa00-pc_10015-1408030905-dwd---bin.gz'
     pg_file = wrl.util.get_wradlib_data_file(filename)
     pg_fid = radolan.get_radolan_filehandle(pg_file)
     header = radolan.read_radolan_header(pg_fid)
     attrs = radolan.parse_DWD_quant_composite_header(header)
     data = radolan.read_radolan_binary_array(pg_fid, attrs['datasize'])
     attrs['nodataflag'] = 255
     arr = radolan.decode_radolan_runlength_array(data, attrs)
     self.assertEqual(arr.shape, (460, 460))
Пример #3
0
    def test_parse_DWD_quant_composite_header(self):
        rx_header = ('RW030950100000814BY1620130VS 3SW   2.13.1PR E-01INT  60'
                     'GP 900x 900MS 58<boo,ros,emd,hnr,pro,ess,asd,neu,nhb,'
                     'oft,tur,isn,fbg,mem>')
        test_rx = {
            'maxrange':
            '150 km',
            'radarlocations': [
                'boo', 'ros', 'emd', 'hnr', 'pro', 'ess', 'asd', 'neu', 'nhb',
                'oft', 'tur', 'isn', 'fbg', 'mem'
            ],
            'nrow':
            900,
            'intervalseconds':
            3600,
            'precision':
            0.1,
            'datetime':
            datetime.datetime(2014, 8, 3, 9, 50),
            'ncol':
            900,
            'radolanversion':
            '2.13.1',
            'producttype':
            'RW',
            'radarid':
            '10000',
            'datasize':
            1620001,
        }

        pg_header = ('PG030905100000814BY20042LV 6  1.0 19.0 28.0 37.0 46.0 '
                     '55.0CS0MX 0MS 82<boo,ros,emd,hnr,pro,ess,asd,neu,nhb,'
                     'oft,tur,isn,fbg,mem,czbrd> are used, BG460460')
        test_pg = {
            'radarlocations': [
                'boo', 'ros', 'emd', 'hnr', 'pro', 'ess', 'asd', 'neu', 'nhb',
                'oft', 'tur', 'isn', 'fbg', 'mem', 'czbrd'
            ],
            'nrow':
            460,
            'level': [1., 19., 28., 37., 46., 55.],
            'datetime':
            datetime.datetime(2014, 8, 3, 9, 5),
            'ncol':
            460,
            'producttype':
            'PG',
            'radarid':
            '10000',
            'nlevel':
            6,
            'indicator':
            'near ground level',
            'imagecount':
            0,
            'datasize':
            19889
        }

        rq_header = ('RQ210945100000517BY1620162VS 2SW 1.7.2PR E-01'
                     'INT 60GP 900x 900VV 0MF 00000002QN 001'
                     'MS 67<bln,drs,eis,emd,ess,fbg,fld,fra,ham,han,muc,'
                     'neu,nhb,ros,tur,umd>')

        test_rq = {
            'producttype':
            'RQ',
            'datetime':
            datetime.datetime(2017, 5, 21, 9, 45),
            'radarid':
            '10000',
            'datasize':
            1620008,
            'maxrange':
            '128 km',
            'radolanversion':
            '1.7.2',
            'precision':
            0.1,
            'intervalseconds':
            3600,
            'nrow':
            900,
            'ncol':
            900,
            'radarlocations': [
                'bln', 'drs', 'eis', 'emd', 'ess', 'fbg', 'fld', 'fra', 'ham',
                'han', 'muc', 'neu', 'nhb', 'ros', 'tur', 'umd'
            ],
            'predictiontime':
            0,
            'moduleflag':
            2,
            'quantification':
            1
        }

        rx = radolan.parse_DWD_quant_composite_header(rx_header)
        pg = radolan.parse_DWD_quant_composite_header(pg_header)
        rq = radolan.parse_DWD_quant_composite_header(rq_header)

        for key, value in rx.items():
            self.assertEqual(value, test_rx[key])
        for key, value in pg.items():
            if type(value) == np.ndarray:
                self.assertTrue(np.allclose(value, test_pg[key]))
            else:
                self.assertEqual(value, test_pg[key])
        for key, value in rq.items():
            if type(value) == np.ndarray:
                self.assertTrue(np.allclose(value, test_rq[key]))
            else:
                self.assertEqual(value, test_rq[key])