def test_tau(): """py.test for tau""" data = ((""" - Displaying Monthly Design Conditions "Climate Design Data 2009 ASHRAE Handbook" - Monthly Optical Sky Depth Beam (taub) and Diffuse (taud) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec taub (beam) 0.289 0.29 0.325 0.351 0.377 0.37 0.362 0.352 0.343 0.323 0.302 0.289 taud (diffuse) 2.641 2.681 2.392 2.292 2.224 2.361 2.489 2.561 2.539 2.534 2.618 2.633 taub = Clear Sky Optical Depth for Beam Irradiance taud = Clear Sky Optical Depth for Diffuse Irradiance """, [0.289, 0.29, 0.325, 0.351, 0.377, 0.37, 0.362, 0.352, 0.343, 0.323, 0.302, 0.289], [2.641, 2.681, 2.392, 2.292, 2.224, 2.361, 2.489, 2.561, 2.539, 2.534, 2.618, 2.633]), # txt, taub, taud ) for txt, taub, taud in data: import StringIO fhandle = StringIO.StringIO(txt) result = clearskyrad.tau(fhandle) assert result == (taub, taud)
spadict['timezone'] = -7.0 # negative west of Greenwich # -12 to 12 hours spadict['delta_t'] = 67 # Difference between earth rotation time # and terrestrial time spadict['longitude'] = -112.066 # negative west of Greenwich # -180 to 180 degrees spadict['latitude'] = 33.43 # N is +ve spadict['elevation'] = 339.14 # meters spadict['pressure'] = 820 # millibars spadict['temperature'] = 11 # C spadict['slope'] = 0 spadict['azm_rotation'] = 0 spadict['atmos_refract'] = 0.5667 # typical value statfilename = './weatherfiles/USA_AZ_Phoenix/USA_AZ_Phoenix.722780_TMY2.stat' taubs, tauds = clearskyrad.tau(open(statfilename)) # for m in range(1, 13): for m in range(1, 13): for d in range(1, calendar.monthrange(spadict['year'], m)[1] + 1): # for d in range(1, 25): for h in range(1, 25): spadict['month'] = m spadict['day'] = d spadict['hour'] = h try: sun = spabase.spacalc(spadict) alt = 90 - sun['zenith'] taub, taud = taubs[m -1], tauds[m -1] thedate = datetime(spadict['year'], m, d) if alt <= 0: