<s> import logging <EOL> pvl_logger = logging . getLogger ( '<STR_LIT>' ) <EOL> import datetime <EOL> import numpy as np <EOL> from numpy import nan <EOL> import pandas as pd <EOL> from nose . tools import raises , assert_almost_equals <EOL> from nose . plugins . skip import SkipTest <EOL> from pandas . util . testing import assert_frame_equal <EOL> from pvlib . location import Location <EOL> from pvlib import solarposition <EOL> from pvlib import tracking <EOL> def test_solar_noon ( ) : <EOL> apparent_zenith = pd . Series ( [ <NUM_LIT:10> ] ) <EOL> apparent_azimuth = pd . Series ( [ <NUM_LIT> ] ) <EOL> tracker_data = tracking . singleaxis ( apparent_zenith , apparent_azimuth , <EOL> axis_tilt = <NUM_LIT:0> , axis_azimuth = <NUM_LIT:0> , <EOL> max_angle = <NUM_LIT> , backtrack = True , <EOL> gcr = <NUM_LIT> / <NUM_LIT> ) <EOL> expect = pd . DataFrame ( { '<STR_LIT>' : <NUM_LIT:10> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> } , <EOL> index = [ <NUM_LIT:0> ] , dtype = np . float64 ) <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> def test_azimuth_north_south ( ) : <EOL> apparent_zenith = pd . Series ( [ <NUM_LIT> ] ) <EOL> apparent_azimuth = pd . Series ( [ <NUM_LIT> ] ) <EOL> tracker_data = tracking . singleaxis ( apparent_zenith , apparent_azimuth , <EOL> axis_tilt = <NUM_LIT:0> , axis_azimuth = <NUM_LIT> , <EOL> max_angle = <NUM_LIT> , backtrack = True , <EOL> gcr = <NUM_LIT> / <NUM_LIT> ) <EOL> expect = pd . DataFrame ( { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : - <NUM_LIT> } , <EOL> index = [ <NUM_LIT:0> ] , dtype = np . float64 ) <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> tracker_data = tracking . singleaxis ( apparent_zenith , apparent_azimuth , <EOL> axis_tilt = <NUM_LIT:0> , axis_azimuth = <NUM_LIT:0> , <EOL> max_angle = <NUM_LIT> , backtrack = True , <EOL> gcr = <NUM_LIT> / <NUM_LIT> ) <EOL> expect [ '<STR_LIT>' ] *= - <NUM_LIT:1> <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> def test_max_angle ( ) : <EOL> apparent_zenith = pd . Series ( [ <NUM_LIT> ] ) <EOL> apparent_azimuth = pd . Series ( [ <NUM_LIT> ] ) <EOL> tracker_data = tracking . singleaxis ( apparent_zenith , apparent_azimuth , <EOL> axis_tilt = <NUM_LIT:0> , axis_azimuth = <NUM_LIT:0> , <EOL> max_angle = <NUM_LIT> , backtrack = True , <EOL> gcr = <NUM_LIT> / <NUM_LIT> ) <EOL> expect = pd . DataFrame ( { '<STR_LIT>' : <NUM_LIT:15> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> } , <EOL> index = [ <NUM_LIT:0> ] , dtype = np . float64 ) <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> def test_backtrack ( ) : <EOL> apparent_zenith = pd . Series ( [ <NUM_LIT> ] ) <EOL> apparent_azimuth = pd . Series ( [ <NUM_LIT> ] ) <EOL> tracker_data = tracking . singleaxis ( apparent_zenith , apparent_azimuth , <EOL> axis_tilt = <NUM_LIT:0> , axis_azimuth = <NUM_LIT:0> , <EOL> max_angle = <NUM_LIT> , backtrack = False , <EOL> gcr = <NUM_LIT> / <NUM_LIT> ) <EOL> expect = pd . DataFrame ( { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> } , <EOL> index = [ <NUM_LIT:0> ] , dtype = np . float64 ) <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> tracker_data = tracking . singleaxis ( apparent_zenith , apparent_azimuth , <EOL> axis_tilt = <NUM_LIT:0> , axis_azimuth = <NUM_LIT:0> , <EOL> max_angle = <NUM_LIT> , backtrack = True , <EOL> gcr = <NUM_LIT> / <NUM_LIT> ) <EOL> expect = pd . DataFrame ( { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> } , <EOL> index = [ <NUM_LIT:0> ] , dtype = np . float64 ) <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> def test_axis_tilt ( ) : <EOL> apparent_zenith = pd . Series ( [ <NUM_LIT:30> ] ) <EOL> apparent_azimuth = pd . Series ( [ <NUM_LIT> ] ) <EOL> tracker_data = tracking . singleaxis ( apparent_zenith , apparent_azimuth , <EOL> axis_tilt = <NUM_LIT:30> , axis_azimuth = <NUM_LIT> , <EOL> max_angle = <NUM_LIT> , backtrack = True , <EOL> gcr = <NUM_LIT> / <NUM_LIT> ) <EOL> expect = pd . DataFrame ( { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : - <NUM_LIT> } , <EOL> index = [ <NUM_LIT:0> ] , dtype = np . float64 ) <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> tracker_data = tracking . singleaxis ( apparent_zenith , apparent_azimuth , <EOL> axis_tilt = <NUM_LIT:30> , axis_azimuth = <NUM_LIT:0> , <EOL> max_angle = <NUM_LIT> , backtrack = True , <EOL> gcr = <NUM_LIT> / <NUM_LIT> ) <EOL> expect = pd . DataFrame ( { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> } , <EOL> index = [ <NUM_LIT:0> ] , dtype = np . float64 ) <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> def test_axis_azimuth ( ) : <EOL> apparent_zenith = pd . Series ( [ <NUM_LIT:30> ] ) <EOL> apparent_azimuth = pd . Series ( [ <NUM_LIT> ] ) <EOL> tracker_data = tracking . singleaxis ( apparent_zenith , apparent_azimuth , <EOL> axis_tilt = <NUM_LIT:0> , axis_azimuth = <NUM_LIT> , <EOL> max_angle = <NUM_LIT> , backtrack = True , <EOL> gcr = <NUM_LIT> / <NUM_LIT> ) <EOL> expect = pd . DataFrame ( { '<STR_LIT>' : <NUM_LIT:30> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> } , <EOL> index = [ <NUM_LIT:0> ] , dtype = np . float64 ) <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> apparent_zenith = pd . Series ( [ <NUM_LIT:30> ] ) <EOL> apparent_azimuth = pd . Series ( [ <NUM_LIT> ] ) <EOL> tracker_data = tracking . singleaxis ( apparent_zenith , apparent_azimuth , <EOL> axis_tilt = <NUM_LIT:0> , axis_azimuth = <NUM_LIT> , <EOL> max_angle = <NUM_LIT> , backtrack = True , <EOL> gcr = <NUM_LIT> / <NUM_LIT> ) <EOL> expect = pd . DataFrame ( { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:30> , '<STR_LIT>' : <NUM_LIT:30> } , <EOL> index = [ <NUM_LIT:0> ] , dtype = np . float64 ) <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> @ raises ( ValueError ) <EOL> def test_index_mismatch ( ) : <EOL> apparent_zenith = pd . Series ( [ <NUM_LIT:30> ] ) <EOL> apparent_azimuth = pd . Series ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> tracker_data = tracking . singleaxis ( apparent_zenith , apparent_azimuth , <EOL> axis_tilt = <NUM_LIT:0> , axis_azimuth = <NUM_LIT> , <EOL> max_angle = <NUM_LIT> , backtrack = True , <EOL> gcr = <NUM_LIT> / <NUM_LIT> ) <EOL> def test_SingleAxisTracker_creation ( ) : <EOL> system = tracking . SingleAxisTracker ( max_angle = <NUM_LIT> , <EOL> gcr = <NUM_LIT> , <EOL> module = '<STR_LIT>' , <EOL> inverter = '<STR_LIT>' ) <EOL> assert system . max_angle == <NUM_LIT> <EOL> assert system . gcr == <NUM_LIT> <EOL> assert system . module == '<STR_LIT>' <EOL> assert system . inverter == '<STR_LIT>' <EOL> def test_SingleAxisTracker_tracking ( ) : <EOL> system = tracking . SingleAxisTracker ( max_angle = <NUM_LIT> , axis_tilt = <NUM_LIT:30> , <EOL> axis_azimuth = <NUM_LIT> , gcr = <NUM_LIT> / <NUM_LIT> , <EOL> backtrack = True ) <EOL> apparent_zenith = pd . Series ( [ <NUM_LIT:30> ] ) <EOL> apparent_azimuth = pd . Series ( [ <NUM_LIT> ] ) <EOL> tracker_data = system . singleaxis ( apparent_zenith , apparent_azimuth ) <EOL> expect = pd . DataFrame ( { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : - <NUM_LIT> } , <EOL> index = [ <NUM_LIT:0> ] , dtype = np . float64 ) <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> pvsyst_solar_azimuth = <NUM_LIT> <EOL> pvsyst_solar_height = <NUM_LIT> <EOL> pvsyst_axis_tilt = <NUM_LIT> <EOL> pvsyst_axis_azimuth = <NUM_LIT> <EOL> pvsyst_system = tracking . SingleAxisTracker ( max_angle = <NUM_LIT> , <EOL> axis_tilt = pvsyst_axis_tilt , <EOL> axis_azimuth = <NUM_LIT> + pvsyst_axis_azimuth , <EOL> backtrack = False ) <EOL> apparent_azimuth = pd . Series ( [ <NUM_LIT> + pvsyst_solar_azimuth ] ) <EOL> apparent_zenith = pd . Series ( [ <NUM_LIT> - pvsyst_solar_height ] ) <EOL> tracker_data = pvsyst_system . singleaxis ( apparent_zenith , apparent_azimuth ) <EOL> expect = pd . DataFrame ( { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> - <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : - <NUM_LIT> } , <EOL> index = [ <NUM_LIT:0> ] , dtype = np . float64 ) <EOL> assert_frame_equal ( expect , tracker_data ) <EOL> def test_LocalizedSingleAxisTracker_creation ( ) : <EOL> localized_system = tracking . LocalizedSingleAxisTracker ( latitude = <NUM_LIT:32> , <EOL> longitude = - <NUM_LIT> , <EOL> module = '<STR_LIT>' , <EOL> inverter = '<STR_LIT>' ) <EOL> assert localized_system . module == '<STR_LIT>' <EOL> assert localized_system . inverter == '<STR_LIT>' <EOL> assert localized_system . latitude == <NUM_LIT:32> <EOL> assert localized_system . longitude == - <NUM_LIT> <EOL> def test_SingleAxisTracker_localize ( ) : <EOL> system = tracking . SingleAxisTracker ( max_angle = <NUM_LIT> , gcr = <NUM_LIT> , <EOL> module = '<STR_LIT>' , inverter = '<STR_LIT>' ) <EOL> localized_system = system . localize ( latitude = <NUM_LIT:32> , longitude = - <NUM_LIT> ) <EOL> assert localized_system . module == '<STR_LIT>' <EOL> assert localized_system . inverter == '<STR_LIT>' <EOL> assert localized_system . latitude == <NUM_LIT:32> <EOL> assert localized_system . longitude == - <NUM_LIT> <EOL> def test_SingleAxisTracker_localize_location ( ) : <EOL> system = tracking . SingleAxisTracker ( max_angle = <NUM_LIT> , gcr = <NUM_LIT> , <EOL> module = '<STR_LIT>' , inverter = '<STR_LIT>' ) <EOL> location = Location ( latitude = <NUM_LIT:32> , longitude = - <NUM_LIT> ) <EOL> localized_system = system . localize ( location = location ) <EOL> assert localized_system . module == '<STR_LIT>' <EOL> assert localized_system . inverter == '<STR_LIT>' <EOL> assert localized_system . latitude == <NUM_LIT:32> <EOL> assert localized_system . longitude == - <NUM_LIT> <EOL> def test_get_irradiance ( ) : <EOL> system = tracking . SingleAxisTracker ( max_angle = <NUM_LIT> , axis_tilt = <NUM_LIT:30> , <EOL> axis_azimuth = <NUM_LIT> , gcr = <NUM_LIT> / <NUM_LIT> , <EOL> backtrack = True ) <EOL> times = pd . DatetimeIndex ( start = '<STR_LIT>' , <EOL> end = '<STR_LIT>' , freq = '<STR_LIT>' ) <EOL> location = Location ( latitude = <NUM_LIT:32> , longitude = - <NUM_LIT> ) <EOL> solar_position = location . get_solarposition ( times ) <EOL> irrads = pd . DataFrame ( { '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT>' : [ <NUM_LIT:100> , <NUM_LIT:0> ] } , <EOL> index = times ) <EOL> solar_zenith = solar_position [ '<STR_LIT>' ] <EOL> solar_azimuth = solar_position [ '<STR_LIT>' ] <EOL> tracker_data = system . singleaxis ( solar_zenith , solar_azimuth ) <EOL> irradiance = system . get_irradiance ( irrads [ '<STR_LIT>' ] , <EOL> irrads [ '<STR_LIT>' ] , <EOL> irrads [ '<STR_LIT>' ] , <EOL> solar_zenith = solar_zenith , <EOL> solar_azimuth = solar_azimuth , <EOL> surface_tilt = tracker_data [ '<STR_LIT>' ] , <EOL> surface_azimuth = tracker_data [ '<STR_LIT>' ] ) <EOL> expected = pd . DataFrame ( data = np . array ( <EOL> [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> ] , <EOL> [ nan , nan , nan , nan , <EOL> nan ] ] ) , <EOL> columns = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> index = times ) <EOL> irradiance = np . round ( irradiance , <NUM_LIT:4> ) <EOL> expected = np . round ( expected , <NUM_LIT:4> ) <EOL> assert_frame_equal ( irradiance , expected ) </s>
