# Path: lmatools/grid/make_grids.py
# def grid_h5flashfiles(h5_filenames, start_time, end_time, **kwargs):
#     """ Grid LMA data contianed in HDF5-format LMA files. Keyword arguments to this function
#         are those to the FlashGridder class and its functions.
# 
#         This function is provided as a convenience for compatibility with earlier
#         implementations of flash gridding.
#     """
# 
#     process_flash_kwargs = {}
#     for prock in ('min_points_per_flash',):
#         if prock in kwargs:
#             process_flash_kwargs[prock] = kwargs.pop(prock)
# 
#     out_kwargs = {}
#     for outk in ('outpath', 'output_writer', 'output_writer_3d',
#                  'output_kwargs', 'output_filename_prefix'):
#         if outk in kwargs:
#             out_kwargs[outk] = kwargs.pop(outk)
# 
#     gridder = FlashGridder(start_time, end_time, **kwargs)
#     gridder.process_flashes(h5_filenames, **process_flash_kwargs)
#     output = gridder.write_grids(**out_kwargs)
#     return output


import datetime
import scipy.io.netcdf as nc
import glob
from .make_grids import grid_h5flashfiles
    start_time = datetime.datetime(2011,11,21, 14,50,00)
    end_time   = datetime.datetime(2011,11,21, 14,51,00)
    frame_interval=60.0
        
    # ctr_lat = 25.0
    # ctr_lon = -95.0
    ctr_lat = 33.7
    ctr_lon = -101.8
    target_datum = 'NAD83'
    target_ellipse = 'GRS80'
    
    
    # gs = GeographicSystem()
    # mp = MapProjection('lcc', 25, -95, 'GRS80', 'NAD83', lat_1=25, lon_0=-95)
    # X,Y,Z = gs.toECEF(-101.8, 33.7, 1000)
    # x,y,z = mp.fromECEF(X,Y,Z)
    # #      (-620594.38006647746, 976685.16351688653, 1000.0000000018626)
    # x0, y0 = -620.0e3, 975.0e3 # Lubbock in system centered on 25, -95
    x0, y0 = 0.0, 0.0
    
    dx=2.0e3
    dy=2.0e3
    x_bnd = (x0-200e3, x0+200e3)
    y_bnd = (y0-200e3, y0+200e3)
    
    # Lambert Conformal Conic, one standard parallel
    # See http://remotesensing.org/geotiff/proj_list/lambert_conic_conformal_1sp.html
    # target_proj = 'lcc'
    target_proj = 'eqc'
        

# Path: lmatools/grid/make_grids.py
# def grid_h5flashfiles(h5_filenames, start_time, end_time, **kwargs):
#     """ Grid LMA data contianed in HDF5-format LMA files. Keyword arguments to this function
#         are those to the FlashGridder class and its functions.
# 
#         This function is provided as a convenience for compatibility with earlier
#         implementations of flash gridding.
#     """
# 
#     process_flash_kwargs = {}
#     for prock in ('min_points_per_flash',):
#         if prock in kwargs:
#             process_flash_kwargs[prock] = kwargs.pop(prock)
# 
#     out_kwargs = {}
#     for outk in ('outpath', 'output_writer', 'output_writer_3d',
#                  'output_kwargs', 'output_filename_prefix'):
#         if outk in kwargs:
#             out_kwargs[outk] = kwargs.pop(outk)
# 
#     gridder = FlashGridder(start_time, end_time, **kwargs)
#     gridder.process_flashes(h5_filenames, **process_flash_kwargs)
#     output = gridder.write_grids(**out_kwargs)
#     return output


# Path: lmatools/grid/AWIPS_tools.py
import datetime
import scipy.io.netcdf as nc
import glob
from .make_grids import grid_h5flashfiles

    start_time = datetime.datetime(2011,11,21, 14,50,00)
    end_time   = datetime.datetime(2011,11,21, 14,51,00)
    frame_interval=60.0
        
    # ctr_lat = 25.0
    # ctr_lon = -95.0
    ctr_lat = 33.7
    ctr_lon = -101.8
    target_datum = 'NAD83'
    target_ellipse = 'GRS80'
    
    
    # gs = GeographicSystem()
    # mp = MapProjection('lcc', 25, -95, 'GRS80', 'NAD83', lat_1=25, lon_0=-95)
    # X,Y,Z = gs.toECEF(-101.8, 33.7, 1000)
    # x,y,z = mp.fromECEF(X,Y,Z)
    # #      (-620594.38006647746, 976685.16351688653, 1000.0000000018626)
    # x0, y0 = -620.0e3, 975.0e3 # Lubbock in system centered on 25, -95
    x0, y0 = 0.0, 0.0
    
    dx=2.0e3
    dy=2.0e3
    x_bnd = (x0-200e3, x0+200e3)
    y_bnd = (y0-200e3, y0+200e3)
    
    # Lambert Conformal Conic, one standard parallel
    # See http://remotesensing.org/geotiff/proj_list/lambert_conic_conformal_1sp.html
    # target_proj = 'lcc'
    target_proj = 'eqc'
        

    x_coord, y_coord, lons, lats, extent_density_grid, outfiles, field_names = grid_h5flashfiles(