pytesmo.grid package¶
Submodules¶
pytesmo.grid.grids module¶
pytesmo.grid.netcdf module¶
pytesmo.grid.resample module¶
Created on Mar 25, 2014
@author: Christoph Paulik christoph.paulik@geo.tuwien.ac.at
-
pytesmo.grid.resample.
hamming_window
(radius, distances)[source]¶ Hamming window filter.
- Parameters
radius (float32) – Radius of the window.
distances (numpy.ndarray) – Array with distances.
- Returns
weights – Distance weights.
- Return type
-
pytesmo.grid.resample.
resample_to_grid
(input_data, src_lon, src_lat, target_lon, target_lat, methods='nn', weight_funcs=None, min_neighbours=1, search_rad=18000, neighbours=8, fill_values=None)[source]¶ resamples data from dictionary of numpy arrays using pyresample to given grid. Searches for the neighbours and then resamples the data to the grid given in togrid if at least min_neighbours neighbours are found
- Parameters
input_data (dict of numpy.arrays) –
src_lon (numpy.array) – longitudes of the input data
src_lat (numpy.array) – src_latitudes of the input data
target_lon (numpy.array) – longitudes of the output data
target_src_lat (numpy.array) – src_latitudes of the output data
methods (string or dict, optional) – method of spatial averaging. this is given to pyresample and can be ‘nn’ : nearest neighbour ‘custom’ : custom weight function has to be supplied in weight_funcs see pyresample documentation for more details can also be a dictionary with a method for each array in input data dict
weight_funcs (function or dict of functions, optional) – if method is ‘custom’ a function like func(distance) has to be given can also be a dictionary with a function for each array in input data dict
min_neighbours (int, optional) – if given then only points with at least this number of neighbours will be resampled Default : 1
search_rad (float, optional) – search radius in meters of neighbour search Default : 18000
neighbours (int, optional) – maximum number of neighbours to look for for each input grid point Default : 8
fill_values (number or dict, optional) – if given the output array will be filled with this value if no valid resampled value could be computed, if not a masked array will be returned can also be a dict with a fill value for each variable
- Returns
data – resampled data on given grid
- Return type
dict of numpy.arrays
- Raises
ValueError : – if empty dataset is resampled
-
pytesmo.grid.resample.
resample_to_grid_only_valid_return
(input_data, src_lon, src_lat, target_lon, target_lat, methods='nn', weight_funcs=None, min_neighbours=1, search_rad=18000, neighbours=8, fill_values=None)[source]¶ resamples data from dictionary of numpy arrays using pyresample to given grid. Searches for the neighbours and then resamples the data to the grid given in togrid if at least min_neighbours neighbours are found
- Parameters
input_data (dict of numpy.arrays) –
src_lon (numpy.array) – longitudes of the input data
src_lat (numpy.array) – src_latitudes of the input data
target_lon (numpy.array) – longitudes of the output data
target_src_lat (numpy.array) – src_latitudes of the output data
methods (string or dict, optional) – method of spatial averaging. this is given to pyresample and can be ‘nn’ : nearest neighbour ‘custom’ : custom weight function has to be supplied in weight_funcs see pyresample documentation for more details can also be a dictionary with a method for each array in input data dict
weight_funcs (function or dict of functions, optional) – if method is ‘custom’ a function like func(distance) has to be given can also be a dictionary with a function for each array in input data dict
min_neighbours (int, optional) – if given then only points with at least this number of neighbours will be resampled Default : 1
search_rad (float, optional) – search radius in meters of neighbour search Default : 18000
neighbours (int, optional) – maximum number of neighbours to look for for each input grid point Default : 8
fill_values (number or dict, optional) – if given the output array will be filled with this value if no valid resampled value could be computed, if not a masked array will be returned can also be a dict with a fill value for each variable
- Returns
data (dict of numpy.arrays) – resampled data on part of the target grid over which data was found
mask (numpy.ndarray) – boolean mask into target grid that specifies where data was resampled
- Raises
ValueError : – if empty dataset is resampled