Writes extracted data to the NetCDF file format

        .. todo:: NetCDF output data time is always in UTC time. Need to convert to local timezone for GSSHA.

        .. warning:: The NetCDF GSSHA file is only supported in GSSHA 7 or greater.

        .. note::
            GSSHA CARDS:
                * HMET_NETCDF pointing to the netcdf_file_path
                * LONG_TERM (see: http://www.gsshawiki.com/Long-term_Simulations:Global_parameters)

        Parameters:
            netcdf_file_path(string): Path to output the NetCDF file for GSSHA.
            data_var_map_array(list): Array to map the variables in the LSM file to the
                                      matching required GSSHA data.
            resample_method(Optional[gdalconst]): Resample input method to match hmet data to GSSHA grid for NetCDF output. Default is None.


        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 NetCDF DATA

            #EXAMPLE DATA ARRAY 1: WRF GRID DATA BASED
            #SEE: http://www.meteo.unican.es/wiki/cordexwrf/OutputVariables

            data_var_map_array = [
                                  ['precipitation_acc', ['RAINC', 'RAINNC']],
                                  ['pressure', 'PSFC'],
                                  ['relative_humidity', ['Q2', 'PSFC', 'T2']], #MUST BE IN ORDER: ['SPECIFIC HUMIDITY', 'PRESSURE', 'TEMPERATURE']
                                  ['wind_speed', ['U10', 'V10']], #['U_VELOCITY', 'V_VELOCITY']
                                  ['direct_radiation', ['SWDOWN', 'DIFFUSE_FRAC']], #MUST BE IN ORDER: ['GLOBAL RADIATION', 'DIFFUSIVE FRACTION']
                                  ['diffusive_radiation', ['SWDOWN', 'DIFFUSE_FRAC']], #MUST BE IN ORDER: ['GLOBAL RADIATION', 'DIFFUSIVE FRACTION']
                                  ['temperature', 'T2'],
                                  ['cloud_cover' , 'CLDFRA'], #'CLOUD_FRACTION'
                                 ]

            g2g.lsm_data_to_subset_netcdf("E/GSSHA/gssha_wrf_data.nc",
                                          data_var_map_array)

        HRRRtoGSSHA Example:

        .. code:: python

            from gsshapy.grid import HRRRtoGSSHA

            #STEP 1: Initialize class
            h2g = HRRRtoGSSHA(
                              #YOUR INIT PARAMETERS HERE
                             )

            #STEP 2: Generate NetCDF DATA

            #EXAMPLE DATA ARRAY 2: HRRR GRID DATA BASED
            data_var_map_array = [
                                  ['precipitation_rate', 'prate'],
                                  ['pressure', 'sp'],
                                  ['relative_humidity', '2r'],
                                  ['wind_speed', ['10u', '10v']],
                                  ['direct_radiation_cc', ['dswrf', 'tcc']],
                                  ['diffusive_radiation_cc', ['dswrf', 'tcc']],
                                  ['temperature', 't'],
                                  ['cloud_cover_pc' , 'tcc'],
                                 ]

            h2g.lsm_data_to_subset_netcdf("E:/GSSHA/gssha_wrf_data.nc",
                                          data_var_map_array)

def lsm_data_to_subset_netcdf(self, netcdf_file_path,
                                        data_var_map_array,
                                        resample_method=None):
        """Writes extracted data to the NetCDF file format

        .. todo:: NetCDF output data time is always in UTC time. Need to convert to local timezone for GSSHA.

        .. warning:: The NetCDF GSSHA file is only supported in GSSHA 7 or greater.

        .. note::
            GSSHA CARDS:
                * HMET_NETCDF pointing to the netcdf_file_path
                * LONG_TERM (see: http://www.gsshawiki.com/Long-term_Simulations:Global_parameters)

        Parameters:
            netcdf_file_path(string): Path to output the NetCDF file for GSSHA.
            data_var_map_array(list): Array to map the variables in the LSM file to the
                                      matching required GSSHA data.
            resample_method(Optional[gdalconst]): Resample input method to match hmet data to GSSHA grid for NetCDF output. Default is None.


        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 NetCDF DATA

            #EXAMPLE DATA ARRAY 1: WRF GRID DATA BASED
            #SEE: http://www.meteo.unican.es/wiki/cordexwrf/OutputVariables

            data_var_map_array = [
                                  ['precipitation_acc', ['RAINC', 'RAINNC']],
                                  ['pressure', 'PSFC'],
                                  ['relative_humidity', ['Q2', 'PSFC', 'T2']], #MUST BE IN ORDER: ['SPECIFIC HUMIDITY', 'PRESSURE', 'TEMPERATURE']
                                  ['wind_speed', ['U10', 'V10']], #['U_VELOCITY', 'V_VELOCITY']
                                  ['direct_radiation', ['SWDOWN', 'DIFFUSE_FRAC']], #MUST BE IN ORDER: ['GLOBAL RADIATION', 'DIFFUSIVE FRACTION']
                                  ['diffusive_radiation', ['SWDOWN', 'DIFFUSE_FRAC']], #MUST BE IN ORDER: ['GLOBAL RADIATION', 'DIFFUSIVE FRACTION']
                                  ['temperature', 'T2'],
                                  ['cloud_cover' , 'CLDFRA'], #'CLOUD_FRACTION'
                                 ]

            g2g.lsm_data_to_subset_netcdf("E/GSSHA/gssha_wrf_data.nc",
                                          data_var_map_array)

        HRRRtoGSSHA Example:

        .. code:: python

            from gsshapy.grid import HRRRtoGSSHA

            #STEP 1: Initialize class
            h2g = HRRRtoGSSHA(
                              #YOUR INIT PARAMETERS HERE
                             )

            #STEP 2: Generate NetCDF DATA

            #EXAMPLE DATA ARRAY 2: HRRR GRID DATA BASED
            data_var_map_array = [
                                  ['precipitation_rate', 'prate'],
                                  ['pressure', 'sp'],
                                  ['relative_humidity', '2r'],
                                  ['wind_speed', ['10u', '10v']],
                                  ['direct_radiation_cc', ['dswrf', 'tcc']],
                                  ['diffusive_radiation_cc', ['dswrf', 'tcc']],
                                  ['temperature', 't'],
                                  ['cloud_cover_pc' , 'tcc'],
                                 ]

            h2g.lsm_data_to_subset_netcdf("E:/GSSHA/gssha_wrf_data.nc",
                                          data_var_map_array)
        """
        self._check_lsm_input(data_var_map_array)

        output_datasets = []
        #DATA
        for gssha_var, lsm_var in data_var_map_array:
            if gssha_var in self.netcdf_attributes:
                self._load_converted_gssha_data_from_lsm(gssha_var, lsm_var, 'netcdf')
                #previously just added data, but needs to be hourly
                gssha_data_var_name = self.netcdf_attributes[gssha_var]['gssha_name']
                self._convert_data_to_hourly(gssha_data_var_name)
                if resample_method:
                    self._resample_data(gssha_data_var_name)
                else:
                    self.data = self.data.lsm.to_projection(gssha_data_var_name,
                                                            projection=self.gssha_grid.projection)

                output_datasets.append(self.data)
            else:
                raise ValueError("Invalid GSSHA variable name: {0} ...".format(gssha_var))
        output_dataset = xr.merge(output_datasets)
        #add global attributes
        output_dataset.attrs['Convention'] = 'CF-1.6'
        output_dataset.attrs['title'] = 'GSSHA LSM Input'
        output_dataset.attrs['history'] = 'date_created: {0}'.format(datetime.utcnow())
        output_dataset.attrs['proj4'] = self.data.attrs['proj4']
        output_dataset.attrs['geotransform'] = self.data.attrs['geotransform']

        output_dataset.to_netcdf(netcdf_file_path)