original_docstring: 
          Update surface type according to climatic mass balance over the last five years.
  
          If 5-year climatic balance is positive, then snow/firn.  If negative, then ice/debris.
          Convention: 0 = off-glacier, 1 = ice, 2 = snow, 3 = firn, 4 = debris
  
          Function Options:
            > 1 (default) - update surface type according to Huss and Hock (2015)
            > 2 - Radic and Hock (2011)
          Huss and Hock (2015): Initially, above median glacier elevation is firn, below is ice. Surface type updated for
            each elevation band and month depending on specific mass balance.  If the cumulative balance since the start
            of mass balance year is positive, then snow is assigned. If the cumulative mass balance is negative (i.e.,
            all snow of current mass balance year has melted), then bare ice or firn exposed. Surface type is assumed to
            be firn if the elevation band's average annual balance over the preceding 5 years (B_t-5_avg) is positive. If
            B_t-5_avg is negative, surface type is ice.
                > climatic mass balance calculated at each bin and used with the mass balance over the last 5 years to
                  determine whether the surface is firn or ice.  Snow is separate based on each month.
          Radic and Hock (2011): "DDF_snow is used above the ELA regardless of snow cover.  Below the ELA, use DDF_ice is
            used only when snow cover is 0.  ELA is calculated from observed annual mass balance profiles averaged over
            the observational period and is kept constant in time for the calibration period.  For the future projections,
            ELA is set to the mean glacier height and is time dependent since glacier volume, area, and length are time
            dependent (volume-area-length scaling).
            Bliss et al. (2014) uses the same as Valentina's model
  
          Parameters
          ----------
          surfacetype : np.ndarray
              Surface type for each elevation bin
          glac_bin_massbalclim_annual : np.ndarray
              Annual climatic mass balance for each year and each elevation bin
          year_index : int
              Count of the year of model run (first year is 0)
          Returns
          -------
          surfacetype : np.ndarray
              Updated surface type for each elevation bin
          firnline_idx : int
              Firn line index
          
docstring: Update surface type according to climatic mass balance over the last five years.
  If 5-year climatic balance is positive, then snow/firn.  If negative, then ice/debris.
  
  Function Options:
  > 1 (default) - update surface type according to Huss and Hock (2015)
  > 2 - Radic and Hock (2011)
  Huss and Hock (2015): Initially, above median glacier elevation is firn, below is ice. Surface type updated for
  each elevation band and month depending on specific mass balance.  If the cumulative balance since the start
  of mass balance year is positive, then snow is assigned. If the cumulative mass balance is negative , then bare ice or firn exposed. Surface type is assumed to
  be firn if the elevation band's average annual balance over the preceding 5 years (B_t-5_avg) is positive. If
  B_t-5_avg is negative, surface type is ice.
  > climatic mass balance calculated at each bin and used with the mass balance over the last 5 years to
  determine whether the surface is firn or ice.  Snow is separate based on each month.
  Radic and Hock (2011): "DDF_snow is used above the ELA regardless of snow cover.  Below the ELA, use DDF_ice is
  used only when snow cover is 0.  ELA is calculated from observed annual mass balance profiles averaged over
  the observational period and is kept constant in time for the calibration period.  For the future projections,
  ELA is set to the mean glacier height and is time dependent since glacier volume, area, and length are time
  dependent (volume-area-length scaling).
  Bliss et al. (2014) uses the same as Valentina's model
  
  Parameters
  
  surfacetype : np.ndarray
  Surface type for each elevation bin
  glac_bin_massbalclim_annual : np.ndarray
  Annual climatic mass balance for each year and each elevation bin
  year_index : int
  Count of the year of model run (first year is 0)
  Returns
  
  surfacetype : np.ndarray
  Updated surface type for each elevation bin
  firnline_idx : int
  Firn line index
