[ https://issues.apache.org/jira/browse/CLIMATE-338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16368748#comment-16368748 ]
Michael Anderson edited comment on CLIMATE-338 at 2/19/18 2:25 AM: ------------------------------------------------------------------- So the code is such that no matter what start and end date is input, the start is set to the literal start of the month and the end is set to the literal end of the month. def _beginning_of_date(time, time_step): '''Calculate the beginning of given time, based on time step. :param time: Given time :type time: Datetime :param time_step: Time step (monthly or daily) :type time_step: String :returns: Beginning of given time :rtype: Datetime ''' if time_step.lower() == 'monthly': if time.day != 1: time = datetime(time.year, time.month, 1) elif time_step.lower() == 'daily': if time.hour != 0 or time.minute != 0 or time.second != 0: time = datetime(time.year, time.month, time.day, 00, 00, 00) return time def _end_of_date(time, time_step): '''Calculate the end of given time, based on time step. :param time: Given time :type time: Datetime :param time_step: Time step (monthly or daily) :type time_step: String :returns: End of given time :rtype: Datetime ''' last_day_of_month = calendar.monthrange(time.year, time.month)[1] if time_step.lower() == 'monthly': time = datetime(time.year, time.month, last_day_of_month) elif time_step.lower() == 'daily': time = datetime(time.year, time.month, time.day, 23, 59, 59) return time was (Author: michael.arthur.ander...@gmail.com): So the code is such that no matter what start and end date is input, the start is set to the literal start of the month and the end is set to the literal end. def _beginning_of_date(time, time_step): '''Calculate the beginning of given time, based on time step. :param time: Given time :type time: Datetime :param time_step: Time step (monthly or daily) :type time_step: String :returns: Beginning of given time :rtype: Datetime ''' if time_step.lower() == 'monthly': if time.day != 1: time = datetime(time.year, time.month, 1) elif time_step.lower() == 'daily': if time.hour != 0 or time.minute != 0 or time.second != 0: time = datetime(time.year, time.month, time.day, 00, 00, 00) return time def _end_of_date(time, time_step): '''Calculate the end of given time, based on time step. :param time: Given time :type time: Datetime :param time_step: Time step (monthly or daily) :type time_step: String :returns: End of given time :rtype: Datetime ''' last_day_of_month = calendar.monthrange(time.year, time.month)[1] if time_step.lower() == 'monthly': time = datetime(time.year, time.month, last_day_of_month) elif time_step.lower() == 'daily': time = datetime(time.year, time.month, time.day, 23, 59, 59) return time > RCMED data source loads datasets improperly based on day attribute of time > values > --------------------------------------------------------------------------------- > > Key: CLIMATE-338 > URL: https://issues.apache.org/jira/browse/CLIMATE-338 > Project: Apache Open Climate Workbench > Issue Type: Bug > Components: data sources > Affects Versions: 0.3-incubating > Reporter: Michael Joyce > Assignee: Michael Anderson > Priority: Major > Fix For: 1.3.0 > > Attachments: test.py > > > When trying to load a dataset with `data_source.rcmed` where the time values > don't fall on the first of the month the end time is not properly bounded. > Consider CRU31, where the day values fall on the 15th of the month. Notice > that the returned end time is not properly bounded by the passed end time. > CRU31 > Passed start time: 1901-02-01 00:00:00 > Returned start time: 1901-02-15 00:00:00 > Passed end time: 1901-04-01 00:00:00 > Returned end time: 1901-04-15 00:00:00 > However, on TRMM, where the time values fall on the first, the values are > properly bounded. > TRMM > Passed start time: 1998-02-01 00:00:00 > Returned start time: 1998-02-01 00:00:00 > Passed end time: 1998-03-01 00:00:00 > Returned end time: 1998-03-01 00:00:00 -- This message was sent by Atlassian JIRA (v7.6.3#76005)