Skip to content

Commit ec6ea70

Browse files
committed
fix(data): Fix minor bug in data cull_to_timestep
1 parent 06132ca commit ec6ea70

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ladybug/datacollection.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,18 @@ def interpolate_to_timestep(self, timestep, cumulative=None):
702702
_new_header._analysis_period = _new_a_per
703703
return HourlyContinuousCollection(_new_header, _new_values)
704704

705+
def cull_to_timestep(self, timestep=1):
706+
"""Get a collection with only datetimes that fit a timestep."""
707+
valid_s = self.header.analysis_period.VALIDTIMESTEPS.keys()
708+
assert timestep in valid_s, \
709+
'timestep {} is not valid. Choose from: {}'.format(timestep, valid_s)
710+
new_ap, new_values, _ = self._timestep_cull(timestep)
711+
new_header = self.header.duplicate()
712+
new_header._analysis_period = new_ap
713+
new_coll = HourlyContinuousCollection(new_header, new_values)
714+
new_coll._validated_a_period = True
715+
return new_coll
716+
705717
def filter_by_conditional_statement(self, statement):
706718
"""Filter the Data Collection based on a conditional statement.
707719

0 commit comments

Comments
 (0)