/usr/lib/python2.7/dist-packages/Pysolar/util.py is in python-pysolar 0.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright Brandon Stafford
#
# This file is part of Pysolar.
#
# Pysolar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Pysolar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Pysolar. If not, see <http://www.gnu.org/licenses/>.
"""Additional support functions for solar geometry, astronomy, radiation correlation
:Original author: Simeon Nwaogaidu
:Contact: SimeonObinna.Nwaogaidu AT lahmeyer DOT de
:Additional author: Holger Zebner
:Contact: holger.zebner AT lahmeyer DOT de
:Additional author: Brandon Stafford
"""
from datetime import datetime as dt
from datetime import timedelta
import math
import pytz
from pytz import all_timezones
from . import solar
# Some default constants
AM_default = 2.0 # Default air mass is 2.0
TL_default = 1.0 # Default Linke turbidity factor is 1.0
SC_default = 1367.0 # Solar constant in W/m^2 is 1367.0. Note that this value could vary by +/-4 W/m^2
TY_default = 365 # Total year number from 1 to 365 days
elevation_default = 0.0 # Default elevation is 0.0
# Useful equations for analysis
def GetSunriseSunset(latitude_deg, longitude_deg, utc_datetime, timezone):
"""This function calculates the astronomical sunrise and sunset times in local time.
Parameters
----------
latitude_deg : float
latitude in decimal degree. A geographical term denoting
the north/south angular location of a place on a sphere.
longitude_deg : float
longitude in decimal degree. Longitude shows your location
in an east-west direction,relative to the Greenwich meridian.
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
timezone : float
timezone as numerical value: GMT offset in hours. A time zone is a region of
the earth that has uniform standard time, usually referred to as the local time.
Returns
-------
sunrise_time_dt : datetime.datetime
Sunrise time in local time as datetime_obj.
sunset_time_dt : datetime.datetime
Sunset time in local time as datetime_obj.
References
----------
.. [1] http://www.skypowerinternational.com/pdf/Radiation/7.1415.01.121_cm121_bed-anleitung_engl.pdf
.. [2] http://pysolar.org/
Examples
--------
>>> gmt_offset = 1
>>> lat = 50.111512
>>> lon = 8.680506
>>> timezone_local = 'Europe/Berlin'
>>> utct = dt.datetime.utcnow()
>>> sr, ss = sb.GetSunriseSunset(lat, lon, utct, gmt_offset)
>>> print 'sunrise: ', sr
>>> print 'sunset:', ss
"""
# Day of the year
day = solar.GetDayOfYear(utc_datetime)
# Solar hour angle
SHA = ((timezone)* 15.0 - longitude_deg)
# Time adjustment
TT = (279.134+0.985647*day)*math.pi/180
# Time adjustment in hours
time_adst = ((5.0323 - 100.976*math.sin(TT)+595.275*math.sin(2*TT)+
3.6858*math.sin(3*TT) - 12.47*math.sin(4*TT) - 430.847*math.cos(TT)+
12.5024*math.cos(2*TT) + 18.25*math.cos(3*TT))/3600)
# Time of noon
TON = (12 + (SHA/15.0) - time_adst)
sunn = (math.pi/2-(23.45*math.pi/180)*math.tan(latitude_deg*math.pi/180)*
math.cos(2*math.pi*day/365.25))*(180/(math.pi*15))
# Sunrise_time in hours
sunrise_time = (TON - sunn + time_adst)
# Sunset_time in hours
sunset_time = (TON + sunn - time_adst)
sunrise_time_dt = date_with_decimal_hour(utc_datetime, sunrise_time)
sunset_time_dt = date_with_decimal_hour(utc_datetime, sunset_time)
return sunrise_time_dt, sunset_time_dt
def GetSunriseTime(latitude_deg, longitude_deg, utc_datetime, timezone):
"Wrapper for GetSunriseSunset that returns just the sunrise time"
sr, ss = GetSunriseSunset(latitude_deg, longitude_deg, utc_datetime, timezone)
return sr
def GetSunsetTime(latitude_deg, longitude_deg, utc_datetime, timezone):
"Wrapper for GetSunriseSunset that returns just the sunset time"
sr, ss = GetSunriseSunset(latitude_deg, longitude_deg, utc_datetime, timezone)
return ss
def mean_earth_sun_distance(utc_datetime):
"""Mean Earth-Sun distance is the arithmetical mean of the maximum and minimum distances
between a planet (Earth) and the object about which it revolves (Sun). However,
the function is used to calculate the Mean earth sun distance.
Parameters
----------
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
Returns
-------
KD : float
Mean earth sun distance
References
----------
.. [1] http://sunbird.jrc.it/pvgis/solres/solmod3.htm#clear-sky%20radiation
.. [2] R. aguiar and et al, "The ESRA user guidebook, vol. 2. database", models and exploitation software-Solar
radiation models, p.113
"""
return (1 - (0.0335 * math.sin(360 * ((solar.GetDayOfYear(utc_datetime)) - 94)) / (365)))
def extraterrestrial_irrad(utc_datetime, latitude_deg, longitude_deg,SC=SC_default):
"""Equation calculates Extratrestrial radiation. Solar radiation incident outside the earth's
atmosphere is called extraterrestrial radiation. On average the extraterrestrial irradiance
is 1367 Watts/meter2 (W/m2). This value varies by + or - 3 percent as the earth orbits the sun.
The earth's closest approach to the sun occurs around January 4th and it is furthest
from the sun around July 5th.
Parameters
----------
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
latitude_deg : float
latitude in decimal degree. A geographical term denoting the north/south angular location
of a place on a sphere.
longitude_deg : float
longitude in decimal degree. Longitude shows your location in an east-west direction,relative
to the Greenwich meridian.
SC : float
The solar constant is the amount of incoming solar electromagnetic radiation per unit area, measured
on the outer surface of Earth's atmosphere in a plane perpendicular to the rays.It is measured by
satellite to be roughly 1366 watts per square meter (W/m^2)
Returns
-------
EXTR1 : float
Extraterrestrial irradiation
References
----------
.. [1] http://solardat.uoregon.edu/SolarRadiationBasics.html
.. [2] Dr. J. Schumacher and et al,"INSEL LE(Integrated Simulation Environment Language)Block reference",p.68
"""
day = solar.GetDayOfYear(utc_datetime)
ab = math.cos(2 * math.pi * (solar.GetDayOfYear(utc_datetime) - 1.0)/(365.0))
bc = math.sin(2 * math.pi * (solar.GetDayOfYear(utc_datetime) - 1.0)/(365.0))
cd = math.cos(2 * (2 * math.pi * (solar.GetDayOfYear(utc_datetime) - 1.0)/(365.0)))
df = math.sin(2 * (2 * math.pi * (solar.GetDayOfYear(utc_datetime) - 1.0)/(365.0)))
decl = solar.GetDeclination(day)
ha = solar.GetHourAngle(utc_datetime, longitude_deg)
ZA = math.sin(latitude_deg) * math.sin(decl) + math.cos(latitude_deg) * math.cos(decl) * math.cos(ha)
return SC * ZA * (1.00010 + 0.034221 * ab + 0.001280 * bc + 0.000719 * cd + 0.000077 * df)
def declination_degree(utc_datetime, TY = TY_default ):
"""The declination of the sun is the angle between Earth's equatorial plane and a line
between the Earth and the sun. It varies between 23.45 degrees and -23.45 degrees,
hitting zero on the equinoxes and peaking on the solstices.
Parameters
----------
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
TY : float
Total number of days in a year. eg. 365 days per year,(no leap days)
Returns
-------
DEC : float
The declination of the Sun
References
----------
.. [1] http://pysolar.org/
"""
return 23.45 * math.sin((2 * math.pi / (TY)) * ((solar.GetDayOfYear(utc_datetime)) - 81))
def solarelevation_function_clear(latitude_deg, longitude_deg, utc_datetime,temperature_celsius = 25,
pressure_millibars = 1013.25, elevation = elevation_default):
"""Equation calculates Solar elevation function for clear sky type.
Parameters
----------
latitude_deg : float
latitude in decimal degree. A geographical term denoting
the north/south angular location of a place on a sphere.
longitude_deg : float
longitude in decimal degree. Longitude shows your location
in an east-west direction,relative to the Greenwich meridian.
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
temperature_celsius : float
Temperature is a physical property of a system that underlies the common notions of hot and cold.
pressure_millibars : float
pressure_millibars
elevation : float
The elevation of a geographic location is its height above a fixed reference point, often the mean
sea level.
Returns
-------
SOLALTC : float
Solar elevation function clear sky
References
----------
.. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status
and proposed new approaches", energy 30 (2005), pp 1533 - 1549.
"""
altitude = solar.GetAltitude(latitude_deg, longitude_deg,utc_datetime, elevation, temperature_celsius,pressure_millibars)
return (0.038175 + (1.5458 * (math.sin(altitude))) + ((-0.59980) * (0.5 * (1 - math.cos(2 * (altitude))))))
def solarelevation_function_overcast(latitude_deg, longitude_deg, utc_datetime,
elevation = elevation_default, temperature_celsius = 25,
pressure_millibars = 1013.25):
""" The function calculates solar elevation function for overcast sky type.
This associated hourly overcast radiation model is based on the estimation of the
overcast sky transmittance with the sun directly overhead combined with the application
of an over sky elavation function to estimate the overcast day global irradiation
value at any solar elevation.
Parameters
----------
latitude_deg : float
latitude in decimal degree. A geographical term denoting the north/south angular location of a place on a
sphere.
longitude_deg : float
longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the
Greenwich meridian.
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
elevation : float
The elevation of a geographic location is its height above a fixed reference point, often the mean sea level.
temperature_celsius : float
Temperature is a physical property of a system that underlies the common notions of hot and cold.
pressure_millibars : float
pressure_millibars
Returns
-------
SOLALTO : float
Solar elevation function overcast
References
----------
.. [1] Prof. Peter Tregenza,"Solar radiation and daylight models", p.89.
.. [2] Also accessible through Google Books: http://tinyurl.com/5kdbwu
Tariq Muneer, "Solar Radiation and Daylight Models, Second Edition: For the Energy Efficient
Design of Buildings"
"""
altitude = solar.GetAltitude(latitude_deg, longitude_deg,utc_datetime, elevation, temperature_celsius,pressure_millibars)
return ((-0.0067133) + (0.78600 * (math.sin(altitude)))) + (0.22401 * (0.5 * (1 - math.cos(2 * altitude))))
def diffuse_transmittance(TL = TL_default):
"""Equation calculates the Diffuse_transmittance and the is the Theoretical Diffuse Irradiance on a horizontal
surface when the sun is at the zenith.
Parameters
----------
TL : float
Linke turbidity factor
Returns
-------
DT : float
diffuse_transmittance
References
----------
.. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed
new approaches", energy 30 (2005), pp 1533 - 1549.
"""
return ((-21.657) + (41.752 * (TL)) + (0.51905 * (TL) * (TL)))
def diffuse_underclear(latitude_deg, longitude_deg, utc_datetime, elevation = elevation_default,
temperature_celsius = 25, pressure_millibars = 1013.25, TL=TL_default):
"""Equation calculates diffuse radiation under clear sky conditions.
Parameters
----------
latitude_deg : float
latitude in decimal degree. A geographical term denoting the north/south angular location of a place on
a sphere.
longitude_deg : float
longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the
Greenwich meridian.
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
elevation : float
The elevation of a geographic location is its height above a fixed reference point, often the mean sea level.
temperature_celsius : float
Temperature is a physical property of a system that underlies the common notions of hot and cold.
pressure_millibars : float
pressure_millibars
TL : float
Linke turbidity factor
Returns
-------
DIFFC : float
Diffuse Irradiation under clear sky
References
----------
.. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed
new approaches", energy 30 (2005), pp 1533 - 1549.
"""
DT = ((-21.657) + (41.752 * (TL)) + (0.51905 * (TL) * (TL)))
altitude = solar.GetAltitude(latitude_deg, longitude_deg,utc_datetime, elevation, temperature_celsius,pressure_millibars)
return mean_earth_sun_distance(utc_datetime) * DT * altitude
def diffuse_underovercast(latitude_deg, longitude_deg, utc_datetime, elevation = elevation_default,
temperature_celsius = 25, pressure_millibars = 1013.25,TL=TL_default):
"""Function calculates the diffuse radiation under overcast conditions.
Parameters
----------
latitude_deg : float
latitude in decimal degree. A geographical term denoting the north/south angular location of a place on a
sphere.
longitude_deg : float
longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the
Greenwich meridian.
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
elevation : float
The elevation of a geographic location is its height above a fixed reference point, often the mean sea level.
temperature_celsius : float
Temperature is a physical property of a system that underlies the common notions of hot and cold.
pressure_millibars : float
pressure_millibars
TL : float
Linke turbidity factor
Returns
-------
DIFOC : float
Diffuse Irradiation under overcast
References
----------
.. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed
new approaches", energy 30 (2005), pp 1533 - 1549.
"""
DT = ((-21.657) + (41.752 * (TL)) + (0.51905 * (TL) * (TL)))
DIFOC = ((mean_earth_sun_distance(utc_datetime)
)*(DT)*(solar.GetAltitude(latitude_deg,longitude_deg, utc_datetime, elevation,
temperature_celsius, pressure_millibars)))
return DIFOC
def direct_underclear(latitude_deg, longitude_deg, utc_datetime,
temperature_celsius = 25, pressure_millibars = 1013.25, TY = TY_default,
AM = AM_default, TL = TL_default,elevation = elevation_default):
"""Equation calculates direct radiation under clear sky conditions.
Parameters
----------
latitude_deg : float
latitude in decimal degree. A geographical term denoting the north/south angular location of a
place on a sphere.
longitude_deg : float
longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the
Greenwich meridian.
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
temperature_celsius : float
Temperature is a physical property of a system that underlies the common notions of hot and cold.
pressure_millibars : float
pressure_millibars
TY : float
Total number of days in a year. eg. 365 days per year,(no leap days)
AM : float
Air mass. An Air Mass is a measure of how far light travels through the Earth's atmosphere. One air mass,
or AM1, is the thickness of the Earth's atmosphere. Air mass zero (AM0) describes solar irradiance in space,
where it is unaffected by the atmosphere. The power density of AM1 light is about 1,000 W/m^2
TL : float
Linke turbidity factor
elevation : float
The elevation of a geographic location is its height above a fixed reference point, often the mean
sea level.
Returns
-------
DIRC : float
Direct Irradiation under clear
References
----------
.. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed
new approaches", energy 30 (2005), pp 1533 - 1549.
"""
KD = mean_earth_sun_distance(utc_datetime)
DEC = declination_degree(utc_datetime,TY)
DIRC = (1367 * KD * math.exp(-0.8662 * (AM) * (TL) * (DEC)
) * math.sin(solar.GetAltitude(latitude_deg,longitude_deg,
utc_datetime,elevation ,
temperature_celsius , pressure_millibars )))
return DIRC
def global_irradiance_clear(DIRC, DIFFC, latitude_deg, longitude_deg, utc_datetime,
temperature_celsius = 25, pressure_millibars = 1013.25, TY = TY_default,
AM = AM_default, TL = TL_default, elevation = elevation_default):
"""Equation calculates global irradiance under clear sky conditions.
Parameters
----------
DIRC : float
Direct Irradiation under clear
DIFFC : float
Diffuse Irradiation under clear sky
latitude_deg : float
latitude in decimal degree. A geographical term denoting the north/south angular location of a place
on a sphere.
longitude_deg : float
longitude in decimal degree. Longitude shows your location in an east-west direction,relative to
the Greenwich meridian.
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
temperature_celsius : float
Temperature is a physical property of a system that underlies the common notions of hot and cold.
pressure_millibars : float
pressure_millibars
elevation : float
The elevation of a geographic location is its height above a fixed reference point, often the
mean sea level.
TY : float
Total number of days in a year. eg. 365 days per year,(no leap days)
AM : float
Air mass. An Air Mass is a measure of how far light travels through the Earth's atmosphere. One air mass,
or AM1, is the thickness of the Earth's atmosphere. Air mass zero (AM0) describes solar irradiance in
space, where it is unaffected by the atmosphere. The power density of AM1 light is about 1,000 W/m.
TL : float
Linke turbidity factor
elevation : float
The elevation of a geographic location is its height above a fixed reference point, often the mean sea
level.
Returns
-------
ghic : float
Global Irradiation under clear sky
References
----------
.. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed
new approaches", energy 30 (2005), pp 1533 - 1549.
"""
DIRC = direct_underclear(latitude_deg, longitude_deg, utc_datetime,
TY, AM, TL, elevation, temperature_celsius = 25,
pressure_millibars = 1013.25)
DIFFC = diffuse_underclear(latitude_deg, longitude_deg, utc_datetime,
elevation, temperature_celsius = 25, pressure_millibars= 1013.25)
ghic = (DIRC + DIFFC)
return ghic
def global_irradiance_overcast(latitude_deg, longitude_deg, utc_datetime,
elevation = elevation_default, temperature_celsius = 25,
pressure_millibars = 1013.25):
"""Calculated Global is used to compare to the Diffuse under overcast conditions.
Under overcast skies, global and diffuse are expected to be equal due to the absence of the beam
component.
Parameters
----------
latitude_deg : float
latitude in decimal degree. A geographical term denoting the north/south angular location of a
place on a sphere.
longitude_deg : float
longitude in decimal degree. Longitude shows your location in an east-west direction,relative
to the Greenwich meridian.
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
elevation : float
The elevation of a geographic location is its height above a fixed reference point, often the
mean sea level.
temperature_celsius : float
Temperature is a physical property of a system that underlies the common notions of hot and
cold.
pressure_millibars : float
pressure_millibars
Returns
-------
ghioc : float
Global Irradiation under overcast sky
References
----------
.. [1] S. Younes, R.Claywell and el al, "Quality
control of solar radiation data: present status
and proposed new approaches", energy 30
(2005), pp 1533 - 1549.
"""
ghioc = (572 * (solar.GetAltitude(latitude_deg, longitude_deg, utc_datetime,
elevation , temperature_celsius , pressure_millibars )))
return ghioc
def diffuse_ratio(DIFF_data,ghi_data):
"""Function calculates the Diffuse ratio.
Parameters
----------
DIFF_data : array_like
Diffuse horizontal irradiation data
ghi_data : array_like
global horizontal irradiation data array
Returns
-------
K : float
diffuse_ratio
References
----------
.. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed
new approaches", energy 30 (2005), pp 1533 - 1549.
"""
K = DIFF_data/ghi_data
return K
def clear_index(ghi_data, utc_datetime, latitude_deg, longitude_deg):
"""This calculates the clear index ratio.
Parameters
----------
ghi_data : array_like
global horizontal irradiation data array
utc_datetime : date_object
utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
latitude_deg : float
latitude in decimal degree. A geographical term denoting the north/south angular location of a place
on a sphere.
longitude_deg : float
longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the
Greenwich meridian.
Returns
-------
KT : float
Clear index ratio
References
----------
.. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed
new approaches", energy 30 (2005), pp 1533 - 1549.
"""
EXTR1 = extraterrestrial_irrad(utc_datetime, latitude_deg, longitude_deg)
KT = (ghi_data/EXTR1)
return KT
def date_with_decimal_hour(date_utc, hour_decimal):
"""This converts dates with decimal hour to datetime_hour.
An improved version :mod:`conversions_time`
Parameters
----------
datetime : datetime.datetime
A datetime object is a single object containing all the information from a
date object and a time object.
hour_decimal : datetime.datetime
An hour is a unit of time 60 minutes, or 3,600 seconds in length.
Returns
-------.
datetime_hour : datetime.datetime
datetime_hour
"""
# Backwards compatibility: round down to nearest round minute
offset_seconds = int(hour_decimal * 60) * 60
datetime_utc = dt(date_utc.year, date_utc.month, date_utc.day)
return datetime_utc + timedelta(seconds=offset_seconds)
|