コード例 #1
0
    def test_interpolate_ked_r_cellsize_1000_from_100(self):
        aggregatefile = r'24uur_20170223080000.h5'
        calibratefile = r'RAD_TF2400_U_20170223080000.h5'
        aggregatefile = os.path.join(testconfig.DATADIR, aggregatefile)
        calibratefile = os.path.join(testconfig.DATADIR, calibratefile)
        cal = Calibrator(
            aggregatefile=aggregatefile,
            calibratefile=calibratefile,
            areamaskfile=testconfig.AREAMASKFILE,
            )

        # resample to 100 x 100 cellsize
        cal.resample(to_cellsize=[100., 100.])

        # interpolate
        cal.interpolate(method=ked_r,
            to_cellsize=[1000., 1000.],
            )

        # resample back to 1000 x 1000 cellsize
        cal.resample(to_cellsize=[1000., 1000.])

        # save
        resultfile = os.path.join(testconfig.RESULTDIR,
            'ked_r_cellsize_1000_from_100_20170223080000.h5')
        cal.save(resultfile=resultfile)
        assert (cal.result is not None) and ('calibrate' in cal.result)
コード例 #2
0
 def test_radar_for_locations(self):
     aggregatefile = r'24uur_20170223080000.h5'
     calibratefile = r'RAD_TF2400_U_20170223080000.h5'
     aggregatefile = os.path.join(testconfig.DATADIR, aggregatefile)
     calibratefile = os.path.join(testconfig.DATADIR, calibratefile)
     cal = Calibrator(
         aggregatefile=aggregatefile,
         calibratefile=calibratefile,
         )
     x, y, z, radar = cal.get_radar_for_locations()
     assert len(x) == len(y) == len(z) == len(radar) == 87
コード例 #3
0
 def test_rainstations_from_calibrate(self):
     aggregatefile = r'24uur_20170223080000.h5'
     calibratefile = r'RAD_TF2400_U_20170223080000.h5'
     aggregatefile = os.path.join(testconfig.DATADIR, aggregatefile)
     calibratefile = os.path.join(testconfig.DATADIR, calibratefile)
     cal = Calibrator(
         aggregatefile=aggregatefile,
         calibratefile=calibratefile,
         )
     assert cal.number_of_stations == 87
コード例 #4
0
 def test_rainstations_from_file(self):
     aggregatefile = r'24uur_20170223080000.h5'
     rainstationsfile = r'grounddata.json'
     aggregatefile = os.path.join(testconfig.DATADIR, aggregatefile)
     rainstationsfile = os.path.join(testconfig.DATADIR, rainstationsfile)
     cal = Calibrator(
         aggregatefile=aggregatefile,
         rainstationsfile=rainstationsfile,
         )
     assert cal.number_of_stations == 0
コード例 #5
0
def calibrate(**kwargs):
    # calibrator instance
    calibrator_kwargs = {
        'aggregatefile': kwargs['aggregatefile'],
        'calibratefile': kwargs['calibratefile'],
        'rainstationsfile': kwargs['rainstationsfile'],
        'areamaskfile': kwargs['areamaskfile'],
    }
    cal = Calibrator(**calibrator_kwargs)

    # perform calibration by interpolation
    interpolation_methods = {
        'ked': ked,
        'ked_r': ked_r,
        'idw': idw,
    }
    interpolate_kwargs = {
        'method': interpolation_methods[kwargs['method']],
        'to_cellsize': kwargs['cellsize'],
        'factor_bounds': kwargs['factor_bounds'],
    }

    cal.interpolate(**interpolate_kwargs)
    if cal.result is None:
        log.warning('no result, exiting')
        return

    # save result to HDF5 file
    resultfile = kwargs['resultfile']
    cal.save(resultfile)
コード例 #6
0
 def test_interpolate_ked_r_cellsize_2000(self):
     aggregatefile = r'24uur_20170223080000.h5'
     calibratefile = r'RAD_TF2400_U_20170223080000.h5'
     aggregatefile = os.path.join(testconfig.DATADIR, aggregatefile)
     calibratefile = os.path.join(testconfig.DATADIR, calibratefile)
     cal = Calibrator(
         aggregatefile=aggregatefile,
         calibratefile=calibratefile,
         )
     cal.interpolate(method=ked_r, to_cellsize=[2000., 2000.])
     resultfile = os.path.join(testconfig.RESULTDIR,
         'ked_r_cellsize_2000_20170223080000.h5')
     cal.save(resultfile=resultfile)
     assert (cal.result is not None) and ('calibrate' in cal.result)