def test_solar_zenith_and_elevation(): j2day=151.2737 #ls=0 x = marstime.subsolar_longitude(j2day) assert within_error(x,114.113,1e-3) assert within_error(marstime.solar_zenith(x,0,j2day),0,1e-4) assert within_error(marstime.solar_zenith(x,15,j2day),15,1e-4) assert within_error(marstime.solar_zenith(x+15,0,j2day),15,1e-4) assert within_error(marstime.solar_elevation(x,45,j2day)- marstime.solar_zenith(x,45,j2day) ,0,1e-4) j2day=349.8778 #ls=90 x = marstime.subsolar_longitude(j2day) assert within_error(x,232.7006,1e-3) assert within_error(marstime.solar_zenith(x,0,j2day),25.441,1e-3) assert within_error(marstime.solar_elevation(x,0,j2day),64.5581,1e-4) try: a= marstime.solar_zenith(0,100,0) assert False except ValueError: assert True except: assert False try: a= marstime.solar_zenith(0,-100,0) assert False except ValueError: assert True except: assert False
def solelev(date, x,y, solar_angular_radius=0.0): """a wrapper for scipy.optimize to reverse the arguments for solar_elevation""" return marstime.solar_elevation(x,y,date)+solar_angular_radius