code: def wetdays(pr, thresh='1.0 mm/day', freq='YS'):
      r
      thresh = utils.convert_units_to(thresh, pr, 'hydro')
  
      wd = (pr >= thresh) * 1
      return wd.resample(time=freq).sum(dim='time')
docs: r"""Wet days
  
      Return the total number of days during period with precipitation over threshold.
  
      Parameters
      ----------
      pr : xarray.DataArray
        Daily precipitation [mm]
      thresh : str
        Precipitation value over which a day is considered wet. Default: '1 mm/day'.
      freq : str, optional
        Resampling frequency defining the periods
        defined in http://pandas.pydata.org/pandas-docs/stable/timeseries.html#resampling.
  
      Returns
      -------
      xarray.DataArray
        The number of wet days for each period [day]
  
      Examples
      --------
      The following would compute for each grid cell of file `pr.day.nc` the number days
      with precipitation over 5 mm at the seasonal frequency, ie DJF, MAM, JJA, SON, DJF, etc.:
  
      >>> pr = xr.open_dataset('pr.day.nc')
      >>> wd = wetdays(pr, pr_min = 5., freq="QS-DEC")