#NEWLINE# def _prepare_datasets_for_evaluation( reference , targets , config_data ) : #NEWLINE# #INDENT# '' #NEWLINE# subset = config_data [ 'evaluation' ] . get ( 'subset' , None ) #NEWLINE# temporal_time_delta = config_data [ 'evaluation' ] . get ( 'temporal_time_delta' , None ) #NEWLINE# spatial_regrid_lats = config_data [ 'evaluation' ] . get ( 'spatial_regrid_lats' , None ) #NEWLINE# spatial_regrid_lons = config_data [ 'evaluation' ] . get ( 'spatial_regrid_lons' , None ) #NEWLINE# string_time_delta = 'monthly' #NEWLINE# if ( temporal_time_delta and ( temporal_time_delta == 1 ) ) : #NEWLINE# #INDENT# string_time_delta = 'daily' #NEWLINE# #UNINDENT# reference = dsp . normalize_dataset_datetimes ( reference , string_time_delta ) #NEWLINE# targets = [ dsp . normalize_dataset_datetimes ( t , string_time_delta ) for t in targets ] #NEWLINE# if subset : #NEWLINE# #INDENT# start = dateutil . parser . parse ( subset [ 4 ] ) #NEWLINE# end = dateutil . parser . parse ( subset [ 5 ] ) #NEWLINE# bounds = Bounds ( subset [ 0 ] , subset [ 1 ] , subset [ 2 ] , subset [ 3 ] , start , end ) #NEWLINE# if reference : #NEWLINE# #INDENT# reference = dsp . safe_subset ( bounds , reference ) #NEWLINE# #UNINDENT# if targets : #NEWLINE# #INDENT# targets = [ dsp . safe_subset ( bounds , t ) for t in targets ] #NEWLINE# #UNINDENT# #UNINDENT# if temporal_time_delta : #NEWLINE# #INDENT# resolution = timedelta ( temporal_time_delta ) #NEWLINE# if reference : #NEWLINE# #INDENT# reference = dsp . temporal_rebin ( reference , resolution ) #NEWLINE# #UNINDENT# if targets : #NEWLINE# #INDENT# targets = [ dsp . temporal_rebin ( t , resolution ) for t in targets ] #NEWLINE# #UNINDENT# #UNINDENT# if ( spatial_regrid_lats and spatial_regrid_lons ) : #NEWLINE# #INDENT# lats = np . arange ( spatial_regrid_lats [ 0 ] , spatial_regrid_lats [ 1 ] , spatial_regrid_lats [ 2 ] ) #NEWLINE# lons = np . arange ( spatial_regrid_lons [ 0 ] , spatial_regrid_lons [ 1 ] , spatial_regrid_lons [ 2 ] ) #NEWLINE# if reference : #NEWLINE# #INDENT# reference = dsp . spatial_regrid ( reference , lats , lons ) #NEWLINE# #UNINDENT# if targets : #NEWLINE# #INDENT# targets = [ dsp . spatial_regrid ( t , lats , lons ) for t in targets ] #NEWLINE# #UNINDENT# #UNINDENT# return ( reference , targets )