コード例 #1
0
def test_complex_reg_av(test_params):
    calc = Calc(intvl_out='ann',
                dtype_out_time='reg.av',
                region=[sahel],
                **test_params)
    calc.compute()
    _test_files_and_attrs(calc, 'reg.av')
コード例 #2
0
def test_simple_reg_ts(test_params):
    calc = Calc(intvl_out='ann',
                dtype_out_time='reg.ts',
                region=[globe],
                **test_params)
    calc.compute()
    _test_files_and_attrs(calc, 'reg.ts')
コード例 #3
0
 def test_monthly_ts(self):
     calc_int = CalcInterface(intvl_out=1,
                              dtype_out_time='ts',
                              **self.test_params)
     calc = Calc(calc_int)
     calc.compute()
     assert isfile(calc.path_out['ts'])
     assert isfile(calc.path_tar_out)
コード例 #4
0
 def test_seasonal_mean(self):
     calc_int = CalcInterface(intvl_out='djf',
                              dtype_out_time='av',
                              **self.test_params)
     calc = Calc(calc_int)
     calc.compute()
     assert isfile(calc.path_out['av'])
     assert isfile(calc.path_tar_out)
コード例 #5
0
 def test_simple_reg_av(self):
     calc_int = CalcInterface(intvl_out='ann',
                              dtype_out_time='reg.av',
                              region=[globe],
                              **self.test_params)
     calc = Calc(calc_int)
     calc.compute()
     assert isfile(calc.path_out['reg.av'])
     assert isfile(calc.path_tar_out)
コード例 #6
0
def test_compute_pressure_thicknesses():
    calc = Calc(intvl_out='ann',
                dtype_out_time='av',
                var=dp,
                proj=example_proj,
                model=example_model,
                run=example_run,
                date_range=('0006', '0006'),
                intvl_in='monthly',
                dtype_in_time='ts',
                dtype_in_vert='sigma',
                dtype_out_vert=None)
    calc.compute()
    _test_files_and_attrs(calc, 'av')
    _clean_test_direcs()
コード例 #7
0
def test_calc_object_no_time_options(dtype_out_time):
    test_params_not_time_defined['dtype_out_time'] = dtype_out_time
    calc = Calc(**test_params_not_time_defined)
    if isinstance(dtype_out_time, list):
        assert calc.dtype_out_time == tuple(dtype_out_time)
    else:
        assert calc.dtype_out_time == tuple([dtype_out_time])
コード例 #8
0
def test_calc_object_time_options():
    time_options = ['av', 'std', 'ts', 'reg.av', 'reg.std', 'reg.ts']
    for i in range(1, len(time_options) + 1):
        for time_option in list(itertools.permutations(time_options, i)):
            if time_option != ('None', ):
                test_params_not_time_defined['dtype_out_time'] = time_option
                with pytest.raises(ValueError):
                    Calc(**test_params_not_time_defined)
コード例 #9
0
def test_recursive_calculation(recursive_test_params):
    basic_params, recursive_params = recursive_test_params

    calc = Calc(intvl_out='ann', dtype_out_time='av', **basic_params)
    calc = calc.compute()
    expected = xr.open_dataset(calc.path_out['av'])['condensation_rain']
    _test_files_and_attrs(calc, 'av')

    calc = Calc(intvl_out='ann', dtype_out_time='av', **recursive_params)
    calc = calc.compute()
    result = xr.open_dataset(
        calc.path_out['av'])['recursive_condensation_rain']
    _test_files_and_attrs(calc, 'av')

    xr.testing.assert_equal(expected, result)
コード例 #10
0
def test_recursive_calculation(recursive_test_params):
    basic_params, recursive_params = recursive_test_params

    calc = Calc(intvl_out='ann', dtype_out_time='av', **basic_params)
    calc = calc.compute()
    with xr.set_options(enable_cftimeindex=True):
        expected = xr.open_dataset(calc.path_out['av'],
                                   autoclose=True)['condensation_rain']
    _test_files_and_attrs(calc, 'av')

    calc = Calc(intvl_out='ann', dtype_out_time='av', **recursive_params)
    calc = calc.compute()
    with xr.set_options(enable_cftimeindex=True):
        result = xr.open_dataset(calc.path_out['av'],
                                 autoclose=True)['recursive_condensation_rain']
    _test_files_and_attrs(calc, 'av')

    xr.testing.assert_equal(expected, result)
コード例 #11
0
def test_calc_object_string_time_options(dtype_out_time):
    test_params_not_time_defined['dtype_out_time'] = dtype_out_time
    with pytest.raises(ValueError):
        Calc(**test_params_not_time_defined)
コード例 #12
0
def test_monthly_ts(test_params):
    calc = Calc(intvl_out=1, dtype_out_time='ts', **test_params)
    calc.compute()
    _test_files_and_attrs(calc, 'ts')
コード例 #13
0
def test_seasonal_ts(test_params):
    calc = Calc(intvl_out='djf', dtype_out_time='ts', **test_params)
    calc.compute()
    _test_files_and_attrs(calc, 'ts')
コード例 #14
0
def test_annual_mean(test_params):
    calc = Calc(intvl_out='ann', dtype_out_time='av', **test_params)
    calc.compute()
    _test_files_and_attrs(calc, 'av')