Created on Aug 26, 2013
@author: Christoph Paulik Christoph.Paulik@geo.tuwien.ac.at
Bases: object
Grid that just has lat,lon coordinates and can find the nearest neighbour. It can also yield the gpi, lat, lon information in order.
Parameters: | lon : numpy.array
lat : numpy.array
gpis : numpy.array, optional
subset : numpy.array, optional
setup_kdTree : boolean, optional
shape : tuple, optional
|
---|
Attributes
arrlon | numpy.array | array of all longitudes of the grid |
arrlat | numpy.array | array of all latitudes of the grid |
n_gpi | int | number of gpis in the grid |
gpidirect | boolean | if true the gpi number is equal to the index of arrlon and arrlat |
gpis | numpy.array | gpi number for elements in arrlon and arrlat gpi[i] is located at arrlon[i],arrlat[i] |
subset | numpy.array | if given then this contains the indices of a subset of the grid. This can be used if only a part of a grid is interesting for a application. e.g. land points, or only a specific country |
allpoints | boolean | if False only a subset of the grid is active |
activearrlon | numpy.array | array of longitudes that are active, is defined by arrlon[subset] if a subset is given otherwise equal to arrlon |
activearrlat | numpy.array | array of latitudes that are active, is defined by arrlat[subset] if a subset is given otherwise equal to arrlat |
activegpis | numpy.array | array of gpis that are active, is defined by gpis[subset] if a subset is given otherwise equal to gpis |
issplit | boolean | if True then the array was split in n parts with the self.split function |
kdTree | object | grid.nearest_neighbor.findGeoNN object for nearest neighbor search |
shape | tuple, optional | if given during initialization then this is the shape the grid can be reshaped to this only makes sense for regular lat,lon grids |
latdim | numpy.array, optional | if shape is given this attribute has contains all latitudes that make up the regular lat,lon grid |
londim | numpy.array, optional | if shape is given this attribute has contains all longitudes that make up the regular lat,lon grid |
Methods
takes other BasicGrid or CellGrid objects and computes a lookup table between them. the lut will have the size of self.n_gpis and will for every grid point have the nearest index into other.arrlon etc.
Parameters: | other : grid object
max_dist : float, optional
into_subset : boolean, optional
|
---|
finds nearest gpi, builds kdTree if it does not yet exist
Parameters: | lon : float
lat : float
|
---|---|
Returns: | gpi : long
distance : float
|
Returns all grid points located in a submitted geographic box, optinal as coordinates
Parameters: | latmin : float, optional
latmax : float, optional
lonmin : float, optional
lonmax : float, optional
coords : boolean, optional
|
---|---|
Returns: | gpi : numpy.array
lat : numpy.array
lon : numpy.array
|
Returns all active grid points
Parameters: | n : int, optional
|
---|---|
Returns: | gpis : numpy.array arrlon : numpy.array arrlat :numpy.array : |
Longitude and Latitude for given GPI.
Parameters: | gpi : int32
|
---|---|
Returns: | lon : float
lat : float |
Yields all grid points in order
Parameters: | n : int, optional
|
---|---|
Returns: | gpi : long
lon : float
lat : float
|
function splits the grid into n parts this changes not function but grid_points() which takes the argument n and will only iterate through this part of the grid
Parameters: | n : int
|
---|
convert grid to cellgrid with a cell partition of cellsize
Parameters: | cellsize : float, optional
cellsize_lon : float, optional
cellsize_lat : float, optional
|
---|---|
Returns: | cell_grid : CellGrid object
|
Bases: pytesmo.grid.grids.BasicGrid
Grid that has lat,lon coordinates as well as cell informatin. It can find nearest neighbour. It can also yield the gpi, lat, lon, cell information in cell order. This is important if the data on the grid is saved in cell files on disk as we can go through all grid points with optimized IO performance
Parameters: | lon : numpy.array
lat : numpy.array
cells : numpy.array
gpis : numpy.array, optional
subset : numpy.array, optional
|
---|
Attributes
arrcell | numpy.array | array of cell number with same shape as arrlon,arrlat |
activearrcell | numpy.array | array of longitudes that are active, is defined by arrlon[subset] if a subset is given otherwise equal to arrlon |
Methods
function to get all cell numbers of the grid
Returns: | cells : numpy.array
|
---|
Returns all active grid points
Parameters: | n : int, optional
|
---|---|
Returns: | gpis : numpy.array arrlon : numpy.array arrlat :numpy.array : cells : numpy.array |
Cell for given GPI.
Parameters: | gpi : int32
|
---|---|
Returns: | cell : int
|
Raises: | IndexError :
|
Partition lon, lat points into cells.
Parameters: | lat: float64, or numpy.array :
lon: float64, or numpy.array :
cellsize: float :
cellsize_lon : float, optional
cellsize_lat : float, optional
|
---|---|
Returns: | cell: int32, or numpy.array :
|
Created on Jul 30, 2013
@author: Christoph Paulik christoph.paulik@geo.tuwien.ac.at
Bases: object
class that takes lat,lon coordinates, transformes them to cartesian (X,Y,Z) coordinates and provides a interface to scipy.spatial.kdTree as well as pykdtree if installed
Parameters: | lon : numpy.array or list
lat : numpy.array or list
R : float, optional
grid : boolean, optional
kd_tree_name : string, optional
|
---|
Attributes
R | float | earth radius to use in computation of x,y,z coordinates |
coords | numpy.array | 3D array of cartesian x,y,z coordinates |
kd_tree_name: string | name of kdTree implementation to use, either ‘pykdtree’ to use pykdtree or ‘scipy’ to use scipy.spatial.kdTree Fallback is always scipy if any other string is given or if pykdtree is not installed | |
kdtree: object | kdTree object that is built only once and saved in this attribute |
Methods
finds nearest index, builds kdTree if it does not yet exist
Parameters: | lon : float, list or numpy.array
lat : float, list or numpy.array
|
---|---|
Returns: | d : float, numpy.array
ind : int, numpy.array
index_lon : numpy.array, optional
index_lat : numpy.array, optional
|
Created on Jan 21, 2014
Module for saving grid to netCDF
@author: Christoph Paulik christoph.paulik@geo.tuwien.ac.at
load a grid from netCDF file
Parameters: | filename : string
|
---|---|
Returns: | grid : BasicGrid or CellGrid instance
|
save a BasicGrid or CellGrid to netCDF it is assumed that a subset should be used as land_points
Parameters: | filename : string
grid : BasicGrid or CellGrid object
subset_name : string, optional
subset_meaning : string, optional
global_attrs : dict, optional
|
---|
saves grid information to netCDF file
Parameters: | filename : string
arrlon : numpy.array
arrlat : numpy.array
arrcell : numpy.array, optional
gpis : numpy.array, optional
subset_points : numpy.array, optional
subset_name : string, optional
subset_meaning : string, optional
global_attrs : dict, optional
|
---|
Created on Mar 25, 2014
@author: Christoph Paulik christoph.paulik@geo.tuwien.ac.at
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
src_lat : numpy.array
target_lon : numpy.array
target_src_lat : numpy.array
methods : string or dict, optional
weight_funcs : function or dict of functions, optional
min_neighbours: int, optional :
search_rad : float, optional
neighbours : int, optional
fill_values : number or dict, optional
Returns : ——- : data : dict of numpy.arrays
Raises : —— : ValueError : :
|
---|