shareloc.geomodels.grid
Localisation functions from multi h direct grids.
Module Contents
Classes
multi H direct localization grid handling class. |
Functions
|
colocalization grid on dtm |
- class shareloc.geomodels.grid.Grid(geomodel_path)[source]
Bases:
shareloc.geomodels.geomodel_template.GeoModelTemplate
multi H direct localization grid handling class. please refer to the main documentation grid format
Derives from GeoModelTemplate
- Parameters:
row0 (float) – grid first pixel center along Y axis (row).
col0 (float) – grid first pixel center along X axis (column).
nbrow (int) – grid size in row
nbcol (int) – grid size in col
steprow (float) – grid step in row
stepcol (float) – grid step in col
rowmax (float) – last row in grid
colmax (float) – last col in grid
repter (str) – ground coordinate system
epsg (int) – epsg code corresponding to shareloc.grid.Grid.repter
nbalt (int) – number of altitude layers
lon_data (np.ndarray of size (nbalt,nbrow,nbcol) size) – longitude array
lat_data (np.ndarray of size (nbalt,nbrow,nbcol) size) – latitude array
alts_down (list) – altitudes in decreasing order
type (str) – geometric model type
geomodel_path (str) –
- classmethod load(geomodel_path)[source]
Load grid and fill Class attributes.
The grid is read as an shareloc.image. Image and class attributes are filled. Shareloc geotiff grids are stored by increasing altitude H0 … Hx 2 data cubes are defined: - lon_data : [alt,row,col] - lat_data : [alt,row,col]
- read()[source]
Load grid and fill Class attributes.
The grid is read as an shareloc.image. Image and class attributes are filled. Shareloc geotiff grids are stored by increasing altitude H0 … Hx 2 data cubes are defined: - lon_data : [alt,row,col] - lat_data : [alt,row,col]
- parse_metadata_alti(metadata)[source]
parse metadata to sort altitude in decreasing order
- Parameters:
metadata (dict) – Geotiff metadata
- get_alt_min_max()[source]
returns altitudes min and max layers
- Returns:
alt_min,lat_max
- Return type:
list
- direct_loc_h(row, col, alt, fill_nan=False)[source]
direct localization at constant altitude
- Parameters:
row (float or 1D numpy.ndarray dtype=float64) – line sensor position
col (float or 1D numpy.ndarray dtype=float64) – column sensor position
alt (float) – altitude
fill_nan (boolean) – fill numpy.nan values with lon and lat offset if true (same as OTB/OSSIM), nan is returned otherwise
- Returns:
ground position (lon,lat,h)
- Return type:
numpy.ndarray 2D dimension with (N,3) shape, where N is number of input coordinates
- compute_los(row, col, epsg)[source]
Compute Line of Sight
- Parameters:
row (float) – line sensor position
col (float) – column sensor position
epsg (int) – epsg code
- Returns:
los
- Return type:
numpy.array
- direct_loc_dtm(row, col, dtm)[source]
direct localization on dtm
TODO explain algorithm TODO optimize code (for loop, …)
- Parameters:
row (float) – line sensor position
col (float) – column sensor position
dtm (shareloc.dtm) – dtm model
- Returns:
ground position (lon,lat,h) in dtm coordinates system.
- Return type:
numpy.ndarray 2D dimension with (N,3) shape, where N is number of input coordinates
- los_extrema(row, col, alt_min, alt_max)[source]
compute los extrema
- Parameters:
row (float) – line sensor position
col (float) – column sensor position
alt_min (float) – los alt min
alt_max (float) – los alt max
- Returns:
los extrema
- Return type:
numpy.array (2x3)
- interpolate_grid_in_plani(row, col)[source]
interpolate positions on multi h grid
- Parameters:
row (float) – line sensor position
col (float) – column sensor position
- Returns:
interpolated positions
- Return type:
list
- interpolate_grid_in_altitude(nbrow, nbcol, nbalt=None)[source]
interpolate equally spaced grid (in altitude)
- Parameters:
nbrow (int) – grid nb row
nbcol (int) – grid nb col
nbalt (int) – grid nb alt, of None self.nbalt is used instead
- Returns:
equally spaced grid
- Return type:
numpy.array
- direct_loc_grid_dtm(row0, col0, steprow, stepcol, nbrow, nbcol, dtm)[source]
direct localization grid on dtm
- Parameters:
row0 (int) – grid origin (row)
col0 (int) – grid origin (col)
steprow (int) – grid step (row)
stepcol (int) – grid step (col)
nbrow (int) – grid nb row
nbcol (int) – grid nb col
dtm (shareloc.dtm) – dtm model
- Returns:
direct localization grid
- Return type:
numpy.array
- return_grid_index(alt)[source]
return layer index enclosing a given altitude
- Parameters:
alt (float) – altitude
- Returns:
grid index (up,down)
- Return type:
tuple
- direct_loc_grid_h(row0, col0, steprow, stepcol, nbrow, nbcol, alt)[source]
direct localization grid at constant altitude TODO not tested.
- Parameters:
row0 (int) – grid origin (row)
col0 (int) – grid origin (col)
steprow (int) – grid step (row)
stepcol (int) – grid step (col)
nbrow (int) – grid nb row
nbcol (int) – grid nb col
alt (float) – altitude of the grid
- Returns:
direct localization grid
- Return type:
numpy.array
- estimate_inverse_loc_predictor(nbrow_pred=3, nbcol_pred=3)[source]
initialize inverse localization polynomial predictor it composed of 4 polynoms estimated on a grid at hmin and hmax
col_min = a0 + a1*lon + a2*lat + a3*lon**2 + a4*lat**2 + a5*lon*lat row_min = b0 + b1*lon + b2*lat + b3*lon**2 + b4*lat**2 + b5*lon*lat col_max = a0 + a1*lon + a2*lat + a3*lon**2 + a4*lat**2 + a5*lon*lat row_max = b0 + b1*lon + b2*lat + b3*lon**2 + b4*lat**2 + b5*lon*lat least squarred method is used to calculate coefficients, which are noramlized in [-1,1]
- Parameters:
nbrow_pred (int) – predictor nb row (3 by default)
nbcol_pred (int) – predictor nb col (3 by default)
- inverse_loc_predictor(lon, lat, alt=0.0)[source]
evaluate inverse localization predictor at a given geographic position
- Parameters:
lon (float) – longitude
lat (float) – latitude
alt (float) – altitude (0.0 by default)
- Returns:
sensor position and extrapolation state (row,col, is extrapolated)
- Return type:
tuple (float, float, boolean)
- inverse_partial_derivative(row, col, alt=0)[source]
calculate partial derivative at a given geographic position it gives the matrix to apply to get sensor shifts from geographic ones it returns M matrix : [dcol,drow]T = M x [dlon,dlat]T dlon/dlat in microrad M is calculated on each node of grid M is necessary for direct localization inversion in iterative inverse loc
- Parameters:
lon (float) – longitude
lat (float) – latitude
alt (float) – altitude (0.0 by default)
- Returns:
matrix
- Return type:
numpy.array
- inverse_loc(lon, lat, alt=0.0, nb_iterations=15)[source]
Inverse localization at a given geographic position First initialize position, * apply inverse predictor lon,lat,at -> col_0,row_0 * direct loc col_0,row_0 -> lon_0, lat_0 Then iterative process: * calculate geographic error dlon,dlat * calculate senor correction dlon,dlat -> dcol,drow * apply direct localization -> lon_i,lat_i
TODO explain algo TODO optimization (for loop,…)
- Parameters:
lon (float) – longitude
lat (float) – latitude
alt (float) – altitude
nb_iterations (int) – max number of iterations (15 by default)
- Returns:
sensor position (row,col,alt)
- Return type:
tuple(1D np.array row position, 1D np.array col position, 1D np.array alt)
- shareloc.geomodels.grid.coloc(multi_h_grid_src, multi_h_grid_dst, dtm, origin, step, size)[source]
colocalization grid on dtm localization on dtm from src grid, then inverse localization in right grid
- Parameters:
multi_h_grid_src (shareloc.grid) – source grid
multi_h_grid_dst (shareloc.grid) – destination grid
origin (list(int)) – grid origin in src grid (row,col)
step (list(int)) – grid step (row,col)
size (list(int)) – grid nb row and nb col
- Returns:
colocalization grid
- Return type:
numpy.array