esmvaltool/diag_scripts/ocean/diagnostic_tools.py
def cube_time_to_float(cube):
    """
    Convert from time coordinate into decimal time.

    Takes an iris time coordinate and returns a list of floats.
    """
    times = cube.coord('time')
    datetime = guess_calendar_datetime(cube)

    dtimes = times.units.num2date(times.points)
    floattimes = []
    for dtime in dtimes:
        # TODO: it would be better to have a calendar dependent value
        # for daysperyear, as this is not accurate for 360 day calendars.
        daysperyear = 365.25

        try:
            dayofyr = dtime.dayofyr
        except AttributeError:
            time = datetime(dtime.year, dtime.month, dtime.day)
            time0 = datetime(dtime.year, 1, 1, 0, 0)
            dayofyr = (time - time0).days

        floattime = dtime.year + dayofyr / daysperyear + dtime.hour / (
            24. * daysperyear)
        if dtime.hour:
            floattime += dtime.hour / (24. * daysperyear)
        if dtime.minute:
            floattime += dtime.minute / (24. * 60. * daysperyear)
        floattimes.append(floattime)
    return floattimes

    Convert from time coordinate into decimal time.

    Takes an iris time coordinate and returns a list of floats.
    
Convert from time coordinate into decimal time.
Takes an iris time coordinate and returns a list of floats.
Convert from time coordinate into decimal time . Takes an iris time coordinate and returns a list of floats .
def cube_time_to_float(cube):
    times = cube.coord('time')
    datetime = guess_calendar_datetime(cube)
    dtimes = times.units.num2date(times.points)
    floattimes = []
    for dtime in dtimes:
        daysperyear = 365.25
        try:
            dayofyr = dtime.dayofyr
        except AttributeError:
            time = datetime(dtime.year, dtime.month, dtime.day)
            time0 = datetime(dtime.year, 1, 1, 0, 0)
            dayofyr = (time - time0).days
        floattime = dtime.year + dayofyr / daysperyear + dtime.hour / (
            24. * daysperyear)
        if dtime.hour:
            floattime += dtime.hour / (24. * daysperyear)
        if dtime.minute:
            floattime += dtime.minute / (24. * 60. * daysperyear)
        floattimes.append(floattime)
    return floattimes
def cube_time_to_float ( cube ) : times = cube . coord ( 'time' ) datetime = guess_calendar_datetime ( cube ) dtimes = times . units . num2date ( times . points ) floattimes = [ ] for dtime in dtimes : daysperyear = 365.25 try : dayofyr = dtime . dayofyr except AttributeError : time = datetime ( dtime . year , dtime . month , dtime . day ) time0 = datetime ( dtime . year , 1 , 1 , 0 , 0 ) dayofyr = ( time - time0 ) . days floattime = dtime . year + dayofyr / daysperyear + dtime . hour / ( 24. * daysperyear ) if dtime . hour : floattime += dtime . hour / ( 24. * daysperyear ) if dtime . minute : floattime += dtime . minute / ( 24. * 60. * daysperyear ) floattimes . append ( floattime ) return floattimes
Convert from time coordinate into decimal time.
Convert from time coordinate into decimal time .
"""
    Convert from time coordinate into decimal time.

    Takes an iris time coordinate and returns a list of floats.
    """ # TODO: it would be better to have a calendar dependent value # for daysperyear, as this is not accurate for 360 day calendars.
cube