Coordinate transformations#

Motivation#

In all fields of science we frequently encounter data that is represented in coordinates or coordinate systems that are not apt for certain operations or visualizations. In these cases we may thus need to compute new coordinates based on one or multiple existing coordinates. For simple cases this may just be done by hand. Consider:

[1]:
import scipp as sc
import plopp as pp

x = sc.linspace(dim='x', unit='m', start=1.0, stop=55.0, num=100)
da = sc.DataArray(data=x * x, coords={'x': x})
da.plot(figsize=(4, 3))
[1]:
../_images/user-guide_coordinate-transformations_1_0.svg

We may want to use \(x^2\) instead of \(x\) as a coordinate, to highlight the quadratic nature of our data:

[2]:
da2 = da.copy()
da2.coords['x_square'] = x * x
da2
[2]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (3.60 KB)
    • x: 100
    • x
      (x)
      float64
      m
      1.0, 1.545, ..., 54.455, 55.0
      Values:
      array([ 1. , 1.54545455, 2.09090909, 2.63636364, 3.18181818, 3.72727273, 4.27272727, 4.81818182, 5.36363636, 5.90909091, 6.45454545, 7. , 7.54545455, 8.09090909, 8.63636364, 9.18181818, 9.72727273, 10.27272727, 10.81818182, 11.36363636, 11.90909091, 12.45454545, 13. , 13.54545455, 14.09090909, 14.63636364, 15.18181818, 15.72727273, 16.27272727, 16.81818182, 17.36363636, 17.90909091, 18.45454545, 19. , 19.54545455, 20.09090909, 20.63636364, 21.18181818, 21.72727273, 22.27272727, 22.81818182, 23.36363636, 23.90909091, 24.45454545, 25. , 25.54545455, 26.09090909, 26.63636364, 27.18181818, 27.72727273, 28.27272727, 28.81818182, 29.36363636, 29.90909091, 30.45454545, 31. , 31.54545455, 32.09090909, 32.63636364, 33.18181818, 33.72727273, 34.27272727, 34.81818182, 35.36363636, 35.90909091, 36.45454545, 37. , 37.54545455, 38.09090909, 38.63636364, 39.18181818, 39.72727273, 40.27272727, 40.81818182, 41.36363636, 41.90909091, 42.45454545, 43. , 43.54545455, 44.09090909, 44.63636364, 45.18181818, 45.72727273, 46.27272727, 46.81818182, 47.36363636, 47.90909091, 48.45454545, 49. , 49.54545455, 50.09090909, 50.63636364, 51.18181818, 51.72727273, 52.27272727, 52.81818182, 53.36363636, 53.90909091, 54.45454545, 55. ])
    • x_square
      (x)
      float64
      m^2
      1.0, 2.388, ..., 2965.298, 3025.000
      Values:
      array([1.00000000e+00, 2.38842975e+00, 4.37190083e+00, 6.95041322e+00, 1.01239669e+01, 1.38925620e+01, 1.82561983e+01, 2.32148760e+01, 2.87685950e+01, 3.49173554e+01, 4.16611570e+01, 4.90000000e+01, 5.69338843e+01, 6.54628099e+01, 7.45867769e+01, 8.43057851e+01, 9.46198347e+01, 1.05528926e+02, 1.17033058e+02, 1.29132231e+02, 1.41826446e+02, 1.55115702e+02, 1.69000000e+02, 1.83479339e+02, 1.98553719e+02, 2.14223140e+02, 2.30487603e+02, 2.47347107e+02, 2.64801653e+02, 2.82851240e+02, 3.01495868e+02, 3.20735537e+02, 3.40570248e+02, 3.61000000e+02, 3.82024793e+02, 4.03644628e+02, 4.25859504e+02, 4.48669421e+02, 4.72074380e+02, 4.96074380e+02, 5.20669421e+02, 5.45859504e+02, 5.71644628e+02, 5.98024793e+02, 6.25000000e+02, 6.52570248e+02, 6.80735537e+02, 7.09495868e+02, 7.38851240e+02, 7.68801653e+02, 7.99347107e+02, 8.30487603e+02, 8.62223140e+02, 8.94553719e+02, 9.27479339e+02, 9.61000000e+02, 9.95115702e+02, 1.02982645e+03, 1.06513223e+03, 1.10103306e+03, 1.13752893e+03, 1.17461983e+03, 1.21230579e+03, 1.25058678e+03, 1.28946281e+03, 1.32893388e+03, 1.36900000e+03, 1.40966116e+03, 1.45091736e+03, 1.49276860e+03, 1.53521488e+03, 1.57825620e+03, 1.62189256e+03, 1.66612397e+03, 1.71095041e+03, 1.75637190e+03, 1.80238843e+03, 1.84900000e+03, 1.89620661e+03, 1.94400826e+03, 1.99240496e+03, 2.04139669e+03, 2.09098347e+03, 2.14116529e+03, 2.19194215e+03, 2.24331405e+03, 2.29528099e+03, 2.34784298e+03, 2.40100000e+03, 2.45475207e+03, 2.50909917e+03, 2.56404132e+03, 2.61957851e+03, 2.67571074e+03, 2.73243802e+03, 2.78976033e+03, 2.84767769e+03, 2.90619008e+03, 2.96529752e+03, 3.02500000e+03])
    • (x)
      float64
      m^2
      1.0, 2.388, ..., 2965.298, 3025.000
      Values:
      array([1.00000000e+00, 2.38842975e+00, 4.37190083e+00, 6.95041322e+00, 1.01239669e+01, 1.38925620e+01, 1.82561983e+01, 2.32148760e+01, 2.87685950e+01, 3.49173554e+01, 4.16611570e+01, 4.90000000e+01, 5.69338843e+01, 6.54628099e+01, 7.45867769e+01, 8.43057851e+01, 9.46198347e+01, 1.05528926e+02, 1.17033058e+02, 1.29132231e+02, 1.41826446e+02, 1.55115702e+02, 1.69000000e+02, 1.83479339e+02, 1.98553719e+02, 2.14223140e+02, 2.30487603e+02, 2.47347107e+02, 2.64801653e+02, 2.82851240e+02, 3.01495868e+02, 3.20735537e+02, 3.40570248e+02, 3.61000000e+02, 3.82024793e+02, 4.03644628e+02, 4.25859504e+02, 4.48669421e+02, 4.72074380e+02, 4.96074380e+02, 5.20669421e+02, 5.45859504e+02, 5.71644628e+02, 5.98024793e+02, 6.25000000e+02, 6.52570248e+02, 6.80735537e+02, 7.09495868e+02, 7.38851240e+02, 7.68801653e+02, 7.99347107e+02, 8.30487603e+02, 8.62223140e+02, 8.94553719e+02, 9.27479339e+02, 9.61000000e+02, 9.95115702e+02, 1.02982645e+03, 1.06513223e+03, 1.10103306e+03, 1.13752893e+03, 1.17461983e+03, 1.21230579e+03, 1.25058678e+03, 1.28946281e+03, 1.32893388e+03, 1.36900000e+03, 1.40966116e+03, 1.45091736e+03, 1.49276860e+03, 1.53521488e+03, 1.57825620e+03, 1.62189256e+03, 1.66612397e+03, 1.71095041e+03, 1.75637190e+03, 1.80238843e+03, 1.84900000e+03, 1.89620661e+03, 1.94400826e+03, 1.99240496e+03, 2.04139669e+03, 2.09098347e+03, 2.14116529e+03, 2.19194215e+03, 2.24331405e+03, 2.29528099e+03, 2.34784298e+03, 2.40100000e+03, 2.45475207e+03, 2.50909917e+03, 2.56404132e+03, 2.61957851e+03, 2.67571074e+03, 2.73243802e+03, 2.78976033e+03, 2.84767769e+03, 2.90619008e+03, 2.96529752e+03, 3.02500000e+03])

While adding a new coordinate may often be done with a single line of code, the above example highlights the first shortcoming of this approach: To actually visualize da using this new coordinate we must additionally rename the dimension:

[3]:
da2 = da2.rename_dims({'x': 'x_square'})
da2.plot(figsize=(4, 3))
[3]:
../_images/user-guide_coordinate-transformations_5_0.svg

Further complications are:

  • The original coordinate is preserved and may get in the way in subsequent operations.

  • Event-coordinates of binned data are not handled.

  • Multi-step conversions with multiple inputs and multiple outputs may be required in practice.

To accommodate these recurring yet highly application-specific needs, Scipp provides a generic mechanism for transforming coordinates. This is described and exemplified in the following.

transform_coords#

Overview#

sc.transform_coords (also available as method of data arrays and datasets) is a tool for transforming one or more input coordinates into one or more output coordinates. It automatically handles:

  • Renaming of dimensions, if dimension-coordinates are transformed.

  • Making coordinates unaligned to avoid interference of coordinates consumed by the transformation in follow-up operations.

  • Conversion of event-coordinates of binned data, if present.

Basic example#

We start by revisiting the example given in Motivation. The building blocks transform_coords operates on are functions with named parameters. The parameter names define the names of the input coordinates to consume. Let us define x_square, which will consume x:

[4]:
def x_square(x):
    return x * x

Next, we create a dict, mapping from an output coord name to a function that can create this coordinate. The sc.show_graph helper is a convenient tool for visualizing the coordinate transformation defined by such as mapping:

[5]:
graph = {'x^2': x_square}
sc.show_graph(graph)
[5]:
../_images/user-guide_coordinate-transformations_9_0.svg

Here, the x coordinate can be consumed by the x_square function, creating the x^2 coordinate. Note that the function name and coordinate are unrelated. Next, we can call transform_coords. Apart from the graph, we also pass a list of desired output coordinates, here simply ['x^2']. transform_coords returns a new (shallow-copied) data array with added coordinates:

