<s> from eemeter . weather import GSODWeatherSource <EOL> from eemeter . weather import TMY3WeatherSource <EOL> class Project ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , location , consumption = [ ] , baseline_period = None , <EOL> reporting_period = None , other_periods = [ ] , weather_source = None , <EOL> weather_normal_source = None ) : <EOL> self . location = location <EOL> self . baseline_period = baseline_period <EOL> self . reporting_period = reporting_period <EOL> self . other_periods = other_periods <EOL> if not type ( consumption ) == list : <EOL> self . consumption = [ consumption ] <EOL> else : <EOL> self . consumption = consumption <EOL> if not type ( other_periods ) == list : <EOL> self . other_periods = [ other_periods ] <EOL> else : <EOL> self . other_periods = other_periods <EOL> if location . station is None : <EOL> message = ( <EOL> "<STR_LIT>" <EOL> ) <EOL> raise ValueError ( message ) <EOL> if weather_source is None : <EOL> weather_source = GSODWeatherSource ( location . station ) <EOL> self . weather_source = weather_source <EOL> if weather_normal_source is None : <EOL> weather_normal_source = TMY3WeatherSource ( location . station ) <EOL> self . weather_normal_source = weather_normal_source <EOL> def all_periods ( self ) : <EOL> periods = [ ] <EOL> if self . baseline_period is not None : <EOL> periods . append ( self . baseline_period ) <EOL> if self . reporting_period is not None : <EOL> periods . append ( self . reporting_period ) <EOL> periods . extend ( self . other_periods ) <EOL> return periods <EOL> def _total_date_range ( self ) : <EOL> periods = self . all_periods ( ) <EOL> consumption_periods = [ cd . total_period ( ) for cd in self . consumption ] <EOL> periods += consumption_periods <EOL> periods = [ p for p in periods if p is not None ] <EOL> period_starts = [ p . start for p in periods ] <EOL> if None in period_starts : <EOL> start_date = None <EOL> else : <EOL> start_date = min ( period_starts ) <EOL> period_ends = [ p . end for p in periods ] <EOL> if None in period_ends : <EOL> end_date = None <EOL> else : <EOL> end_date = max ( period_ends ) <EOL> return start_date , end_date <EOL> def segmented_consumption_data ( self ) : <EOL> """<STR_LIT>""" <EOL> periods = self . all_periods ( ) <EOL> views = [ c . filter_by_period ( p ) for c in self . consumption <EOL> for p in periods ] <EOL> return views </s>
