credit.solar
============

.. py:module:: credit.solar


Attributes
----------

.. autoapisummary::

   credit.solar.tsi_data
   credit.solar.lons


Functions
---------

.. autoapisummary::

   credit.solar.era5_tsi_data
   credit.solar.get_tsi
   credit.solar.get_toa_radiation
   credit.solar.get_solar_radiation_loc
   credit.solar.get_solar_index


Module Contents
---------------

.. py:function:: era5_tsi_data() -> xarray.DataArray

   A TsiDataProvider that returns ERA5 compatible TSI data. From [Graphcast](https://github.com/google-deepmind/graphcast/blob/main/graphcast/solar_radiation.py).


.. py:data:: tsi_data

.. py:function:: get_tsi(timestamps: collections.abc.Sequence, tsi_data: xarray.DataArray) -> numpy.array

   Returns TSI values for the given timestamps.

   TSI values are interpolated from the provided yearly TSI data.

   :param timestamps: Timestamps for which to compute TSI values.
   :param tsi_data: A DataArray with a single dimension `time` that has coordinates in
   :param units of years since 0000-1-1. E.g. 2023.5 corresponds to the middle of:
   :param the year 2023.:

   :returns: An Array containing interpolated TSI data.


.. py:function:: get_toa_radiation(start_date: str, end_date: str, step_freq: str = '1h', sub_freq: str = '10Min')

   Calculate top of atmosphere solar irradiance

   :param start_date: Start date of time series
   :type start_date: str
   :param end_date: End date of time series (inclusive).
   :type end_date: str
   :param step_freq: How much time between steps in pandas time string format (e.g., 1h, 10Min)
   :type step_freq: str
   :param sub_freq: How much time between substeps that are integrated forward (e.g., 10Min)
   :type sub_freq: str

   :returns: top of atmosphere radiation in W m**-2.


.. py:function:: get_solar_radiation_loc(toa_radiation: pandas.Series, lon: float, lat: float, altitude: float, start_date: str, end_date: str, step_freq: str = '1h', sub_freq: str = '10Min', solar_var: str = 'tsi') -> xarray.Dataset

   Calculate total solar irradiance at a single location over a range of times. Solar irradiance is integrated
   over the step frequency at specified substeps.

   :param toa_radiation: Top of atmosphere solar radiation in W m**-2.
   :type toa_radiation: pd.Series
   :param lon: longitude.
   :type lon: float
   :param lat: latitude.
   :type lat: float
   :param altitude: altitude in meters.
   :type altitude: float
   :param start_date: date str for the beginning of the period (inclusive).
   :type start_date: str
   :param end_date: date str for the end of the period (inclusive).
   :type end_date: str
   :param step_freq: period over which irradiance is integrated. Defaults to "1h".
   :type step_freq: str
   :param sub_freq: sub step frequency over the step period. Defaults to "5Min".
   :type sub_freq: str

   :returns: total solar irradiance and cosine of solar zenith angle time series with metadata.
   :rtype: xarray.Dataset


.. py:function:: get_solar_index(curr_date, ref_date='2000-01-01')

.. py:data:: lons

