docstr: Shade the darkside of the Earth, accounting for refraction.
  
  Parameters
  ----------
  date : datetime
      A UTC datetime object used to calculate the position of the sun.
      Default: datetime.datetime.utcnow()
  delta : float
      Stepsize in degrees to determine the resolution of the
      night polygon feature (``npts = 180 / delta``).
  refraction : float
      The adjustment in degrees due to refraction,
      thickness of the solar disc, elevation etc...
  
  Note
  ----
      Matplotlib keyword arguments can be used when drawing the feature.
      This allows standard Matplotlib control over aspects such as
      'color', 'alpha', etc.
code: def __init__(
      self,
      date=None,
      delta=0.1,
      refraction=-0.83,
      color="k",
      alpha=0.5,
      **kwargs,
  ):
      """
      Shade the darkside of the Earth, accounting for refraction.
  
      Parameters
      ----------
      date : datetime
          A UTC datetime object used to calculate the position of the sun.
          Default: datetime.datetime.utcnow()
      delta : float
          Stepsize in degrees to determine the resolution of the
          night polygon feature (``npts = 180 / delta``).
      refraction : float
          The adjustment in degrees due to refraction,
          thickness of the solar disc, elevation etc...
  
      Note
      ----
          Matplotlib keyword arguments can be used when drawing the feature.
          This allows standard Matplotlib control over aspects such as
          'color', 'alpha', etc.
  
      """
      if date is None:
          date = datetime.datetime.utcnow()
  
      # make sure date is UTC, or naive with respect to time zones
      if date.utcoffset():
          raise ValueError(
              f"datetime instance must be UTC, not {date.tzname()}"
          )
  
      # Returns the Greenwich hour angle,
      # need longitude (opposite direction)
      lat, lon = _solar_position(date)
      pole_lon = lon
      if lat > 0:
          pole_lat = -90 + lat
          central_lon = 180
      else:
          pole_lat = 90 + lat
          central_lon = 0
  
      rotated_pole = ccrs.RotatedPole(
          pole_latitude=pole_lat,
          pole_longitude=pole_lon,
          central_rotated_longitude=central_lon,
      )
  
      npts = int(180 / delta)
      x = np.empty(npts * 2)
      y = np.empty(npts * 2)
  
      # Solve the equation for sunrise/sunset:
      # https://en.wikipedia.org/wiki/Sunrise_equation#Generalized_equation
      # NOTE: In the generalized equation on Wikipedia,
      #       delta == 0. in the rotated pole coordinate system.
      #       Therefore, the max/min latitude is +/- (90+refraction)
  
      # Fill latitudes up and then down
      y[:npts] = np.linspace(-(90 + refraction), 90 + refraction, npts)
      y[npts:] = y[:npts][::-1]
  
      # Solve the generalized equation for omega0, which is the
      # angle of sunrise/sunset from solar noon
      # We need to clip the input to arccos to [-1, 1] due to floating
      # point precision and arccos creating nans for values outside
      # of the domain
      arccos_tmp = np.clip(
          np.sin(np.deg2rad(refraction)) / np.cos(np.deg2rad(y)), -1, 1
      )
      omega0 = np.rad2deg(np.arccos(arccos_tmp))
  
      # Fill the longitude values from the offset for midnight.
      # This needs to be a closed loop to fill the polygon.
      # Negative longitudes
      x[:npts] = -(180 - omega0[:npts])
      # Positive longitudes
      x[npts:] = 180 - omega0[npts:]
  
      kwargs.setdefault("facecolor", color)
      kwargs.setdefault("alpha", alpha)
  
      geom = sgeom.Polygon(np.column_stack((x, y)))
      return super().__init__([geom], rotated_pole, **kwargs)
  
file_path: cartopy/lib/cartopy/feature/nightshade.py
imports: import datetime
  import numpy
  import shapely.geometry
  from ..None import crs
  from .None import ShapelyFeature
label_desc: Use image node_id 1 to create a new Nightshade object from inherited base classes: ShapelyFeature with example: obj = Nightshade(date, delta, refraction, color, alpha)