<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_grid_local(tiles, params):
 """ Write a file for each tile """

  # TODO: this isn't being used right now, will need to be
  # ported to gfile if we want to keep it
  for ti,tj,tile in enumerate_tiles(tiles):
    filename = "{directory}/{name}/tile_{n_layer}_{n_tile}_{ti}_{tj}".format(ti=ti, tj=tj, **params) #directory=directory, name=name, n_layer=n_layer, n_tile=n_tile, 
    # write out the tile as a npz
    print("saving", filename + ".npz")
    np.savez_compressed(filename + ".npz", **tile)
    # write out the tile as a csv
    print("saving", filename + ".csv")
    df = pd.DataFrame(tile)
    df.to_csv(filename + ".csv", index=False)