def get_decimal_dates(self): """ Returns dates and time as a vector of decimal dates """ neq = self.get_number_events() year = np.zeros(neq, dtype=int) month = np.zeros(neq, dtype=int) day = np.zeros(neq, dtype=int) hour = np.zeros(neq, dtype=int) minute = np.zeros(neq, dtype=int) second = np.zeros(neq, dtype=float) for iloc, event in enumerate(self.events): is_selected = False for origin in event.origins: if is_selected: continue if origin.is_prime: year[iloc] = origin.date.year month[iloc] = origin.date.month day[iloc] = origin.date.day hour[iloc] = origin.time.hour minute[iloc] = origin.time.minute second[iloc] = float(origin.time.second) + \ (float(origin.time.microsecond) / 1.0E6) is_selected = True if not is_selected: # No prime origins - take the first year[iloc] = event.origins[0].date.year month[iloc] = event.origins[0].date.month day[iloc] = event.origins[0].date.day hour[iloc] = event.origins[0].time.hour minute[iloc] = event.origins[0].time.minute second[iloc] = float(event.origins[0].time.second) + \ (float(event.origins[0].time.microsecond) / 1.0E6) return decimal_time(year, month, day, hour, minute, second)
def datetime_to_decimal_time(date, time): ''' Converts a datetime object to decimal time ''' # Seconds, microseconds to floating seconds seconds = np.array(float(time.second)) microseconds = np.array(float(time.microsecond)) seconds = seconds + (microseconds / 1.0E6) return decimal_time(np.array([date.year]), np.array([date.month]), np.array([date.day]), np.array([time.hour]), np.array([time.minute]), np.array([seconds]))
def get_decimal_dates(self): """ Returns dates and time as a vector of decimal dates """ neq = self.get_number_events() year = np.zeros(neq, dtype=int) month = np.zeros(neq, dtype=int) day = np.zeros(neq, dtype=int) hour = np.zeros(neq, dtype=int) minute = np.zeros(neq, dtype=int) second = np.zeros(neq, dtype=float) for iloc, event in enumerate(self.events): for origin in event.origins: if len(event.origins) > 1 and not origin.is_prime: continue else: year[iloc] = origin.date.year month[iloc] = origin.date.month day[iloc] = origin.date.day hour[iloc] = origin.time.hour minute[iloc] = origin.time.minute second[iloc] = float(origin.time.second) + \ (float(origin.time.microsecond) / 1.0E6) return decimal_time(year, month, day, hour, minute, second)