def filter_by_analysis_period(self, analysis_period):
self._check_analysis_period(analysis_period)<EOL>analysis_period = self._get_analysis_period_subset(analysis_period)<EOL>if analysis_period.st_hour == <NUM_LIT:0> and analysis_period.end_hour == <NUM_LIT>:<EOL><INDENT>t_s = <NUM_LIT> / analysis_period.timestep<EOL>st_ind = int((analysis_period.st_time.moy / t_s) -<EOL>(self.header.analysis_period.st_time.moy / t_s))<EOL>end_ind = int((analysis_period.end_time.moy / t_s) -<EOL>(analysis_period.st_time.moy / t_s) + st_ind + <NUM_LIT:1>)<EOL>if end_ind > st_ind:<EOL><INDENT>_filt_values = self._values[st_ind:end_ind]<EOL><DEDENT>else:<EOL><INDENT>_filt_values = self._values[st_ind:] + self._values[:end_ind]<EOL><DEDENT>_filt_header = self.header.duplicate()<EOL>_filt_header._analysis_period = analysis_period<EOL>return HourlyContinuousCollection(_filt_header, _filt_values)<EOL><DEDENT>else:<EOL><INDENT>_filtered_data = self.filter_by_moys(analysis_period.moys)<EOL>_filtered_data.header._analysis_period = analysis_period<EOL>return _filtered_data<EOL><DEDENT>
Filter the Data Collection based on an analysis period.

        Args:
           analysis period: A Ladybug analysis period

        Return:
            A new Data Collection with filtered data