docs: def curtailment(network, carrier='solar', filename=None):
      """
      Plot curtailment of selected carrier
  
  
      Parameters
      ----------
      network : PyPSA network container
          Holds topology of grid including results from powerflow analysis
      carrier: str
          Plot curtailemt of this carrier
      filename: str or None
          Save figure in this direction
      
  
      Returns
      -------
      Plot
      """
      p_by_carrier = network.generators_t.p.groupby\
          (network.generators.carrier, axis=1).sum()
      capacity = network.generators.groupby("carrier").sum().at[carrier, "p_nom"]
      p_available = network.generators_t.p_max_pu.multiply(
              network.generators["p_nom"])
      p_available_by_carrier = p_available.groupby(
          network.generators.carrier, axis=1).sum()
      p_curtailed_by_carrier = p_available_by_carrier - p_by_carrier
      print(p_curtailed_by_carrier.sum())
      p_df = pd.DataFrame({carrier +
                           " available": p_available_by_carrier[carrier],
                           carrier +
                           " dispatched": p_by_carrier[carrier], carrier +
                           " curtailed": p_curtailed_by_carrier[carrier]})
  
      p_df[carrier + " capacity"] = capacity
      p_df[carrier + " curtailed"][p_df[carrier + " curtailed"] < 0.] = 0.
  
      fig, ax = plt.subplots(1, 1)
      fig.set_size_inches(12, 6)
      p_df[[carrier + " dispatched", carrier + " curtailed"]
           ].plot(kind="area", ax=ax, linewidth=3)
      p_df[[carrier + " available", carrier + " capacity"]
           ].plot(ax=ax, linewidth=3)
  
      ax.set_xlabel("")
      ax.set_ylabel("Power [MW]")
      ax.set_ylim([0, capacity * 1.1])
      ax.legend()
      if filename is None:
          plt.show()
      else:
          plt.savefig(filename)
          plt.close()