docstring_tokens: Update surface type according to climatic mass balance over the last five years . If 5 - year climatic balance is positive then snow / firn . If negative then ice / debris . Function Options : > 1 ( default ) - update surface type according to Huss and Hock ( 2015 ) > 2 - Radic and Hock ( 2011 ) Huss and Hock ( 2015 ) : Initially above median glacier elevation is firn below is ice . Surface type updated for each elevation band and month depending on specific mass balance . If the cumulative balance since the start of mass balance year is positive then snow is assigned . If the cumulative mass balance is negative then bare ice or firn exposed . Surface type is assumed to be firn if the elevation band ' s average annual balance over the preceding 5 years ( B_t - 5_avg ) is positive . If B_t - 5_avg is negative surface type is ice . > climatic mass balance calculated at each bin and used with the mass balance over the last 5 years to determine whether the surface is firn or ice . Snow is separate based on each month . Radic and Hock ( 2011 ) : " DDF_snow is used above the ELA regardless of snow cover . Below the ELA use DDF_ice is used only when snow cover is 0 . ELA is calculated from observed annual mass balance profiles averaged over the observational period and is kept constant in time for the calibration period . For the future projections ELA is set to the mean glacier height and is time dependent since glacier volume area and length are time dependent ( volume - area - length scaling ) . Bliss et al . ( 2014 ) uses the same as Valentina ' s model Parameters surfacetype : np . ndarray Surface type for each elevation bin glac_bin_massbalclim_annual : np . ndarray Annual climatic mass balance for each year and each elevation bin year_index : int Count of the year of model run ( first year is 0 ) Returns surfacetype : np . ndarray Updated surface type for each elevation bin firnline_idx : int Firn line index
code: def _surfacetypebinsannual(self, surfacetype, glac_bin_massbalclim_annual, year_index):
          """
          Update surface type according to climatic mass balance over the last five years.
  
          If 5-year climatic balance is positive, then snow/firn.  If negative, then ice/debris.
          Convention: 0 = off-glacier, 1 = ice, 2 = snow, 3 = firn, 4 = debris
  
          Function Options:
            > 1 (default) - update surface type according to Huss and Hock (2015)
            > 2 - Radic and Hock (2011)
          Huss and Hock (2015): Initially, above median glacier elevation is firn, below is ice. Surface type updated for
            each elevation band and month depending on specific mass balance.  If the cumulative balance since the start
            of mass balance year is positive, then snow is assigned. If the cumulative mass balance is negative (i.e.,
            all snow of current mass balance year has melted), then bare ice or firn exposed. Surface type is assumed to
            be firn if the elevation band's average annual balance over the preceding 5 years (B_t-5_avg) is positive. If
            B_t-5_avg is negative, surface type is ice.
                > climatic mass balance calculated at each bin and used with the mass balance over the last 5 years to
                  determine whether the surface is firn or ice.  Snow is separate based on each month.
          Radic and Hock (2011): "DDF_snow is used above the ELA regardless of snow cover.  Below the ELA, use DDF_ice is
            used only when snow cover is 0.  ELA is calculated from observed annual mass balance profiles averaged over
            the observational period and is kept constant in time for the calibration period.  For the future projections,
            ELA is set to the mean glacier height and is time dependent since glacier volume, area, and length are time
            dependent (volume-area-length scaling).
            Bliss et al. (2014) uses the same as Valentina's model
  
          Parameters
          ----------
          surfacetype : np.ndarray
              Surface type for each elevation bin
          glac_bin_massbalclim_annual : np.ndarray
              Annual climatic mass balance for each year and each elevation bin
          year_index : int
              Count of the year of model run (first year is 0)
          Returns
          -------
          surfacetype : np.ndarray
              Updated surface type for each elevation bin
          firnline_idx : int
              Firn line index
          """
          # Next year's surface type is based on the bin's average annual climatic mass balance over the last 5 years.  If
          #  less than 5 years, then use the average of the existing years.
          if year_index < 5:
              # Calculate average annual climatic mass balance since run began
              massbal_clim_mwe_runningavg = glac_bin_massbalclim_annual[:,0:year_index+1].mean(1)
          else:
              massbal_clim_mwe_runningavg = glac_bin_massbalclim_annual[:,year_index-4:year_index+1].mean(1)
          # If the average annual specific climatic mass balance is negative, then the surface type is ice (or debris)
          surfacetype[(surfacetype !=0 ) & (massbal_clim_mwe_runningavg <= 0)] = 1
          # If the average annual specific climatic mass balance is positive, then the surface type is snow (or firn)
          surfacetype[(surfacetype != 0) & (massbal_clim_mwe_runningavg > 0)] = 2
          # Compute the firnline index
          try:
              # firn in bins >= firnline_idx
              firnline_idx = np.where(surfacetype==2)[0][0]
          except:
              # avoid errors if there is no firn, i.e., the entire glacier is melting
              firnline_idx = np.where(surfacetype!=0)[0][-1]
          # Apply surface type model options
          # If firn surface type option is included, then snow is changed to firn
          if pygem_prms.include_firn == 1:
              surfacetype[surfacetype == 2] = 3
          return surfacetype, firnline_idx
