blogs/lightning/ltgpred/goesutil/goesio.py
def create_data_grid(nc, data, griddef):
  """Create a ndarray of the data in the netcdf file.

  Args:
    nc (NetcdfFile): file
    data (str): which variable to pull out
    griddef (pyresample.GridDefinition): output grid definition

  Returns:
    ndarray of data in specified grid
  """
  # Subsatellite_Longitude is where the GEO satellite is
  lon_0 = nc.variables['nominal_satellite_subpoint_lon'][0]
  ht_0 = nc.variables['nominal_satellite_height'][0] * 1000  # meters
  x = nc.variables['x'][:] * ht_0  # / 1000.0
  y = nc.variables['y'][:] * ht_0  # / 1000.0
  nx = len(x)
  ny = len(y)
  max_x, min_x, max_y, min_y = x.max(), x.min(), y.max(), y.min()
  half_x = (max_x - min_x) / nx / 2.
  half_y = (max_y - min_y) / ny / 2.
  extents = (min_x - half_x, min_y - half_y, max_x + half_x, max_y + half_y)
  old_grid = pr.geometry.AreaDefinition(
      'geos', 'goes_conus', 'geos', {
          'proj': 'geos',
          'h': str(ht_0),
          'lon_0': str(lon_0),
          'a': '6378169.0',
          'b': '6356584.0'
      }, nx, ny, extents)

  # now do remapping
  logging.info('Remapping from %s', old_grid)
  return pr.kd_tree.resample_nearest(
      old_grid, data, griddef, radius_of_influence=50000)
Create a ndarray of the data in the netcdf file.

  Args:
    nc (NetcdfFile): file
    data (str): which variable to pull out
    griddef (pyresample.GridDefinition): output grid definition

  Returns:
    ndarray of data in specified grid
  
Create a ndarray of the data in the netcdf file.
Create a ndarray of the data in the netcdf file .
def create_data_grid(nc, data, griddef):
  lon_0 = nc.variables['nominal_satellite_subpoint_lon'][0]
  ht_0 = nc.variables['nominal_satellite_height'][0] * 1000  
  x = nc.variables['x'][:] * ht_0  
  y = nc.variables['y'][:] * ht_0  
  nx = len(x)
  ny = len(y)
  max_x, min_x, max_y, min_y = x.max(), x.min(), y.max(), y.min()
  half_x = (max_x - min_x) / nx / 2.
  half_y = (max_y - min_y) / ny / 2.
  extents = (min_x - half_x, min_y - half_y, max_x + half_x, max_y + half_y)
  old_grid = pr.geometry.AreaDefinition(
      'geos', 'goes_conus', 'geos', {
          'proj': 'geos',
          'h': str(ht_0),
          'lon_0': str(lon_0),
          'a': '6378169.0',
          'b': '6356584.0'
      }, nx, ny, extents)
  logging.info('Remapping from %s', old_grid)
  return pr.kd_tree.resample_nearest(
      old_grid, data, griddef, radius_of_influence=50000)
def create_data_grid ( nc , data , griddef ) : lon_0 = nc . variables [ 'nominal_satellite_subpoint_lon' ] [ 0 ] ht_0 = nc . variables [ 'nominal_satellite_height' ] [ 0 ] * 1000 x = nc . variables [ 'x' ] [ : ] * ht_0 y = nc . variables [ 'y' ] [ : ] * ht_0 nx = len ( x ) ny = len ( y ) max_x , min_x , max_y , min_y = x . max ( ) , x . min ( ) , y . max ( ) , y . min ( ) half_x = ( max_x - min_x ) / nx / 2. half_y = ( max_y - min_y ) / ny / 2. extents = ( min_x - half_x , min_y - half_y , max_x + half_x , max_y + half_y ) old_grid = pr . geometry . AreaDefinition ( 'geos' , 'goes_conus' , 'geos' , { 'proj' : 'geos' , 'h' : str ( ht_0 ) , 'lon_0' : str ( lon_0 ) , 'a' : '6378169.0' , 'b' : '6356584.0' } , nx , ny , extents ) logging . info ( 'Remapping from %s' , old_grid ) return pr . kd_tree . resample_nearest ( old_grid , data , griddef , radius_of_influence = 50000 )
Create a ndarray of the data in the netcdf file.
Create a ndarray of the data in the netcdf file .
"""Create a ndarray of the data in the netcdf file.

  Args:
    nc (NetcdfFile): file
    data (str): which variable to pull out
    griddef (pyresample.GridDefinition): output grid definition

  Returns:
    ndarray of data in specified grid
  """ # Subsatellite_Longitude is where the GEO satellite is # meters # / 1000.0 # / 1000.0 # now do remapping
ndarray of data in specified grid
ndarray of data in specified grid
nc
None
data
which variable to pull out
which variable to pull out
griddef
output grid definition
output grid definition