def _calcAirMassForScalar(dt, loc): """ calcAirMassForScalar(dt, loc) -> airmass approximation sec(SolarZenithAngle) Расчет массы атмосферы dt - datetime, UTC lon - tuple(longitude, latitude) """ time = sun.cTime() pos = sun.cLocation() pos.dLongitude = loc[0] pos.dLatitude = loc[1] time.dHours = dt.hour time.dMinutes = dt.minute time.dSeconds = dt.second time.iYear = dt.year time.iMonth = dt.month time.iDay = dt.day ret = sun.sunposf(time, pos) ret = 1.0/np.cos(ret.dZenithAngle*np.pi/180.0) return ret
import numpy as np import sunpos from datetime import datetime, timedelta t0 = datetime(2013, 4, 1, 10, 0, 0) t1 = datetime(2013, 4, 1, 19, 0, 0) dt = timedelta(minutes=1) dt0 = timedelta(hours=11) t0 = t0 - dt0 t1 = t1 - dt0 loc = sunpos.cLocation() loc.dLatitude = 43.1 loc.dLongitude = 131.9 time = sunpos.cTime() I0 = 1.0 ret = sunpos.cSunCoordinates() T = [] I = [] while t0 < t1: time.iYear = t0.year time.iMonth = t0.month time.iDay = t0.day time.dHours = t0.hour time.dMinutes = t0.minute time.dSeconds = t0.second sunpos.sunpos(time, loc, ret)