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

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
      [-3632.0494775 -303.82134774 5225.47128799], [ 2440.47249133 -1678.24250256 -5640.67700916], ..., [ 3849.13665142 -2480.72690949 4429.4223144 ], [-971.30988626 2760.04636446 5659.3588127 ]
      Values:
      array([[-3632.0494775 , -303.82134774, 5225.47128799], [ 2440.47249133, -1678.24250256, -5640.67700916], [ -259.09852963, 1616.79457772, 6156.98662053], ..., [-1204.20178788, -4870.22837372, -3926.88357885], [ 3849.13665142, -2480.72690949, 4429.4223144 ], [ -971.30988626, 2760.04636446, 5659.3588127 ]])
    • (location, datetime)
      float64
      counts
      6.831, 6.250, ..., 4.881, 5.584
      Values:
      array([[6.8314083 , 6.24975438, 5.65215419, ..., 6.36933346, 6.07421667, 6.1950198 ], [1.02407702, 0.61881209, 0.00691255, ..., 1.81735284, 0.85422213, 0.67006561], [4.86177753, 5.15140484, 6.1793967 , ..., 3.80743463, 4.50769465, 4.3365563 ], ..., [3.36951236, 2.08183831, 1.66663967, ..., 3.6863298 , 3.69598535, 3.06313935], [3.30043022, 2.2750297 , 2.14345118, ..., 3.40518786, 3.06926457, 2.34348387], [4.72876281, 5.78116339, 5.64754525, ..., 3.75963153, 4.88059833, 5.58427388]])

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]:
sc.plotting.plot(da, projection='3d', positions='location')
[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
      55.104, -62.297, ..., 44.047, 62.660
      Values:
      array([ 5.51044594e+01, -6.22967928e+01, 7.51071582e+01, -3.68681778e+01, -3.14895797e+00, -2.69091593e+01, -2.53417346e+01, -5.17433565e+01, -4.50028670e+01, -4.84792173e+01, 3.06070430e+01, -1.36571709e+01, -9.50823284e+00, -3.35482984e+01, 3.56842363e+00, 3.22082819e+01, 1.09859796e+01, 4.05692837e+01, -3.63499748e+01, -4.64291723e+00, 2.54381192e+01, -4.61446602e+01, -3.23878983e+01, -2.61099617e+01, 7.06753633e+01, -3.27102991e+01, -2.13296382e+01, 4.29557958e+01, 5.40905747e+01, 1.22480194e+01, -8.58903333e+00, 3.90806105e+01, 4.30740289e+01, -1.63093872e+01, 3.95335143e+01, -1.23638948e+01, -4.29669337e+01, -2.96303465e+01, -3.19928111e+01, -3.34604256e+01, -4.14001531e+01, 3.20619091e+01, 1.43500510e+01, -4.24376216e+01, 3.18893671e+01, -7.01682071e+01, -1.87361179e+01, 3.91485749e+01, 5.11721713e+01, 3.66252804e+01, 6.88125817e+01, -3.68065717e+01, -5.85451244e+00, 4.48115629e+01, -3.45425437e+01, -5.95651471e+00, -2.46317492e+01, 5.68556887e+01, 1.97463685e+01, 6.47884851e+01, -2.89917742e+01, 6.70733924e+01, 3.48983179e+01, -3.81061811e+01, 1.16720336e+01, 3.70171436e+01, 6.17572359e+01, 2.93680822e+01, -2.01486415e+00, -3.17685999e+01, 2.50487164e+01, -3.40149792e+01, -2.71160416e+01, 6.31466991e+01, 7.16864608e+00, -2.42720711e+01, -2.47587763e+01, 5.50793737e+01, 5.31747400e+01, 3.84876636e+01, -4.79776482e+01, -6.76577314e+01, 3.46936101e+01, 3.81734938e+01, -2.39846480e+00, -4.91796158e+01, 3.72507582e+01, -3.63926302e+01, -3.76079667e+01, 2.66314130e+01, -7.14325066e+01, 6.81158883e+00, 7.35867768e+01, -1.22052392e+01, -4.42828981e+01, 1.58283971e+01, 1.56562636e+01, -6.27699256e+01, -4.40475858e+01, 2.89227970e+01, 2.42798855e+01, 1.41005158e+01, 4.44681401e+00, -1.24322008e+01, -6.04838966e+01, -3.11848127e+01, -8.66856208e+01, -3.50183624e+01, 4.34459111e+01, -4.70559304e+01, -2.20669427e+01, -2.30975014e+01, -3.78875707e+01, 2.81296253e+01, 2.00953385e+01, -1.84135034e+01, -1.42360975e+01, 4.37684277e+01, 8.25802444e+00, 5.63442870e+01, 3.34263293e+01, -4.07221256e+01, -4.69954983e+00, 2.71727772e+01, 3.15840562e+01, -7.73082694e+01, -4.04920888e+01, 8.18099240e+01, 3.77674141e+01, 3.03710395e+01, 5.40122595e+00, -4.94863617e+01, -9.47918677e+00, -2.28131617e+01, -2.53221502e+01, -1.18357078e+01, -2.20522464e+01, 5.51695333e+01, -1.76322317e+01, 3.35354869e+01, 2.90581627e+01, 4.81246843e+01, -4.54228625e+01, -5.11446284e+01, 3.03163096e+01, -1.15852506e+01, -4.95868439e+01, 3.76821380e+01, -6.19120619e+01, 4.25994396e+01, -3.83380184e+01, -4.75274263e+01, 5.02635089e+01, 8.32513163e+01, 4.05212513e+01, -2.85121434e+01, 2.35237086e+01, -4.19194621e+01, -2.18253906e+01, 3.14536720e+01, 6.69672053e+01, 3.44045636e+01, 4.42704185e+01, -2.38010472e+01, -3.99168947e+00, -3.25584286e+01, -4.40463540e+01, 3.12948396e+01, 2.95030401e+01, 3.59002618e+01, -7.82448605e+01, -1.03189349e+01, 5.44194953e+01, 3.87621758e+01, -2.88627525e+01, -5.57536560e+01, -6.05125573e+00, -2.53056191e+01, -3.70321327e+01, 2.73449509e+01, -5.89740557e+01, -3.84739666e+01, -3.80809590e+00, -7.30643668e+01, -3.75323241e+01, -4.41669370e+01, 1.08855125e+01, 1.41727577e+01, -3.48125327e+01, -8.65384048e+00, -2.50843304e+01, 4.65690888e+01, 2.60638485e+01, 2.29946691e+01, 2.08328901e+01, -4.02936688e+01, 3.75243709e+01, -3.87879152e+01, -8.14785753e+00, 2.41999533e+01, 5.05280602e+01, -5.96747477e+01, 7.95475180e+00, 3.05837258e+01, 4.55934714e+01, 1.90730428e+01, 5.08929263e+01, 4.25079443e+01, -4.11333462e+01, -1.11193981e+01, -2.55750550e+01, 4.21305444e+01, 3.70723418e+01, -7.51046728e+01, 4.23611195e+01, -2.05402437e+00, -1.63256718e+01, -2.22499508e+01, 3.51554730e+01, -1.89668973e+01, 3.21767574e+01, -3.72048394e+01, 8.14440630e+01, -1.70005627e+01, -2.69166626e+01, 4.79723674e+01, 4.29673208e+01, -4.03192941e+01, 3.23950043e+01, 5.24369741e+01, -1.81026794e+01, -4.30219546e+01, -4.30190489e+01, 5.40287583e+01, 1.58017597e+00, -3.79236673e+01, -2.39536350e+01, 3.71407326e+01, 7.16204432e+01, -5.48334777e+01, -3.87619244e+00, -2.57557860e+01, 3.41396813e+01, 2.81682167e+01, -2.45649627e+01, 2.97115728e+01, -2.18445724e+00, 3.01930290e+01, -4.63191082e+01, -3.18796492e+01, -1.62851618e+01, -1.68972197e+01, -4.47165186e+01, 5.45767182e+01, -1.93143765e+00, -2.65873758e+01, 1.04315920e-01, -4.62314340e+01, -6.08753162e+01, -4.84620441e+01, 9.54550702e+00, -5.97826793e+01, 2.51516008e+01, 1.02448414e+00, 3.96635935e+01, 1.25735896e+01, -7.24561161e+01, -6.12046084e+01, -5.82317357e+01, 4.08770227e+01, 6.27486952e+01, -3.05730168e+00, 2.58786303e+01, -5.44766452e+01, -4.21346789e+01, 4.10791961e+01, 3.40770721e-01, -2.64348922e+01, -1.04770540e+01, -2.97131590e+01, 1.43861773e+01, 4.56419262e+01, 6.81093217e+00, 5.59398717e+01, -2.39996230e+01, 3.14948045e+01, -2.87713836e+01, -3.87341291e+01, -4.13351793e+01, -1.90211716e+01, -5.33861404e+01, -3.42775404e+01, -4.20721009e+01, -3.08298762e+01, 3.04279302e+01, -4.24674583e+01, -5.21151454e+01, -7.31100077e+01, -3.82987894e+01, -6.08116861e+01, 3.78595442e+01, 2.51954672e+01, 5.29914605e+01, 2.56299007e+01, 5.11040189e+01, -2.98090215e+01, -1.92275870e+01, -4.07169715e+01, -6.07613323e+01, -4.40813544e+00, -2.34350238e+01, 6.76428326e+01, -3.43480460e+01, 5.94633037e+00, 4.36208764e+01, -6.35798592e+01, -2.66323401e+01, -1.05317799e+01, -1.97763531e+01, 5.93313833e+01, 1.00758921e+01, 2.42027177e+01, -2.71275515e+01, -2.88858818e+01, -8.35584058e+00, -1.81464905e+01, 7.98442876e+01, 1.87005043e+01, 3.26516313e+01, -3.42473433e+01, -5.05267939e+01, 2.50308263e+01, -5.75057021e+01, -4.12746976e+01, -7.59883189e+00, -2.84154717e+01, -4.18110588e+00, 4.81153656e+01, 2.94513465e+01, -8.99016735e+00, 8.47427109e+00, -3.77324227e+01, -4.91450347e+01, 7.15058583e+01, 3.15486422e+01, 1.36495151e+01, 2.90127307e+01, -1.16350393e+01, 5.12562142e+01, -4.50489463e+01, 8.00383717e+00, -4.21157674e+01, -7.76834806e+01, -4.30207009e-01, 2.52409742e+01, -1.50018567e+01, 5.91670507e+01, 3.99501452e+01, 3.27645272e+00, 3.32886629e+01, -4.66006073e+01, 4.66757153e+01, -4.62318258e+01, 4.04281286e+01, -1.73825925e+01, 2.67318378e+01, -6.62019741e+01, 3.52215391e+01, 2.78710550e+01, 2.77098539e+01, -2.42145737e+01, -1.64122980e+01, 2.74681261e+01, -3.28519320e+01, -1.03625787e+01, 5.98775210e+01, 5.19569861e+01, 8.49120308e+00, -6.06072708e+01, -3.55352563e+01, 5.36586462e+01, -1.46281756e+01, 3.58495675e+01, 1.71614704e+01, -2.79421285e+01, -3.46537623e+01, 7.23995364e+01, 4.42573961e+01, -6.13481193e+01, 2.44229784e+01, -2.96795041e+01, -3.36880387e+01, 2.43731602e+01, -1.34723580e+01, -4.30650597e+01, 7.29569061e+01, 1.26509894e+01, -2.72602401e+01, -3.83129327e+00, 1.79203557e+01, -4.27861073e+01, -2.48058338e+01, 4.69021748e+01, -3.33542115e+01, -3.10788607e+01, -2.00274866e+01, 3.83048758e+01, -3.55078395e+01, -2.74536048e+01, -6.02079399e-01, -4.47747476e+01, 4.50364825e+01, 1.69512042e+01, 7.53612495e+00, -9.55808559e+00, -8.16571960e+00, -4.01318982e+01, 5.10474856e+01, 6.93594336e+01, 3.75831406e+01, -3.04395320e+01, -2.92889546e+01, -1.12243440e+01, 1.97246138e+01, 2.58920598e+01, -6.44258273e+01, -1.47592931e+01, 2.82405642e+01, 4.28413681e+01, -4.87582713e+01, 6.73807333e+01, -3.19323408e+01, -3.89309770e+00, -2.76292073e+01, 3.79962733e+01, 4.76473394e+01, -3.63240875e+01, 3.14865659e+01, 1.61929440e+01, -4.75483252e+01, -3.81214700e+01, -2.48973016e+00, -6.04246422e+00, 1.54967784e+01, 4.20732225e+01, 1.44620726e+01, 3.46618814e+01, 4.79926929e+01, -3.59086657e+01, -5.55817259e+01, -2.72328296e+00, -4.29493786e+01, -3.75779259e+01, -1.98822917e+01, 2.60740650e+01, -1.21870816e+01, 4.89598787e+01, 4.79773264e+01, 3.38969835e+01, -8.71976493e+00, -3.21384603e+00, 4.99209658e+01, -3.35988396e+01, 4.86290129e+00, -9.43784014e+00, 3.49870887e+01, 2.54735362e+01, -3.43529818e+01, 3.12824138e+01, 5.20890774e+01, -2.72026482e+01, 4.98141918e+01, -1.16467362e+01, -7.31922382e+00, -1.85211984e+00, 4.16991605e+01, 3.35439101e+01, 3.65663595e+01, 4.73488221e+00, 6.72119023e+01, -5.78425639e+01, 5.25951404e+01, -6.99326711e+01, 1.42158248e+01, -6.61942756e+01, -7.53409260e+00, -4.41251707e+01, 6.20588723e+01, 5.05362959e+01, 6.00128896e+01, 3.43445741e+01, -4.40500520e+01, -2.47876884e+01, 5.25522776e+01, 1.18774310e+00, -7.00534583e+01, 2.58507320e+00, 3.03373326e+01, -3.62526953e+01, 1.28987720e+01, -8.95499028e+00, 5.77598388e+01, 1.08891168e+01, 4.72841692e+01, 5.52246491e+01, -2.95645408e+01, -4.00505599e+01, 3.78908043e+01, 2.73591249e+01, 1.45181401e+01, 4.43959397e+01, 7.49112136e+01, 1.01045710e+01, 6.78026166e+01, -3.29713524e+01, 5.51358506e+01, 5.30426134e+01, 2.52371312e+01, 3.92522848e+01, 4.64707503e+01, 3.11025032e+01, -5.05122932e+01, 5.54782517e+00, -1.97952348e+01, 3.27783444e+01, 1.93841281e+01, 3.17858935e+01, -1.12450363e+01, 2.43445058e+01, -9.45371328e+00, 2.70179701e+01, 3.07905668e+01, -6.14424124e+01, -3.95679503e+01, 5.19046803e+01, 4.28461347e+01, 6.15377230e+01, -7.04868201e+01, 4.58140860e+01, -2.74390675e+01, 4.06013046e+01, 2.71191285e+01, 1.81024479e+01, -3.90175638e+01, 1.07823035e-01, 4.42269932e+01, 1.48367206e+01, 2.55145493e+01, -1.19401324e+01, 3.05254490e+01, -3.99252141e+01, -4.42641812e+01, 5.47005186e+00, -3.11680655e+01, 3.93159773e+01, 6.87733923e+01, 4.56344218e+01, 2.02246553e+01, 3.01351849e+01, 2.99458692e+01, -5.10887446e+01, 4.37116226e+01, -2.82140048e+01, 3.99595356e+01, -1.24356066e+01, -3.88859852e+01, 2.44303633e+01, -3.10121867e+01, -3.79094006e+01, -8.39788786e+00, -4.48546195e+00, -9.70283290e-01, 3.61464787e+01, 4.24856184e+01, -6.26787385e+01, 8.56120856e+00, -1.35100330e+01, 3.42161882e+01, -3.27508341e+01, -4.11878640e+01, 5.25729000e+01, -3.97716881e+01, -3.40857578e-01, -1.18647512e+01, -5.14818550e+01, 5.01831103e+00, -6.98234264e+01, -1.98185866e+01, 5.42160388e+01, -4.03990621e+01, 3.78643763e+01, 3.34410590e+01, -7.63185961e+01, -3.92583643e+01, -2.87988972e+01, 7.41574060e+00, 1.82836385e+01, -1.97306504e+01, -5.10689715e+01, -2.62339549e+01, -4.04409709e+01, 2.67052268e+00, -2.08314802e+01, -6.17661835e+01, 6.18082566e+01, -3.71143259e+01, 4.41939945e+01, 5.17600719e+01, -1.10667623e+00, 2.50374497e+01, 4.69588203e+01, 4.02586811e+01, -5.39093645e+01, 5.27659630e+01, 2.82184802e+01, -6.64835910e+01, 6.65281417e+01, 5.61929455e+01, -2.26374795e+01, -6.53684237e+01, -5.60185810e+01, -4.28984523e+01, -4.71762643e+01, -3.68245459e+01, -4.22882621e+01, 4.23137807e+01, -2.19985534e+01, -4.38364595e+01, 6.24257741e+01, 2.26076746e+01, -1.16731872e+01, 5.32459827e+01, -1.20745033e+00, -3.43834971e+01, 1.80559778e+01, -4.34289158e+01, -5.47079547e+01, -3.20542776e+00, 2.29719409e+01, -3.30173697e+00, -4.10941227e+00, -3.28889671e+01, -1.75170265e+01, 3.67328983e+01, -3.59030343e+01, 1.59266866e+01, -4.57575568e+01, -2.79100132e+01, -7.30161467e+00, -4.15309695e+01, -2.06850925e+01, -4.65752264e+01, 1.51627608e+01, 5.92368888e+01, 1.84297616e+01, -4.34295768e+01, 8.60285064e+00, 5.80355026e+01, -3.27013346e+01, -2.62229157e+01, 4.72854478e+01, 1.28670242e-02, -2.03693173e+01, 6.71176855e+01, -2.28888219e+01, 2.15011220e+01, -6.64865107e+01, -3.06746907e+01, 5.05610507e+01, -1.03348152e+01, -1.86171941e+01, -5.49172501e-01, -2.27665700e+01, -4.83457180e+01, -2.22875229e+01, -3.27885967e+00, 1.12124982e+00, -2.21510971e+01, 1.03436378e+01, -2.61275520e+01, -5.52242221e+00, 6.10623647e+01, -3.80272228e+01, 6.85033295e+01, 5.13780436e+01, 3.39070618e+01, 1.23923571e+01, 3.08304205e+01, -3.63364539e+01, 2.26768282e+01, -4.95734584e+01, 7.03679275e+01, 5.99737447e+01, 2.96148872e+00, -1.32467055e+01, -2.11742370e+01, 4.47649498e+01, 1.22030098e+01, -3.36842038e+01, -2.09216105e+01, -1.75447563e+01, -4.74271575e+01, 4.33216637e+01, -5.74237085e+01, -4.89164294e+01, -4.15305757e+01, 5.38958172e+01, 5.66147852e+01, -3.75535505e+01, -5.66852088e+01, -2.20197108e+01, -5.25827375e+01, 2.79043336e+01, 2.09768453e+01, 1.21124376e+01, -1.70796312e+01, -5.15803781e+01, 1.33560291e+01, -3.25347294e+01, 2.05125918e+01, 3.41717835e+01, 5.48959498e+01, 1.08271670e+01, 5.30527215e+01, -6.16478216e+01, 3.94093101e+01, -1.92808486e+01, 3.22496185e+01, -2.81431235e+01, -1.06164979e+01, 6.07980376e+01, -1.76747664e+01, 5.87712124e+01, 3.57462855e+01, 4.47009101e+01, 2.34464469e+01, -2.06996414e+01, 2.04597169e+01, 2.32205932e+01, 2.03107104e+01, -2.84811995e+01, -2.96377538e+01, -1.04753674e+01, 3.45510259e+01, -5.77657144e+01, -3.52767901e+01, 3.96683721e+01, 1.25172800e+01, -2.80807299e+01, 2.19827501e+01, -4.44904129e+01, -3.30834497e+01, 1.78822580e+01, 3.29398760e+01, 2.83693045e+01, 3.95848128e+01, 1.91164886e+00, -7.14261624e-01, -5.45068560e+01, -5.65890453e+01, -3.96523984e+01, 4.32165566e+01, -4.83548983e+01, 3.63836404e+01, 2.25477017e+01, -1.95786289e+01, 4.13860264e+01, 1.60455288e+01, -1.40583835e+01, 3.91783506e+01, 4.08038908e+01, -3.18200135e+01, 5.59559005e+00, 2.98656164e+01, -4.80342686e+01, -4.84460015e+01, -3.19491702e+01, -4.57988344e+00, 1.81680230e+01, 4.78660953e+01, -2.51057090e+01, -2.34940486e+01, -8.92158118e+00, 9.00215068e+00, -7.51478218e+01, -3.94555622e+01, -8.69051128e+00, 4.01090798e+01, -1.20015201e+01, -8.44914701e+00, -1.99113903e+01, -2.39639239e+00, 8.24368852e+01, 3.09429094e+01, 1.60743958e-01, 4.24613787e+01, -4.30275813e+00, 2.86385029e+00, 1.73832670e+01, -3.21797377e+01, -5.29753073e+01, 3.48725054e+01, 7.04335725e+00, 1.05221103e+01, -9.74164177e+00, 1.27655582e+00, -5.69838984e+01, -7.78841388e+00, -3.74211807e+00, -1.84301558e+01, 3.95121793e+01, 1.44140856e+01, -3.07804910e+00, 3.97949309e+01, 3.28548447e+01, 3.53841496e+01, -6.91299291e+01, 2.58570492e+01, -5.46529817e+01, 8.34278772e+01, -3.16797978e+01, 6.00860534e+01, 1.56155536e+01, -6.05988570e+00, 3.78961215e+01, 5.02014122e+01, -3.53830139e+01, 2.90397543e+01, 5.59221295e+01, 5.01597299e+01, -1.05282695e+01, -2.50043256e+01, -1.92953980e+01, -6.34505578e+01, 5.35827759e+01, 7.40609853e+01, -6.41859558e+01, 4.64571120e+01, -2.50341143e+01, -5.31395809e+01, 7.37474864e+01, 1.04883931e+01, -3.29386865e+01, 1.43856548e+01, 5.80840724e+00, 7.97390258e+00, 4.33367778e+01, 6.70109668e+01, -3.43164204e+01, -1.30313883e+01, 3.75062420e+01, -6.74630892e+01, -1.38102702e+01, 7.23723647e+01, -5.37154254e-01, -7.33214568e+00, 2.37138511e+01, -5.41390536e+01, -1.78787775e+01, -4.08645190e+01, -5.11849851e+01, -1.52395127e+01, 4.96496057e+01, -5.55097265e+00, -4.75164306e+01, 2.82781682e+01, 6.13080429e+01, -3.10413304e+01, -6.52742177e+00, 3.21422034e+01, -4.21356316e+01, -5.24849726e+01, -2.91327353e+01, 1.89362638e+01, 2.12325600e+01, 3.57154921e+01, -2.68861969e+01, 3.03684903e+01, -3.27518274e+01, -2.40289760e+01, 2.31267345e+01, 1.59692855e+01, -2.31318460e+01, 2.64525242e+01, -8.86984369e+00, -9.87170817e+00, 2.93407669e+01, 9.83282098e+00, 4.13789562e+01, 1.83694410e+01, -1.10286838e+01, 3.92593472e+01, -4.52967274e+01, 1.40599353e+01, 2.28521442e+01, 2.78334761e+01, 5.59102880e+01, -2.33341707e+01, -5.89631337e+01, 1.47786571e+01, 1.15318613e+00, 4.84151621e+01, -1.34896757e+01, 2.09410794e+01, -7.18188954e+01, -4.93824772e+01, 4.60361350e+01, -5.38125724e+01, 2.56005213e+01, 6.05060907e+01, 1.24835072e+00, -4.46574876e+01, -3.03612250e+01, -8.04407799e+00, 2.97907219e+01, -4.28376592e+01, 3.04673084e+01, 5.52846051e+01, 3.67047971e+01, 2.59992870e+01, -4.35170553e+00, -1.42064413e+00, -3.58601511e+01, -5.06682885e+01, -1.85870818e+01, 2.24973149e+01, 4.32819947e+01, -4.37462383e+01, 4.25286210e+01, -8.53563626e+00, -2.70069457e+01, 6.37142352e+01, -6.58679563e+01, -4.86030152e+01, -3.96663781e+01, -1.75833174e+01, -2.26703163e+01, -6.33507677e+01, 4.56785432e+01, 2.41100582e+01, -3.95087938e+01, -3.23647773e+01, -5.10457096e+01, -2.17043899e+01, 4.82871716e+01, -2.27676825e+01, 1.67553250e+01, 2.06890505e+01, -5.30271677e+01, -1.31950910e+00, -4.99883959e+01, -3.14660253e+01, -4.95814215e+01, -4.26539670e+01, -4.08320930e+01, -3.09484410e+01, 4.17706506e+01, 3.22784975e+01, 3.11335375e+01, 7.27844208e+01, -3.94093261e+01, 2.29915165e+01, 4.47323958e+01, -2.53065263e+01, -4.11666626e+01, 1.75232353e+01, 6.20444835e+01, 4.72301367e+01, -3.51419882e+01, 1.49753967e+01, -2.11814835e+00, -3.28143596e+01, -5.46406890e+00, 8.74672104e+00, 4.70424651e+01, -7.83996475e+01, -3.01503578e+01, 1.20980538e+01, 2.25140640e+01, -3.51345697e+01, 3.55894388e+01, -4.63745042e+01, -3.14997419e+01, 4.18518580e+01, -4.07101880e+01, -7.32262594e+00, 2.94825544e+00, 5.54660490e+00, -3.05980268e+01, 1.85147828e+01, -4.85693878e+01, -4.68269311e+01, 4.84909135e+01, 3.82501993e+01, -1.13786088e+01, -2.92755178e+01, -3.63187663e+01, -3.80514238e+01, 4.40469492e+01, 6.26603874e+01])
    • local_time
      (location, local_time)
      float64
      s
      6.480e+04, 6.840e+04, ..., 3.600e+04, 3.960e+04
      Values:
      array([[64800., 68400., 72000., ..., 54000., 57600., 61200.], [10800., 14400., 18000., ..., 0., 3600., 7200.], [39600., 43200., 46800., ..., 28800., 32400., 36000.], ..., [82800., 0., 3600., ..., 72000., 75600., 79200.], [10800., 14400., 18000., ..., 0., 3600., 7200.], [43200., 46800., 50400., ..., 32400., 36000., 39600.]])
    • (location, local_time)
      float64
      counts
      6.831, 6.250, ..., 4.881, 5.584
      Values:
      array([[6.8314083 , 6.24975438, 5.65215419, ..., 6.36933346, 6.07421667, 6.1950198 ], [1.02407702, 0.61881209, 0.00691255, ..., 1.81735284, 0.85422213, 0.67006561], [4.86177753, 5.15140484, 6.1793967 , ..., 3.80743463, 4.50769465, 4.3365563 ], ..., [3.36951236, 2.08183831, 1.66663967, ..., 3.6863298 , 3.69598535, 3.06313935], [3.30043022, 2.2750297 , 2.14345118, ..., 3.40518786, 3.06926457, 2.34348387], [4.72876281, 5.78116339, 5.64754525, ..., 3.75963153, 4.88059833, 5.58427388]])
    • 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-01T18:00:00, 2021-06-01T19:00:00, ..., 2021-06-05T10:00:00, 2021-06-05T11:00:00
      Values:
      array([['2021-06-01T18:00:00', '2021-06-01T19:00:00', '2021-06-01T20:00:00', ..., '2021-06-04T15:00:00', '2021-06-04T16:00:00', '2021-06-04T17: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'], ['2021-06-02T11:00:00', '2021-06-02T12:00:00', '2021-06-02T13:00:00', ..., '2021-06-05T08:00:00', '2021-06-05T09:00:00', '2021-06-05T10:00:00'], ..., ['2021-06-01T23:00:00', '2021-06-02T00:00:00', '2021-06-02T01:00:00', ..., '2021-06-04T20:00:00', '2021-06-04T21:00:00', '2021-06-04T22: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'], ['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']], dtype='datetime64[s]')
    • location
      (location)
      vector3
      km
      [-3632.0494775 -303.82134774 5225.47128799], [ 2440.47249133 -1678.24250256 -5640.67700916], ..., [ 3849.13665142 -2480.72690949 4429.4223144 ], [-971.30988626 2760.04636446 5659.3588127 ]
      Values:
      array([[-3632.0494775 , -303.82134774, 5225.47128799], [ 2440.47249133, -1678.24250256, -5640.67700916], [ -259.09852963, 1616.79457772, 6156.98662053], ..., [-1204.20178788, -4870.22837372, -3926.88357885], [ 3849.13665142, -2480.72690949, 4429.4223144 ], [ -971.30988626, 2760.04636446, 5659.3588127 ]])
    • longitude
      (location)
      float64
      deg
      -175.218, -34.515, ..., -32.801, 109.388
      Values:
      array([-1.75218334e+02, -3.45151809e+01, 9.91044915e+01, 1.50216603e+02, 1.00662588e+02, 8.60776392e+01, -1.27529209e+02, 1.13446350e+02, 1.30758695e+02, -7.10920787e+01, -2.77994569e+01, 1.22516360e+02, 1.31206732e+02, -1.31462524e+02, -1.44360450e+02, 1.70604430e+02, -4.66014135e+01, 6.96100315e+01, -1.57141536e+02, -1.51665401e+02, 1.83897520e+01, -4.39198152e+01, 1.45090410e+02, 7.84033876e+01, -1.11527782e+02, 1.00503677e+02, 8.26233828e+00, -1.39713440e+02, -6.87536093e+01, 1.54337985e+01, -1.69152789e+02, -1.25181033e+02, 1.02724972e+02, 1.09562402e+02, -3.72175156e+01, 1.43716373e+02, -1.05808320e+02, -6.39500358e+01, 1.33707153e+02, 1.15321907e+02, -1.42585137e+02, 7.99703397e+01, -1.43627885e+02, -5.01731798e+01, 4.29308054e+01, 3.78346308e+01, -6.74017166e+01, 4.44387935e+01, -1.01818030e+02, 4.80948138e+01, 1.15261580e+02, -9.96466966e+01, -1.47471676e+02, -4.03379763e+00, -4.74608988e+01, 6.98409876e+01, -1.66913612e+02, 1.51163347e+02, 1.51222975e+01, 1.75635724e+02, -7.71438357e+01, -8.67514678e+01, 4.46377913e+01, 1.43542983e+02, -8.67024165e+00, 6.96584422e+01, 1.25625218e+02, -9.86860714e+01, -1.69410672e+02, 1.52410281e+02, -6.46763433e+00, 1.49612661e+02, -3.34931642e+01, -3.45731384e+01, 1.30751817e+02, -1.01501536e+02, 1.18913813e+02, 1.09852432e+02, 1.33398687e+00, -4.33117644e+01, 4.48306516e+01, -2.66805434e+01, -1.56881027e+02, 1.70661380e+02, 7.18996560e+01, 9.43661726e+01, 1.63512098e+02, -8.98700464e+01, 1.36778862e+02, 9.55480953e-01, 2.82104025e+01, 3.36379479e+01, -7.70086953e+01, -8.81182756e+01, -8.54926285e+01, 1.36470945e+02, -4.22919203e+01, 8.46749019e+01, 6.45365364e+01, 9.48510356e+00, -1.19804348e+02, -1.44877151e+02, -3.99882480e+01, -3.36411033e+01, -7.02443976e+01, 2.11147185e+00, -5.99693238e+01, -1.73942288e+02, -1.14822335e+02, 1.66093336e+02, 1.43838664e+00, 1.05368226e+01, -9.76495840e+01, 8.72175719e+01, 1.40296568e+02, -2.52852396e+01, -4.86045475e+01, -6.45373933e+01, 3.54919731e+01, -1.41883332e+02, -3.84067971e+01, -1.33048440e+02, -4.41281226e+01, 8.19349481e+01, 3.45638365e+01, 4.92042590e+01, -3.25488061e+01, 7.88780753e+01, -7.47056640e+01, -6.13278346e+01, 8.05764997e+01, -8.92853730e+01, 6.89134239e+01, -1.66971558e+02, 1.17737787e+02, -7.66754701e+01, -1.56657459e+02, 1.41721870e+02, 1.61133343e+02, 1.95355303e+01, 1.61075084e+02, -5.05714968e+01, -2.49466917e+00, 1.73331279e+02, 3.00970438e+01, -1.56940193e+01, -1.98654218e+01, 5.14128773e+01, 1.30839056e+02, -2.30615096e+01, 1.61590846e+02, 1.58146792e+01, -1.21995553e+02, -1.09698162e+02, 7.68193441e+01, -5.85697969e+00, 1.55395497e+02, 1.24644293e+02, -1.76196855e+01, 1.26810605e+02, 4.68058472e+01, 1.98427786e+01, 8.10261007e+01, -1.80863974e+01, -1.23365870e+02, -1.53326109e+02, -1.30628804e+02, -1.51735646e+02, 5.59012990e+01, 4.27959032e+01, -1.53009352e+02, -6.45576730e+01, 5.84142240e+01, 1.63993936e+02, -1.27841202e+01, 3.41661330e+01, 1.39511710e+02, 1.59930703e+02, 1.69750758e+02, 1.14553449e+02, 1.64286520e+02, 1.47746448e+02, -1.47272891e+02, -5.25362763e+01, -2.68049429e+00, -1.73693506e+02, -1.00698250e+02, -5.44079913e+01, 1.28642807e+02, 1.33672768e+02, 4.54768346e+01, 2.43401234e+01, -2.96593205e+01, 1.35382812e+02, -4.06654536e+01, -1.44685476e+02, 8.28565085e+01, -6.15149175e+01, -1.31276859e+02, -1.24186703e+01, 1.62212578e+02, 9.98348382e+01, 3.91947855e+01, 1.01745178e+01, -5.66756984e+01, 6.68132041e-01, -5.39478207e+01, -1.17373467e+02, -6.72443955e+01, -1.15040729e+02, -1.25943228e+02, -9.99612603e+01, -7.75082069e+01, -1.25922765e+02, -8.90314487e+01, -5.03097802e+00, 1.06566701e+02, 3.54033342e+01, -1.46468603e+02, -1.12957754e+02, -5.39080506e+01, 5.91511931e+01, -2.72236993e+01, -1.68574550e+02, 1.19765680e+02, -1.31687965e+02, -1.66998631e+02, 1.63850247e+02, 4.64345877e+01, -4.41748261e+01, 1.81373777e+01, 8.21682278e+01, 3.41643053e+01, 1.52874600e+02, 1.20908573e+02, 1.87749570e+01, -8.68963878e+00, -1.51705207e+02, -1.05593137e+01, -8.81669665e+01, -4.34901396e+01, -1.43193753e+02, 1.34136101e+02, 4.29053455e+01, 1.20395479e+02, -1.26143662e+02, 1.50988377e+02, 8.57713010e+01, 1.13141124e+02, -1.51597199e+02, -1.45330356e+02, -1.48286977e+01, -1.35152183e+02, 1.54292001e+02, -6.60162843e+01, 6.95538662e+01, -6.63795816e+01, -7.70698653e+01, 6.73336394e+01, -9.46128405e+01, 1.18694027e+02, 4.03950687e+01, -4.24110626e+01, -1.40288535e+02, 2.96386041e+01, -1.45961419e+01, -1.03454113e+02, -3.72627018e+01, 1.30104291e+02, 2.75483026e+01, 6.59042991e+01, 9.24311332e+01, -4.86850790e+01, 1.01739297e+02, 9.15163310e+01, -1.74715768e+02, 1.00550042e+02, 1.92942813e+01, -7.92954899e+01, -1.00496684e+01, -1.40517556e+02, 1.91092128e+01, 3.49284649e+01, 1.12688718e+02, -6.03761666e+01, -8.73371769e+01, -1.38970085e+02, -1.72898603e+02, -3.61362891e+01, -1.09918217e+02, 3.62886322e+01, -5.52503951e+01, -1.38930327e+01, 4.04598954e+01, 1.16073519e+02, -4.41968144e+01, -7.71117240e+01, 1.10868584e+02, 8.44657285e+01, 6.16157552e+01, -3.26985589e+01, 5.94220361e+01, -7.34320341e+01, 1.13879068e+02, 1.32537696e+01, 5.21970920e+01, 2.95404826e+01, 1.52253722e+02, -1.48662399e+02, -6.09550388e+01, 1.42126664e+02, 5.89433443e+01, -8.34984674e+01, -1.13458695e+01, -1.50058681e+02, -8.66028930e+01, 4.72989780e+01, 4.09295768e+01, -1.45580709e+02, -9.89792134e+01, -1.41569240e+02, -1.45757862e+02, -4.30881700e+00, 1.30805904e+02, -1.34532840e+02, -1.21915931e+02, -1.08980041e+02, -1.42096025e+02, 2.93541969e+01, 4.65833491e+01, -3.72040420e+01, -1.25414447e+02, 1.29648686e+02, -1.48793659e+01, -1.56312991e+02, 9.34352472e+01, 3.77099769e+01, 5.14695879e+01, 9.55891889e+01, -1.52120844e+02, -1.74081539e+02, 1.60952537e+02, -9.21641752e+01, 7.89146800e+01, 1.34049691e+02, 1.58737543e+02, -8.77925999e+01, -1.39860480e+02, 1.11129947e+02, -1.62936550e+02, -1.67177170e+02, 1.13005063e+02, 4.56663180e+01, 1.40108914e+02, 4.86641432e+01, 1.02530451e+02, 1.18834092e+01, 7.84660722e+01, -3.90015057e+01, 8.43247573e+00, -3.55780968e+01, -1.24887402e+02, 8.47719325e+01, -1.11611359e+02, 4.69178107e+01, -2.46884973e+01, -3.32340812e+01, 1.97406011e+01, 1.17031071e+02, -1.97282179e+00, 2.43811926e+01, 4.07543597e+01, -1.29510927e+02, -1.46756827e+02, -4.82881983e+01, 1.24784086e+02, -3.93593472e+01, 8.25798808e+01, -4.27115090e+01, 6.98681764e+01, -7.84613253e+01, -1.15624789e+01, 9.67030907e+01, 8.38567884e+01, 8.07707683e+01, -1.48878210e+02, -9.00082886e+01, 1.08589001e+02, 7.32349650e+01, 2.19839650e+01, 1.16382223e+02, -3.03419755e+01, 2.23488141e+01, 9.73072142e+01, -1.48649957e+02, -1.46713444e+02, 1.15756123e+02, 1.43749653e+02, 3.36739134e+01, -1.15367039e+02, -7.69806228e+01, -4.49489406e+01, -1.57256183e+02, -5.55254400e+01, -5.04200596e+01, -1.60611606e+02, -3.38717576e+01, 1.22832053e+02, -1.26526815e+02, -7.33089543e+01, 1.13426296e+02, -4.24252094e+01, -2.81988121e+01, -1.65473440e+02, 1.73438157e+02, -1.50655938e+02, -1.03908805e+02, -1.54258955e+02, 2.04980461e+01, -1.07061894e+02, -9.76844874e+01, 1.50482627e+02, -1.33030661e+02, -1.33009103e+02, 1.45192506e+02, -5.93555791e+01, -1.33319206e+02, 1.77847630e+02, -8.31278499e+01, -1.75458533e+02, -5.89570561e+01, -1.08448719e+02, 6.27159217e+01, 1.27690721e+02, 1.75366743e+01, 1.16899304e+01, 1.06441505e+02, -1.02201591e+02, -1.45510245e+02, 9.99205272e+00, 5.65581562e+01, 2.62608644e+01, -1.13648204e+02, 6.03335529e+01, 4.87666856e+01, 1.48429721e+02, -1.68276602e+02, 1.28405921e+02, 8.83885215e+01, 4.72295789e+01, 3.40345294e+01, -1.41248466e+02, 6.69766128e+01, -1.41768132e+02, -4.80734336e+01, 1.41907605e+02, 7.15932190e+01, 7.02074690e+01, 3.36829500e+01, 1.43192630e+02, 4.84067220e+01, -1.47334390e+02, 4.83803595e+01, 1.08026738e+02, -9.09700528e+01, -7.51852431e+01, 8.73974356e+01, 2.80586330e+01, -1.49212556e+02, 6.22328397e+01, 1.30231238e+02, 1.22997617e+01, -6.14211603e+01, 9.30900698e+00, -1.18554826e+02, 6.63588523e+00, -6.31528941e+00, 1.45208807e+02, 1.64113951e+02, 6.21015101e+01, 1.52760678e+02, -7.64981880e+01, 1.31834998e+02, 1.08248632e+02, 1.41458077e+02, -1.06943939e+02, 6.33605609e+00, -7.41295280e+01, 1.61284861e+02, -7.15907595e+01, 2.67870748e+01, 1.20704481e+01, -8.31163585e+01, -1.71899378e+02, 3.91159581e+01, 9.33177363e+00, -1.19946084e+02, 4.02966572e+01, -1.41479834e+02, -4.55477601e+01, 1.15297876e+02, -3.21953455e+00, -1.63206270e+02, 1.60930611e+02, 1.73475043e+02, -6.39895867e+01, 8.06402108e+00, -7.79078275e+01, 5.07261801e+01, -1.41734675e+02, -1.46995639e+02, 1.34603926e+02, -1.64030513e+02, -1.18496069e+02, -1.79707540e+02, 3.48223055e+01, 4.30977998e+01, -2.38200137e+01, 8.85568341e+01, 1.29646547e+02, -1.32282016e+02, 7.55213766e+01, -3.61039598e+01, 3.69527303e+01, -2.60003975e+01, 1.48557997e+02, 1.49305358e+02, -1.32664248e+02, -1.40075985e+02, -1.41769125e+02, -1.43536585e+02, 1.69116345e+02, 1.21710369e+02, 1.33238543e+02, 1.05694838e+02, 7.18752339e+01, -5.26647936e+01, 7.65239727e+01, 1.44810131e+02, -9.56850659e+01, 1.37211066e+02, -5.06797947e+01, -1.35729062e+02, -1.25665195e+01, -2.85335398e+01, 1.51813848e+01, -1.84064811e+01, 4.50577440e+01, 1.37385267e+02, 1.75548310e+02, -9.06725237e+01, -1.36526143e+02, -1.39349106e+01, -6.82774617e+00, -3.72940607e+01, 8.26106458e+01, -7.60445080e+01, -1.20340864e+02, -1.62086947e+02, -2.03859612e+01, -3.69989830e+01, -5.06157874e+00, -5.26043783e+01, -5.90713044e+01, -1.17875576e+02, -1.71513718e+02, -1.19995761e+02, -3.41277331e+01, -5.76034541e+01, -6.08462896e+01, 7.31296347e+01, -3.33549875e+01, 1.39194324e+02, -1.51634565e+02, 1.66882598e+02, 1.04157139e+02, -1.20791621e+02, 9.10533830e+01, -1.32708993e+02, 7.70602017e+00, -1.62728108e+01, -6.23196383e+01, 5.21972173e+01, 2.12292901e+01, -4.78761483e+01, -9.16090118e+00, 6.20453272e+01, -1.35454581e+02, -1.72038607e+02, -1.55409832e+02, -1.46844713e+02, 1.15463697e+01, 1.39899680e+02, -1.57564658e+02, 4.23094268e+01, -1.04573521e+01, 3.61299168e+01, 9.52516938e+01, 1.37690123e+02, -1.48967934e+02, -1.79929054e+02, 9.03357912e+01, -1.45936025e+02, 1.17126251e+02, -9.21070580e+01, 1.63663040e-02, 9.19880263e+01, 1.05826218e+02, 5.56447529e+01, -1.35564594e+02, 1.59062660e+02, 3.52537403e+01, 1.48828715e+02, 6.12792995e+01, 1.44336885e+01, -3.25355408e+01, -8.18664195e+01, 1.08067907e+01, -6.44427547e+01, 1.39921937e+01, -3.96062232e+01, 1.76750821e+02, -3.70076535e+01, -1.30672425e+02, 1.03094686e+02, -1.18828768e+02, 4.92273866e+01, -1.60772875e+02, -1.58019774e+02, -1.69862856e+02, 1.53582291e+02, 1.49624487e+02, -1.64199857e+02, -7.25856283e+01, -9.49997148e+01, 1.76095164e+02, -1.65170109e+02, -8.52143506e+01, 1.17064272e+02, 9.70108363e+01, 3.79511773e+01, 9.95754966e+01, -1.58884398e+02, 1.40668225e+02, -4.84832592e+01, -1.60863869e+02, -1.66481620e+02, -1.53694536e+02, 4.80981161e+01, 1.50404888e+02, -1.32017399e+02, 1.19646988e+02, -1.13701098e+02, -3.99621433e+01, -1.55691746e+02, -2.46838157e+01, -1.67014721e+02, 3.24294034e+00, -1.54403256e+02, -1.29195936e+02, 6.40552494e+01, -3.22445801e+00, 1.49558628e+02, -6.45440969e+01, -1.74983477e+02, 4.57513925e+00, -9.80329456e+01, -1.29215610e+02, 5.12931276e+01, -1.57907145e+02, 1.78677947e+02, -1.84835564e+01, -3.36220042e+01, -1.35409853e+02, 1.46991137e+02, 1.09920089e+02, 1.00595805e+02, -1.14760560e+02, 4.65120973e+01, 1.25901150e+01, -7.78233214e+01, 2.51558732e+00, -1.30886946e+02, -1.35800394e+02, -1.67917725e+02, 6.32620157e+00, -1.50472039e+02, -1.03843043e+02, 1.47975426e+02, -1.44223286e+02, -7.60048910e+01, 1.29061503e+02, -1.49044370e+01, -7.46850049e+01, -6.90850078e+01, -2.99413247e+01, 2.53348952e+01, -8.63121709e+01, -1.64484576e+02, 1.40603049e+02, -8.43416642e+01, -1.67037085e+02, -1.75246788e+02, 1.78741181e+02, -5.02996331e-01, -1.68494506e+02, 9.63176513e-01, -3.21345716e+00, 1.36025304e+02, -1.77191442e+02, -1.12374460e+02, 5.86214673e+01, 4.91036206e+01, 1.28849957e+02, 4.58208734e+01, 1.27311420e+02, -1.77077916e+02, 1.53111135e+02, -1.42995166e+02, 1.19860234e+02, 2.05302596e+01, 7.07621419e+01, -4.64619484e+01, 1.57483475e+02, 5.92194552e+01, 1.22872281e+02, -1.50610741e+02, 3.42242605e+01, -5.39780002e+01, 1.08532161e+02, -1.74954501e+02, 4.03820866e+01, -1.43447091e+02, -1.39762225e+02, 1.41072809e+02, -6.24688206e+01, 1.10254488e+02, -1.29556630e+02, 1.37349040e+02, -1.74231274e+02, -9.44830810e+01, -3.10226206e+01, -1.43030167e+02, 9.97992684e+01, -3.29328357e+01, 4.76401543e+00, -1.75767803e+02, 1.27372253e+02, 1.68418552e+02, -4.18539220e+01, 1.60703063e+02, -4.85709978e+01, -6.10201494e+01, -9.65774863e+01, 1.44412125e+02, 6.49720237e+01, 7.45104512e+01, 3.93022755e+01, 3.48848555e+01, 1.73854830e+02, 6.31230755e+01, -1.69582850e+02, -1.54583757e+02, -1.16338609e+01, 1.51858358e+02, -1.32449226e+01, -9.84931749e+01, 4.49962288e+01, 7.71302589e+01, -7.49996027e+01, -5.85799022e+01, -1.35060959e+02, 1.46215753e+02, 1.24711258e+02, 1.26460323e+02, 1.59021299e+02, 1.44677069e+02, -1.18547982e+02, 1.09938957e+01, -4.11099109e+01, -1.61830133e+02, 1.67512554e+01, -1.29801824e+02, 1.36616575e+02, -1.06766579e+02, -1.40926964e+02, 1.62467528e+02, 1.27228448e+02, 1.58104273e+02, -1.49072840e+02, 7.33436665e+01, 6.63869865e+01, 1.05839984e+02, 1.57696823e+02, 1.29807569e+02, 4.19829752e+01, -4.25819848e+01, -4.94652414e+01, 1.35369073e+02, 5.65705889e+01, -1.19977789e+02, -1.55506470e+02, -8.13506499e+01, -1.06108410e+02, -6.18763249e+01, 1.59971129e+02, 1.17652493e+02, 1.17310773e+02, -4.02103281e+01, -1.39210438e+02, 1.39376339e+02, -1.19555394e+02, 1.28965537e+02, 1.05264403e+02, -1.29380748e+02, -1.44938153e+02, 1.36440995e+01, 1.34514672e+02, 5.80952475e+01, -3.82474854e+00, 3.64643818e+00, 4.31859745e+01, 1.73730918e+01, -4.37281040e+01, -3.12979854e+01, 7.42660704e+01, -4.26181855e+01, -1.40935992e+02, -2.27372145e+01, 7.08315614e+01, 6.11021827e+01, -1.36361972e+01, 3.95706091e+01, 1.08866513e+02, 3.94273218e+01, 2.72633877e+01, -4.54430396e+01, 1.68096674e+02, -1.54591182e+02, -1.35253645e+01, -4.24495411e+01, -3.63082300e+01, 7.03350744e+01, 1.33974062e+02, -3.94839073e+01, 1.33654469e+02, -1.21600536e+02, 9.36595539e+01, 2.62156709e+01, 1.39983677e+02, 4.52415716e+01, 1.27289986e+02, -1.26654708e+02, -2.46478184e+01, -1.23559406e+02, 1.12418938e+02, 4.58860760e+01, 8.56661717e+01, 1.57861834e+02, 1.44284881e+02, -1.29492234e+01, 6.13319953e+01, -1.93955981e+01, -1.46313179e+01, -1.01143818e+02, 1.53634907e+02, -4.70969506e+01, -1.07510335e+02, 6.08973137e+01, 1.64053759e+02, -1.24957935e+02, 8.20328477e+01, -4.15429872e+01, 4.26848384e+01, -2.22335467e+01, -1.63438048e+02, -4.74740384e-02, -6.91375965e+01, -4.70545478e+01, 1.31620862e+02, -1.34981727e+02, -1.26684231e+02, -1.30879017e+02, -1.15965920e+02, 1.38423881e+02, -1.61252349e+02, 1.59397101e+02, -2.70614370e+01, -8.81590749e+01, -2.66521219e+01, -1.56251063e+02, -1.22914378e+02, -1.41078735e+02, -5.74402226e+01, -8.03051952e+01, -2.58828011e+01, 6.68576199e+01, -1.18022172e+02, -1.56963345e+02, -5.16686369e+01, -1.28097154e+02, -2.29663352e+01, 3.58879693e+01, -4.48558736e+01, -5.05966316e+01, -1.27748387e+02, 6.34694056e+01, -7.06244818e+01, 9.44088542e+01, -1.21399330e+02, 8.73407409e+01, -3.42573320e+01, -1.43933354e+02, 1.12479312e+02, 3.00033177e+01, 4.24307745e+01, 1.16062263e+02, 1.62041415e+02, -4.09144515e+01, 8.54613639e+01, -5.50304923e+01, -1.29730017e+02, -1.44004619e+02, 2.41270028e+01, 1.58111851e+02, -1.48388879e+02, 1.06834839e+02, 3.19775592e+01, 8.95958873e+01, -1.81254446e+01, -1.40903284e+00, -2.26803555e+01, 1.80466609e+01, 8.23231223e+01, 1.38729084e+01, -4.96145711e+01, 1.50351124e+02, 1.44760852e+02, 1.29334983e+02, 1.19248527e+02, 1.42669969e+02, -6.82144845e+01, -9.14404177e+01, -3.43025351e+01, -1.03878720e+02, 1.40260680e+02, 1.10680517e+02, 1.11914114e+02, -1.45903415e+02, -5.03892768e+01, -1.01028950e+02, 1.48637584e+01, 6.18166203e+01, 2.02687462e+01, 1.54539509e+02, 1.24055469e+02, -8.91671691e+01, -6.41552509e+01, -1.14153853e+02, 7.38126311e+01, -6.58519078e+01, 1.37573076e+02, 6.75117160e+01, 8.99164739e+00, 1.31794147e+02, 3.97861364e+01, -6.82812121e+01, -7.57138065e+01, -7.18408802e+01, 8.29791996e+01, 1.25676948e+02, 1.32035672e+02, -1.06259696e+02, 7.02216655e+01, 7.92921760e+01, -1.30318689e+02, -1.13515251e+02, 1.36868744e+02, -1.49981195e+01, 7.42895356e+01, -3.15046034e+01, -3.05152394e+01, 2.55089213e+01, 1.56392967e+02, 1.39502898e+02, 1.17005762e+01, 1.56956917e+02, 1.38528236e+02, -1.31156663e+02, -4.59253798e+00, 2.76507174e+01, 6.66696348e+01, -9.97027655e+01, 5.50855288e+01, 9.89889460e+01, -1.45115112e+02, 3.16515054e+01, -1.03888272e+02, -3.28013421e+01, 1.09387886e+02])

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:443: 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.