crt1d.diagnostics ================= .. py:module:: crt1d.diagnostics .. autoapi-nested-parse:: Calculations/plots using the CRT solutions (irradiance spectral profiles), using the model output dataset created by :meth:`crt1d.Model.to_xr()`. Functions --------- .. autoapisummary:: crt1d.diagnostics.band crt1d.diagnostics.compare_ebal crt1d.diagnostics.plot_compare_band crt1d.diagnostics.plot_compare_spectra Module Contents --------------- .. py:function:: band(ds, *, variables=None, band_name='PAR', bounds=None, calc_PFD=False) Reduce spectral variables in `ds` by summing in-band irradiances to give the integrated irradiance in a given spectral band. `bounds` does not have to be provided if `band_name` is one of the known bands. If `variables` is ``None``, we attempt to guess. Optionally, we additionally calculate photon flux density (PFD) variants of the quantities. It is important to do this at this stage (rather than after integrating) due to the non-linear dependence of photon energy on wavelength. :returns: :class:`xarray.Dataset` -- New dataset with no wavelength dimension, only height. .. py:function:: compare_ebal(dsets, *, band_name='solar', bounds=None) For `dsets`, assess energy balance closure by comparing computed canopy and soil absorption to incoming minus outgoing radiation at the top of the canopy. :param dsets: Created using :meth:`~crt1d.Model.to_xr`. :type dsets: :class:`list` of :class:`xarray.Dataset` :returns: :class:`pandas.DataFrame` .. py:function:: plot_compare_band(dsets, *, band_name='PAR', bounds=None, marker='.', ref=None, ref_label=None, ref_relative=False, ds_labels='scheme_long_name', legend_outside=True) Multi-panel plot to compare profiles for the specified band for a set of datasets. `bounds` does not have to be provided if `band_name` is one of the known bands. This uses :func:`band` to sum irradiances within the band. :ref:`Usage examples ` :param dsets: Created using :meth:`crt1d.Model.to_xr`. :type dsets: :class:`list` of :class:`xarray.Dataset` :param marker: Marker to be used when plotting the lines. Pass `None` to get no markers (this can make it easier to see what's going on if there are many levels). :type marker: :class:`str`, *optional* :param ref: Dataset to be used as the reference (it will be subtracted from the others in the plot). If ``str``, the first found with ``name`` `ref` will be used, so ``str`` should only be used when comparing disparate schemes, like ``2s`` vs ``4s``). Default: no reference. :type ref: :class:`str`, :class:`xarray.Dataset`, *optional* :param ref_label: If not provided, a dataset attribute will be used (``scheme_short_name`` or the one being used for legend labels). :type ref_label: :class:`str`, *optional* :param ref_relative: Whether to present relative error when using a `ref`. If false (default), absolute error is presented. :type ref_relative: :class:`bool`, *optional* :param ds_labels: If ``str``, must be a dataset attribute (that all in `dsets` have). If ``list``, should be same length as `dsets`. :type ds_labels: :class:`str` or :class:`list` of :class:`str`, *optional* :param legend_outside: Whether to place the legend outside the axes area or within. If outside, it will be placed upper right. If within, it will be placed on top of the lower left ax. :type legend_outside: :class:`bool`, *optional* .. seealso:: :obj:`band` Related function that returns a dataset for a given spectral band. :obj:`plot_compare_spectra` Similar routine, but plots one spectral variable as function of height and wavelength. .. py:function:: plot_compare_spectra(dsets, which='I_d', *, dwl_relative=True, toc_relative=False, ref=None, ref_label=None, ref_relative=False, ref_plot=False, ds_labels='scheme_short_name', norm=None, plot_type='pcolormesh', shading='auto', hspace=0.025, wspace=0.03) Multi-panel plot to compare spectra at each height for a set of datasets. :ref:`Usage examples ` :param dsets: Created using :meth:`crt1d.Model.to_xr`. :type dsets: :class:`list` of :class:`xarray.Dataset` :param which: Which spectrum to compare. Default: ``"I_d"`` (downward irradiance). :type which: :class:`str` :param dwl_relative: Whether to divide by the wavelength band width. Default: true. :type dwl_relative: :class:`bool`, *optional* :param toc_relative: Whether to divide by the top-of-canopy spectrum. :type toc_relative: :class:`bool`, *optional* :param ref: Dataset to be used as the reference (it will be subtracted from the others in the plot). If ``str``, the first found with ``name`` `ref` will be used, so ``str`` should only be used when comparing disparate schemes, like ``2s`` vs ``4s``). Default: no reference. :type ref: :class:`str`, :class:`xarray.Dataset`, *optional* :param ref_label: If not provided, a dataset attribute will be used (``scheme_short_name`` or the one being used for legend labels). :type ref_label: :class:`str`, *optional* :param ref_relative: Whether to present relative error when using a `ref`. If false (default), absolute error is presented. :type ref_relative: :class:`bool`, *optional* :param ref_plot: Whether to plot the reference. :type ref_plot: :class:`bool`, *optional* :param ds_labels: If ``str``, must be a dataset attribute (that all in `dsets` have). If ``list``, should be same length as `dsets`. :type ds_labels: :class:`str` or :class:`list` of :class:`str`, *optional* :param norm: Used if provided. :type norm: :class:`matplotlib.colors.Normalize`, *optional* :param plot_type: Currently only one `plot_type` is supported. :type plot_type: ``{"pcolormesh"}`` :param shading: For pcolormesh. :type shading: :class:`str` :param hspace: For the figure gridspec. :type hspace: :class:`float` :param wspace: For the figure gridspec. :type wspace: :class:`float` .. seealso:: :obj:`plot_compare_band` Similar routine, but integrates over a wave band and plots profiles of multiple variables.