<s> import unittest <EOL> import datetime <EOL> import os <EOL> from ocw import dataset_processor as dp <EOL> from ocw import dataset as ds <EOL> from ocw . data_source import local <EOL> import numpy as np <EOL> import numpy . ma as ma <EOL> import logging <EOL> logging . basicConfig ( level = logging . CRITICAL ) <EOL> class TestEnsemble ( unittest . TestCase ) : <EOL> def test_unequal_dataset_shapes ( self ) : <EOL> self . ten_year_dataset = ten_year_monthly_dataset ( ) <EOL> self . two_year_dataset = two_year_daily_dataset ( ) <EOL> with self . assertRaises ( ValueError ) : <EOL> self . ensemble_dataset = dp . ensemble ( [ self . ten_year_dataset , self . two_year_dataset ] ) <EOL> def test_ensemble_logic ( self ) : <EOL> self . datasets = [ ] <EOL> self . datasets . append ( build_ten_cube_dataset ( <NUM_LIT:1> ) ) <EOL> self . datasets . append ( build_ten_cube_dataset ( <NUM_LIT:2> ) ) <EOL> self . three = build_ten_cube_dataset ( <NUM_LIT:3> ) <EOL> self . datasets . append ( self . three ) <EOL> self . datasets . append ( build_ten_cube_dataset ( <NUM_LIT:4> ) ) <EOL> self . datasets . append ( build_ten_cube_dataset ( <NUM_LIT:5> ) ) <EOL> self . ensemble = dp . ensemble ( self . datasets ) <EOL> self . ensemble_flat = self . ensemble . values . flatten ( ) <EOL> self . three_flat = self . three . values . flatten ( ) <EOL> np . testing . assert_array_equal ( self . ensemble_flat , self . three_flat ) <EOL> def test_ensemble_name ( self ) : <EOL> self . ensemble_dataset_name = "<STR_LIT>" <EOL> self . datasets = [ ] <EOL> self . datasets . append ( build_ten_cube_dataset ( <NUM_LIT:1> ) ) <EOL> self . datasets . append ( build_ten_cube_dataset ( <NUM_LIT:2> ) ) <EOL> self . ensemble = dp . ensemble ( self . datasets ) <EOL> self . assertEquals ( self . ensemble . name , self . ensemble_dataset_name ) <EOL> class TestTemporalRebin ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . ten_year_monthly_dataset = ten_year_monthly_dataset ( ) <EOL> self . ten_year_annual_times = np . array ( [ datetime . datetime ( year , <NUM_LIT:7> , <NUM_LIT:2> ) for year in range ( <NUM_LIT> , <NUM_LIT> ) ] ) <EOL> self . two_years_daily_dataset = two_year_daily_dataset ( ) <EOL> def test_monthly_to_annual_rebin ( self ) : <EOL> annual_dataset = dp . temporal_rebin ( self . ten_year_monthly_dataset , "<STR_LIT>" ) <EOL> np . testing . assert_array_equal ( annual_dataset . times , self . ten_year_annual_times ) <EOL> def test_monthly_to_full_rebin ( self ) : <EOL> full_dataset = dp . temporal_rebin ( self . ten_year_monthly_dataset , "<STR_LIT>" ) <EOL> full_times = [ datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ] <EOL> self . assertEqual ( full_dataset . times , full_times ) <EOL> def test_daily_to_monthly_rebin ( self ) : <EOL> """<STR_LIT>""" <EOL> monthly_dataset = dp . temporal_rebin ( self . two_years_daily_dataset , "<STR_LIT>" ) <EOL> bins = list ( set ( [ datetime . datetime ( time_reading . year , time_reading . month , <NUM_LIT:15> ) for time_reading in self . two_years_daily_dataset . times ] ) ) <EOL> bins = np . array ( bins ) <EOL> bins . sort ( ) <EOL> np . testing . assert_array_equal ( monthly_dataset . times , bins ) <EOL> def test_daily_to_annual_rebin ( self ) : <EOL> annual_dataset = dp . temporal_rebin ( self . two_years_daily_dataset , "<STR_LIT>" ) <EOL> bins = list ( set ( [ datetime . datetime ( time_reading . year , <NUM_LIT:7> , <NUM_LIT:2> ) for time_reading in self . two_years_daily_dataset . times ] ) ) <EOL> bins = np . array ( bins ) <EOL> bins . sort ( ) <EOL> np . testing . assert_array_equal ( annual_dataset . times , bins ) <EOL> def test_non_rebin ( self ) : <EOL> """<STR_LIT>""" <EOL> monthly_dataset = dp . temporal_rebin ( self . ten_year_monthly_dataset , "<STR_LIT>" ) <EOL> bins = list ( set ( [ datetime . datetime ( time_reading . year , time_reading . month , <NUM_LIT:15> ) for time_reading in self . ten_year_monthly_dataset . times ] ) ) <EOL> bins = np . array ( bins ) <EOL> bins . sort ( ) <EOL> np . testing . assert_array_equal ( monthly_dataset . times , bins ) <EOL> def test_variable_propagation ( self ) : <EOL> annual_dataset = dp . temporal_rebin ( self . ten_year_monthly_dataset , <EOL> "<STR_LIT>" ) <EOL> self . assertEquals ( annual_dataset . name , <EOL> self . ten_year_monthly_dataset . name ) <EOL> self . assertEquals ( annual_dataset . variable , <EOL> self . ten_year_monthly_dataset . variable ) <EOL> class TestRcmesSpatialRegrid ( unittest . TestCase ) : <EOL> def test_return_array_shape ( self ) : <EOL> spatial_values = np . ones ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> spatial_values = ma . array ( spatial_values ) <EOL> lat_range = ma . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> lon_range = ma . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> lons , lats = np . meshgrid ( lon_range , lat_range ) <EOL> lats = ma . array ( lats ) <EOL> lons = ma . array ( lons ) <EOL> lat2_range = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:4> ) ) <EOL> lon2_range = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:4> ) ) <EOL> lons2 , lats2 = np . meshgrid ( lon2_range , lat2_range ) <EOL> lats2 = ma . array ( lats2 ) <EOL> lons2 = ma . array ( lons2 ) <EOL> regridded_values = dp . _rcmes_spatial_regrid ( spatial_values , lats , lons , lats2 , lons2 ) <EOL> self . assertEqual ( regridded_values . shape , lats2 . shape ) <EOL> self . assertEqual ( regridded_values . shape , lons2 . shape ) <EOL> class TestSpatialRegrid ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . input_dataset = ten_year_monthly_dataset ( ) <EOL> self . new_lats = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:4> ) ) <EOL> self . new_lons = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:4> ) ) <EOL> self . regridded_dataset = dp . spatial_regrid ( self . input_dataset , self . new_lats , self . new_lons ) <EOL> def test_returned_lats ( self ) : <EOL> np . testing . assert_array_equal ( self . regridded_dataset . lats , self . new_lats ) <EOL> def test_returned_lons ( self ) : <EOL> np . testing . assert_array_equal ( self . regridded_dataset . lons , self . new_lons ) <EOL> def test_shape_of_values ( self ) : <EOL> regridded_data_shape = self . regridded_dataset . values . shape <EOL> expected_data_shape = ( len ( self . input_dataset . times ) , len ( self . new_lats ) , len ( self . new_lons ) ) <EOL> self . assertSequenceEqual ( regridded_data_shape , expected_data_shape ) <EOL> def test_variable_propagation ( self ) : <EOL> self . assertEquals ( self . input_dataset . name , self . regridded_dataset . name ) <EOL> self . assertEquals ( self . input_dataset . variable , self . regridded_dataset . variable ) <EOL> class TestNormalizeDatasetDatetimes ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . monthly_dataset = ten_year_monthly_15th_dataset ( ) <EOL> self . daily_dataset = two_year_daily_2hr_dataset ( ) <EOL> def test_daily ( self ) : <EOL> new_ds = dp . normalize_dataset_datetimes ( self . monthly_dataset , '<STR_LIT>' ) <EOL> self . assertTrue ( all ( x . hour == <NUM_LIT:0> for x in new_ds . times ) ) <EOL> def test_montly ( self ) : <EOL> new_ds = dp . normalize_dataset_datetimes ( self . monthly_dataset , '<STR_LIT>' ) <EOL> self . assertTrue ( all ( x . day == <NUM_LIT:1> for x in new_ds . times ) ) <EOL> class TestSubset ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . target_dataset = ten_year_monthly_dataset ( ) <EOL> self . name = '<STR_LIT:foo>' <EOL> self . subregion = ds . Bounds ( <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> ) <EOL> self . non_exact_spatial_subregion = ds . Bounds ( <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> ) <EOL> self . non_exact_temporal_subregion = ds . Bounds ( <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:15> ) , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:15> ) <EOL> ) <EOL> def test_subset ( self ) : <EOL> subset = dp . subset ( self . subregion , self . target_dataset ) <EOL> self . assertEqual ( subset . lats . shape [ <NUM_LIT:0> ] , <NUM_LIT> ) <EOL> self . assertSequenceEqual ( list ( np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) ) , <EOL> list ( subset . lats ) ) <EOL> self . assertEqual ( subset . lons . shape [ <NUM_LIT:0> ] , <NUM_LIT> ) <EOL> self . assertEqual ( subset . times . shape [ <NUM_LIT:0> ] , <NUM_LIT> ) <EOL> self . assertEqual ( subset . values . shape , ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> def test_subset_name ( self ) : <EOL> subset = dp . subset ( self . subregion , self . target_dataset ) <EOL> self . assertEqual ( subset . name , self . name ) <EOL> def test_subset_name_propagation ( self ) : <EOL> subset_name = '<STR_LIT>' <EOL> subset = dp . subset ( self . subregion , self . target_dataset , subset_name ) <EOL> self . assertEqual ( subset . name , subset_name ) <EOL> def test_subset_using_non_exact_spatial_bounds ( self ) : <EOL> index_slices = dp . _get_subregion_slice_indices ( self . non_exact_spatial_subregion , self . target_dataset ) <EOL> control_index_slices = { "<STR_LIT>" : <NUM_LIT:5> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT:10> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT:12> , <EOL> "<STR_LIT>" : <NUM_LIT> } <EOL> self . assertDictEqual ( index_slices , control_index_slices ) <EOL> def test_subset_using_non_exact_temporal_bounds ( self ) : <EOL> index_slices = dp . _get_subregion_slice_indices ( self . non_exact_temporal_subregion , self . target_dataset ) <EOL> control_index_slices = { "<STR_LIT>" : <NUM_LIT:5> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT:10> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> } <EOL> self . assertDictEqual ( index_slices , control_index_slices ) <EOL> class TestSafeSubset ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> lats = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> ) ) <EOL> lons = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> ) ) <EOL> times = np . array ( [ datetime . datetime ( year , month , <NUM_LIT:1> ) <EOL> for year in range ( <NUM_LIT> , <NUM_LIT> ) <EOL> for month in range ( <NUM_LIT:1> , <NUM_LIT> ) ] ) <EOL> values = np . ones ( [ len ( times ) , len ( lats ) , len ( lons ) ] ) <EOL> self . target_dataset = ds . Dataset ( lats , <EOL> lons , <EOL> times , <EOL> values , <EOL> variable = "<STR_LIT>" , <EOL> units = '<STR_LIT>' , <EOL> name = '<STR_LIT:foo>' ) <EOL> self . spatial_out_of_bounds = ds . Bounds ( <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> ) <EOL> self . temporal_out_of_bounds = ds . Bounds ( <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:15> ) , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:15> ) <EOL> ) <EOL> self . everything_out_of_bounds = ds . Bounds ( <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:15> ) , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:15> ) <EOL> ) <EOL> def test_partial_spatial_overlap ( self ) : <EOL> '''<STR_LIT>''' <EOL> ds = dp . safe_subset ( self . spatial_out_of_bounds , self . target_dataset ) <EOL> spatial_bounds = ds . spatial_boundaries ( ) <EOL> self . assertEquals ( spatial_bounds [ <NUM_LIT:0> ] , - <NUM_LIT> ) <EOL> self . assertEquals ( spatial_bounds [ <NUM_LIT:1> ] , <NUM_LIT> ) <EOL> self . assertEquals ( spatial_bounds [ <NUM_LIT:2> ] , - <NUM_LIT> ) <EOL> self . assertEquals ( spatial_bounds [ <NUM_LIT:3> ] , <NUM_LIT> ) <EOL> def test_partial_temporal_overlap ( self ) : <EOL> '''<STR_LIT>''' <EOL> ds = dp . safe_subset ( self . temporal_out_of_bounds , self . target_dataset ) <EOL> temporal_bounds = ds . time_range ( ) <EOL> start = datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> end = datetime . datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:1> ) <EOL> self . assertEquals ( temporal_bounds [ <NUM_LIT:0> ] , start ) <EOL> self . assertEquals ( temporal_bounds [ <NUM_LIT:1> ] , end ) <EOL> def test_entire_bounds_overlap ( self ) : <EOL> ds = dp . safe_subset ( self . everything_out_of_bounds , self . target_dataset ) <EOL> spatial_bounds = ds . spatial_boundaries ( ) <EOL> temporal_bounds = ds . time_range ( ) <EOL> start = datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> end = datetime . datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:1> ) <EOL> self . assertEquals ( spatial_bounds [ <NUM_LIT:0> ] , - <NUM_LIT> ) <EOL> self . assertEquals ( spatial_bounds [ <NUM_LIT:1> ] , <NUM_LIT> ) <EOL> self . assertEquals ( spatial_bounds [ <NUM_LIT:2> ] , - <NUM_LIT> ) <EOL> self . assertEquals ( spatial_bounds [ <NUM_LIT:3> ] , <NUM_LIT> ) <EOL> self . assertEquals ( temporal_bounds [ <NUM_LIT:0> ] , start ) <EOL> self . assertEquals ( temporal_bounds [ <NUM_LIT:1> ] , end ) <EOL> class TestFailingSubset ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . target_dataset = ten_year_monthly_dataset ( ) <EOL> self . target_dataset . lats = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> self . target_dataset . lons = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> self . subregion = ds . Bounds ( <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> - <NUM_LIT> , <NUM_LIT> , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> ) <EOL> def test_out_of_dataset_bounds_lat_min ( self ) : <EOL> self . subregion . lat_min = - <NUM_LIT> <EOL> with self . assertRaises ( ValueError ) : <EOL> dp . subset ( self . subregion , self . target_dataset ) <EOL> def test_out_of_dataset_bounds_lat_max ( self ) : <EOL> self . subregion . lat_max = <NUM_LIT> <EOL> with self . assertRaises ( ValueError ) : <EOL> dp . subset ( self . subregion , self . target_dataset ) <EOL> def test_out_of_dataset_bounds_lon_min ( self ) : <EOL> self . subregion . lon_min = - <NUM_LIT> <EOL> with self . assertRaises ( ValueError ) : <EOL> dp . subset ( self . subregion , self . target_dataset ) <EOL> def test_out_of_dataset_bounds_lon_max ( self ) : <EOL> self . subregion . lon_max = <NUM_LIT> <EOL> with self . assertRaises ( ValueError ) : <EOL> dp . subset ( self . subregion , self . target_dataset ) <EOL> def test_out_of_dataset_bounds_start ( self ) : <EOL> self . subregion . start = datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> with self . assertRaises ( ValueError ) : <EOL> dp . subset ( self . subregion , self . target_dataset ) <EOL> def test_out_of_dataset_bounds_end ( self ) : <EOL> self . subregion . end = datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> with self . assertRaises ( ValueError ) : <EOL> dp . subset ( self . subregion , self . target_dataset ) <EOL> class TestNetCDFWrite ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . ds = ten_year_monthly_dataset ( ) <EOL> self . file_name = '<STR_LIT>' <EOL> def tearDown ( self ) : <EOL> if os . path . isfile ( self . file_name ) : <EOL> os . remove ( self . file_name ) <EOL> def test_file_write ( self ) : <EOL> dp . write_netcdf ( self . ds , self . file_name ) <EOL> self . assertTrue ( os . path . isfile ( self . file_name ) ) <EOL> def test_that_file_contents_are_valid ( self ) : <EOL> dp . write_netcdf ( self . ds , self . file_name ) <EOL> new_ds = local . load_file ( self . file_name , self . ds . variable ) <EOL> self . assertEqual ( self . ds . variable , new_ds . variable ) <EOL> np . testing . assert_array_equal ( self . ds . lats , new_ds . lats ) <EOL> np . testing . assert_array_equal ( self . ds . lons , new_ds . lons ) <EOL> np . testing . assert_array_equal ( self . ds . times , new_ds . times ) <EOL> np . testing . assert_array_equal ( self . ds . values , new_ds . values ) <EOL> def ten_year_monthly_dataset ( ) : <EOL> lats = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> lons = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> times = np . array ( [ datetime . datetime ( year , month , <NUM_LIT:1> ) for year in range ( <NUM_LIT> , <NUM_LIT> ) for month in range ( <NUM_LIT:1> , <NUM_LIT> ) ] ) <EOL> values = np . ones ( [ len ( times ) , len ( lats ) , len ( lons ) ] ) <EOL> input_dataset = ds . Dataset ( lats , lons , times , values , variable = "<STR_LIT>" , units = '<STR_LIT>' , name = '<STR_LIT:foo>' ) <EOL> return input_dataset <EOL> def ten_year_monthly_15th_dataset ( ) : <EOL> lats = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> lons = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> times = np . array ( [ datetime . datetime ( year , month , <NUM_LIT:1> ) for year in range ( <NUM_LIT> , <NUM_LIT> ) for month in range ( <NUM_LIT:1> , <NUM_LIT> ) ] ) <EOL> values = np . ones ( [ len ( times ) , len ( lats ) , len ( lons ) ] ) <EOL> input_dataset = ds . Dataset ( lats , lons , times , values , variable = "<STR_LIT>" , units = '<STR_LIT>' ) <EOL> return input_dataset <EOL> def two_year_daily_dataset ( ) : <EOL> lats = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> lons = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> times = np . array ( [ datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) + datetime . timedelta ( days = d ) for d in range ( <NUM_LIT> ) ] ) <EOL> values = np . ones ( [ len ( times ) , len ( lats ) , len ( lons ) ] ) <EOL> dataset = ds . Dataset ( lats , lons , times , values , variable = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> return dataset <EOL> def two_year_daily_2hr_dataset ( ) : <EOL> lats = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> lons = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> times = np . array ( [ datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) + datetime . timedelta ( days = d , hours = <NUM_LIT:2> ) for d in range ( <NUM_LIT> ) ] ) <EOL> values = np . ones ( [ len ( times ) , len ( lats ) , len ( lons ) ] ) <EOL> dataset = ds . Dataset ( lats , lons , times , values , variable = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> return dataset <EOL> def build_ten_cube_dataset ( value ) : <EOL> lats = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> lons = np . array ( range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> times = np . array ( [ datetime . datetime ( year , <NUM_LIT:1> , <NUM_LIT:1> ) for year in range ( <NUM_LIT> , <NUM_LIT> ) ] ) <EOL> values = np . ones ( [ len ( times ) , len ( lats ) , len ( lons ) ] ) <EOL> values = values * value <EOL> dataset = ds . Dataset ( lats , lons , times , values ) <EOL> return dataset <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
