def solar_longitude( day, orb=const.orb_present, days_per_year = None ):
if days_per_year is None:<EOL><INDENT>days_per_year = const.days_per_year<EOL><DEDENT>ecc = orb['<STR_LIT>']<EOL>long_peri_rad = deg2rad( orb['<STR_LIT>'])<EOL>delta_lambda = (day - <NUM_LIT>) * <NUM_LIT:2>*pi/days_per_year<EOL>beta = sqrt(<NUM_LIT:1> - ecc**<NUM_LIT:2>)<EOL>lambda_long_m = -<NUM_LIT:2>*((ecc/<NUM_LIT:2> + (ecc**<NUM_LIT:3>)/<NUM_LIT:8> ) * (<NUM_LIT:1>+beta) * sin(-long_peri_rad) -<EOL>(ecc**<NUM_LIT:2>)/<NUM_LIT:4> * (<NUM_LIT:1>/<NUM_LIT:2> + beta) * sin(-<NUM_LIT:2>*long_peri_rad) + (ecc**<NUM_LIT:3>)/<NUM_LIT:8> *<EOL>(<NUM_LIT:1>/<NUM_LIT:3> + beta) * sin(-<NUM_LIT:3>*long_peri_rad)) + delta_lambda<EOL>lambda_long = ( lambda_long_m + (<NUM_LIT:2>*ecc - (ecc**<NUM_LIT:3>)/<NUM_LIT:4>)*sin(lambda_long_m - long_peri_rad) +<EOL>(<NUM_LIT:5>/<NUM_LIT:4>)*(ecc**<NUM_LIT:2>) * sin(<NUM_LIT:2>*(lambda_long_m - long_peri_rad)) + (<NUM_LIT>/<NUM_LIT:12>)*(ecc**<NUM_LIT:3>)<EOL>* sin(<NUM_LIT:3>*(lambda_long_m - long_peri_rad)) )<EOL>return lambda_long<EOL>
Estimates solar longitude from calendar day.

    Method is using an approximation from :cite:`Berger_1978` section 3
    (lambda = 0 at spring equinox).

    **Function-call arguments** \n

    :param array day:           Indicator of time of year.
    :param dict orb:            a dictionary with three members (as provided by
                                :class:`~climlab.solar.orbital.OrbitalTable`)

                                * ``'ecc'`` - eccentricity

                                    * unit: dimensionless
                                    * default value: ``0.017236``

                                * ``'long_peri'`` - longitude of perihelion
                                  (precession angle)

                                    * unit: degrees
                                    * default value: ``281.37``

                                * ``'obliquity'`` - obliquity angle

                                    * unit: degrees
                                    * default value: ``23.446``
    :param float days_per_year: number of days in a year (optional)
                                (default: 365.2422)
                                Reads the length of the year from
                                :mod:`~climlab.utils.constants` if available.
    :returns:                   solar longitude ``lambda_long``
                                in dimension``( day.size, ecc.size )``
    :rtype:                     array

    Works for both scalar and vector orbital parameters.