code: def ice_days(tasmax, freq='YS'):
      r
      tu = units.parse_units(tasmax.attrs['units'].replace('-', '**-'))
      fu = 'degC'
      frz = 0
      if fu != tu:
          frz = units.convert(frz, fu, tu)
      f = (tasmax < frz) * 1
      return f.resample(time=freq).sum(dim='time')
docs: r"""Number of ice/freezing days
  
      Number of days where daily maximum temperatures are below 0℃.
  
      Parameters
      ----------
      tasmax : xarrray.DataArray
        Maximum daily temperature [℃] or [K]
      freq : str, optional
        Resampling frequency
  
      Returns
      -------
      xarray.DataArray
        Number of ice/freezing days.
  
      Notes
      -----
      Let :math:`TX_{ij}` be the daily maximum temperature at day :math:`i` of period :math:`j`. Then
      counted is the number of days where:
  
      .. math::
  
          TX_{ij} < 0℃