This function takes array data and writes out a GSSHA ascii grid.

        Parameters:
            out_grid_file(str): Location of ASCII file to generate.
            lsm_data_var(str or list): This is the variable name for precipitation in the LSM files.
            gssha_convert_var(str): This is the name of the variable used in GRIDtoGSSHA to convert data with.
            time_step(Optional[int, datetime]): Time step in file to export data from. Default is the initial time step.
            ascii_format(Optional[str]): Default is 'grass' for GRASS ASCII. If you want Arc ASCII, use 'arc'.

        GRIDtoGSSHA Example:

        .. code:: python

            from gsshapy.grid import GRIDtoGSSHA

            # STEP 1: Initialize class
            g2g = GRIDtoGSSHA(gssha_project_folder='/path/to/gssha_project',
                              gssha_project_file_name='gssha_project.prj',
                              lsm_input_folder_path='/path/to/wrf-data',
                              lsm_search_card='*.nc',
                              lsm_lat_var='XLAT',
                              lsm_lon_var='XLONG',
                              lsm_time_var='Times',
                              lsm_lat_dim='south_north',
                              lsm_lon_dim='west_east',
                              lsm_time_dim='Time',
                              )

            # STEP 2: Generate init snow grid (from LSM)
            # NOTE: Card is INIT_SWE_DEPTH
            g2g.lsm_var_to_grid(out_grid_file="E:/GSSHA/swe_grid.asc",
                                lsm_data_var='SWE_inst',
                                gssha_convert_var='swe')

def lsm_var_to_grid(self, out_grid_file, lsm_data_var, gssha_convert_var, time_step=0, ascii_format='grass'):
        """This function takes array data and writes out a GSSHA ascii grid.

        Parameters:
            out_grid_file(str): Location of ASCII file to generate.
            lsm_data_var(str or list): This is the variable name for precipitation in the LSM files.
            gssha_convert_var(str): This is the name of the variable used in GRIDtoGSSHA to convert data with.
            time_step(Optional[int, datetime]): Time step in file to export data from. Default is the initial time step.
            ascii_format(Optional[str]): Default is 'grass' for GRASS ASCII. If you want Arc ASCII, use 'arc'.

        GRIDtoGSSHA Example:

        .. code:: python

            from gsshapy.grid import GRIDtoGSSHA

            # STEP 1: Initialize class
            g2g = GRIDtoGSSHA(gssha_project_folder='/path/to/gssha_project',
                              gssha_project_file_name='gssha_project.prj',
                              lsm_input_folder_path='/path/to/wrf-data',
                              lsm_search_card='*.nc',
                              lsm_lat_var='XLAT',
                              lsm_lon_var='XLONG',
                              lsm_time_var='Times',
                              lsm_lat_dim='south_north',
                              lsm_lon_dim='west_east',
                              lsm_time_dim='Time',
                              )

            # STEP 2: Generate init snow grid (from LSM)
            # NOTE: Card is INIT_SWE_DEPTH
            g2g.lsm_var_to_grid(out_grid_file="E:/GSSHA/swe_grid.asc",
                                lsm_data_var='SWE_inst',
                                gssha_convert_var='swe')


        """
        self._load_converted_gssha_data_from_lsm(gssha_convert_var, lsm_data_var, 'grid', time_step)
        gssha_data_var_name = self.netcdf_attributes[gssha_convert_var]['gssha_name']
        self.data = self.data.lsm.to_projection(gssha_data_var_name,
                                                projection=self.gssha_grid.projection)
        self._resample_data(gssha_data_var_name)
        arr_grid = ArrayGrid(in_array=self.data[gssha_data_var_name].values,
                             wkt_projection=self.data.lsm.projection.ExportToWkt(),
                             geotransform=self.data.lsm.geotransform)

        if ascii_format.strip().lower() == 'grass':
            arr_grid.to_grass_ascii(out_grid_file)
        elif ascii_format.strip().lower() == 'arc':
            arr_grid.to_arc_ascii(out_grid_file)
        else:
            raise ValueError("Invalid argument for 'ascii_format'. Only 'grass' or 'arc' allowed.")