Пример #1
0
def convert_cube_time_coord_to_standard_time_assuming_gregorian_calendar(cube):
    """Converts the time coordinate from the one in the cube to one based on a standard time unit.

    This approach assumes that source date is valid as a date in the calendar set for the
    standard time unit (Gregorian) which will not always be true.
    :param cube: cube to modify
    :return: the cube
    """
    # Get the current time coordinate and it's data dimension
    t_coord = cube.coord(standard_name='time')
    data_dim = cube.coord_dims(t_coord)

    # And remove it from the cube
    cube.remove_coord(t_coord)

    # Convert the raw time numbers to our 'standard' time
    new_datetimes = convert_numpy_array(t_coord.points, 'O', t_coord.units.num2date)
    new_datetime_nums = convert_obj_to_standard_date_array(new_datetimes)

    # Create a new time coordinate by copying the old one, but using our new points and units
    new_time_coord = t_coord
    new_time_coord.points = new_datetime_nums
    new_time_coord.units = cis_standard_time_unit

    # And add the new coordinate back into the cube
    cube.add_dim_coord(new_time_coord, data_dim)

    return cube
Пример #2
0
def parse_datetimestr_to_std_time_array(string_time_array):
    from utils import convert_numpy_array

    return convert_numpy_array(string_time_array, "float64", parse_datetimestr_to_std_time)
Пример #3
0
def convert_obj_to_standard_date_array(time_array):
    return convert_numpy_array(time_array, 'float64', convert_datetime_to_std_time)
Пример #4
0
def convert_julian_date_to_std_time_array(julian_time_array, calender='standard'):
    return convert_numpy_array(julian_time_array, 'float64', convert_julian_date_to_std_time, calender)
Пример #5
0
def convert_sec_since_to_std_time_array(tai_time_array, ref):
    return convert_numpy_array(tai_time_array, 'float64', convert_sec_since_to_std_time, ref)