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., stop=55., 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.

  • Change of coordinates to attributes 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^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])
    • 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. ])

Note how x is now an attribute, 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/D')
    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=[.5, .5, .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. * sc.Unit('km')
north.unit = sc.units.one
da += 2. * (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
      [ 5135.56104006 3355.69597687 -1718.99921891], [-3910.9132985 -1611.63813862 -4764.13902838], ..., [-2641.11258554 5226.50902114 2509.53556709], [ 4731.30601769 -4262.80204557 -181.3920815 ]
      Values:
      array([[ 5135.56104006, 3355.69597687, -1718.99921891], [-3910.9132985 , -1611.63813862, -4764.13902838], [-4525.61999267, 1597.54179507, -4190.01967716], ..., [ 144.57817626, -6167.76385182, -1589.78841963], [-2641.11258554, 5226.50902114, 2509.53556709], [ 4731.30601769, -4262.80204557, -181.3920815 ]])
    • (location, datetime)
      float64
      counts
      1.068, 0.934, ..., 1.423, 0.532
      Values:
      array([[1.06759774, 0.93412011, 2.00191019, ..., 0.62478473, 0.78405169, 0.71983639], [4.46831297, 3.94040992, 3.36710467, ..., 4.62120557, 4.18348212, 4.68942005], [4.44685675, 4.19653778, 4.24152204, ..., 3.9633969 , 3.81913796, 4.01446062], ..., [2.65840261, 2.15532767, 1.19133788, ..., 3.49422706, 2.59156669, 2.90339407], [5.69287789, 5.95529523, 6.05121772, ..., 4.46599479, 5.00889203, 5.31807082], [0.9007174 , 0.43445985, 0.50351122, ..., 1.74957274, 1.42292044, 0.53178357]])

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.input_node(da)
    slider = pw.SliceWidget(da, dims=['datetime'])
    slider_node = pp.widget_node(slider)
    slice_node = pw.slice_dims(inp, slider_node)
    fig = pp.figure3d(slice_node, x='x', y='y', z='z', pixel_size=500)
    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
    • latitude
      (location)
      float64
      deg
      -15.653, -48.399, ..., 23.197, -1.632
      Values:
      array([-1.56533319e+01, -4.83988811e+01, -4.11224639e+01, -8.39499056e+01, 5.27781871e+01, -3.41833385e+01, 3.69943269e+01, 3.63013488e+01, 1.84266921e+01, -3.66711814e+01, -2.50454305e+01, 1.12748740e+01, 6.31244679e+00, -3.07890509e+01, 4.11812965e+01, -6.98175626e+01, -2.64208125e+01, -3.03332288e+01, -6.04437242e+01, 4.88067309e+01, 4.47114254e+01, -6.46071483e+00, 3.29319960e+01, -9.69338088e+00, -2.26968282e+01, -1.27257180e+01, 4.46790899e+01, 1.85050398e+01, -1.17001937e+01, 3.24293124e+01, -4.00073987e+01, -2.74286230e+01, -3.58783706e+01, -5.50406405e+01, -4.26968570e+01, -7.21061065e+01, 1.51092976e+00, 1.73303331e+01, -5.40076241e+01, 6.03229150e+00, -2.61425699e+01, 3.32111049e+01, -4.66413927e+01, 5.21018239e+01, 3.11572329e+01, 4.39061378e+01, -4.01787588e+00, -4.78886493e+01, -1.03787304e+01, -2.64716487e+01, 3.91406544e+01, 3.26881339e+01, 1.22081840e+01, -3.40294376e+00, 4.89680179e+01, 8.21573016e+00, 3.30319301e+01, -1.18460601e+01, 2.86520900e+01, -1.78894380e+01, 2.32254780e+00, -2.41579828e+01, -1.07323327e+01, -4.84658820e+01, 1.24162186e+01, 3.67441624e+01, -2.35929036e+01, 2.65364642e+01, -7.74366019e+01, -2.10169903e+00, 2.72941103e+01, 3.17516287e+01, 2.49279663e+01, -2.24017787e+01, 2.78351592e+00, -4.13355406e+01, -5.25074249e+01, -3.09194367e+01, -3.64308047e+00, -2.62708037e+01, -4.44143397e+01, 3.79845036e+01, 2.16190940e+01, -5.33428301e+01, 3.14719403e+01, -1.97330578e+01, -4.22301468e+01, -1.35754776e+01, 2.45515419e+01, 2.94634581e+01, -2.90841977e+01, -4.93113394e+01, 4.00912547e+01, 3.93300539e+01, 5.02265301e+01, 1.66940595e+01, 5.35050060e+01, -1.76541143e+01, 2.55612953e+01, -3.56192183e+01, -3.14801629e+01, -7.50668400e+01, 1.76978566e+01, -4.12418826e+01, 4.28871692e+01, 6.51689778e+00, -4.36008955e+01, -4.35821862e+01, -5.24326763e+01, -3.84224400e+01, 4.26336561e+01, -4.48930785e+01, 6.05138042e+01, 2.47847377e+01, -8.53884141e+00, 6.95581223e+01, 5.48903389e+01, 3.55217404e+01, 1.48057938e+01, -5.42173591e+01, 5.12971569e+01, 4.29843717e+01, 2.38804763e+01, 2.32783587e+01, 8.05510796e+00, -2.42943467e+01, 2.76647762e+01, 4.20755450e+01, -4.06356529e+01, 2.64621326e+01, -4.34651194e+01, 3.58659464e+01, -3.57906916e+01, 2.81858823e+01, -4.28403408e+01, -5.04731462e+01, -5.73103401e+01, 3.99408359e+01, 2.15175807e+01, 1.96587632e+00, -2.18051829e+01, -3.23106552e+01, -2.50796218e+01, 6.33350208e+01, -4.08905272e+01, 1.33491391e+01, 3.47222819e+00, 7.12746732e+01, 4.46989538e+01, -8.98039015e-01, 1.57070198e+01, -4.06227594e+01, -4.01178151e+01, -1.25500718e+01, 4.00961901e+01, 6.63178634e+01, -1.59101775e+01, -3.70900628e+01, -1.74580320e+01, 4.47334901e+01, 8.28620850e+01, 4.30102924e+01, -2.00215571e+01, -4.57847030e+01, 5.32274362e+01, -2.30155020e+01, 2.19854933e+01, 2.84916505e+01, 3.25903740e+01, 2.35950470e+01, -3.45726779e+01, -5.00295501e+01, 4.30517329e+01, -4.61544036e+01, 2.31557969e+01, -1.27123074e+01, 5.65700652e+01, 4.00773833e+01, 2.85549241e+01, -4.08198082e-01, -1.11669952e+01, 7.22496020e+01, 3.73534836e+01, -3.58752887e+00, 1.25297801e+01, -4.47350020e+01, -4.82993734e+01, -8.86513691e+00, 2.95148986e+01, 1.01998324e+01, 3.33873039e+01, 2.46490937e+01, -4.19114030e+00, 1.90618518e+01, -4.88731448e+01, 4.93858866e+01, -3.27628976e+01, 9.21149454e+00, -7.13487784e+01, -3.58345026e+01, 7.30807432e+00, 3.84984068e+01, -5.67630900e+01, -4.18473592e+01, 2.89012082e+01, -5.91459280e+01, 4.06353185e+01, -7.97945236e-02, 2.04774046e+01, -5.15428413e+01, 2.99300097e+01, -2.41883242e+01, 4.57634008e+01, 2.56284318e+01, -3.86325255e+01, -2.59708400e+00, -6.89352089e+01, 3.04129284e+01, 3.56764375e+01, 2.85230453e+01, -1.62105380e+01, -3.53950104e+01, 1.14337215e+01, -1.52288742e+01, -2.93941273e+01, -9.19312631e+00, -1.94455399e+01, -5.92567154e+01, -3.04224642e+01, 2.92911134e+01, -6.74363463e+01, -4.99429379e+01, -5.96483082e+01, -4.11654415e+01, -6.13306336e+01, -3.10018765e+01, -3.95335947e+01, 7.26735067e+01, 1.22583297e+01, 4.00046475e+00, -3.94132363e+01, 3.95187848e+01, 5.80562525e+01, -4.47965594e+01, 4.25660206e+01, 3.38609390e+01, 3.61509701e+01, -3.49420152e+01, 1.74088959e+01, -1.63776664e+01, 4.21164512e+01, 2.37501541e+01, 2.95726999e+01, 4.44896757e+01, -3.69812115e+01, -1.92117838e+01, 7.08510489e+01, -5.13796609e+01, 3.91171824e+01, 2.87314392e+01, 4.09452017e+01, -5.78014961e+01, 2.92563027e+01, -6.29290161e+01, -3.21954282e+01, 6.41009419e+01, 1.19564430e+01, -3.79097549e+01, 9.32123192e+00, 4.34745072e+01, 5.87382779e+01, 4.59364927e+01, -6.69071805e+01, 6.60406682e+01, 4.62204864e+01, 4.82123930e+01, 4.35858776e+01, 4.46244229e+01, 5.22414676e+01, 6.12743335e+00, 5.09074633e+01, 3.61020255e+01, 1.54630556e+01, -7.71680937e+00, -3.65402380e+01, -4.84652276e+01, 5.35911164e+01, -3.86220239e-01, -3.87511743e+01, 2.42238778e+01, -4.53196773e+00, -8.16350227e+00, 4.86025903e+01, 4.99957141e+01, -2.12888441e+01, 3.85655072e+01, -7.09822422e+00, 1.22829369e+01, -6.53178775e+00, -7.67726142e+00, -1.06975010e+01, 3.35565383e+01, 4.58391763e+01, -2.79776503e+01, 5.73488493e+01, -4.42633816e+01, -5.43946096e+01, 6.74097700e+01, -2.84005202e+01, 5.22193020e+01, 1.89041304e+01, 4.68663946e+00, 2.80674555e+01, -3.86101191e+01, -7.65799719e+01, -2.97376058e+01, 3.21429590e+00, 2.21778014e+01, 3.54125568e+01, -1.30697737e+01, 4.07937747e+01, -4.93028861e+01, -8.77887174e+00, 6.27766619e+01, 2.43453578e+01, 1.31429920e+01, 1.01213761e+01, 8.75633876e+00, 2.26950122e+01, 4.03801190e+01, 3.70632388e+01, 5.09795727e+01, -5.12404843e+01, -4.04432931e+01, 1.68907398e+01, -3.60022145e+01, -4.07491921e+01, -9.92141848e+00, -7.56045402e+01, 2.03179865e+00, 3.14368563e+01, 3.46278157e+01, 8.63840205e+00, -3.32474797e+01, 3.31673085e+01, -3.22684415e+01, 8.34073668e+00, -4.38660688e+01, 9.20683357e-01, -3.80738940e+01, 5.02312388e+00, -5.95967449e-01, 6.73282580e+01, 5.44166610e+01, -3.22593341e+01, 4.98423442e+01, -5.53448444e+01, -4.67662577e+01, -4.73238453e+01, 1.87410703e+01, 9.03158881e-01, 2.34310431e+01, 1.27217305e+01, 6.76565985e+01, -2.94509222e+01, -5.94855480e+01, 1.13250969e+01, -2.50828236e+01, -6.56463764e+01, 8.96477008e+00, 3.00416945e+01, 3.75769453e+01, -3.32488338e+01, 5.99914797e+01, 3.61117520e+01, 6.36143523e+01, 4.18393887e+01, 4.30380968e+00, 3.96212765e+01, 3.08497834e+01, -5.66919031e+01, 2.50479557e+01, 2.92112507e+01, 3.96654428e+01, 5.67126533e+01, 5.12576307e+01, -3.06228012e+01, -3.03747811e+01, 5.79012775e+01, -4.57813505e+01, -3.58971739e+01, -2.83812296e+01, -5.12625244e+01, 2.35301772e+01, -4.29181013e+01, 7.55067582e+01, -3.94378062e+01, -3.44203270e+00, -6.32337833e+01, 1.32289688e+01, 3.85292544e+01, -4.88171440e+01, 3.55993832e+01, -3.70690719e+00, 1.52348478e+00, -6.64561038e+00, 2.30290109e+01, -4.55862384e+01, -1.39647666e+01, -3.88681424e+01, 3.27124781e+01, 5.48577219e+01, 2.18527999e+01, 2.79947353e+01, -1.66068116e+01, -9.33459199e-02, 2.37398539e+01, -7.00188620e+00, 4.38892532e+01, 6.29026473e+01, 9.42467301e+00, 1.80240917e+01, 4.03180902e+01, -2.61482296e+01, 4.34569880e+01, 1.70936366e+01, -1.42039774e+01, 1.97644971e+00, -1.80093192e+01, 4.23138644e+01, -3.79974249e+01, 5.83852533e+01, 2.09660043e+01, -3.66648330e+01, -9.33982321e+00, 1.33219388e+01, -4.48329741e+01, 2.52765035e+01, 1.88991512e+01, -2.21508693e+01, 7.67812836e+00, -6.79729932e+01, -1.50249950e+01, 4.50072560e+01, -4.44375393e+01, -2.83669164e+01, -2.35411778e+01, 3.59806006e+01, 4.41854839e+01, -3.66069362e+01, 3.02267821e+01, 8.72926350e+00, 3.43703631e+00, -4.61324653e+01, -6.84744856e+01, 5.96163301e+01, -6.93629271e+01, -6.74400937e+00, 3.43922537e+01, -6.72991335e+01, 3.62838628e+01, -2.41940507e+01, 5.53827322e+01, 3.04215743e+01, -1.17190914e+01, 2.94459017e+01, -4.42110061e+01, 3.83127467e+01, 3.63413830e+01, 3.43056954e+01, 4.77743847e+01, -6.05218969e+01, -4.48050760e+01, 6.51280736e+01, -3.68534933e+01, 3.01899827e+01, -3.99269081e+00, 5.17363319e+00, -1.36514649e+01, 2.48701327e+01, 8.64849674e+00, 3.31876762e+01, -8.03345782e+00, 1.05415557e+01, 3.56238953e+01, -1.34376313e+01, 4.89169459e+01, 3.46442957e+01, -3.56836848e+01, -3.76129075e+01, -6.61660844e+01, -4.57140552e+01, 1.94195924e+01, -3.46971887e+01, -3.26606727e+01, 2.23702582e+01, -4.06651747e+01, -4.95136611e+01, 1.69381278e+01, -1.74026080e+01, -7.80665637e+01, 1.06275140e+01, 1.77601946e+01, -2.39037903e+01, 3.88673143e+01, -4.74012244e+00, -8.38779014e-01, 2.22052644e+01, 2.58924595e+01, 3.38454296e+01, 6.71731222e+01, 1.06224642e+01, 4.94010639e+01, -1.26240460e+00, 2.08561768e+01, -4.70976970e+01, 6.84297985e+01, 4.97282383e+01, -7.55908402e+00, 6.04676911e-01, -1.99569111e+01, -2.68405605e+01, 2.43664720e+00, -4.35742651e+01, -5.31474484e+01, -5.35499893e+01, -1.50601549e+01, -1.18220467e+01, 1.66712539e+01, -4.54465493e+01, -3.31644056e+01, -3.81674576e+01, 1.51137728e+01, 1.99942729e+01, 3.53905970e+01, -2.80299286e+01, 1.93623254e+01, 2.99349013e+01, -7.41141522e+01, -5.76566441e+01, 4.63481225e+00, 2.34628035e+01, -2.15766491e+00, 1.21330502e+00, 4.49451883e+01, 3.77093904e+01, 5.61050702e+01, -4.50743986e+01, 4.66754451e+01, 1.19222777e+01, 4.62623870e+01, -2.22267835e+01, -3.22915557e+01, 4.80167756e+01, -2.80135160e+01, 4.84211762e+01, 2.63537696e+01, 7.30804521e+00, 2.81224125e+01, 3.80557296e+01, 1.54902931e+01, -2.64436674e+01, 8.64679471e+01, -5.10892110e+00, 7.22456798e+01, -4.65684958e+01, -1.09450337e+01, -9.35254982e+00, -1.55241770e+01, 3.92724335e+01, -4.15035288e+01, -1.00180237e+01, 1.56639833e+01, -3.24819402e+01, -4.50303311e+01, -2.67957162e+01, 2.53068542e+01, -4.80306686e+01, -4.52537919e+01, 7.19945403e+01, 4.05204477e+01, 1.66373604e+01, 6.34769780e+01, 5.70693527e+01, -3.51066847e+01, -7.04403548e-01, -4.08580873e+01, -2.52678402e+01, 6.72334891e+00, 4.80787296e+00, 5.19157704e+01, 7.70003363e+01, -6.54115393e+01, 4.36575453e+01, -1.13667489e+00, 5.43892383e+01, 3.19405512e+01, 3.36918470e+01, -3.77772305e+01, 3.88293448e+01, -3.78169831e+01, 2.32667309e+01, -4.35080952e+01, 3.72382127e+01, 3.27163549e+01, -4.12473731e+01, -5.35393840e+01, -1.01383467e+01, -2.79636767e+00, 4.94341553e+00, -5.22618719e+01, 2.78835751e+01, -7.58590293e+01, 2.95762433e+01, -3.04139734e+01, 7.35057542e+01, 6.67097256e+01, -1.42641935e+01, 3.83658082e+01, -9.44687248e+00, -4.55459400e+01, -4.16756735e+01, -3.29405514e+00, 5.33328061e+01, 2.43320844e+01, 5.58205009e+01, -2.46087133e+01, -1.80856823e+01, 2.37565823e+00, -1.45820254e+01, -3.05054943e+01, 3.79148338e+01, 2.75381830e+01, 1.34448880e+01, 1.22190522e+01, -1.93525892e+01, -2.79513105e+01, -2.03442343e+01, 6.35455239e+01, -3.73121890e+01, 1.71850722e+01, 3.63799418e+01, 4.77428427e+01, -5.82368387e+01, -3.89480186e+01, 1.44718016e+01, -3.76435691e+01, 5.24385423e+01, 3.97451638e+01, -1.13787669e+01, -1.66366295e+01, -3.32388992e+01, 4.40431934e+00, 2.10285885e+01, -5.15046925e+01, 3.30119462e+00, 5.32735001e+01, 2.13151452e+01, -2.31925323e+01, 7.57290153e+00, 1.40878965e+01, -4.72831797e+01, 4.95889057e+01, -1.20003798e+01, 2.43013238e+01, 3.57530691e+01, -1.94492675e+01, 3.28505744e+01, 2.17029457e+01, 5.20672446e+00, -5.29355245e+00, 1.83281584e+01, -2.50070651e+01, 6.80181504e+01, 3.28676115e+01, -4.58246273e+01, -2.77742197e+01, 4.24078098e+01, 1.06981360e+01, -5.03939413e+00, 3.10758559e+01, -6.37643646e+01, -5.02025220e+01, 9.76612481e+00, -1.06932474e+00, -2.25925239e+01, -8.71640760e+01, 4.65101608e+01, 2.61454115e+01, 3.10119544e+01, -7.84335589e+01, 4.92989954e+01, 1.14072883e+01, 3.51963093e+01, 4.03039098e+01, 3.69102987e+01, -5.04483579e+01, -1.02984323e+01, -8.33141716e+00, 4.98668595e+00, 5.70411226e+01, 5.48637436e+01, 4.66547222e+01, -1.95587265e+01, 6.10777288e+01, 5.58758416e+01, 4.19160355e+01, -7.27622569e+00, -2.95164723e+01, -1.57369375e+01, -1.23768707e+01, -2.13742604e+01, -3.60158746e+00, -4.26189387e+01, -1.68181255e+01, 5.39757025e+01, -1.71688559e+01, -4.93537644e+01, -2.06715785e+01, -2.86078121e+01, -3.86408548e+01, -2.46501318e+01, -1.73332605e+01, 5.25024255e+01, -3.82616474e+01, 3.13852422e+01, -3.64540811e+01, 4.75138486e+01, 1.18702005e+00, 4.76529222e+01, -4.00695299e+01, 6.55503760e+01, 2.84125416e+01, 1.54158598e+01, 4.65055382e+01, -9.57559948e+00, 1.03305410e+01, -8.21921709e+01, 2.73352170e+01, 4.04508445e+01, 5.60743529e-01, 6.38416598e+01, 4.87050273e+01, -3.58127001e+01, 3.09679830e+01, 3.29797920e+01, -2.59580106e+01, 3.88749232e+01, 3.16945020e+01, 5.28771625e+01, 2.55359898e+01, 2.77416811e+01, 4.95501691e+01, -3.25887895e+01, -5.74951270e+01, 4.43947347e+01, 4.42307559e+01, -3.16374498e+01, 1.21633639e+01, -5.30966882e+01, 2.47826230e+01, -7.64161631e+01, 1.52989997e+01, -1.72475638e+01, -1.10669163e+01, 5.83425417e+01, 5.34852616e+01, 8.27335961e+00, 1.43876673e+01, 4.19169303e+01, 3.85620017e+00, 3.32501539e+01, -4.04166563e+01, 2.70058335e+01, -2.94875398e+01, -7.80536160e+01, 1.54708433e+01, -4.27734914e+01, -1.38996092e+01, 2.66461364e+01, 3.66032300e+01, -3.26367620e+01, 4.37514862e+01, 6.33765653e+01, 2.88124996e+01, -6.56263917e+01, 3.15023239e+01, -2.99111161e+00, 1.07151647e+01, -4.17870316e+01, 4.58462456e+01, 1.94514163e+00, 3.95302695e+01, 6.53686611e+01, -8.39124391e+00, 1.36793271e+01, -4.40627201e+01, -7.52282274e+00, 5.06600707e+01, 2.03203930e+00, 2.32761561e+01, 5.41308321e+01, 3.63535278e+01, -3.55628850e+01, -2.36271873e+01, -7.15484613e+00, -1.82234643e+01, 4.75034291e+01, 4.72661174e+01, -6.60438131e+01, 1.20624941e+00, 5.67555567e+01, 4.03579454e+01, 3.04269964e+01, 2.32836025e+01, 1.65507084e+01, 4.13764784e-01, -1.08583329e+01, 2.43852569e+01, -8.11665697e+00, 1.21931625e+01, 1.26511162e+00, 1.91350519e+01, 4.63207380e+01, -3.29669587e+00, 3.87097263e+01, 1.06329572e+01, 2.63408112e+01, -3.01481366e-01, -1.69656006e+01, 4.01597608e+01, -2.71274679e+00, 4.75647012e+01, 1.09553114e+01, 4.06976525e+01, 2.23092181e+01, 1.78123310e+01, 4.05515710e+00, -1.30877944e+01, -5.71053412e+01, -1.29372560e+01, -3.53014313e+01, -2.55538109e+01, -6.37204364e+01, -2.93236011e+01, -3.60762405e+01, 1.01452612e+01, -2.63610257e+01, -4.36750781e+00, -4.40750645e+01, -2.96075249e+01, -2.89966458e+01, -5.46155495e+01, -2.40619259e+01, -9.68217797e-01, 2.29922043e+01, -5.60472169e+01, 4.64940524e+01, 3.49613276e+01, -3.25252972e+01, 3.42346588e+01, 6.15457939e+01, -3.07486824e+01, 4.14126145e+00, 2.66492844e+01, 3.37274274e+01, 1.68974087e+01, 1.34240539e+01, 5.02689159e+00, 2.76269779e+01, 3.91179883e+01, -3.30002864e+01, -2.68850795e+01, -4.81702429e+01, -3.36071202e+01, 4.25420858e+01, 3.50095796e+01, -1.51155578e+01, -2.73410486e+01, -3.79716591e+01, -2.04689571e+01, 2.37645927e+01, -6.21533897e+01, -3.17567507e+01, 1.82842923e+01, 6.62842164e+00, 3.49985562e+01, -1.00226883e+01, 1.61563659e+01, -4.90158937e+01, -1.25562861e+01, -5.10809727e+00, 4.82603485e+01, -3.34132206e+01, 2.28028334e+01, 1.74695143e+01, -1.16538118e+01, 6.74110755e+01, -4.19366528e+01, -4.65328594e+01, 4.51592031e+01, 2.79111418e+01, 3.37782676e+01, 4.12567198e+01, 2.72659708e+01, 4.10834917e+00, 4.10195648e+00, 5.57974490e+01, 2.59683450e+01, 5.63184972e+01, 1.56910281e+01, -4.35430016e+01, -5.16658532e+01, 1.51345569e+00, 2.40568005e+01, 2.45365819e+01, -4.51549801e+01, 4.04277631e+01, -5.05672010e+01, -6.39049175e+00, 3.01728123e+01, -3.10343773e+01, -5.49513912e+01, 1.77356403e+01, 3.23753224e+01, -3.69996179e+01, -3.72205903e+01, 1.51255958e-01, -9.45648267e-01, 4.84105569e+01, -4.51588336e+01, 1.89617731e+00, 3.18919812e+01, -7.59458754e+01, 9.28933205e+00, -3.58950210e+01, -3.63816735e+01, -5.79891751e+01, -5.52269877e+01, -4.54678592e+01, -3.27963715e+01, 4.33376090e+00, 3.33174675e+01, -7.04685335e+01, -2.53659685e+01, -4.04162997e+01, 1.66229493e+01, 3.74467505e+01, -5.63138376e+01, -5.70679657e+01, -3.25986226e+01, -4.48490245e+01, 1.97321760e+01, 4.68599994e+01, -4.17235031e+00, 2.88399145e+01, -1.23122838e+01, -5.66101927e+01, -4.66608267e+01, -3.02069223e+01, -3.81800136e+01, 1.04252686e+01, 1.59175192e+01, -1.85995417e+01, -7.50965433e+01, -4.50076516e+01, 1.99486930e+00, -4.53969228e+01, -2.03649825e+01, -7.97089726e-01, 8.19759551e+00, 5.10076865e+01, 1.90954317e+01, 4.21257654e+01, -4.46586908e+01, 7.48032346e+00, -3.70143278e+01, 1.91737517e+01, 2.41943872e+01, 3.99265553e+01, -9.26204907e+00, -6.32424183e+01, -4.74544433e+01, 8.34430028e+01, 4.26784566e+01, 7.12921944e+01, 3.84371500e+01, 2.25787204e+01, -7.85691786e+01, 5.73300766e+01, 4.60391265e+01, -6.76456375e+01, -3.34707274e+01, 6.18101509e+01, 3.94710178e+01, 2.40257465e+01, 3.10551798e+01, -1.44500063e+01, 2.31973745e+01, -1.63151866e+00])
    • local_time
      (location, local_time)
      float64
      s
      2.520e+04, 2.880e+04, ..., 3600.000, 7200.000
      Values:
      array([[25200., 28800., 32400., ..., 14400., 18000., 21600.], [68400., 72000., 75600., ..., 57600., 61200., 64800.], [54000., 57600., 61200., ..., 43200., 46800., 50400.], ..., [ 0., 3600., 7200., ..., 75600., 79200., 82800.], [43200., 46800., 50400., ..., 32400., 36000., 39600.], [10800., 14400., 18000., ..., 0., 3600., 7200.]])
    • (location, local_time)
      float64
      counts
      1.068, 0.934, ..., 1.423, 0.532
      Values:
      array([[1.06759774, 0.93412011, 2.00191019, ..., 0.62478473, 0.78405169, 0.71983639], [4.46831297, 3.94040992, 3.36710467, ..., 4.62120557, 4.18348212, 4.68942005], [4.44685675, 4.19653778, 4.24152204, ..., 3.9633969 , 3.81913796, 4.01446062], ..., [2.65840261, 2.15532767, 1.19133788, ..., 3.49422706, 2.59156669, 2.90339407], [5.69287789, 5.95529523, 6.05121772, ..., 4.46599479, 5.00889203, 5.31807082], [0.9007174 , 0.43445985, 0.50351122, ..., 1.74957274, 1.42292044, 0.53178357]])
    • 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]')
    • local_datetime
      (location, local_time)
      datetime64
      s
      2021-06-02T07:00:00, 2021-06-02T08:00:00, ..., 2021-06-05T01:00:00, 2021-06-05T02:00:00
      Values:
      array([['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-01T19:00:00', '2021-06-01T20:00:00', '2021-06-01T21:00:00', ..., '2021-06-04T16:00:00', '2021-06-04T17:00:00', '2021-06-04T18: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-02T00:00:00', '2021-06-02T01:00:00', '2021-06-02T02:00:00', ..., '2021-06-04T21:00:00', '2021-06-04T22:00:00', '2021-06-04T23:00:00'], ['2021-06-02T12:00:00', '2021-06-02T13:00:00', '2021-06-02T14:00:00', ..., '2021-06-05T09:00:00', '2021-06-05T10:00:00', '2021-06-05T11:00:00'], ['2021-06-02T03:00:00', '2021-06-02T04:00:00', '2021-06-02T05:00:00', ..., '2021-06-05T00:00:00', '2021-06-05T01:00:00', '2021-06-05T02:00:00']], dtype='datetime64[s]')
    • location
      (location)
      vector3
      km
      [ 5135.56104006 3355.69597687 -1718.99921891], [-3910.9132985 -1611.63813862 -4764.13902838], ..., [-2641.11258554 5226.50902114 2509.53556709], [ 4731.30601769 -4262.80204557 -181.3920815 ]
      Values:
      array([[ 5135.56104006, 3355.69597687, -1718.99921891], [-3910.9132985 , -1611.63813862, -4764.13902838], [-4525.61999267, 1597.54179507, -4190.01967716], ..., [ 144.57817626, -6167.76385182, -1589.78841963], [-2641.11258554, 5226.50902114, 2509.53556709], [ 4731.30601769, -4262.80204557, -181.3920815 ]])
    • longitude
      (location)
      float64
      deg
      33.162, -157.604, ..., 116.809, -42.018
      Values:
      array([ 3.31615421e+01, -1.57604058e+02, 1.60556991e+02, 3.53466129e+00, -1.64759057e+01, 1.54805288e+02, -1.50542643e+02, 1.28888814e+02, -3.12213180e+01, 2.53475296e+01, -1.29310860e+02, 1.41515806e+02, 9.74419145e+01, -8.25962489e+01, -1.52634937e+02, -1.26522324e+02, -7.69306710e+01, 4.67291143e+01, 3.38298233e+01, -1.48101435e+02, -7.28813410e+01, -1.49563132e+02, 9.98527396e+01, -9.96740457e-03, -1.45825211e+02, 7.86293838e+01, 1.44719774e+02, 5.83808965e+00, 7.23386589e+00, 4.90351394e+01, 2.52987097e+01, 9.29675479e+00, 1.34414665e+02, -4.89347118e+00, -3.32124943e+00, -1.14115355e+01, -4.42477665e+01, 1.25286579e+02, 1.78465959e+02, 1.20842977e+02, 1.67101897e+02, -5.43777165e+01, 2.37680667e+01, -1.28720356e+02, -1.47962243e+02, 3.27212366e+01, 9.54613357e+01, 2.31583223e+01, 4.71837787e+01, 1.52706169e+02, -1.47986970e+02, -1.42554479e+02, -1.49177795e+01, 1.26261873e+02, -7.66600947e+01, 2.48786009e+01, 4.97843392e+01, -1.42576639e+02, 4.73902965e+01, 1.66034470e+02, 1.08655556e+02, -5.40266890e+01, 1.21264692e+02, 1.20604323e+02, -1.43721752e+02, 1.37152671e+02, 5.73315736e+01, 1.69051764e+02, -7.10624286e+01, -9.66199651e+00, 1.08225142e+02, -9.92549045e+01, -1.53935889e+02, 4.54237660e+01, 3.83901522e+01, 1.53023534e+01, 1.50374737e+02, 4.05828274e+01, -7.21632332e+01, 1.36475635e+02, 1.63868997e+02, -3.97670741e+01, 1.43026915e+01, 8.07079944e+00, -1.19749117e+02, 1.56270970e+02, -6.49304420e+01, 8.59742667e+01, -1.63386598e+01, 4.25543451e+01, -1.07106320e+02, 6.60392819e+01, 1.09479146e+02, 5.12707167e+01, -9.41864258e+01, 1.27942928e+02, -1.77578775e+02, -1.31143620e+02, 8.62546263e+01, -3.23943226e+01, -7.13426937e+01, -1.72979883e+02, -1.16473110e+02, 1.59321941e+02, 4.40874648e+01, 2.23040144e+01, -3.25665416e+01, -1.56758627e+02, 1.54061015e+02, 3.67717936e+01, -1.35582776e+02, -1.24836747e+02, -1.26282958e+02, 7.06506443e+01, 1.64624080e+02, 1.58560452e+02, -3.47753444e+01, -2.88637125e+01, -2.98039136e+01, -1.52055133e+02, -2.81806072e+01, 1.20488066e+01, -1.29713766e+02, 9.66202786e+01, -1.24123703e+02, -4.39576149e+01, -1.19824812e+02, 1.31423151e+02, -3.38677600e+01, -1.30616650e+01, -4.90596318e+01, 1.19456314e+02, -1.39162290e+02, 3.38280917e+01, -7.81647646e+01, -1.36423009e+02, -7.04453852e+01, 8.16239789e+01, -3.98750063e+01, 1.79002194e+02, -1.29944562e+02, 1.31340484e+02, -8.02900994e+01, -1.03547791e+02, 5.24719701e+01, -1.41982105e+02, 5.87319895e+01, -6.19871851e+01, 6.23911966e+01, 1.44375311e+02, -1.47487695e+02, -1.58533491e+01, 1.16904757e+02, 6.03264051e+01, -2.81965704e+01, -1.16897178e+02, 4.20756549e+01, -1.78092108e+02, 1.38569243e+01, -1.47261118e+02, 7.22077500e+01, 1.62482175e+02, -7.52207979e+01, -9.18097149e+01, 8.75446854e+01, -3.64705002e+01, 1.28783330e+02, -4.89082741e+01, -3.25785488e+01, 3.58172292e+01, -4.24837584e+01, 1.22838174e+02, 1.64434333e+02, -9.23732628e+01, 1.72450831e+02, 6.21851725e+01, -1.20602879e+02, 1.28855648e+01, 5.42422176e+01, 4.99305787e+01, 5.12249956e+01, 1.06296450e+02, -6.29715634e+01, -5.01372625e+01, 1.39866144e+02, 1.55916633e+01, 1.17864462e+02, 6.78052542e+01, -2.92078793e+01, -8.92626822e+01, -4.68965661e+01, -1.57424986e+02, 6.38132749e+01, 1.27845828e+02, 1.01481210e+02, 6.20547126e+01, 1.68783818e+02, -5.00124871e+01, 5.85453139e+01, 7.99615856e+01, -4.98423180e+01, 1.05464827e+02, 1.05493778e+01, -6.06602010e+01, 1.45428526e+02, -1.49402316e+02, -1.18873164e+02, -1.67406722e+02, -1.36171380e+02, -1.00911287e+02, 5.79706508e+01, -1.47617521e+02, -5.43752055e+01, 3.97989771e+01, 3.58532035e+01, 1.24095944e+02, -3.94251433e-01, 1.61707561e+02, -1.53977961e+02, 1.36999409e+02, 8.21424144e+01, -1.68891265e+02, -1.35039626e+02, -1.14278901e+02, -1.31861873e+02, -8.73028338e+01, -7.85524752e+01, -9.08609102e+01, 5.02974097e+01, 3.90385351e+01, 2.49990270e+01, -1.24276530e+02, -1.32262121e+02, -1.00505051e+02, -2.41442243e+01, -1.76672039e+02, 4.43627507e+01, -2.93012828e+01, 1.47685871e+02, 3.98508019e+01, -1.11759409e+02, 4.36122285e+01, -8.90904106e+01, -5.00336871e+01, -1.49612419e+02, -1.37554148e+02, 1.08988325e+02, -4.09389817e+01, -1.36492844e+02, 9.18622331e+01, 3.13005459e+01, -1.76091171e+02, -1.30603034e+02, -1.74056172e+02, -4.75864999e+01, 3.60859149e+01, 5.91937354e+01, 4.11161911e+01, 2.00524129e+01, 3.87665837e+01, -7.79772651e+01, -5.84636195e+01, -1.37350484e+02, 9.68900355e+01, -1.38625219e+02, -1.53565775e+02, -5.79027536e+01, -5.86696492e+01, 5.05829229e+01, -1.27078695e+02, 1.69478188e+02, 1.12410008e+01, -1.66304507e+01, -1.78422210e+02, -1.69011672e+02, 5.69807069e+01, -1.23715924e+02, 2.75679078e+01, 1.33191760e+02, 1.56845895e+02, -1.37969530e+02, 1.57172315e+02, 8.35346551e+00, 1.50587203e+02, 3.40176102e+01, 1.72143985e+02, 1.10234859e+02, 1.51955506e+02, 1.20952345e+02, 5.74041293e+01, 3.41359503e+01, -1.25852882e+01, 1.34899052e+02, -8.57341165e+01, 2.64115426e+01, -1.51349807e+02, -5.25013939e+01, -1.66602185e+02, 1.39798374e+02, 1.47851537e+02, 1.25012846e+02, -1.79866617e+02, -1.18268108e+02, -5.02911384e+01, 7.73815387e+01, 8.04284257e+01, -9.06641434e+01, -3.15282816e+01, 1.28865486e+02, 1.79593902e+02, 3.63835825e+01, 1.39605868e+02, -5.87220297e+01, -3.44815684e+01, 1.63218139e+02, -1.74890146e+02, -1.68740982e+01, -8.89893947e+01, 1.40840002e+02, -1.43659731e+01, 5.79858317e+01, -1.10381113e+02, 3.91419548e+01, 1.58065308e+02, -1.36138339e+02, -6.36668924e+01, 1.27266293e+02, 1.43255393e+02, -6.45831092e+01, -1.07776124e+02, -5.57830787e+01, -1.49025958e+02, 1.56693974e+02, -4.30208919e+01, -7.93747478e+01, 1.29016091e+02, -4.29658245e+01, -5.65821589e+01, -9.54590048e+01, 3.70615267e+01, -1.11986365e+02, -1.25084902e+02, -2.10581323e+01, -1.48538958e+02, 1.75715957e+02, 4.35388641e+01, 5.00711891e+01, 4.88789443e+01, 1.33712135e+02, 1.48948682e+02, -1.71804457e+02, 3.67049349e+01, -1.12813159e+02, -1.48768871e+02, -5.21840286e+01, 1.36620574e+02, 2.31315923e+01, 8.86471599e+00, -5.01721388e+01, 7.07008708e+01, -1.06204961e+02, -4.30968143e+01, -1.35346285e+02, 5.71295560e-01, -2.07837080e+01, 6.25003558e+01, 5.37851683e+01, -3.00589860e+01, 1.15275452e+02, -1.53901981e+02, 3.09980408e+01, -9.44923987e+01, 1.39917728e+02, -2.50867527e+01, 1.64332527e+02, 3.85564403e+01, -2.29779556e+01, -2.94730314e+01, 5.23334673e+01, 2.91564945e+01, 9.27233977e+01, -1.65712826e+02, -1.40018004e+01, 3.22233129e+01, 1.43287207e+02, 9.54914806e+00, 1.53217676e+02, -2.66217697e+01, -1.63152037e+02, -1.17246591e+02, -4.54675328e+01, -5.48641729e+01, -1.51352051e+01, -8.11112269e+01, 1.20679900e+02, -3.16967496e+00, 1.66771367e+02, 3.33208593e-01, -1.57425241e+02, -5.51901288e+01, -1.15758883e+02, -1.61260289e+02, -1.37410298e+02, -1.43953729e+02, 9.75545660e+01, -9.90665165e+01, -1.16076799e+02, -1.13420255e+02, -1.47174807e+02, -1.01943017e+02, 1.10417588e+02, 1.51251823e+02, -9.97562798e+01, -3.46445223e+01, -4.53185008e+01, 1.65571945e+02, 9.39825234e+01, 7.48403541e+01, 4.99648792e+01, 1.52894056e+02, -3.58814287e+01, 1.76720013e+02, -5.49824692e+01, 4.04412087e+01, 1.09589451e+02, -3.68327461e+01, 1.27090308e+02, 4.48752617e+01, 1.70806206e+02, 1.14492037e+02, -1.60933395e+02, -6.22017585e+01, -1.06268302e+02, 9.59616159e+01, -9.81072012e+00, 7.32462107e+01, -1.64475022e+02, 1.54604661e+02, -3.13944076e+01, -5.36988846e+01, 1.75986455e+02, 6.28378538e+01, 5.42702363e+01, 9.06495415e+01, -1.53234065e+02, 1.36466329e+02, -6.99816304e+01, 2.77769377e+01, 1.39615390e+02, 7.35324729e+01, -7.78356715e+01, 1.60930047e+02, 3.44305108e+01, 1.73448515e+02, 8.47681610e+01, 1.06646735e+02, 7.80223231e+01, 5.08067379e+01, 3.96289781e+01, -5.70522699e+01, -5.73946315e+01, 3.78164759e+00, -1.48296010e+02, -4.85266066e+01, 4.25721063e+01, 4.93265326e+01, -1.51449732e+02, 1.60056566e+02, 4.29652893e+01, 1.68139666e+02, -8.98866240e+01, 1.43642480e+02, -1.93535644e+01, 1.32335552e+02, -1.55457324e+02, -1.67332783e+01, 1.39685854e+02, 3.04203618e+01, 1.15921371e+02, -6.67299181e+01, 8.37221283e+01, 4.86870548e+01, -4.74169330e+01, 7.22184246e+01, 4.96501930e+01, -1.35400257e+02, 1.08881634e+02, -1.00787441e+02, 2.38929109e+01, -3.02009552e+01, 5.24916705e+01, -3.18126194e+01, 1.56179072e+02, 9.19873452e+01, -1.99022923e+01, 1.50080837e+02, 3.37839521e+01, -1.62367242e+02, -3.38790880e+01, 3.01856767e+00, 1.54633281e+02, -1.36937464e+02, 8.84958395e+01, 1.33045554e+02, -1.47891842e+02, 6.33325113e+01, -1.10245012e+02, -1.48651825e+02, -7.47066766e+01, -8.60187740e+01, -7.86256939e+01, -1.55441795e+02, -2.96571291e+01, 6.86041703e+01, 1.29412325e+02, -6.79157022e+01, 3.96585066e+01, -1.26674141e+02, 1.51254323e+02, 8.15683453e+01, -1.14275204e+02, 1.23516524e+02, 4.02691866e+01, 1.34974041e+02, 1.37394474e+02, 8.14026119e+01, -5.70412535e+01, -1.76109872e+02, -6.27523739e+01, -1.63686022e+02, 2.12725804e+01, -1.44439027e+02, -5.48405493e+01, 6.46782596e+01, -2.35697828e+00, 1.66540212e+02, 1.26039302e+02, -4.47055892e+01, -1.04133136e+02, -8.32333516e+01, 1.22162268e+02, 7.60549120e+01, -7.87453956e+01, 1.15121057e+02, 7.08716594e+01, 5.75359732e+00, 5.09468414e+01, 1.83245690e+01, -3.80307157e+01, 4.83978867e+01, -1.30480857e+02, -1.09641785e+02, 5.62134209e+01, 1.02752448e+02, -1.35711223e+02, 4.70919779e+01, 1.46489488e+02, 2.86359464e+00, 1.34665694e+02, -1.26016896e+02, 1.63029857e+02, -5.11883677e+01, -4.07813586e+01, -1.26157624e+02, -1.00424209e+02, -9.25466700e+01, -4.54961051e+01, 6.27137461e+01, -1.31002197e+02, -1.50063748e+02, -7.88767619e+01, 1.37238991e+02, 9.15210780e+01, 1.41077722e+02, 7.65002325e+00, 7.55547572e+01, -3.04435870e+01, -1.51071674e+02, 6.77555098e+01, 1.44021348e+02, 1.52847518e+02, -1.65350076e+02, 2.57502037e+01, -1.41755332e+02, 7.07201469e+00, -4.84060011e+01, -1.15579750e+02, -1.41091911e+02, 1.68591937e+02, -1.34068378e+02, 3.21410208e+01, -2.57943980e+01, -1.52232560e+02, 1.70046388e+02, 8.93306919e+01, -1.98405216e+00, 8.45900301e+01, 5.90027419e+01, -3.14736027e+01, -9.45996529e+01, 1.62033436e+02, -1.09376585e+02, 1.79108352e+02, 1.03939389e+02, 4.03183590e+01, -3.87812374e+01, -1.21890652e+02, 1.45918808e+02, -1.52565668e+01, 4.99273187e+01, -1.58532747e+02, -1.52053991e+02, 1.59343449e+02, -1.30394498e+02, 1.36984934e+02, -9.15208643e+01, -1.58581428e+02, 1.03583347e+02, -1.08263472e+02, 2.91652738e+01, 8.85041576e+01, 3.60986400e+01, -8.96621173e+01, 1.77571594e+02, -6.34324187e+01, 1.30013322e+02, 1.33741114e+01, 3.09822941e+01, -1.40708003e+02, 7.89816340e+01, 1.36251071e+02, 1.78643702e+02, 7.99015039e+01, 1.09996117e+02, 1.35575836e+02, 2.16812703e+01, -7.74783170e+01, -9.94125070e+01, 6.32640645e+01, 1.31202309e+02, -1.18034270e+02, 6.05777784e+01, 3.73897921e+01, -1.77758407e+02, -4.43821450e+01, 4.59652803e+01, 1.39371792e+02, 6.02731130e+01, -1.57790566e+02, -1.28709308e+02, 6.25316787e+01, 5.57728166e+01, 3.85294035e+01, 2.22448449e+01, 8.25197080e+01, 1.75316639e+02, 6.90779429e+00, -1.32545581e+02, -6.96664111e-01, -4.20883250e+01, 1.34834122e+02, 8.80137689e+00, 9.70925219e+01, -8.80181423e+01, 1.44562080e+02, 1.42992873e+02, -8.22701573e+01, 1.34789612e+02, 1.36794953e+02, -1.62859270e+02, -1.30427989e+02, 3.35545200e+01, -1.77911495e+01, -1.45558523e+02, 1.46725058e+02, -1.13996250e+02, 5.02367331e+01, 4.21629697e+01, 2.76698300e+01, -1.52787155e+02, 1.52047559e+02, -1.62829370e+02, 1.75335257e+02, -1.58974122e+01, 1.21800625e+02, -1.65792309e+02, -3.05536449e+01, -1.46554203e+02, 1.48337601e+02, -9.59483732e+01, 4.86873940e+01, -1.00027486e+02, 9.95037805e+01, -1.53076407e+02, 1.58374922e+02, -8.17447423e+00, -1.20756698e+02, 1.39973109e+02, -2.76763717e+01, -2.28616743e+01, -9.54963990e+01, -8.55509783e+01, 1.63272220e+02, 8.10987187e+01, -3.16962670e+01, 8.23326485e+01, 1.37809097e+02, -1.38147773e+02, 1.39742747e+02, -1.36108917e+02, -8.87318407e+01, 4.50122677e+01, 9.79683555e+01, -1.72737572e+01, 1.39874844e+02, 1.24609400e+02, 5.96783551e+01, 5.47388135e+00, -1.38092216e+02, -6.93216068e+01, 1.33178064e+02, -1.27920211e+02, 8.21665404e+01, 1.57617948e+02, 1.06619515e+02, -1.18268687e+02, -1.65955109e+02, -7.69921024e+01, -8.22105159e+01, -7.93758913e+01, 3.95865485e+01, -4.97428705e+01, -1.22303094e+02, 1.33776843e+02, 5.25193332e+01, -1.55461343e+02, -2.76395640e+01, 2.47795658e+01, 1.34597534e+02, 9.63455661e+01, 4.20729322e+01, -1.36095991e+02, 1.14646606e+01, 3.11424697e+01, -1.14984892e+02, -2.52722933e+01, 1.56168213e+02, 1.23352894e+02, -1.26271400e+02, 1.48299159e+02, 5.59328904e+01, 2.84881012e+01, 8.66956004e+01, -3.35829988e+01, 4.55720877e+01, -1.28486145e+01, 1.00669177e+02, 1.73164382e+02, -1.26029717e+02, 1.70368872e+01, -1.12323164e+02, 1.11026343e+02, -1.38880020e+02, 2.25174245e+01, -1.60680410e+02, 6.09345525e+01, 1.22891319e+02, -5.00227749e+01, 1.26868005e+02, 9.76520352e+01, -9.86308799e+01, 1.22831127e+02, 1.40518397e+02, 2.55261095e+01, -1.01801733e+02, 1.09579297e+02, -1.08065683e+02, -1.31615306e+01, -6.81937599e+01, -3.88434264e+01, -2.67503295e+01, 9.25234418e+01, -8.79979202e+01, -1.13805329e+02, 2.00248469e+01, -6.92845054e+01, 3.97989886e+01, 1.50557322e+02, -1.69763424e+02, -1.21441196e+02, 1.08178744e+01, -1.21620650e+02, 4.80794313e+01, 6.87826358e+01, -1.37223686e+02, -4.25431233e+01, 4.38153711e+01, 1.36951800e+02, -6.26380134e+01, 8.61422771e+01, 1.13695093e+02, -1.41782744e+02, 2.49935962e+01, 1.10672727e+02, -6.13409991e+01, 1.18073400e+02, 6.38029004e+01, -1.07090395e+01, -6.07429805e+01, 1.21614014e+02, 4.43400770e+01, -1.30770268e+02, 2.79452684e+01, -1.24353504e+02, 6.94560403e+01, -6.56573942e+01, 1.47203934e+01, -4.86224397e+01, 3.45571366e+00, -8.79871766e+01, -1.22663870e+02, 2.81695499e+01, -2.52964218e+01, 6.28181407e+01, -2.89439803e+01, 5.21881931e+01, 1.26041356e+02, -1.11516227e+02, 4.36730906e+01, 1.35744895e+02, 3.55045567e+01, 2.99094989e+01, 3.95988985e+01, 1.21087013e+02, 1.46072022e+02, -1.20867194e+02, 1.19337938e+02, 7.56972543e+01, 9.46005877e+01, 1.56481265e+02, 1.28017552e+02, -1.24801190e+02, -9.01745664e+01, 7.14577207e+01, 1.15647831e+02, 1.77508633e+02, 1.52004945e+02, 1.07353520e+02, 9.81195672e+01, -4.28438558e+01, 2.41856753e+01, 1.65893471e+02, -1.05867561e+02, -5.58179475e+01, 1.17121165e+02, -1.44668924e+02, -1.00662712e+02, 8.34457240e+01, 5.16435262e+01, -4.13987784e+01, 2.58039895e+01, -3.62499149e+01, 4.63162585e+01, 1.91282637e+01, -6.81392237e+01, -9.39522287e+00, 9.13566169e+01, -3.14051140e+00, 6.49568134e+01, 6.78498664e+01, -1.00446255e+02, -7.05937742e+01, 4.20631469e+01, 9.50758794e+01, -1.47549779e+02, 1.44964322e+02, -1.28416882e+02, -8.94979254e+01, -6.53601121e+01, 8.56471961e+01, -1.50942930e+02, 1.71738083e+02, -1.75587944e+02, -3.41243424e+00, -1.02403474e+02, 4.13689524e+01, 1.13708018e+02, 3.65682299e+01, 2.18976020e+01, 1.46677896e+01, -8.08545234e+00, 1.54621574e+02, -4.42373986e+01, -1.36944785e+02, 9.04049891e+01, -1.19399354e+02, 1.54120046e+02, -3.46131698e+01, -1.50501583e+02, 1.11902230e+02, 2.58237885e+01, 1.13437970e+01, -8.54764814e+01, 8.73858088e+01, 9.60181861e+01, -1.33648958e+02, 2.88853900e+01, 1.23019876e+01, 6.03465503e+01, 3.81364355e+01, 1.32423118e+02, -1.41880895e+02, -2.29793900e+01, -4.04860527e+01, 1.98837703e+00, 3.74561501e+01, 5.44000387e+01, -5.82584874e+01, -1.68766847e+02, 1.19133424e+02, 1.28371937e+02, -5.60552423e+01, 1.43251974e+02, -5.07515950e+01, -1.55670217e+02, -8.64388074e+01, -1.07345503e+02, -4.11573228e+01, 4.37417277e+01, -2.81364812e+01, 9.28267879e+01, 1.56309677e+02, 1.46063981e+02, 1.14980798e+02, 1.18023472e+02, -4.58880883e+01, -4.57041042e+01, -8.20162116e+01, -3.68738843e+01, 1.25521070e+02, -3.60607389e+01, -1.00075948e+02, 4.39784125e+01, 1.23344529e+02, -1.18571467e+02, 7.35680304e+01, 1.50893396e+02, 1.05048918e+02, 4.39022992e-01, 1.19549726e+02, 1.08866069e+02, -1.14981464e+02, -6.15690124e-01, -1.36315518e+02, -1.20082813e+02, 3.25811910e+01, -4.64747331e+01, -4.92994225e+01, -1.04568774e+02, -3.22212643e+01, 8.23151329e+01, -1.69495495e+02, -1.78016807e+02, 6.00001504e+01, -1.24166293e+02, 1.70559129e+02, 7.05573577e+01, 1.53698685e+02, -1.63141698e+02, 1.24980265e+02, 1.32272188e+02, 3.41379788e+01, 6.22021383e+01, -7.01438505e+01, 1.12909245e+02, 4.93591887e+01, 1.17717982e+02, 1.72461976e+02, -6.41034380e+01, 1.25707034e+01, 6.64822531e+01, 1.44099731e+02, 3.15892766e+01, -1.33165512e+02, -6.94331852e+01, 1.10374201e+02, -7.43406029e+01, 4.33423618e+01, -7.49031737e+01, 1.45858285e+02, -1.67867390e+01, -1.72706757e+02, 5.44522136e+01, 1.64155906e+00, -9.91544608e+01, -1.22719279e+02, -1.39328104e+02, -8.86571790e+01, 1.16808846e+02, -4.20181522e+01])

In the above:

  • latitude and local_time coordinates have been computed as requested.

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

  • The location and datetime coordinates (which have been consumed by the transformation) have been converted to attributes (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'), edges=[latitude, time_edges])
/home/runner/work/scipp/scipp/.tox/docs/lib/python3.8/site-packages/scipp/core/binning.py:444: UserWarning: The 'edges', 'groups', and 'erase' keyword arguments are deprecated. Use, e.g., 'sc.bin(da, x=x_edges)' or 'sc.group(da, groups)'. See the documentation for details.
  warnings.warn(

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.