[6]:
transformed = da.transform_coords(['x^2'], graph=graph)
transformed
[6]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (3.60 KB)
    • x^2: 100
    • x
      (x^2)
      float64
      m
      1.0, 1.545, ..., 54.455, 55.0
      Values:
      array([ 1. , 1.54545455, 2.09090909, 2.63636364, 3.18181818, 3.72727273, 4.27272727, 4.81818182, 5.36363636, 5.90909091, 6.45454545, 7. , 7.54545455, 8.09090909, 8.63636364, 9.18181818, 9.72727273, 10.27272727, 10.81818182, 11.36363636, 11.90909091, 12.45454545, 13. , 13.54545455, 14.09090909, 14.63636364, 15.18181818, 15.72727273, 16.27272727, 16.81818182, 17.36363636, 17.90909091, 18.45454545, 19. , 19.54545455, 20.09090909, 20.63636364, 21.18181818, 21.72727273, 22.27272727, 22.81818182, 23.36363636, 23.90909091, 24.45454545, 25. , 25.54545455, 26.09090909, 26.63636364, 27.18181818, 27.72727273, 28.27272727, 28.81818182, 29.36363636, 29.90909091, 30.45454545, 31. , 31.54545455, 32.09090909, 32.63636364, 33.18181818, 33.72727273, 34.27272727, 34.81818182, 35.36363636, 35.90909091, 36.45454545, 37. , 37.54545455, 38.09090909, 38.63636364, 39.18181818, 39.72727273, 40.27272727, 40.81818182, 41.36363636, 41.90909091, 42.45454545, 43. , 43.54545455, 44.09090909, 44.63636364, 45.18181818, 45.72727273, 46.27272727, 46.81818182, 47.36363636, 47.90909091, 48.45454545, 49. , 49.54545455, 50.09090909, 50.63636364, 51.18181818, 51.72727273, 52.27272727, 52.81818182, 53.36363636, 53.90909091, 54.45454545, 55. ])
    • x^2
      (x^2)
      float64
      m^2
      1.0, 2.388, ..., 2965.298, 3025.000
      Values:
      array([1.00000000e+00, 2.38842975e+00, 4.37190083e+00, 6.95041322e+00, 1.01239669e+01, 1.38925620e+01, 1.82561983e+01, 2.32148760e+01, 2.87685950e+01, 3.49173554e+01, 4.16611570e+01, 4.90000000e+01, 5.69338843e+01, 6.54628099e+01, 7.45867769e+01, 8.43057851e+01, 9.46198347e+01, 1.05528926e+02, 1.17033058e+02, 1.29132231e+02, 1.41826446e+02, 1.55115702e+02, 1.69000000e+02, 1.83479339e+02, 1.98553719e+02, 2.14223140e+02, 2.30487603e+02, 2.47347107e+02, 2.64801653e+02, 2.82851240e+02, 3.01495868e+02, 3.20735537e+02, 3.40570248e+02, 3.61000000e+02, 3.82024793e+02, 4.03644628e+02, 4.25859504e+02, 4.48669421e+02, 4.72074380e+02, 4.96074380e+02, 5.20669421e+02, 5.45859504e+02, 5.71644628e+02, 5.98024793e+02, 6.25000000e+02, 6.52570248e+02, 6.80735537e+02, 7.09495868e+02, 7.38851240e+02, 7.68801653e+02, 7.99347107e+02, 8.30487603e+02, 8.62223140e+02, 8.94553719e+02, 9.27479339e+02, 9.61000000e+02, 9.95115702e+02, 1.02982645e+03, 1.06513223e+03, 1.10103306e+03, 1.13752893e+03, 1.17461983e+03, 1.21230579e+03, 1.25058678e+03, 1.28946281e+03, 1.32893388e+03, 1.36900000e+03, 1.40966116e+03, 1.45091736e+03, 1.49276860e+03, 1.53521488e+03, 1.57825620e+03, 1.62189256e+03, 1.66612397e+03, 1.71095041e+03, 1.75637190e+03, 1.80238843e+03, 1.84900000e+03, 1.89620661e+03, 1.94400826e+03, 1.99240496e+03, 2.04139669e+03, 2.09098347e+03, 2.14116529e+03, 2.19194215e+03, 2.24331405e+03, 2.29528099e+03, 2.34784298e+03, 2.40100000e+03, 2.45475207e+03, 2.50909917e+03, 2.56404132e+03, 2.61957851e+03, 2.67571074e+03, 2.73243802e+03, 2.78976033e+03, 2.84767769e+03, 2.90619008e+03, 2.96529752e+03, 3.02500000e+03])
    • (x^2)
      float64
      m^2
      1.0, 2.388, ..., 2965.298, 3025.000
      Values:
      array([1.00000000e+00, 2.38842975e+00, 4.37190083e+00, 6.95041322e+00, 1.01239669e+01, 1.38925620e+01, 1.82561983e+01, 2.32148760e+01, 2.87685950e+01, 3.49173554e+01, 4.16611570e+01, 4.90000000e+01, 5.69338843e+01, 6.54628099e+01, 7.45867769e+01, 8.43057851e+01, 9.46198347e+01, 1.05528926e+02, 1.17033058e+02, 1.29132231e+02, 1.41826446e+02, 1.55115702e+02, 1.69000000e+02, 1.83479339e+02, 1.98553719e+02, 2.14223140e+02, 2.30487603e+02, 2.47347107e+02, 2.64801653e+02, 2.82851240e+02, 3.01495868e+02, 3.20735537e+02, 3.40570248e+02, 3.61000000e+02, 3.82024793e+02, 4.03644628e+02, 4.25859504e+02, 4.48669421e+02, 4.72074380e+02, 4.96074380e+02, 5.20669421e+02, 5.45859504e+02, 5.71644628e+02, 5.98024793e+02, 6.25000000e+02, 6.52570248e+02, 6.80735537e+02, 7.09495868e+02, 7.38851240e+02, 7.68801653e+02, 7.99347107e+02, 8.30487603e+02, 8.62223140e+02, 8.94553719e+02, 9.27479339e+02, 9.61000000e+02, 9.95115702e+02, 1.02982645e+03, 1.06513223e+03, 1.10103306e+03, 1.13752893e+03, 1.17461983e+03, 1.21230579e+03, 1.25058678e+03, 1.28946281e+03, 1.32893388e+03, 1.36900000e+03, 1.40966116e+03, 1.45091736e+03, 1.49276860e+03, 1.53521488e+03, 1.57825620e+03, 1.62189256e+03, 1.66612397e+03, 1.71095041e+03, 1.75637190e+03, 1.80238843e+03, 1.84900000e+03, 1.89620661e+03, 1.94400826e+03, 1.99240496e+03, 2.04139669e+03, 2.09098347e+03, 2.14116529e+03, 2.19194215e+03, 2.24331405e+03, 2.29528099e+03, 2.34784298e+03, 2.40100000e+03, 2.45475207e+03, 2.50909917e+03, 2.56404132e+03, 2.61957851e+03, 2.67571074e+03, 2.73243802e+03, 2.78976033e+03, 2.84767769e+03, 2.90619008e+03, 2.96529752e+03, 3.02500000e+03])

Note how x is now unaligned (not shown in bold), i.e., operations will not use it for alignment anymore. This is important since it will allow for operations combining transformed with other data that may have matching x^2 but not x.

Example: Multi-step transform splitting and combining input coords#

Introduction#

Let us consider a more complex example. Imagine we have sensors around the globe, counting lightning strikes. For each sensor get have data recorded at a certain UTC, and the sensor location. We may be interested in variation of lightning strike frequency with time of day, as well as latitude. To obtain this, we must:

  1. Extract latitude and longitude information from the sensor locations.

  2. Compute the local datetime from the datetime and a “timezone” offset from the longitude.

  3. Extract the time from the local datetime.

For this purpose, we may define functions that look as follows. We suggest ignoring the implementation details of these functions, since they are approximations and irrelevant for this example:

[7]:
def lat_long(location):
    x = location.fields.x
    y = location.fields.y
    z = location.fields.z
    theta = sc.to_unit(sc.atan2(y=sc.sqrt(x * x + y * y), x=z), 'deg', copy=False)
    phi = sc.to_unit(sc.atan2(y=y, x=x), 'deg', copy=False)
    return {'latitude': 90.0 * sc.Unit('deg') - theta, 'longitude': phi}


def local_datetime(datetime, longitude):
    long = sc.to_unit(longitude, unit='deg', copy=False)
    angular_velocity = (360.0 * sc.Unit('deg')) / (24.0 * sc.Unit('hour'))
    offset = (long / angular_velocity).astype('int64') + 12 * sc.Unit('hour')
    return sc.to_unit(offset, datetime.unit) + datetime


def time(local_datetime):
    seconds_per_day = sc.scalar(24 * 60 * 60, unit='s')
    start_day = sc.scalar(start.value.astype('datetime64[D]'))
    start_day_in_seconds = sc.scalar(start_day.values.astype('datetime64[s]'))
    offset = local_datetime - start_day_in_seconds
    time = (offset % seconds_per_day).astype('float64')
    return time

Defining a transformation graph#

Based on these functions we may then create a mapping between coordinate names and functions. The visualization of the graph gives a handy summary of the desired conversion outlined above:

[8]:
graph = {
    (
        'longitude',
        'latitude',
    ): lat_long,
    'local_time': time,
    'local_datetime': local_datetime,
}
sc.show_graph(graph, size='6')
[8]:
../_images/user-guide_coordinate-transformations_15_0.svg

Sample data#

Next, let us look at the data we are working with. Here we simply create some fake data, the details of the following code cell are irrelevant and should also be ignored:

[9]:
import numpy as np

hour_steps = sc.arange(
    dim='datetime',
    dtype='int64',
    unit='s',
    start=0,
    stop=3 * 24 * 60 * 60,
    step=60 * 60,
)
start = sc.scalar(np.datetime64('2021-06-01T17:00:00'))
datetime = start + hour_steps
nsite = 1000
ntime = len(datetime)
# Note that these points are NOT uniformly distributed on a sphere, this is NOT a good way to generate such points
location = sc.vectors(dims=['location'], values=np.random.rand(nsite, 3)) - sc.vector(
    value=[0.5, 0.5, 0.5]
)
location *= 6371 * sc.Unit('km') / sc.norm(location)
da = sc.DataArray(
    data=sc.array(dims=['location', 'datetime'], values=np.random.rand(nsite, ntime)),
    coords={'location': location, 'datetime': datetime},
)
north = location.fields.z > 0.0 * sc.Unit('km')
north.unit = sc.units.one
da += 2.0 * (north).astype('float64')  # more lightning strikes in northern hemisphere
phi0 = sc.atan2(y=location.fields.y, x=location.fields.x) - sc.to_unit(
    90.0 * sc.Unit('deg'), 'rad'
)
sin = sc.sin(
    phi0 + sc.linspace(dim='datetime', unit='rad', start=0, stop=6 * np.pi, num=ntime)
)
da += 2 * (sin + 1)  # more lightning strikes later in the day
da.unit = 'counts'

Our input data looks as follows, a 2-D data array with dimensions datetime and location, and corresponding coordinates:

