code: def wind_direction(u, v):
      r
      wdir = 90. * units.deg - np.arctan2(-v, -u)
      origshape = wdir.shape
      wdir = atleast_1d(wdir)
      wdir[wdir <= 0] += 360. * units.deg
      # Need to be able to handle array-like u and v (with or without units)
      # np.any check required for legacy numpy which treats 0-d False boolean index as zero
      calm_mask = (np.asarray(u) == 0.) & (np.asarray(v) == 0.)
      if np.any(calm_mask):
          wdir[calm_mask] = 0. * units.deg
      return wdir.reshape(origshape).to('degrees')
docs: r"""Compute the wind direction from u and v-components.
  
      Parameters
      ----------
      u : array_like
          Wind component in the X (East-West) direction
      v : array_like
          Wind component in the Y (North-South) direction
  
      Returns
      -------
      direction: `pint.Quantity`
          The direction of the wind in interval [0, 360] degrees, specified as the direction from
          which it is blowing, with 360 being North.
  
      See Also
      --------
      wind_components
  
      Notes
      -----
      In the case of calm winds (where `u` and `v` are zero), this function returns a direction
      of 0.