def _get_analysis_period_subset(self, a_per):
if self.header.analysis_period.is_annual:<EOL><INDENT>return a_per<EOL><DEDENT>new_needed = False<EOL>n_ap = [a_per.st_month, a_per.st_day, a_per.st_hour,<EOL>a_per.end_month, a_per.end_day, a_per.end_hour,<EOL>a_per.timestep, a_per.is_leap_year]<EOL>if a_per.st_hour < self.header.analysis_period.st_hour:<EOL><INDENT>n_ap[<NUM_LIT:2>] = self.header.analysis_period.st_hour<EOL>new_needed = True<EOL><DEDENT>if a_per.end_hour > self.header.analysis_period.end_hour:<EOL><INDENT>n_ap[<NUM_LIT:5>] = self.header.analysis_period.end_hour<EOL>new_needed = True<EOL><DEDENT>if a_per.st_time.doy < self.header.analysis_period.st_time.doy:<EOL><INDENT>n_ap[<NUM_LIT:0>] = self.header.analysis_period.st_month<EOL>n_ap[<NUM_LIT:1>] = self.header.analysis_period.st_day<EOL>new_needed = True<EOL><DEDENT>if a_per.end_time.doy > self.header.analysis_period.end_time.doy:<EOL><INDENT>n_ap[<NUM_LIT:3>] = self.header.analysis_period.end_month<EOL>n_ap[<NUM_LIT:4>] = self.header.analysis_period.end_day<EOL>new_needed = True<EOL><DEDENT>if new_needed is False:<EOL><INDENT>return a_per<EOL><DEDENT>else:<EOL><INDENT>return AnalysisPeriod(*n_ap)<EOL><DEDENT>
Return an analysis_period is always a subset of the Data Collection