[10]:
da
[10]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (587.81 KB)
    • location: 1000
    • datetime: 72
    • datetime
      (datetime)
      datetime64
      s
      2021-06-01T17:00:00, 2021-06-01T18:00:00, ..., 2021-06-04T15:00:00, 2021-06-04T16:00:00
      Values:
      array(['2021-06-01T17:00:00', '2021-06-01T18:00:00', '2021-06-01T19:00:00', '2021-06-01T20:00:00', '2021-06-01T21:00:00', '2021-06-01T22:00:00', '2021-06-01T23:00:00', '2021-06-02T00:00:00', '2021-06-02T01:00:00', '2021-06-02T02:00:00', '2021-06-02T03:00:00', '2021-06-02T04:00:00', '2021-06-02T05:00:00', '2021-06-02T06:00:00', '2021-06-02T07:00:00', '2021-06-02T08:00:00', '2021-06-02T09:00:00', '2021-06-02T10:00:00', '2021-06-02T11:00:00', '2021-06-02T12:00:00', '2021-06-02T13:00:00', '2021-06-02T14:00:00', '2021-06-02T15:00:00', '2021-06-02T16:00:00', '2021-06-02T17:00:00', '2021-06-02T18:00:00', '2021-06-02T19:00:00', '2021-06-02T20:00:00', '2021-06-02T21:00:00', '2021-06-02T22:00:00', '2021-06-02T23:00:00', '2021-06-03T00:00:00', '2021-06-03T01:00:00', '2021-06-03T02:00:00', '2021-06-03T03:00:00', '2021-06-03T04:00:00', '2021-06-03T05:00:00', '2021-06-03T06:00:00', '2021-06-03T07:00:00', '2021-06-03T08:00:00', '2021-06-03T09:00:00', '2021-06-03T10:00:00', '2021-06-03T11:00:00', '2021-06-03T12:00:00', '2021-06-03T13:00:00', '2021-06-03T14:00:00', '2021-06-03T15:00:00', '2021-06-03T16:00:00', '2021-06-03T17:00:00', '2021-06-03T18:00:00', '2021-06-03T19:00:00', '2021-06-03T20:00:00', '2021-06-03T21:00:00', '2021-06-03T22:00:00', '2021-06-03T23:00:00', '2021-06-04T00:00:00', '2021-06-04T01:00:00', '2021-06-04T02:00:00', '2021-06-04T03:00:00', '2021-06-04T04:00:00', '2021-06-04T05:00:00', '2021-06-04T06:00:00', '2021-06-04T07:00:00', '2021-06-04T08:00:00', '2021-06-04T09:00:00', '2021-06-04T10:00:00', '2021-06-04T11:00:00', '2021-06-04T12:00:00', '2021-06-04T13:00:00', '2021-06-04T14:00:00', '2021-06-04T15:00:00', '2021-06-04T16:00:00'], dtype='datetime64[s]')
    • location
      (location)
      vector3
      km
      [-3055.48486007 1084.19088687 -5484.35806551], [-5110.86485901 1718.49404102 3393.44657007], ..., [-3976.48157919 -4963.4986908 -375.38779522], [-2851.47744583 -3340.25608785 -4615.34469389]
      Values:
      array([[-3055.48486007, 1084.19088687, -5484.35806551], [-5110.86485901, 1718.49404102, 3393.44657007], [ 3703.14454664, -4238.04137142, 2985.86114895], ..., [ 2625.73189403, 2515.83631629, 5231.2274516 ], [-3976.48157919, -4963.4986908 , -375.38779522], [-2851.47744583, -3340.25608785, -4615.34469389]])
    • (location, datetime)
      float64
      counts
      4.199, 4.622, ..., 4.498, 4.040
      Values:
      array([[4.1989904 , 4.6219724 , 4.91565976, ..., 3.50366737, 3.8152402 , 4.78244421], [6.18424077, 6.35623821, 6.15636215, ..., 5.49167705, 6.46872201, 5.94955705], [3.51903312, 2.88841647, 2.68537886, ..., 4.1815094 , 3.56748077, 3.40431362], ..., [3.46305724, 3.55267095, 3.4578613 , ..., 2.48243824, 3.17435282, 2.67290095], [3.30654397, 3.76634568, 2.51640137, ..., 3.92386063, 4.17224194, 3.25339933], [4.09523843, 3.20079461, 2.84129613, ..., 4.58537985, 4.49772514, 4.04035121]])

A 3-D scatter plot may be used to visualize this. When dragging the datetime slider we can observe how the lightning counts shifts around the globe with the time of the day (the fake data covers a period of 3 days). Note that the slider is only functional when running the notebook and is not functional in the online documentation page:

[11]:
def scatter_plot(da):
    from plopp import widgets as pw

    da = da.copy(deep=False)
    da.coords['x'] = da.coords['location'].fields.x
    da.coords['y'] = da.coords['location'].fields.y
    da.coords['z'] = da.coords['location'].fields.z
    inp = pp.Node(da)
    slider = pw.SliceWidget(da, dims=['datetime'])
    slider_node = pp.widget_node(slider)
    slice_node = pw.slice_dims(inp, slider_node)
    fig = pp.scatter3dfigure(slice_node, x='x', y='y', z='z', pixel_size=500, cbar=True)
    return pw.Box([fig, slider])


scatter_plot(da)
[11]:

Performing a transformation#

With this setup, the actual coordinate transformation is now very simple:

[12]:
transformed = da.transform_coords(['latitude', 'local_time'], graph=graph)

The result is:

[13]:
transformed
[13]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (1.69 MB)
    • location: 1000
    • local_time: 72
    • datetime
      (local_time)
      datetime64
      s
      2021-06-01T17:00:00, 2021-06-01T18:00:00, ..., 2021-06-04T15:00:00, 2021-06-04T16:00:00
      Values:
      array(['2021-06-01T17:00:00', '2021-06-01T18:00:00', '2021-06-01T19:00:00', '2021-06-01T20:00:00', '2021-06-01T21:00:00', '2021-06-01T22:00:00', '2021-06-01T23:00:00', '2021-06-02T00:00:00', '2021-06-02T01:00:00', '2021-06-02T02:00:00', '2021-06-02T03:00:00', '2021-06-02T04:00:00', '2021-06-02T05:00:00', '2021-06-02T06:00:00', '2021-06-02T07:00:00', '2021-06-02T08:00:00', '2021-06-02T09:00:00', '2021-06-02T10:00:00', '2021-06-02T11:00:00', '2021-06-02T12:00:00', '2021-06-02T13:00:00', '2021-06-02T14:00:00', '2021-06-02T15:00:00', '2021-06-02T16:00:00', '2021-06-02T17:00:00', '2021-06-02T18:00:00', '2021-06-02T19:00:00', '2021-06-02T20:00:00', '2021-06-02T21:00:00', '2021-06-02T22:00:00', '2021-06-02T23:00:00', '2021-06-03T00:00:00', '2021-06-03T01:00:00', '2021-06-03T02:00:00', '2021-06-03T03:00:00', '2021-06-03T04:00:00', '2021-06-03T05:00:00', '2021-06-03T06:00:00', '2021-06-03T07:00:00', '2021-06-03T08:00:00', '2021-06-03T09:00:00', '2021-06-03T10:00:00', '2021-06-03T11:00:00', '2021-06-03T12:00:00', '2021-06-03T13:00:00', '2021-06-03T14:00:00', '2021-06-03T15:00:00', '2021-06-03T16:00:00', '2021-06-03T17:00:00', '2021-06-03T18:00:00', '2021-06-03T19:00:00', '2021-06-03T20:00:00', '2021-06-03T21:00:00', '2021-06-03T22:00:00', '2021-06-03T23:00:00', '2021-06-04T00:00:00', '2021-06-04T01:00:00', '2021-06-04T02:00:00', '2021-06-04T03:00:00', '2021-06-04T04:00:00', '2021-06-04T05:00:00', '2021-06-04T06:00:00', '2021-06-04T07:00:00', '2021-06-04T08:00:00', '2021-06-04T09:00:00', '2021-06-04T10:00:00', '2021-06-04T11:00:00', '2021-06-04T12:00:00', '2021-06-04T13:00:00', '2021-06-04T14:00:00', '2021-06-04T15:00:00', '2021-06-04T16:00:00'], dtype='datetime64[s]')
    • latitude
      (location)
      float64
      deg
      -59.410, 32.184, ..., -3.378, -46.421
      Values:
      array([-5.94100825e+01, 3.21839726e+01, 2.79476373e+01, -3.99753654e+01, 4.83128032e+01, 8.43894928e+00, 1.97333514e+01, -4.41775310e+01, -5.25737977e+01, -2.03219898e+01, -4.26744711e+01, -1.22526581e+01, 5.11074699e+01, 3.76713270e+01, -9.54979970e+00, 2.68411136e+01, -3.20788453e+01, 3.20402826e+01, -5.72204376e+01, -6.00357204e+01, -2.55135335e+01, -5.97418406e+01, 3.94571096e+01, 3.24519546e+00, 8.82244799e+00, -4.11996014e+01, 1.53370802e+01, 6.69932636e+01, 2.59670241e+01, -3.36982446e+01, -2.13960057e+01, 6.97611318e+00, 6.95561897e+00, -3.61773616e+01, -2.94598375e+01, -4.77257434e+01, -1.62427550e+01, -1.14202249e+01, -1.74032815e+01, 4.66641719e+01, -1.46176302e+01, 4.31498770e+01, 3.34905573e-01, -2.63972692e+01, -2.60619441e+01, 2.86893124e+01, 6.51655850e+01, -4.98306146e+01, -4.89767294e+01, -3.03450666e+01, 2.40190292e+01, -4.34266937e+01, -6.92246438e+01, 5.03379083e+01, 7.28941665e+01, -4.06805720e+00, 6.77431569e+01, 8.74219876e+00, -4.48056941e+01, 4.72207801e+01, 3.97041200e+01, 1.62165140e+01, 4.75772289e+01, -1.51804007e+01, 4.34550486e+01, -7.16799948e-01, 1.86396791e+01, 1.60550366e+01, -3.27709585e+01, -3.20501731e+01, -3.56927019e-01, -2.29343384e+01, -7.38649666e+01, 5.03838649e+01, 1.98470876e+01, -1.20991943e+01, 3.46141018e+01, -9.39494567e+00, -5.91344886e+01, 4.99432622e+01, -3.14362737e+01, 2.50667690e+01, 3.15083600e+01, -2.96290413e+01, -5.83161527e+01, 1.91131208e+01, 2.23310628e+01, -3.49642587e+00, 6.52492227e+01, 4.03897956e+01, -4.20540737e+01, 2.26314649e+01, 1.86209192e+01, 2.99831685e+01, -2.43727628e+01, -2.57222855e+01, -7.77429448e+01, 5.72190560e+01, 6.30003004e+00, 7.62402550e+00, 4.34935359e+01, 3.57367382e+01, 5.63878261e+01, 3.48070966e+01, 6.39598216e+01, 9.42458993e-01, -2.37423545e-01, -4.01311572e+01, -2.72507844e+01, -3.05091680e+01, -2.13392853e+01, -7.89015914e+00, -8.36265106e+01, -3.93480469e+01, -4.58661427e+01, -5.44415398e+01, -1.89408387e+01, 2.21881094e+01, -3.22008091e+01, 5.06589977e+00, 4.99696389e+00, 1.98376377e+01, 1.73828982e+01, -3.67553527e+01, 3.79389387e+01, 6.64872004e+01, 5.99085956e+01, -1.66632201e+01, -5.86392761e+01, 3.79228069e+01, 6.98924572e+01, 6.06246131e+01, -3.21152568e+01, 3.12368699e+01, 3.30811538e+01, -3.43691154e+01, -3.66500056e+01, -6.12648357e+01, -7.74006331e+01, -2.50405499e+01, 2.65081340e+01, -2.56497130e-01, 1.66226180e+01, 5.27595445e+01, -3.14147972e+00, 4.26105251e+01, 3.09037688e-02, -2.50016133e+00, 7.14969910e+01, 4.15697582e+00, 3.42268504e+01, -4.67381001e+01, 3.87357907e+01, 5.15672074e+01, 2.28998333e+01, -1.47261498e+00, -4.37242465e+01, 3.47336455e+01, -5.99727966e+01, 4.76208941e+01, -5.87053729e+01, 4.81654265e+01, 5.40125383e+01, 6.79417410e+01, -4.04649488e+01, 2.01857092e+01, -3.48386545e+01, 6.86153604e+00, 5.43714613e+01, 5.74518358e+01, -1.80310102e+01, 7.11383935e+01, 1.77526600e+01, -3.85091476e+01, -6.67193403e+01, 1.27649324e+01, -5.15330142e+01, 1.74959608e+01, -2.66481563e+01, 4.35130921e+01, -2.57280527e+00, 4.49202741e+01, 2.13122644e+01, 4.74938799e+01, 8.42926360e+00, -3.62217804e-01, -2.01449870e+01, -6.51316084e+01, 2.34503136e+01, -2.18408570e+01, -3.79322965e+01, 4.20923988e+01, -4.04154629e+01, -4.00455065e+01, -2.56171517e+01, -2.04572920e+01, 3.03280287e+01, 2.91800238e+01, -7.97891692e+00, 4.50158771e+01, -1.48077257e+01, -1.16940361e+01, 2.92866419e+01, -1.46488597e+01, -1.57712307e+01, 5.43039266e+00, -8.29659912e+00, -2.98836929e+01, -1.03296567e+01, -4.94887792e+00, 3.93552122e+01, -1.57814184e+01, -8.34117875e+00, 9.43833349e+00, -2.84823054e+00, 4.75726470e+00, 3.04585494e+01, -4.61558858e+01, -3.06919378e+01, 2.36771303e+01, -6.18110354e+01, -3.73634233e+01, 4.54074494e+01, 2.17269293e+01, 2.14724558e+00, -2.52859990e+01, -2.59572474e+01, 1.25147483e+01, 6.13775662e+01, 4.11726373e+01, -2.40769440e+01, 3.80187833e+01, -7.77870395e+01, -4.21877716e+01, 2.56566893e+01, 3.57982670e+01, -4.47929786e+01, -7.89733794e+00, 4.73270891e+01, -4.61208803e+01, 4.53961872e+01, 2.90219845e+01, -3.09778269e+01, -4.89727637e+01, 1.00051778e+01, 1.63452840e+00, 8.48376265e+01, -2.31606610e+01, 5.70217425e+01, 2.70344290e+01, -8.65839390e+00, -8.42705979e+01, -2.01941449e+01, -3.92693528e+01, 4.90543692e+01, 7.28561700e+01, -2.22603311e+01, -4.93011660e+01, 4.95472859e+01, 3.86656903e+01, 3.33000669e+01, -4.53426362e+01, 3.00191880e+01, 2.14051030e+01, 5.70845170e+01, -9.89407661e+00, -4.36391300e+01, 3.45943493e+01, 4.95159348e+01, 1.22472666e+00, -1.49805979e+01, 3.80050664e+01, -1.49994412e+00, -2.05322188e+01, 1.89364592e+01, 5.82449248e+01, -2.12183019e+01, -2.93406111e+01, -6.14652481e+01, 2.93495977e+01, -5.62003073e+01, 4.61353831e+01, -1.63631272e+01, -1.34986794e+01, 3.94689953e+01, -4.74567068e+01, 1.66254139e+01, -3.22659559e+01, 3.44934128e+01, -1.10625578e+01, -4.82189310e+01, -6.67218404e+01, -4.11276275e+00, -3.40401411e+01, 2.11488134e+01, -1.94830365e+01, -1.36579603e+00, -1.46323303e+01, -3.97335163e+01, -2.45965532e+01, 5.80275332e+01, 8.37282821e+00, 3.17080932e+01, 4.42824797e+01, -4.54725399e+01, -3.59135243e+01, 4.10541941e+01, 1.88098062e+01, -5.84570319e+01, -5.04834368e+00, 1.03838713e+01, 5.08132798e+01, 4.17430299e+01, -7.61468060e+01, -6.72907807e+01, 5.74823252e+01, 5.03427308e+01, -4.18090565e+01, -1.53560432e+01, -4.12732130e+01, -5.73189943e+01, -5.23204758e+01, 2.16277270e+01, -1.46311153e+00, -3.67012181e+01, -1.17114530e+01, 4.70548639e+01, 5.20521568e+01, -2.59827660e+01, 2.42766309e+01, 6.73187481e+01, -4.21732325e+01, -3.69063606e+01, 3.38946225e+01, 1.95441013e+01, -4.34594118e+01, 1.54269513e+01, -2.17494842e+01, -2.40299740e+01, -5.32461045e+01, 8.89744092e+00, 5.66490877e+01, 1.26539864e+01, 4.23826416e+01, 2.42878051e+01, -3.99923036e+01, 3.19960120e+01, -5.66879972e+00, 2.22981710e+01, 5.21951753e+01, -4.97201152e+00, 4.60761864e+01, -2.72355328e+01, -5.23107776e+01, -4.30944794e+01, 2.63181642e+01, -3.77805009e+01, -5.10030152e+01, -1.74874767e+01, -5.18083173e+01, 2.17779252e+01, -2.14058593e+01, 7.44832996e+01, -2.90193226e+01, 1.79624322e+01, -2.16438408e+01, 3.01328776e+01, 2.78738700e+01, 1.46394323e+01, -1.81300037e+01, 2.46122868e+01, 2.68258981e+01, 2.57984508e+01, 2.78043029e+01, -2.37941695e+01, -2.68115491e+01, 4.28023762e+01, 3.15712220e+01, 7.19750935e+01, 4.30544023e+01, -3.04878501e+01, -3.24472411e+01, 2.82907697e+00, -1.49847612e+01, -5.02340036e+01, 3.42683567e+01, 6.25301610e+01, 1.98819443e+01, 2.99799103e+01, -2.94612611e+01, 1.16750458e+01, -2.67689157e+01, 3.28029196e+00, -3.37377793e+01, 2.71692452e+00, -6.90351036e+01, 2.01320785e+01, 5.90711462e+01, 1.29265350e+01, 6.18699845e+01, 2.76667011e+01, 3.97776528e+01, 3.17342815e+01, 1.31660388e+01, -5.58017185e+01, -1.35602823e+00, 1.29810903e+01, -1.58995421e+01, 4.54942035e+01, 5.20986182e+01, 4.74629507e+01, -3.71718954e+01, -3.99715582e+01, -4.02678774e+01, -5.03432629e+00, -3.09405098e+01, 3.16499455e+01, 3.86112887e+01, -2.91561974e+01, 4.82255553e+01, -1.10891513e+01, 2.27609693e+01, -4.87907672e+01, -6.82755982e+00, 2.93846807e+01, -2.81488514e+00, -5.29098330e+01, 4.48709474e+01, 5.18108602e+01, 6.41760618e+01, 1.48516314e+01, -4.15543960e+01, -3.05874428e+01, 3.46049472e+01, 3.71797248e+00, -6.02487490e+01, 1.59050038e+01, 3.32475215e+01, 6.10603341e+01, 1.94325622e+00, 6.75683451e+01, -3.26463451e+01, 3.78975534e+00, -4.02873020e+01, 6.51662206e+01, 4.48873446e+01, 5.52529605e+01, -4.47695602e+01, 4.67951958e+01, -3.06892088e+01, -4.63878171e+01, -4.75857322e+01, -6.29895494e+00, 1.82575573e+01, 1.41126255e+01, -1.19073828e+01, 5.95405051e+01, -3.84671750e+01, -6.88272421e+01, 8.69104318e+00, 3.29307687e+01, 2.26612392e+01, -6.61025417e+01, 1.49240919e+01, 6.13158254e+00, -1.56861082e+01, 8.43092241e+01, -2.14503637e+01, 6.42698788e+01, -1.66428068e+01, -2.77318006e+01, 3.54210011e+01, 2.15341124e+01, 4.30925572e+01, 4.92305795e+01, 2.27230248e+01, -2.28310620e+01, 4.47226784e+01, 1.52015888e+01, 1.43418703e+01, 2.24916892e+01, -3.07160071e+01, -3.62268479e+01, 1.65414925e+01, 9.27329241e-02, 3.92341837e+01, -9.12932600e+00, 1.53937348e+00, -2.28713137e+01, -3.91563055e+01, 4.63210086e+01, -3.99992387e+01, 3.69032407e+01, -1.06381067e+01, -1.43302114e+01, -5.41148724e+01, 5.09106054e+01, -3.69494357e+01, -1.87424644e+01, -1.30632007e+01, -5.55267690e+01, 2.91441279e+01, -4.41147823e+01, 6.20203481e+01, -1.95525052e+01, 1.44800267e+01, 2.91090548e+01, 3.51553675e+01, 3.48782870e+01, 2.67383999e+01, 5.51147998e+01, 1.74982297e+01, 4.09630442e+01, 3.47219905e+01, 2.52626537e+01, 1.21882578e+01, -3.12041595e+01, -3.97737954e+01, -2.06228201e+01, -5.41807367e+01, -5.69776922e+01, -1.42781832e+01, -6.19601362e+01, -3.17374475e+01, -7.05388836e+01, 3.33000894e+01, 3.37600391e+01, 5.19772903e+01, -5.54086865e+01, 7.28707294e+01, 1.91129415e+01, 5.18382400e+01, 4.09782448e+01, -2.66250537e+01, -3.35671071e+01, 3.47226675e+00, 4.49887356e+01, -2.27310138e+01, 3.73083530e+01, 3.56622611e+01, 3.71351179e+01, 4.00988994e+01, -3.21616446e+01, 4.66018806e+01, -2.72858456e+01, 3.18681894e+01, 2.36503800e+01, -8.00169715e+01, 1.48127206e+01, 6.39579817e+01, -2.44814190e+01, 4.41412300e+01, -4.89274089e+01, -3.70592035e+01, 4.80504596e+01, 1.93483034e+01, -3.35455483e+01, -5.07670448e+00, 5.66939662e+01, -8.60727939e+00, 2.54609906e+00, 6.43521905e+01, -4.21551298e+01, -4.84559187e+01, 6.16639576e+01, 3.44805530e+01, 7.06568029e+00, 4.12532168e+01, 5.24666125e+01, -9.85193017e-01, 5.42810286e+01, -1.92226939e+01, 4.46866390e+01, -1.97477955e+01, 5.84835793e+01, -2.70915955e+01, 4.71267351e+01, 1.29229229e+01, 1.36960282e+01, -1.71986929e+01, 3.37220841e+00, -2.82775941e+01, -1.86197008e+00, -1.11943361e+01, -3.64927009e+01, 5.67481380e+01, 3.44644704e+01, 3.43069645e+00, 4.95519628e+01, -3.71052277e+01, -2.53095085e+01, 1.26649072e+01, 4.34982572e+01, -3.69775048e+01, -1.55017224e+01, -3.58884432e+01, -6.97993034e+01, 1.39959951e+01, 4.47421262e+01, -4.66811043e+01, -4.48900824e+00, -6.58298650e+01, -3.05992735e+01, -3.63206205e+01, 7.58102733e+00, 1.51733074e+01, 2.18950281e+01, -4.43680096e+01, -2.19144987e+01, 6.40838033e+01, -4.11809751e+01, 2.14742305e+01, -3.26290510e+00, -1.80141885e+01, 1.63570919e+00, -2.07096346e+01, 2.75305539e+01, -1.23076780e+01, -2.82629792e+01, -3.36941698e+01, 2.91936742e+01, -3.26854490e+01, -1.79560977e+01, 7.00799821e+01, -3.87965196e+01, -4.68533036e+00, 9.19476097e+00, 1.94877530e+01, -4.29690911e+01, -2.96722973e+01, 5.80364469e+01, 6.60977297e+01, 5.67625897e+01, -1.92867109e+01, 7.89294191e+01, 5.76196186e+00, 4.20411490e+01, 4.55719163e+01, -3.47676635e+01, 3.08453709e+01, 6.12014639e+01, 3.75397329e+01, -6.28270471e+01, 3.41476536e+01, -2.32583358e+01, 5.17301679e+01, -1.97505585e+01, -3.61959786e+01, -4.78526557e+01, 4.28766305e+01, 1.04291572e+01, -4.60130176e+01, 4.11378568e+01, 8.27772303e-01, -6.02732100e+01, -5.00189529e+01, 5.14839537e+00, -7.08835758e+00, -6.16832613e+01, -2.63699858e+01, -2.79451549e+01, 5.38944936e+01, -6.09375222e+01, 5.88156880e+01, 2.12133090e+00, -1.03288864e+01, 5.27225863e+00, 2.97784235e+01, 4.99875842e+01, -9.72086294e+00, -3.23622690e+01, 8.43889783e+00, 1.01557026e+01, -2.53449736e+01, 6.25173725e+01, -4.35207722e+01, -5.83089883e+00, -5.47710472e+01, -3.45258640e+01, 1.04118734e+01, 5.93556578e+01, 1.79766450e+00, 4.76208132e+01, -2.79473492e+01, -6.12200662e+01, 4.27439073e+01, -4.20018554e+01, 1.15921488e+01, -1.49397235e+01, 1.74980648e+01, 5.75704552e+01, -2.84260296e+01, -3.25088135e+01, -1.06368276e+01, 1.37425939e+01, -7.34874074e+00, -4.27227840e+01, -5.51371458e+01, -3.72362661e+01, -1.18508200e+01, 3.37991299e+01, -4.23946960e+01, 4.75876715e+01, 3.30950106e+01, -3.84122511e+01, -1.57883958e+01, 1.21268494e+01, 5.18389585e+01, -2.21331876e+01, 2.16699983e+01, -4.01604991e+01, 1.23620467e+01, 4.72384660e+01, 3.04488834e+01, 1.67454748e+01, -4.27960941e+01, 7.07268076e+00, -2.45312127e+01, 7.27871162e+01, -7.78651672e+00, 7.10340856e+01, 4.15679942e+01, -4.40254269e+01, -1.29671408e+01, -2.71852506e+01, -4.61861391e+01, 4.87961773e+01, -4.52197287e+01, -5.25736748e+01, 2.36863435e+01, -4.00423101e+01, -2.76889772e+01, -5.45866301e+01, 3.50677579e+01, 3.38305098e+01, 4.39529206e+01, -4.29153835e+01, -1.41475092e+01, -2.01709333e+01, -5.21356101e+01, -9.98420963e+00, -4.05976426e+01, 4.90236480e+01, -3.99359636e+01, -2.56861116e+01, 3.49098483e+01, -1.68590051e+01, -2.45288107e+01, 3.89293596e+01, 5.04993392e+01, -1.45644731e+01, 1.17096099e+01, 2.59687221e-01, -1.03872256e+01, -5.50294895e+01, 3.66162527e+01, 3.91066128e+01, 5.18968246e+01, 4.17125633e+01, -1.05940993e+01, -4.05709965e+01, 7.54040906e+01, 4.89947266e+01, -3.33533537e+01, 5.30802579e+01, -3.04322107e+01, 4.38048919e+01, -1.40757224e+01, 3.31499883e+00, 2.81108573e+01, 1.16159132e+01, -4.52632088e+01, 4.31661136e+01, 3.82115000e+01, -2.08284108e+01, -8.86603691e+00, -2.27584335e+01, -2.20612389e+01, 1.63761921e+01, 3.99816401e+01, -3.45108818e+01, -4.49701735e+01, 3.99770994e+01, 3.90176359e+01, 4.57859837e+01, -3.48162279e+01, -5.21043583e+01, 7.76560082e+01, 3.71382154e+01, 4.66942746e+01, -5.80281811e+00, 6.47662633e+01, -4.46246593e+01, -6.42045647e+00, -2.51495123e+01, -4.14337623e+01, 2.11250438e+01, 4.28892244e+01, 5.03728913e+01, -5.12854798e+01, -8.76512403e+00, 8.52945297e-01, 7.85190797e+01, -7.03414398e+00, -1.35785440e+01, 3.05998846e+01, 4.87408139e+01, 3.53428655e+01, 6.49805220e+00, 2.36141852e+01, -5.14093346e+01, 4.74620028e+01, 6.96472514e+01, 5.58654988e+01, -5.98845809e+01, 5.59602270e+01, 2.56381457e+01, -4.62067551e+01, -2.49029585e+01, 2.61851173e+01, 2.47518099e+01, 2.67766040e+01, 6.14894002e+01, -4.72007720e+00, 2.85506581e+01, -1.30892843e+01, 5.60931605e+01, 5.41949549e+01, -4.03200121e+01, 2.99392194e+01, -3.99848109e+01, 4.76484994e+01, 5.20732524e+01, -3.48065470e+01, -6.02688003e+01, 1.14570721e+00, 3.44488812e+01, 2.20050340e+01, 7.26233397e+01, 1.68025923e+01, -2.15731914e+01, 8.59457876e+01, -2.60585180e+01, -6.55768208e+00, 1.87296488e+01, 3.53110916e+01, 1.48633582e+01, 3.35828693e+01, 3.06850715e+01, 2.17750682e+01, 8.13785986e+01, -1.28886172e+01, 3.94151718e+01, 5.26626961e+01, -3.60004825e+01, 1.36322260e+01, 3.80919972e+01, 2.58315478e+01, -2.08494724e+01, 4.73016798e+01, -6.10083750e+00, 3.31988613e+01, -2.50207503e+01, -3.41744951e+01, -1.93623747e+01, 4.88195039e+01, -2.60371167e+01, 1.44123494e+01, 2.86222172e+01, 5.38787915e+01, -6.67429442e-01, 7.41287562e+00, 1.09622424e+01, -2.79522293e+00, 4.37675839e+01, -3.64817577e+01, 6.52286045e+01, 2.93372072e+01, 1.21782742e+01, -4.98923159e+01, 3.30366478e+01, 5.07080923e+01, 4.25846306e+01, -4.38283350e+01, -1.15821078e+01, 1.58336277e+01, 8.03159936e+01, -2.33266801e+01, -2.90015334e+01, 2.74431429e+00, -7.47000131e+01, -4.25593998e+01, -3.65754612e+01, 4.21515848e+01, -5.10996585e+01, -1.31872523e+01, -3.63249659e+01, 1.21336630e+01, -8.23002056e+01, 7.77380475e+01, -6.98544448e+00, -6.86089877e+01, 4.74553729e+01, 2.93128960e+01, -3.60392317e+00, 4.50538495e+01, -8.82078048e+00, 4.60849928e+01, -3.77989561e+01, 3.11170245e+01, 2.61301781e+01, -2.57922951e+01, 4.91361369e+00, 1.79885745e+01, 1.64298036e+01, 1.07013194e+01, -4.82100397e+01, -5.18288724e+01, -1.61120758e+01, 2.94102104e+00, -2.77521761e+01, -3.72383919e+01, 4.48738974e+01, 8.48788509e+00, -7.69281039e+01, 7.49060834e+01, -6.14887462e+01, -7.79787718e+01, -4.53870852e+01, -4.75994444e+01, -1.72975324e+01, 3.55900307e+01, 3.76659266e+01, -1.64780732e+01, 3.50145993e+01, 4.40018288e+01, -2.25520484e+01, 3.19487246e+01, -4.95910121e+01, 1.25689649e+01, -4.40313982e+01, 5.82068437e+00, -2.36763089e+01, -2.36343232e+01, 6.79788419e+01, 6.05731720e+01, -4.36665092e+01, -5.28285407e+01, -4.28131616e+01, -3.55150238e+01, -5.23969066e+01, 3.96055462e+00, 7.36397498e+00, 3.26438380e+01, 6.16140018e+01, -1.48309509e+01, 2.90710264e+01, -3.60426245e+01, -7.49099239e+01, 2.60734715e+01, 1.37013920e+01, 1.31850322e+01, 3.64307064e+01, 2.85028936e+01, -2.55386917e+01, -4.53535378e+01, -3.12421567e+01, -5.20535410e+01, 4.03589895e-01, -6.11894854e+00, -4.77299017e+01, -7.09809541e+01, -2.31873072e+01, -4.65281106e+01, -3.53448598e+01, -1.82969784e+01, 4.43681224e+01, 4.12895998e+01, 4.31751301e+01, 1.24767930e+01, -2.74977331e+01, -4.12176659e+01, -6.38534465e+00, 2.21963129e+01, 1.06915537e+01, -1.73859142e+01, 3.29207878e+01, 1.61710824e+01, -1.69698247e+01, 2.28787263e+01, 1.23802149e+01, 2.66784998e+00, -3.64771844e+01, 3.05172029e+01, -6.03397076e+01, 4.37358066e+01, -2.40368531e+01, 5.51950498e+01, -3.37790000e+00, -4.64214664e+01])
    • local_datetime
      (location, local_time)
      datetime64
      s
      2021-06-02T15:00:00, 2021-06-02T16:00:00, ..., 2021-06-04T19:00:00, 2021-06-04T20:00:00
      Values:
      array([['2021-06-02T15:00:00', '2021-06-02T16:00:00', '2021-06-02T17:00:00', ..., '2021-06-05T12:00:00', '2021-06-05T13:00:00', '2021-06-05T14:00:00'], ['2021-06-02T15:00:00', '2021-06-02T16:00:00', '2021-06-02T17:00:00', ..., '2021-06-05T12:00:00', '2021-06-05T13:00:00', '2021-06-05T14:00:00'], ['2021-06-02T02:00:00', '2021-06-02T03:00:00', '2021-06-02T04:00:00', ..., '2021-06-04T23:00:00', '2021-06-05T00:00:00', '2021-06-05T01:00:00'], ..., ['2021-06-02T07:00:00', '2021-06-02T08:00:00', '2021-06-02T09:00:00', ..., '2021-06-05T04:00:00', '2021-06-05T05:00:00', '2021-06-05T06:00:00'], ['2021-06-01T21:00:00', '2021-06-01T22:00:00', '2021-06-01T23:00:00', ..., '2021-06-04T18:00:00', '2021-06-04T19:00:00', '2021-06-04T20:00:00'], ['2021-06-01T21:00:00', '2021-06-01T22:00:00', '2021-06-01T23:00:00', ..., '2021-06-04T18:00:00', '2021-06-04T19:00:00', '2021-06-04T20:00:00']], dtype='datetime64[s]')
    • local_time
      (location, local_time)
      float64
      s
      5.400e+04, 5.760e+04, ..., 6.840e+04, 7.200e+04
      Values:
      array([[54000., 57600., 61200., ..., 43200., 46800., 50400.], [54000., 57600., 61200., ..., 43200., 46800., 50400.], [ 7200., 10800., 14400., ..., 82800., 0., 3600.], ..., [25200., 28800., 32400., ..., 14400., 18000., 21600.], [75600., 79200., 82800., ..., 64800., 68400., 72000.], [75600., 79200., 82800., ..., 64800., 68400., 72000.]])
    • location
      (location)
      vector3
      km
      [-3055.48486007 1084.19088687 -5484.35806551], [-5110.86485901 1718.49404102 3393.44657007], ..., [-3976.48157919 -4963.4986908 -375.38779522], [-2851.47744583 -3340.25608785 -4615.34469389]
      Values:
      array([[-3055.48486007, 1084.19088687, -5484.35806551], [-5110.86485901, 1718.49404102, 3393.44657007], [ 3703.14454664, -4238.04137142, 2985.86114895], ..., [ 2625.73189403, 2515.83631629, 5231.2274516 ], [-3976.48157919, -4963.4986908 , -375.38779522], [-2851.47744583, -3340.25608785, -4615.34469389]])
    • longitude
      (location)
      float64
      deg
      160.464, 161.415, ..., -128.700, -130.486
      Values:
      array([ 1.60463569e+02, 1.61415127e+02, -4.88534682e+01, 1.17379817e+02, -1.51322478e+01, 4.74374043e+01, -9.95963976e+01, -6.92366326e+01, -4.65957213e+01, 4.63526783e+01, -3.27196455e+01, 3.59564045e+01, -1.72162007e+02, 1.41644551e+02, -1.11360771e+02, 1.05545381e+02, -4.93646527e+01, -2.25967759e+01, 1.68920902e+02, -7.36524421e+01, -7.26889061e+01, -5.36225327e+01, 1.34793747e+02, 1.72753895e+02, 1.58726445e+02, 1.57677137e+02, -6.81424441e+01, -1.50493092e+02, 2.76584222e+01, 1.08723289e+02, -7.66779232e+01, -1.40295606e+02, -4.01495110e+01, 4.91171647e+01, 1.32706539e+02, 1.60005058e+02, -1.23319508e+02, -1.47442851e+02, 5.85954222e+01, -1.07178260e+02, -1.02252301e+01, -1.01347394e+02, -1.64654358e+02, 1.57536844e+02, -1.08614802e+02, 1.36225065e+02, 1.55441712e+02, -1.15131755e+02, -1.37319304e+02, -6.28683076e+01, -4.17082350e+01, -1.28040891e+02, 5.69610791e+01, -7.54912520e+01, 9.60972053e+00, 1.11216231e+01, -1.61892266e+02, 4.11528683e+01, 7.91622191e+01, -6.47423455e+01, 6.48869828e+01, -1.39782156e+02, -2.77049792e+01, -9.09536062e+01, -6.33451592e+01, -1.32970200e+02, -1.38714588e+02, -7.05640061e+01, 8.35679398e+01, 7.82377787e+01, -3.58645407e+01, -5.44045427e+01, -5.41226141e+01, -5.34150661e+00, 4.79277094e+01, 1.11353939e+02, 1.42161610e+02, -1.70276596e+02, -1.31969754e+02, -5.48597060e+01, -4.42531232e+01, -1.02864984e+02, -1.53181868e+02, -1.64972329e+02, -1.57290917e+02, -1.80326571e+01, 1.55617546e+02, -1.22552965e+01, -1.30159374e+02, -5.06552107e+01, -1.59144198e+02, 7.46868282e+01, -1.42969384e+02, -2.58774962e+01, 1.60248063e+02, 1.12709094e+02, -1.08719626e+02, -1.34139804e+02, -6.16524833e+01, -4.20055684e+01, -1.68094473e+02, 1.39422440e+02, 1.35253859e+02, 7.08978933e+01, 9.08867858e+00, 1.15734367e+02, -6.30930896e+01, -1.64102669e+02, -5.94757808e+00, 7.51339101e+01, -1.07519740e+02, 1.45131342e+02, -8.83367945e+01, 1.34402358e+01, 3.35208142e+01, -1.26759877e+02, -8.91602606e+01, 9.01418820e+01, -5.51322916e+01, 6.14139732e+01, 1.27933252e+02, 1.29054622e+02, -6.61421287e+00, 7.46661209e+01, -1.26784420e+02, 1.64201760e+02, -4.06855636e+01, 4.50937534e+01, 9.56274179e+01, -6.03015177e+01, -5.50663140e+01, 2.32743927e+01, 1.18219466e+02, 2.89299630e+01, 1.35672993e+02, -4.72019765e+01, 7.93117526e+01, 1.08116936e+02, -1.25660790e+02, 4.96489453e+01, 3.29146885e+01, -5.46667503e+01, -1.49750764e+02, 4.39238358e+01, 1.69387850e+02, 1.78973083e+02, 4.48912650e+01, 1.39144602e+02, -9.75088844e+01, 1.29095511e+02, -1.09877470e+02, 1.56541258e+02, 4.01918876e+01, -1.73682295e+02, 1.40870943e+02, -1.36870268e+02, -1.39426814e+02, 8.94281034e+01, 5.42912801e+01, -5.32225333e+01, 7.36879677e+01, 1.30014827e-01, -4.31391293e+01, 9.58078370e+01, 1.69131215e+02, 7.99499300e+01, 1.27997090e+02, -3.60325301e+01, -9.90112752e+01, 2.02192742e+01, 1.32165340e+02, -5.63792894e+01, 5.35448473e+01, -1.32043458e+02, -2.51970384e-01, 2.65999335e+01, -1.26099742e+02, 1.26154759e+02, -1.76555853e+02, 5.18938621e+01, 1.07495667e+02, -1.26660845e+01, -1.19053672e+02, -1.49246362e+02, -1.74763740e+02, 5.27178310e+01, 1.26927550e+02, 1.03676968e+02, -1.28170438e+02, 1.62492331e+02, -1.36332435e+02, 1.33821142e+02, 1.40481400e+02, -1.27325199e+02, -1.97188191e+01, -3.38960818e+01, -1.25033399e+02, -2.32147824e+00, 1.47275662e+01, 6.70036528e+01, 1.56396837e+02, 1.78768264e+01, -5.43659387e+01, -6.31455114e+01, 1.32395550e+01, 1.27544661e+02, 7.51697746e+01, -1.29574962e+02, -3.73696449e+01, -2.98428255e+01, 2.55294876e+01, -6.77764307e+01, 1.28570488e+02, 1.36859592e+02, 2.99234657e+01, -7.48747954e+01, -1.39874353e+02, 1.00349060e+01, -5.33049214e+01, 1.52145686e+02, 1.59086080e+02, 2.59659592e+01, 2.25160608e+01, 1.04878482e+02, 1.52172575e+02, 1.00789065e+02, 4.52400831e+01, -1.35872796e+02, -8.99223669e+01, -3.38202936e+01, -1.29163597e+02, 1.22786376e+02, 1.37372801e+00, 6.14828898e+01, 1.01134869e+01, -1.55000273e+02, -2.95997709e+01, 1.21427969e+02, -9.08399024e+01, 7.99783183e+01, -2.74245058e+01, 1.00649821e+02, -5.97701999e+01, 3.46430486e+01, -6.68439386e+01, -1.75870391e+02, 1.26708153e+02, 4.62705048e+01, -9.31999865e+01, -7.01948365e+01, -6.85330729e+01, -2.62125231e+01, -4.04504186e+01, 1.74426397e+02, 2.32676617e+01, -5.21019304e+00, -3.85390396e+01, -5.09940559e+01, -9.22840005e+01, -1.59779269e+02, -1.93825706e+01, -1.13001632e+02, -1.21238869e-01, -5.30943954e+01, -4.50105888e+01, 3.22288722e+01, -6.83122959e+01, -3.13147633e+01, 3.74319168e+01, 1.05102929e+02, 1.60220623e+02, 1.07991559e+02, -1.38984774e+02, 4.54161544e+01, -2.84180059e+01, -9.20112326e+00, 1.48876323e+02, -1.07647321e+01, 2.58387564e+01, -1.47453852e+02, -4.40496214e+01, 1.06420381e+02, -2.00964788e+01, 1.59469643e+02, 1.53017970e+02, -8.18308397e+01, -4.27742743e+01, -1.48156184e+02, 1.79076512e+02, 1.34425975e+02, -1.67275890e+02, 1.03250649e+02, -1.26077494e+02, 3.21565420e+01, -1.46274085e+02, -4.03087968e+01, -1.09100858e+02, 1.65210779e+01, 1.59231803e+02, 1.25908160e+02, -8.00949473e+01, -1.35745973e+02, -1.32741687e+02, -4.24736915e+01, 1.67656735e+02, -5.18821919e+01, 1.47883210e+02, 3.30850375e+01, -2.55325024e+01, 1.59788660e+02, -1.07974901e+02, -1.73451925e+02, -4.37149861e+01, 5.35062759e+01, -1.74494427e+02, -1.00663117e+02, -1.20632174e+01, -1.67062523e+02, 1.33902338e+02, 1.41906582e+02, -1.21306885e+02, 9.43224748e+01, -1.57962559e+02, -5.22210366e+01, 7.24535007e+01, -4.09733655e+01, 1.26166969e+02, -8.49692863e+01, 1.70888344e+02, -1.67034074e+02, 1.24038321e+02, -9.55641816e+00, -1.33983447e+02, 5.87484612e+01, -1.66183583e+02, 3.91190139e+01, 7.18946329e+01, 3.69170458e+01, 1.72452663e+02, -2.91358286e+00, 2.09604851e+01, -3.56488833e+01, 7.12765545e+01, 1.72693441e+02, -5.55066557e+01, -8.01158744e+01, 2.28010902e+01, 4.64156447e+01, 1.38806642e+02, -4.68465713e+01, 1.19685240e+02, -3.07267610e+01, -7.90878304e+01, -8.12668981e+01, 3.63780027e+01, 1.37430621e+02, 1.41762458e+02, -9.97967327e+01, 1.35467178e+02, -3.96082715e+00, 8.85673759e+01, -3.75088496e+01, -8.34744877e+01, 1.40331679e+02, -5.85549656e+00, -1.08298885e+02, 6.11224819e+01, -2.74499053e+01, -1.30481873e+02, -1.61481292e+02, -1.32846440e+02, -1.06597575e+02, -5.79036193e+01, 9.62119389e+01, -1.47430902e+02, 1.16259729e+02, -6.09836861e+01, -1.73680809e+02, 1.70385165e+02, 1.75783849e+02, -1.42642873e+02, -1.88729511e+01, -9.70655756e+01, 5.35910850e+01, 1.37931918e+02, -1.19299858e+02, 1.31813331e+02, -1.38155640e+02, -1.53265712e+02, 1.54197493e+02, 1.46956699e+02, -1.45113991e+02, -1.79598477e+02, 4.22999982e+01, 4.73466869e+01, 1.41840387e+02, 5.61211514e+01, 7.21865049e+01, 2.66623057e+01, -9.21966164e+01, 4.30191829e+01, -2.33730097e+01, 1.75779969e+02, -1.64875177e+02, -8.48334008e+01, 1.61730751e+01, 1.71242173e+02, 4.91678267e+01, -6.07798374e+01, -1.59428485e+02, -1.44734384e+02, -2.64764125e+01, 2.23639807e+01, -1.11920968e+02, -5.14333637e+01, -6.57640999e+01, -5.46357834e+01, 2.29989017e+01, -7.52352846e+00, -6.06777559e+01, 1.54619856e+02, 1.44740204e+02, 4.21981101e-01, -4.07907310e+01, -1.29324532e+02, -2.56282270e+01, 6.45235228e+01, 1.36129530e+02, 3.44865869e+01, 3.58331808e+01, 6.29024696e+01, -1.74843523e+02, 1.35602819e+02, -7.43154889e+01, -2.58640309e+01, -5.72357927e+01, -1.26417360e+02, -1.45899539e+02, 1.97165728e+01, 9.96926722e+01, -7.15951517e+01, -3.52983986e+01, -2.46218148e+01, 1.55399974e+01, 1.84027466e-01, 4.70322949e+01, 1.54061557e+00, -1.53723544e+02, -1.04709402e+02, -1.41585762e+02, -1.68721200e+02, -5.11742371e+01, 1.56681541e+01, -1.64341443e+02, 8.58801150e+01, 1.71810601e+02, -6.15276196e+01, -4.74214002e+01, 1.75754547e+02, -1.50049516e+02, -1.30021630e+02, 6.59944937e+01, 9.85583043e+01, 4.37644141e+01, 2.10044556e+01, -1.78961018e+02, 1.79178013e+02, 4.45167119e+01, 2.69404154e+01, 1.15580075e+02, -7.55443938e+01, -8.16424332e+01, -3.74691414e+01, 3.28619313e+01, -1.33866116e+02, 4.95008466e+01, -1.25534396e+02, -1.16865009e+02, -1.53250038e+02, -3.18897048e+01, -7.38286072e+01, -1.45253497e+02, -8.93053044e+01, -1.58202376e+02, 1.03036855e+02, -1.34528612e+02, 8.57410336e+01, 1.76359621e+01, 1.27293216e+02, -1.01722680e+02, 1.12353806e+02, -3.53516052e+01, 3.62908849e+01, -1.40846103e+02, 1.72825860e+02, -1.46599452e+02, -1.28226266e+02, -5.67443146e+01, -1.26003907e+02, 1.70436563e+02, -1.65388004e+02, 4.70282971e+01, 5.34661638e+01, 1.48587653e+02, 1.42908136e+02, 1.01577960e+02, 6.05866091e+01, -1.45424898e+02, -1.00021376e+02, -1.49282028e+02, 1.87175625e+01, 1.48461892e+02, 3.67072817e+01, -1.08573940e+02, 1.00490353e+02, 1.69653001e+02, 4.09517825e+01, 3.04264188e+01, -7.70940615e+01, -5.02462332e+00, 8.43094555e+00, 3.67281946e+01, 7.10925341e+01, 2.08248315e+00, 1.25928900e+02, -1.01063296e+02, -7.88601017e+00, -4.80555134e+01, -1.08573892e+02, 8.09032645e+01, -7.63257678e+00, -6.25134142e+00, -7.88541071e+01, 1.35416698e+02, -1.28277300e+02, 8.27588818e+01, 8.93054721e+01, -1.10216547e+02, -1.34279994e+01, 1.04115984e+02, 6.34077360e+01, -5.13611618e+01, -2.49249943e+01, -1.14907085e+02, 1.63178291e+02, -1.66245314e+02, -1.28306347e+02, -3.00009065e+01, -1.31166694e+02, 4.78762215e+01, -3.46615240e+01, -1.16116057e+02, 1.52364162e+02, -1.50234196e+02, -4.57657264e+01, 6.22575569e+01, 4.69609947e+01, 1.58723938e+01, 3.94183910e+01, -1.38258974e+02, -1.22648544e+02, -1.09056430e+02, 1.12799954e+02, -8.38792892e+01, -1.08639886e+02, 1.29944452e+02, 3.76081446e+01, -1.62816697e+02, -5.55778264e+01, -1.55269786e+02, 1.76128395e+02, -4.94100647e+01, 8.32774494e+01, 1.73082901e+02, 1.40505316e+02, 3.60711439e+01, 9.75491133e+01, -1.70585716e+02, -1.37357232e+02, 1.47030957e+02, -7.17205198e+01, -1.21068237e+02, 1.30790703e+02, -5.42211780e+00, 4.98098708e+01, 1.28006668e+02, -1.23812606e+02, -2.56464532e+01, 1.02452710e+00, 1.36903225e+02, -6.20267371e+01, 2.76862688e+01, 1.11937147e+02, -9.49724973e+01, -3.13803629e+01, -1.44419499e+01, 1.36396150e+02, -1.79035039e+02, 4.09694385e+01, -7.30455197e+01, 1.16504278e+01, 1.13798807e+02, 1.32808958e+02, 5.50326692e+01, 3.49328044e+01, 5.35666657e+01, 1.32222976e+01, 1.14578445e+02, -1.25059406e+02, 6.79500973e+01, -7.68215354e+01, -3.92480805e+01, 1.67543781e+02, 1.31656998e+02, 9.60609841e+01, 5.22926862e+01, -1.30386521e+02, -5.24680752e+01, 8.81890631e+01, 8.15149219e+01, -1.41966699e+01, 4.10762894e+01, -1.38618059e+02, -7.00363289e+01, 1.04372540e+02, 9.15386491e+01, -9.74854997e+01, -4.42621853e+01, 6.38911741e+01, -1.75152869e+02, 2.39225260e+01, 4.67308937e+01, -1.60363596e+02, -5.60791341e+01, 9.13958399e+01, 6.09912369e+01, -1.13331700e+02, -1.00538856e+02, -4.30212965e+01, 3.00327152e+01, -1.24730625e+01, -4.67687515e+01, -4.98326881e+01, -1.49801534e+02, -1.34010592e+02, 9.33051455e+01, -1.37233323e+02, 4.87299886e+01, 1.07933696e+02, -1.77945413e+02, -5.02571877e+01, 3.68266401e+01, 5.11243236e+01, -5.38588332e+01, -1.19628395e+02, -7.76959866e+01, -3.67773064e+01, -1.38395782e+02, 3.17645973e+01, -2.53400258e+01, -3.29850375e+01, -1.08955341e+02, -1.51532793e+02, 1.15202896e+02, 1.40679526e+02, -1.15277913e+02, -1.82099547e+01, 6.06943549e+01, -9.42315001e+01, 2.58938716e+01, 1.26821916e+02, -1.17849301e+02, -1.47636636e+02, -1.39453040e+02, -8.65104554e+01, 1.19731688e+02, -3.88002800e+01, 4.11423979e+01, -6.04229140e+01, -4.64923937e+01, -2.66997677e+00, 5.64217300e+01, -1.22159491e+02, -3.35023198e+01, -4.58172199e+01, -1.13282466e+02, 6.67972105e+01, 8.67089869e+01, -1.20734001e+02, 1.67517392e+02, -7.33318351e+01, -4.86040716e+01, -4.24813999e+01, -5.73278657e+01, -1.17685480e+01, 2.54917932e+01, 1.52226940e+02, 8.25579297e+01, -5.83052101e+01, -1.77138269e+02, -2.39516999e+01, -4.63776230e+01, 1.79839850e+01, 4.01869730e+01, 6.01503575e+01, 1.63345887e+02, -1.02866030e+02, 4.29887195e+01, -1.47248069e+02, -1.34225380e+02, -6.41846855e+01, 6.61285321e+01, 1.26933218e+02, -8.39435190e+01, 1.26743627e+02, 1.76019841e+02, -4.22221394e+01, -8.50013149e+01, -1.52604528e+02, -1.25629703e+02, 1.02678140e+02, -1.27654234e+02, 1.05637355e+02, 7.84491356e+01, -1.26448586e+02, -6.70569540e+01, -1.68707847e+02, 1.73751780e+02, -1.40213652e+02, -1.31964481e+02, 2.78374944e+01, -1.54654945e+01, -7.74869098e+01, 1.29657120e+02, -1.65752810e+02, 6.87982878e+01, 1.36368867e+02, 2.35844756e+01, 5.31341831e+01, -1.34992054e+02, 1.20743227e+02, 5.99995324e+01, -1.30965856e+02, 1.61539994e+02, -1.26582026e+02, -9.15011454e+01, 6.59128126e+01, -1.34109740e+02, 1.50265694e+02, 1.70454040e+02, -1.60123982e+02, 6.51185480e+01, 7.51845284e+01, 7.61728148e+00, 8.75085544e-01, 5.26180593e+01, 1.65496994e+02, -1.66558969e+02, -1.04820965e+02, -5.11805005e+01, -5.05833005e+01, -7.25249572e+00, 1.67562835e+02, 1.41309493e+02, 1.35642671e+02, -8.68175326e+01, -6.24884009e+01, 1.39926724e+02, 1.43319480e+02, 3.31121372e+01, 2.72713602e+01, -4.79284556e+01, 3.64085501e+01, -1.38753967e+02, -1.37384438e+02, -1.22184957e+02, 3.91637864e+01, 1.44130354e+01, 5.25580325e+01, 4.95466582e+01, -1.36919251e+02, -4.52893218e+01, 3.49189632e+01, -8.57641674e+01, 1.36309877e+02, 5.71384119e+00, 4.55573220e+01, -1.65723888e+02, -1.06831636e+02, -5.75639505e+01, 3.42546966e+01, -2.22783761e+01, 1.76765436e+02, 3.82223827e+01, 3.97674743e+01, 2.85479047e+01, 8.24543483e+01, -1.37973237e+02, 9.96717556e+01, 1.05059163e+02, -1.73003202e+02, 6.97963468e+01, -1.39455117e+02, 1.52365800e+02, 4.89282759e+01, -7.18757171e+01, -5.93313901e+01, -1.26786059e+02, 1.27363470e+02, -1.11765229e+02, -4.09084275e+01, 7.93452741e+01, -1.21481018e+02, -1.06117822e+02, 8.13624745e+01, 1.39372999e+02, -5.02011741e+01, -4.27058990e+01, -7.82690053e+01, 2.43905887e+01, 6.51817624e+01, -7.59610869e+01, -1.03454752e+01, -1.76454137e+02, 1.47358171e+02, -5.89062164e+01, -2.51669737e+01, -9.82903947e+01, -3.80552781e+01, -1.23296004e+02, -6.89072186e+01, -3.03696988e+01, 8.07082033e+01, 4.77533321e+01, 8.51699359e+01, -6.56317161e+01, 1.31825759e+02, -7.42071945e+01, -9.70024253e+01, 6.30958979e+01, -1.79856724e+02, 7.85131642e+01, -5.02187961e+01, -8.32098828e+01, -1.47569675e+02, 1.15629944e+02, 5.92753256e+00, 3.70911446e+01, 1.23502404e+02, 1.53941410e+02, 6.63522460e+00, -3.40877798e+01, 1.35988597e+02, 1.56299520e+01, -1.12240679e+02, -1.37618479e+01, 1.49111711e+02, 6.62338170e+01, -1.76385423e+02, -3.16134849e+01, -1.46834381e+02, -6.95328037e+01, -1.77863854e+02, -3.36058060e+01, 4.93930291e+01, 4.29548703e+01, -1.65273773e+02, 1.99845149e+00, 7.58083318e+01, 8.75461584e+01, 1.72865399e+02, 1.33178566e+02, 1.16451720e+02, 1.06615561e+02, 2.36781301e+01, -6.58132911e+00, 1.51493781e+02, -6.41585814e+01, -1.17865402e+02, -1.58178604e+02, 6.00693796e+01, 1.40631836e+00, -1.21667859e+02, 1.52595413e+02, 1.44879688e+02, -1.34179369e+01, -5.13504206e+01, -1.30685995e+02, 1.47498746e+01, 1.43454776e+02, -1.61577117e+02, 4.63891139e+01, -8.41112448e+01, -3.39427372e+01, -8.45127201e+01, -4.17633267e+01, 1.43093408e+02, -5.65055385e+01, 6.13398309e+01, -1.14843607e+02, -1.42707776e+02, -1.53187856e+02, 4.22405442e+01, -1.17293786e+02, 2.56796918e+01, 3.75875776e+01, 1.23473088e+02, 3.52776518e+01, 1.13340958e+02, 1.76425196e+02, 7.09588352e+00, 1.21326286e+02, 3.58732724e+01, -1.52660067e+02, -8.19717868e+01, 4.23421683e+01, -1.74104043e+02, 2.97880018e+01, 5.03440641e+01, -6.17551395e+01, 1.69039783e+02, -8.73604163e+01, 8.45232375e+01, -1.39580477e+02, 1.11374230e+02, -7.24452888e+01, 3.66090443e+00, -5.01958131e+01, -9.71838525e+00, -1.34349903e+02, 2.86336914e+01, -1.46355999e+02, -1.22796367e+02, 1.30740325e+02, -5.68511977e+01, 1.28719115e+02, -9.93542029e+01, 7.39579375e+01, 9.35503862e+01, 3.84032243e+01, 1.49352232e+01, 5.64458681e+01, -1.16321884e+02, -3.66638004e+01, -1.34817837e+02, -5.88595447e+00, -2.25174498e+01, 2.84868629e+01, 2.23436283e+01, -3.58753632e+01, 8.66516485e+00, 1.55984961e+01, 1.16479091e+02, 9.07946928e+01, 1.00401762e+02, -1.39619854e+01, 1.40406457e+02, -1.73517757e+01, 1.33734436e+02, -9.46334390e+00, 8.31329555e+01, -1.62788680e+02, -3.23455057e+01, 1.28467399e+02, 1.24756041e+02, 8.17160596e+01, -8.85769291e+01, -1.74396300e+02, 4.89871360e+01, 1.75775609e+02, -1.34557314e+02, 4.61237166e+01, -1.61746600e+01, 4.87941803e+01, 7.59571053e+01, -1.52480726e+02, 1.64268097e+02, -2.78705478e+01, -1.73947653e+02, -1.12627731e+02, 7.24964842e+01, -4.33182129e+01, 1.09417445e+02, 4.48969099e+01, 5.77828817e+01, 8.07448501e+01, -1.68505648e+01, -6.18105670e+01, 5.48780619e+01, 1.55722967e+02, 7.65808732e+01, 5.10913650e-01, -2.06927210e+01, 1.12030081e+02, -1.46283701e+02, 1.69888984e+02, 1.65299859e+01, 4.37755498e+01, -1.28699784e+02, -1.30486402e+02])
    • (location, local_time)
      float64
      counts
      4.199, 4.622, ..., 4.498, 4.040
      Values:
      array([[4.1989904 , 4.6219724 , 4.91565976, ..., 3.50366737, 3.8152402 , 4.78244421], [6.18424077, 6.35623821, 6.15636215, ..., 5.49167705, 6.46872201, 5.94955705], [3.51903312, 2.88841647, 2.68537886, ..., 4.1815094 , 3.56748077, 3.40431362], ..., [3.46305724, 3.55267095, 3.4578613 , ..., 2.48243824, 3.17435282, 2.67290095], [3.30654397, 3.76634568, 2.51640137, ..., 3.92386063, 4.17224194, 3.25339933], [4.09523843, 3.20079461, 2.84129613, ..., 4.58537985, 4.49772514, 4.04035121]])

In the above:

  • latitude and local_time coordinates have been computed as requested.

  • The intermediate results local_datetime and longitude were preserved as unaligned coordinates (use keep_intermediate=False to drop them).

  • The location and datetime coordinates (which have been consumed by the transformation) have been converted to unaligned coordinates (use keep_inputs=False to drop them).

  • The datetime dimension has been consumed by the local_time coordinate and thus renamed to local_time (use rename_dims=False to disable). For more details see section Renaming of Dimensions.

Post-processing#

In some cases the above result may be all we need. Frequently however, we may need to resample or bin our data after this coordinate transformation.

In the above case, local_time is now a 2-D coordinate, and the coordinate is not ordered since the “date” component of the datetime has been removed. We may thus want to bin this data into latitude/local_time bins. Here we first use flatten with a dummy dimension to make the data suitable for sc.bin:

[14]:
time_edges = sc.linspace(dim='local_time', unit='s', start=0, stop=24 * 60 * 60, num=6)
latitude = sc.linspace(dim='latitude', unit='deg', start=-90, stop=90, num=13)
binned = sc.bin(transformed.flatten(to='dummy'), latitude=latitude, local_time=time_edges)

The result looks as follows. If this was real data (the sample data is fake!) we might observe that there are more lightning strikes on the northern hemisphere as well as later in the day. This might be attributed to more thunderstorms after hot summer days. Note that this example does not represent reality and is merely meant to illustrate several concepts of transform_coords:

[15]:
binned.hist(latitude=36, local_time=24).plot()
[15]:
../_images/user-guide_coordinate-transformations_29_0.svg

Renaming of Dimensions#

This section is somewhat advanced and not required to understand the basic usage of transform_coords.

As shown above, transform_coords can rename dimensions of the data array if it processes dimension-coordinates. The rules controlling it are described in this section. They are generic and tend to favor not renaming a dimension if it is not entirely clear what the new name should be.

A dimension is only renamed if its dimension-coordinate can be uniquely associated with one output coordinate of transform_coords. In the example above, there are two dimension-coordinates in the input, datetime and location. The latter is used to compute two new coordinates, namely longitude and latitude. It is thus not possible to find a unique new name for the location dimension. datetime on the other hand is used to construct only a single coordinate, local_datetime, which is finally transformed into local_time. The datetime dimension is therefore renamed to local_time.

Identifying outputs with dimension-coordinates can be expressed as a graph-coloring problem. We assign a unique color to each dimension-coordinate (coordinate name matching a dimension of the coordinate); other coordinates are left uncolored (black). We then propagate colors through the directed graph using the following rules

  1. If a node has exactly one colored parent, use that parent’s color (graph 1).

  2. If a node has several colored parents, leave the node black (graph 2). The same happens if no parent is colored.

  3. If a node has more than one child, it is not counted for rules 1 and 2; its color is not applied to its children (graph 3). Other colored nodes are free to apply their color to shared children (graph 4). It makes no difference if the children are computed by the same function or from multiple functions.

base rules

All graphs used by transform_coords are directed acyclic graphs, but they can still have undirected cycles. In those cases, it can be possible to identify an output with a dimension-coordinate even when it has multiple children as part of a cycle.

  1. If a cycle has one and only one colored node as input (w.r.t. directions of the edges) and exactly one output, that output takes the color of the input. In example 1 below, a can be uniquely associated with c. But example 2, this is not possible because there are two final nodes that depend on a.

cycle rules

The following graphs illustrate how the rules interact in larger examples. In particular, it shows that dimensions are renamed to the ‘farthest away’ coordinate even if that is not a final result of the transformation.

  • In graph 1, a is renamed to c because of rule 1. d is renamed to f because of the second part of rule 3. g cannot be renamed because rule 2 applies to its only child, h.

  • In graph 2, a is renamed to h because c and h can be associated with each other through the cycle according to rule 4.

  • This is no longer the case when d is also a dimension-coordinate (graph 3). Like in example 1, a is renamed to c and d to f. But h depends on f directly and c through the cycle and can therefore not be associated with a single dimension.

larger examples

More details on how the algorithm works and the rationale behind it can be found in Architecture Decision Record 0011.