Пример #1
0
#     periods += [10]
#     periods += [15]
    domains = 2 # domains to be processed
#     domains = None # process all domains
#     filetypes = ['srfc','xtrm','plev3d','hydro','lsm'] # filetypes to be processed # ,'rad'
    filetypes = ['hydro'] # filetypes to be processed
    grid = 'native'

  # check and expand WRF experiment list
  experiments = getExperimentList(experiments, project, 'WRF')
  if isinstance(domains, (np.integer,int)): domains = [domains]
  if isinstance(periods, (np.integer,int)): periods = [periods]

  # shall we do some fancy regridding on-the-fly?
  if grid == 'native': griddef = None
  else: griddef = getCommonGrid(grid)
  
  # print an announcement
  print('\n Computing Climatologies for WRF experiments:\n')
  print([exp.name for exp in experiments])
  if grid != 'native': print('\nRegridding to \'{0:s}\' grid.\n'.format(grid))
  print('\nOVERWRITE: {0:s}\n'.format(str(loverwrite)))
      
  # assemble argument list and do regridding
  args = [] # list of arguments for workers, i.e. "work packages"
  # generate list of parameters
  for experiment in experiments:    
    # loop over file types
    for filetype in filetypes:                
      # effectively, loop over domains
      if domains is None:
Пример #2
0
        if mode == 'climatology':
            periodlist = periods if isinstance(periods,
                                               (tuple, list)) else (periods, )
        elif mode == 'time-series':
            periodlist = (None, )  # ignore periods
        else:
            raise NotImplementedError, "Unrecognized Mode: '{:s}'".format(mode)

        # loop over target grids ...
        for grid, reses in grids.iteritems():
            # ... and resolutions
            if reses is None: reses = (None, )
            for res in reses:

                # load target grid definition
                griddef = getCommonGrid(grid, res=res, lfilepath=True)
                # check if grid was defined properly
                if not isinstance(griddef, GridDefinition):
                    raise GDALError, 'No valid grid defined! (grid={0:s})'.format(
                        grid)

                # observational datasets (grid depends on dataset!)
                for dataset in datasets:
                    mod = import_module('datasets.{0:s}'.format(dataset))
                    if isinstance(resolutions, dict):
                        if dataset not in resolutions:
                            resolutions[dataset] = ('', )
                        elif not isinstance(resolutions[dataset],
                                            (list, tuple)):
                            resolutions[dataset] = (resolutions[dataset], )
                    elif resolutions is not None:
Пример #3
0
  for mode in modes:
    # only climatology mode has periods    
    if mode == 'climatology': 
      periodlist = periods if isinstance(periods, (tuple,list)) else (periods,)
    elif mode == 'time-series': 
      periodlist = (None,) # ignore periods
    else: raise NotImplementedError, "Unrecognized Mode: '{:s}'".format(mode)

    # loop over target grids ...
    for grid,reses in grids.iteritems():
      # ... and resolutions
      if reses is None: reses = (None,)
      for res in reses:
        
        # load target grid definition
        griddef = getCommonGrid(grid, res=res, lfilepath=True)
        # check if grid was defined properly
        if not isinstance(griddef,GridDefinition): 
          raise GDALError, 'No valid grid defined! (grid={0:s})'.format(grid)        
        
        # observational datasets (grid depends on dataset!)
        for dataset in datasets:
          mod = import_module('datasets.{0:s}'.format(dataset))
          if isinstance(resolutions,dict): 
            if dataset not in resolutions: resolutions[dataset] = ('',)
            elif not isinstance(resolutions[dataset],(list,tuple)): resolutions[dataset] = (resolutions[dataset],)                
          elif resolutions is not None: raise TypeError                                
          if mode == 'climatology':
            # some datasets come with a climatology 
            if lLTM:
              if resolutions is None: dsreses = mod.LTM_grids
Пример #4
0
        #     periods += [30]
        #     domains = 1 # domains to be processed
        domains = None  # process all domains
        #     WRF_filetypes = ['srfc','xtrm','plev3d','hydro','lsm','rad'] # filetypes to be processed # ,'rad'
        WRF_filetypes = ['hydro', 'xtrm', 'hydro', 'lsm', 'rad']
        #     WRF_filetypes = ['srfc'] # filetypes to be processed
        grid = None  # use native grid

    # check and expand WRF experiment list
    WRF_experiments = getExperimentList(WRF_experiments, WRF_project, 'WRF')
    if isinstance(domains, (np.integer, int)): domains = [domains]
    if isinstance(periods, (np.integer, int)): periods = [periods]

    # shall we do some fancy regridding on-the-fly?
    if not grid: griddef = None
    else: griddef = getCommonGrid(grid)

    # print an announcement
    print('\n Computing Climatologies for WRF experiments:\n')
    print([exp.name for exp in WRF_experiments])
    if grid: print('\nRegridding to \'{0:s}\' grid.\n'.format(grid))
    print('\nOVERWRITE: {0:s}\n'.format(str(loverwrite)))

    # assemble argument list and do regridding
    args = []  # list of arguments for workers, i.e. "work packages"
    # generate list of parameters
    for experiment in WRF_experiments:
        # loop over file types
        for filetype in WRF_filetypes:
            # effectively, loop over domains
            if domains is None:
Пример #5
0
  args = []  # list of job packages
  # loop over modes
  for mode in modes:
    # only climatology mode has periods    
    if mode == 'climatology': periodlist = periods
    elif mode == 'time-series': periodlist = (None,)
    else: raise NotImplementedError, "Unrecognized Mode: '{:s}'".format(mode)

    # loop over target grids ...
    for grid,reses in grids.iteritems():
      # ... and resolutions
      if reses is None: reses = (None,)
      for res in reses:
        
        # load target grid definition
        griddef = getCommonGrid(grid, res=res)
        # check if grid was defined properly
        if not isinstance(griddef,GridDefinition): 
          raise GDALError, 'No valid grid defined! (grid={0:s})'.format(grid)        
        
        # observational datasets (grid depends on dataset!)
        for dataset in datasets:
          mod = import_module('datasets.{0:s}'.format(dataset))
          if isinstance(resolutions,dict): 
            if dataset not in resolutions: resolutions[dataset] = ('',)
            elif not isinstance(resolutions[dataset],(list,tuple)): resolutions[dataset] = (resolutions[dataset],)                
          elif resolutions is not None: raise TypeError                                
          if mode == 'climatology':
            # some datasets come with a climatology 
            if lLTM:
              if resolutions is None: dsreses = mod.LTM_grids
Пример #6
0
    # loop over modes
    for mode in modes:
        # only climatology mode has periods
        if mode == 'climatology': periodlist = periods
        elif mode == 'time-series': periodlist = (None, )
        else:
            raise NotImplementedError, "Unrecognized Mode: '{:s}'".format(mode)

        # loop over target grids ...
        for grid, reses in grids.iteritems():
            # ... and resolutions
            if reses is None: reses = (None, )
            for res in reses:

                # load target grid definition
                griddef = getCommonGrid(grid, res=res)
                # check if grid was defined properly
                if not isinstance(griddef, GridDefinition):
                    raise GDALError, 'No valid grid defined! (grid={0:s})'.format(
                        grid)

                # observational datasets (grid depends on dataset!)
                for dataset in datasets:
                    mod = import_module('datasets.{0:s}'.format(dataset))
                    if isinstance(resolutions, dict):
                        if dataset not in resolutions:
                            resolutions[dataset] = ('', )
                        elif not isinstance(resolutions[dataset],
                                            (list, tuple)):
                            resolutions[dataset] = (resolutions[dataset], )
                    elif resolutions is not None: