def get_elevation(self, lat, lon, block_size=50000): """ Interpolate the elevation values for lat/lon. This is relative to the EGM96 geoid by DTED specification. Parameters ---------- lat : numpy.ndarray lon : numpy.ndarray block_size : None|int If `None`, then the entire calculation will proceed as a single block. Otherwise, block processing using blocks of the given size will be used. The minimum value used for this is 50,000, and any smaller value will be replaced with 50,000. Default is 50,000. Returns ------- numpy.ndarray Elevation values of the same shape as lat/lon. """ o_shape, lat, lon = argument_validation(lat, lon) out = numpy.full(lat.shape, numpy.nan, dtype=numpy.float64) if block_size is None: boolc = self.in_bounds(lat, lon) if numpy.any(boolc): out[boolc] = self._get_elevation(lat[boolc], lon[boolc]) else: block_size = min(50000, int(block_size)) start_block = 0 while start_block < lat.size: end_block = min(lat.size, start_block + block_size) lat1 = lat[start_block:end_block] lon1 = lon[start_block:end_block] boolc = self.in_bounds(lat1, lon1) out1 = numpy.full(lat1.shape, numpy.nan, dtype=numpy.float64) out1[boolc] = self._get_elevation(lat1[boolc], lon[boolc]) out[start_block:end_block] = out1 start_block = end_block if o_shape == (): return float(out[0]) else: return numpy.reshape(out, o_shape)
def get_elevation_geoid(self, lat, lon, block_size=50000): """ Get the elevation value relative to the geoid. .. Note:: DTED elevation is relative to the egm96 geoid, though using the egm2008 model will result in only minor differences. Parameters ---------- lat : numpy.ndarray|list|tuple|int|float lon : numpy.ndarray|list|tuple|int|float block_size : None|int If `None`, then the entire calculation will proceed as a single block. Otherwise, block processing using blocks of the given size will be used. The minimum value used for this is 50000, and any smaller value will be replaced with 50000. Default is 50000. Returns ------- numpy.ndarray the elevation relative to the geoid """ o_shape, lat, lon = argument_validation(lat, lon) if block_size is None: out = self._get_elevation_geoid(lat, lon) else: block_size = min(50000, int(block_size)) out = numpy.full(lat.shape, numpy.nan, dtype=numpy.float64) start_block = 0 while start_block < lat.size: end_block = min(lat.size, start_block+block_size) out[start_block:end_block] = self._get_elevation_geoid( lat[start_block:end_block], lon[start_block:end_block]) start_block = end_block out[numpy.isnan(out)] = 0.0 # set missing values to geoid=0 (MSL) if o_shape == (): return float(out[0]) else: return numpy.reshape(out, o_shape)
def get(self, lat, lon, cubic=True, block_size=50000): """ Calculate the height of the geoid above the ellipsoid in meters at the given points. Parameters ---------- lat : numpy.ndarray lon : numpy.ndarray cubic : bool Use a simple cubic spline interpolation, otherwise us simple linear. Default is `True`. block_size : None|int If `None`, then the entire calculation will proceed as a single block. Otherwise, block processing using blocks of the given size will be used. The minimum value used for this is 50,000, and any smaller value will be replaced with 50,000. Default is 50,000. Returns ------- numpy.ndarray """ o_shape, lat, lon = argument_validation(lat, lon) if block_size is None: out = self._do_block(lat, lon, cubic) else: block_size = max(50000, int(block_size)) out = numpy.empty(lat.shape, dtype=numpy.float64) start_block = 0 while start_block < lat.size: end_block = min(start_block + block_size, lat.size) out[start_block:end_block] = self._do_block( lat[start_block:end_block], lon[start_block:end_block], cubic) start_block = end_block if o_shape == (): return float(out[0]) else: return numpy.reshape(out, o_shape)