Beispiel #1
0
    def test_union(test_instance, list_of_objects, time_exp):
        """Test input types for Time.union function.

        Parameters
        ----------
        list_of_objects:
            List with input objects
        time_exp:
            Expected result time

        """
        if test_instance:
            instance = Time(list_of_objects[0])
            assert np.all(instance.union(list_of_objects[1:]) == time_exp)
        else:
            assert np.all(Time.union(list_of_objects) == time_exp)
Beispiel #2
0
    def _unify_time_axis(
        orientation: xr.DataArray, coordinates: Union[xr.DataArray, TimeSeries]
    ) -> tuple:
        """Unify time axis of orientation and coordinates if both are DataArrays."""
        if (
            not isinstance(coordinates, TimeSeries)
            and ("time" in orientation.dims)
            and ("time" in coordinates.dims)
            and (not np.all(orientation.time.data == coordinates.time.data))
        ):
            time_union = Time.union([orientation.time, coordinates.time])
            orientation = ut.xr_interp_orientation_in_time(orientation, time_union)
            coordinates = ut.xr_interp_coordinates_in_time(coordinates, time_union)

        return (orientation, coordinates)