code_tokens: def _surfacetypebinsannual ( self , surfacetype , glac_bin_massbalclim_annual , year_index ) : if year_index < 5 : massbal_clim_mwe_runningavg = glac_bin_massbalclim_annual [ : , 0 : year_index + 1 ] . mean ( 1 ) else : massbal_clim_mwe_runningavg = glac_bin_massbalclim_annual [ : , year_index - 4 : year_index + 1 ] . mean ( 1 ) surfacetype [ ( surfacetype != 0 ) & ( massbal_clim_mwe_runningavg <= 0 ) ] = 1 surfacetype [ ( surfacetype != 0 ) & ( massbal_clim_mwe_runningavg > 0 ) ] = 2 try : firnline_idx = np . where ( surfacetype == 2 ) [ 0 ] [ 0 ] except : firnline_idx = np . where ( surfacetype != 0 ) [ 0 ] [ - 1 ] if pygem_prms . include_firn == 1 : surfacetype [ surfacetype == 2 ] = 3 return surfacetype , firnline_idx
short_docstring: Update surface type according to climatic mass balance over the last five years.
short_docstring_tokens: Update surface type according to climatic mass balance over the last five years .
comment: """
          Update surface type according to climatic mass balance over the last five years.
  
          If 5-year climatic balance is positive, then snow/firn.  If negative, then ice/debris.
          Convention: 0 = off-glacier, 1 = ice, 2 = snow, 3 = firn, 4 = debris
  
          Function Options:
            > 1 (default) - update surface type according to Huss and Hock (2015)
            > 2 - Radic and Hock (2011)
          Huss and Hock (2015): Initially, above median glacier elevation is firn, below is ice. Surface type updated for
            each elevation band and month depending on specific mass balance.  If the cumulative balance since the start
            of mass balance year is positive, then snow is assigned. If the cumulative mass balance is negative (i.e.,
            all snow of current mass balance year has melted), then bare ice or firn exposed. Surface type is assumed to
            be firn if the elevation band's average annual balance over the preceding 5 years (B_t-5_avg) is positive. If
            B_t-5_avg is negative, surface type is ice.
                > climatic mass balance calculated at each bin and used with the mass balance over the last 5 years to
                  determine whether the surface is firn or ice.  Snow is separate based on each month.
          Radic and Hock (2011): "DDF_snow is used above the ELA regardless of snow cover.  Below the ELA, use DDF_ice is
            used only when snow cover is 0.  ELA is calculated from observed annual mass balance profiles averaged over
            the observational period and is kept constant in time for the calibration period.  For the future projections,
            ELA is set to the mean glacier height and is time dependent since glacier volume, area, and length are time
            dependent (volume-area-length scaling).
            Bliss et al. (2014) uses the same as Valentina's model
  
          Parameters
          ----------
          surfacetype : np.ndarray
              Surface type for each elevation bin
          glac_bin_massbalclim_annual : np.ndarray
              Annual climatic mass balance for each year and each elevation bin
          year_index : int
              Count of the year of model run (first year is 0)
          Returns
          -------
          surfacetype : np.ndarray
              Updated surface type for each elevation bin
          firnline_idx : int
              Firn line index
          """$SEP$# Next year's surface type is based on the bin's average annual climatic mass balance over the last 5 years.  If$SEP$#  less than 5 years, then use the average of the existing years.$SEP$# Calculate average annual climatic mass balance since run began$SEP$# If the average annual specific climatic mass balance is negative, then the surface type is ice (or debris)$SEP$# If the average annual specific climatic mass balance is positive, then the surface type is snow (or firn)$SEP$# Compute the firnline index$SEP$# firn in bins >= firnline_idx$SEP$# avoid errors if there is no firn, i.e., the entire glacier is melting$SEP$# Apply surface type model options$SEP$# If firn surface type option is included, then snow is changed to firn