title: Numpy best way to assign array to a single point in another array (4D)
body: <p>I would like to store each one of the arrays (new_grid) at a given cell on another array (master_grid), which varies according to i and j:</p>
  
  <p><code>master_grid[i][j]=new_grid</code></p>
  
  <p>When I run the code it returns the following error for the above line:</p>
  
  <pre><code>&lt;ipython-input-233-e449b6b2f1a1&gt; in &lt;module&gt;
       16         new_grid=coordinates_within_radius(coords_ref, coords_grid, radius)
       17 
  ---&gt; 18         master_grid[i,j]=new_grid
  
  TypeError: list indices must be integers or slices, not tuple
  </code></pre>
  
  <p>I'm using both numpy and xarray, but so far couldn't figure out a way of indexing the "inner" arrays into the <code>master_grid</code>.</p>
  
  <p>As it can be seen in the code, there is a function that determines which points are within a radius and the result is a grid with latitude and longitude.</p>
  
  <pre><code>import numpy as np
  import pandas as pd
  import matplotlib.pyplot as plt
  import xarray as xr
  import cartopy.crs as ccrs
  import seaborn as sns
  import geopy.distance
  
   ### Code for locating points within a radius        
  def coordinates_within_radius( coords_ref, coords_grid, radius ):
      if type(coords_grid) == np.ndarray or type(coords_grid) == list:
          new_grid = [coords_grid[i] for i in range(len(coords_grid)) if geopy.distance.distance(coords_ref, coords_grid[i]).km &lt; radius]
      else:
          if geopy.distance.distance(coords_ref, coords_grid).km &lt; radius:
              new_grid=coords_grid;
  
      if len(new_grid) == 0:
          print('the grid is empty')
  
      return new_grid
  
  storm=[1,2,3,4]
  date_time=[1,2,3,4,5]
  radius=500
  scale_lat=6
  master_grid=[]
  
  for i in range(len(storm)):
      for j in range(len(date_time)):
          coords_ref = [30, -80]
          lon = np.arange(coords_ref[1] - scale_lat,coords_ref[1] + scale_lat, 0.25)
          lat = np.arange(coords_ref[0] - scale_lat,coords_ref[0] + scale_lat, 0.25)
          coords_grid=np.zeros((len(lon) * len(lat), 2))
  
          coords_grid = [[lat[y],lon[x]] for x in range(len(lat)) for y in range(len(lon))]
  
          new_grid=coordinates_within_radius(coords_ref, coords_grid, radius)
  
          master_grid[i,j]=new_grid 
  </code></pre>