Coordinate transformations#

Motivation#

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

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

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

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

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

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

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

Further complications are:

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

  • Event-coordinates of binned data are not handled.

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

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

transform_coords#

Overview#

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

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

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

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

Basic example#

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

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

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

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

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

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

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

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

Introduction#

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

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

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

  3. Extract the time from the local datetime.

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

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


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


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

Defining a transformation graph#

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

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

Sample data#

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

[9]:
import numpy as np

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

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

[10]:
da
[10]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (587.81 KB)
    • location: 1000
    • datetime: 72
    • datetime
      (datetime)
      datetime64
      s
      2021-06-01T17:00:00, 2021-06-01T18:00:00, ..., 2021-06-04T15:00:00, 2021-06-04T16:00:00
      Values:
      array(['2021-06-01T17:00:00', '2021-06-01T18:00:00', '2021-06-01T19:00:00', '2021-06-01T20:00:00', '2021-06-01T21:00:00', '2021-06-01T22:00:00', '2021-06-01T23:00:00', '2021-06-02T00:00:00', '2021-06-02T01:00:00', '2021-06-02T02:00:00', '2021-06-02T03:00:00', '2021-06-02T04:00:00', '2021-06-02T05:00:00', '2021-06-02T06:00:00', '2021-06-02T07:00:00', '2021-06-02T08:00:00', '2021-06-02T09:00:00', '2021-06-02T10:00:00', '2021-06-02T11:00:00', '2021-06-02T12:00:00', '2021-06-02T13:00:00', '2021-06-02T14:00:00', '2021-06-02T15:00:00', '2021-06-02T16:00:00', '2021-06-02T17:00:00', '2021-06-02T18:00:00', '2021-06-02T19:00:00', '2021-06-02T20:00:00', '2021-06-02T21:00:00', '2021-06-02T22:00:00', '2021-06-02T23:00:00', '2021-06-03T00:00:00', '2021-06-03T01:00:00', '2021-06-03T02:00:00', '2021-06-03T03:00:00', '2021-06-03T04:00:00', '2021-06-03T05:00:00', '2021-06-03T06:00:00', '2021-06-03T07:00:00', '2021-06-03T08:00:00', '2021-06-03T09:00:00', '2021-06-03T10:00:00', '2021-06-03T11:00:00', '2021-06-03T12:00:00', '2021-06-03T13:00:00', '2021-06-03T14:00:00', '2021-06-03T15:00:00', '2021-06-03T16:00:00', '2021-06-03T17:00:00', '2021-06-03T18:00:00', '2021-06-03T19:00:00', '2021-06-03T20:00:00', '2021-06-03T21:00:00', '2021-06-03T22:00:00', '2021-06-03T23:00:00', '2021-06-04T00:00:00', '2021-06-04T01:00:00', '2021-06-04T02:00:00', '2021-06-04T03:00:00', '2021-06-04T04:00:00', '2021-06-04T05:00:00', '2021-06-04T06:00:00', '2021-06-04T07:00:00', '2021-06-04T08:00:00', '2021-06-04T09:00:00', '2021-06-04T10:00:00', '2021-06-04T11:00:00', '2021-06-04T12:00:00', '2021-06-04T13:00:00', '2021-06-04T14:00:00', '2021-06-04T15:00:00', '2021-06-04T16:00:00'], dtype='datetime64[s]')
    • location
      (location)
      vector3
      km
      [-6165.33371683 -670.5502179 -1458.99402516], [1951.17118809 2300.34204199 5611.68410413], ..., [-1196.52156821 3740.62034681 5016.54627786], [-3922.92215559 4737.30100145 1660.81365085]
      Values:
      array([[-6165.33371683, -670.5502179 , -1458.99402516], [ 1951.17118809, 2300.34204199, 5611.68410413], [-5148.41772949, -3752.27990129, -61.89850632], ..., [ -816.88483536, 4516.17366728, 4418.88171065], [-1196.52156821, 3740.62034681, 5016.54627786], [-3922.92215559, 4737.30100145, 1660.81365085]])
    • (location, datetime)
      float64
      counts
      4.812, 4.207, ..., 5.238, 5.321
      Values:
      array([[4.81225579, 4.20724141, 4.34063877, ..., 4.42298981, 4.41200631, 4.75514249], [2.92951832, 4.03897211, 4.12054987, ..., 2.50591396, 2.62969441, 3.56034441], [4.3660348 , 3.44432132, 2.85860647, ..., 4.63940706, 4.33848381, 4.29951815], ..., [4.53917894, 5.12976627, 5.32374029, ..., 3.42129015, 4.13336022, 4.64065341], [5.197703 , 5.11205354, 5.9545098 , ..., 3.57835021, 4.1780514 , 4.77331352], [5.8634951 , 6.22655871, 6.59822089, ..., 5.24535465, 5.23757166, 5.320753 ]])

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

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

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


scatter_plot(da)
[11]:

Performing a transformation#

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

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

The result is:

[13]:
transformed
[13]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (1.69 MB)
    • location: 1000
    • local_time: 72
    • datetime
      (local_time)
      datetime64
      s
      2021-06-01T17:00:00, 2021-06-01T18:00:00, ..., 2021-06-04T15:00:00, 2021-06-04T16:00:00
      Values:
      array(['2021-06-01T17:00:00', '2021-06-01T18:00:00', '2021-06-01T19:00:00', '2021-06-01T20:00:00', '2021-06-01T21:00:00', '2021-06-01T22:00:00', '2021-06-01T23:00:00', '2021-06-02T00:00:00', '2021-06-02T01:00:00', '2021-06-02T02:00:00', '2021-06-02T03:00:00', '2021-06-02T04:00:00', '2021-06-02T05:00:00', '2021-06-02T06:00:00', '2021-06-02T07:00:00', '2021-06-02T08:00:00', '2021-06-02T09:00:00', '2021-06-02T10:00:00', '2021-06-02T11:00:00', '2021-06-02T12:00:00', '2021-06-02T13:00:00', '2021-06-02T14:00:00', '2021-06-02T15:00:00', '2021-06-02T16:00:00', '2021-06-02T17:00:00', '2021-06-02T18:00:00', '2021-06-02T19:00:00', '2021-06-02T20:00:00', '2021-06-02T21:00:00', '2021-06-02T22:00:00', '2021-06-02T23:00:00', '2021-06-03T00:00:00', '2021-06-03T01:00:00', '2021-06-03T02:00:00', '2021-06-03T03:00:00', '2021-06-03T04:00:00', '2021-06-03T05:00:00', '2021-06-03T06:00:00', '2021-06-03T07:00:00', '2021-06-03T08:00:00', '2021-06-03T09:00:00', '2021-06-03T10:00:00', '2021-06-03T11:00:00', '2021-06-03T12:00:00', '2021-06-03T13:00:00', '2021-06-03T14:00:00', '2021-06-03T15:00:00', '2021-06-03T16:00:00', '2021-06-03T17:00:00', '2021-06-03T18:00:00', '2021-06-03T19:00:00', '2021-06-03T20:00:00', '2021-06-03T21:00:00', '2021-06-03T22:00:00', '2021-06-03T23:00:00', '2021-06-04T00:00:00', '2021-06-04T01:00:00', '2021-06-04T02:00:00', '2021-06-04T03:00:00', '2021-06-04T04:00:00', '2021-06-04T05:00:00', '2021-06-04T06:00:00', '2021-06-04T07:00:00', '2021-06-04T08:00:00', '2021-06-04T09:00:00', '2021-06-04T10:00:00', '2021-06-04T11:00:00', '2021-06-04T12:00:00', '2021-06-04T13:00:00', '2021-06-04T14:00:00', '2021-06-04T15:00:00', '2021-06-04T16:00:00'], dtype='datetime64[s]')
    • latitude
      (location)
      float64
      deg
      -13.239, 61.741, ..., 51.944, 15.111
      Values:
      array([-1.32385283e+01, 6.17410562e+01, -5.56675399e-01, 4.72903866e+01, -3.50055299e+01, 4.59748578e+01, -1.05290000e+01, 4.82472911e+01, 8.43691330e+00, -4.28359159e+01, -6.07988497e+01, 1.00987630e+01, 3.67192004e+01, -4.03740787e+01, -4.13465268e+00, 2.59574311e+01, -2.96395227e+01, 1.39357211e+00, -5.04973883e+01, 5.25854588e+00, 2.59216089e+01, 2.39773828e+01, 4.17480617e+01, -5.11576127e+00, 4.65174093e+01, 6.29428697e+01, 9.42289104e+00, 1.81225037e+01, 1.91650704e+01, 1.79894206e+01, 2.49882716e+01, 3.52210283e+01, 3.08422755e+00, 1.99560272e+01, 2.43535428e+01, 5.62743302e+01, -4.31864876e+01, 7.38563145e+00, 2.09279881e+01, 2.26646887e+01, 3.27387050e+01, -4.43139010e+01, 3.93308344e+01, -5.37283356e+01, 3.82213958e+01, -6.33063552e+01, 8.48985422e+01, -4.59498615e+01, -2.75398152e+01, 2.48807489e+01, -4.82795734e+01, -3.56895541e+01, 9.46235934e+00, 4.00140698e+01, 5.46201612e+01, -4.40478368e+01, 1.63120092e+01, -5.98537222e+01, -4.13612573e+01, 3.79774399e+01, 4.95583834e+01, -3.11858865e+01, 4.63419432e+01, -1.34347931e+01, -4.24725810e+01, 4.61805800e+01, 9.16337469e-01, -1.56383309e+01, -5.29716016e+01, 2.01398306e+01, 6.24610178e+01, 2.61500555e+01, -1.32073523e+01, 3.70088347e+01, 2.14905538e+01, 7.13183469e+00, -3.74793627e+01, 2.69513489e+01, 3.92036936e+01, -2.57502943e+01, 4.53694022e+01, -8.72767382e+01, -5.40450052e+01, -4.40149498e+01, -3.75062338e+01, 2.06928201e+01, 2.33017145e+01, 1.41907946e+01, 7.95304963e+01, 3.04044928e+01, 5.04025682e+01, -4.20750328e+01, -5.95633997e+01, -2.04774210e+01, 3.74151218e+01, 8.28600702e+01, -4.93410184e+01, -5.16294746e+01, -5.15310483e+01, -7.21333906e+00, 4.61629849e+01, 3.47948929e+01, -2.92323323e+01, -1.87355483e+00, -2.32300405e+01, -2.56103016e+01, 3.80601739e+01, -4.39101541e+01, -1.68146768e+01, -4.95442181e+01, 4.99042721e+01, 4.91678473e+01, 6.33326693e+00, 3.59465935e+01, 3.47511845e+01, 3.99542432e+01, -2.16786419e+01, 5.88169446e+01, -7.27887879e+01, 3.62180651e+01, 3.58703331e+01, 7.05109969e+00, -8.27209042e+00, 2.43245901e+01, 3.53822735e+01, -6.05255454e+01, 4.19019447e+01, 6.97509637e+00, 2.18218151e+00, 3.90596628e+01, 5.98646044e+01, -3.96094836e+01, -4.51935263e+01, 4.27289004e+01, 5.79356230e+00, 2.24723656e+01, -3.76062307e+01, -5.32182279e+01, -3.89047295e+01, 4.71331449e+01, 3.90113801e+01, -1.40242112e+01, 5.76405660e+01, 1.99019520e+01, -4.21001395e+00, -4.90800639e+01, -5.28505832e+01, 2.73278044e+01, -1.23594379e+01, -7.61174296e+01, 7.39389901e+01, 3.47405749e+01, -3.37459661e+01, -3.48728519e+00, 1.13528467e+01, -2.96287786e+01, 4.12311803e+01, 2.21622727e+01, 5.95808942e+01, -9.46570579e+00, 3.35603219e+01, 1.41854491e+01, 6.42757297e+01, -4.48592596e+01, 4.28895444e+01, 2.57492517e+00, -2.70150807e+01, -1.35255113e+01, -1.79069743e+01, 7.75479468e+01, -4.01658020e+01, -2.36928695e+01, 4.10711231e+01, 2.27617298e+01, -1.25661657e+01, -1.03685314e+00, -3.95036867e+01, 6.45484707e+00, -4.06991205e+01, 8.31775521e+00, -1.56875157e+01, -1.90815529e+01, 4.10475472e+01, -5.97352096e+01, 3.83846485e+01, -6.86683558e+01, 4.57436070e+01, 3.02403989e+01, 1.88401236e+01, -3.81674163e+01, 6.63640884e+01, -2.55654844e+01, -6.93575825e+01, 1.55920362e+01, 4.60382227e+00, -5.60221833e+00, -1.21301549e+01, 3.46195818e+01, 4.52425328e+00, 3.36781040e+01, -3.90402433e+01, 3.78404684e+01, -3.34362558e+01, -9.69953789e+00, -2.60354734e+01, -4.22644304e+01, -1.26915525e+01, -4.37620697e+01, 2.37062188e+01, -2.26624515e+01, -3.27846594e+01, -4.19100283e+00, 7.43542786e+00, -1.23333370e+01, -3.27116209e+01, -3.12850190e+01, -1.47645246e+01, -4.76789689e+01, 4.21929724e+00, 1.54574014e+01, -2.76923418e+01, 2.12913784e+01, -3.81593990e+01, 2.51428715e+01, 2.52624150e+01, 5.23296305e+01, -4.18840996e+01, 3.51054127e+01, -3.26875946e+01, -4.15308585e+01, 7.73371104e+01, -5.33340307e+00, -4.34254030e+01, -4.85122338e+01, -3.54048051e+01, -2.41847506e+01, -6.75114794e+01, -3.59940561e+01, 6.00579672e+01, -3.71461584e+01, 2.73881007e+01, 2.78166330e+01, -6.28916816e+01, -6.79275436e+00, -1.04723331e+01, -3.77418837e+01, 3.77364889e+01, -5.51935837e+01, -4.69702690e+01, 6.10923284e+01, -2.99874925e+01, 2.73657338e+01, 1.26560191e+01, 2.91851299e+01, -1.88792394e+01, -1.86342897e+01, 6.30705122e+00, 1.53366052e+01, -8.69203987e-01, -4.51792592e+01, -2.77117075e+01, -3.86454628e+01, 3.12477891e+01, -1.88157979e+01, 8.67464829e+00, 4.44766114e+01, 6.01617022e+01, -3.70843137e+01, 4.50353590e+01, 5.17998164e+00, 5.41705684e+01, -5.02022114e+01, -2.19211679e+01, 4.45664981e+01, -4.22229405e+01, 4.04949031e+01, -5.24412249e+01, -1.58640112e+01, -4.75835052e+01, -4.70409049e+01, -5.13996926e+01, 2.06548907e+01, -1.60115465e+01, 3.51964536e+01, 9.78125798e+00, -4.68119788e+01, -1.81637290e+01, -3.70379427e+01, -1.54120717e+01, 2.83850459e+01, -4.70701180e+01, 2.53560107e+01, -3.37939004e+01, 7.31399279e+01, -7.48437152e+01, -5.22412131e+01, -4.24744908e+01, -4.03176707e+01, -5.52907180e+00, -5.43812195e+01, -8.68819897e+00, 5.88906400e+01, 5.88944584e+01, -6.08087329e+01, -4.78714286e+01, -1.10747717e+01, 3.80850459e+00, -4.52220592e+01, 3.39535126e+01, -2.20907512e+01, -5.46662223e+01, 1.59287750e+00, -6.51633978e+00, -5.64834293e+01, -8.92132601e+00, 1.55489396e+01, -4.05472202e+01, 3.55178588e+01, -1.31230152e+01, 2.34123847e+01, -1.22238089e+01, 3.66264216e+00, 1.09251652e+01, 3.04649969e+01, 5.51311239e+01, -2.77621446e+01, 2.95975189e+01, 9.82884552e+00, -4.86744706e+00, -2.98577355e+01, 1.97873225e+00, 3.54046210e+01, 2.66972866e+01, -1.33978921e+01, 5.53751656e+01, -4.28458234e+01, 5.38329570e+01, -1.19346128e+01, 5.96439107e+01, 4.34614237e+01, 5.27651575e+01, 4.00963688e+01, -1.77607872e+01, -2.81360238e+01, -3.47973810e+01, 4.30689675e+01, -2.93355647e+01, 6.97873186e+01, 5.75406218e+01, 1.18143191e+01, -1.37740563e+01, 5.45088727e+01, 4.07129451e+01, 5.04688552e+01, -4.19364519e+01, 2.51263909e+01, -2.23466407e+01, -4.95702952e+00, 1.42470853e+01, -4.14936008e+01, 3.11601950e+01, -2.62135635e+01, 4.66840908e+01, 2.20642957e+01, -9.14084713e+00, 2.53481688e+01, -1.79710905e+01, -9.71762166e+00, 2.61927880e+00, -4.50154251e+01, -3.71728692e+01, -5.27154713e+01, -4.63273703e+01, -4.76950368e+01, 9.03688972e+00, 8.06209531e+00, 2.57271756e+01, -6.29890780e+01, 4.60509881e+00, -4.76156122e+01, -5.50553655e+01, -6.63364622e+00, -2.02789641e+01, -2.51908045e+01, -5.89581223e+01, 5.95228786e+01, 1.93831471e+01, 2.84223617e+01, 3.20190869e+00, 3.61315780e+01, -5.82995343e+01, 5.67821117e+01, -4.43314493e+01, 1.82962363e+01, -2.82836140e+01, -4.13480057e+01, -1.51220391e+01, -2.08028667e+00, -3.75902889e+01, 4.64203894e+01, -3.16702916e+01, 6.52493756e+00, 4.38619284e+01, -1.71851840e+01, 6.53578932e+00, 6.48392986e+00, -4.38685399e+01, 4.48334884e+01, -4.43119064e+01, 8.06014918e+01, 1.38212350e+01, 3.55977216e+01, 5.23113054e+01, -5.17169539e+00, 1.27297118e+01, -3.07436907e+01, 2.23964870e+01, -3.51574862e+01, -1.55265537e+01, -6.61914958e+01, 4.00821529e+01, -6.60873478e+01, -4.70502754e+01, 4.97916299e+01, -2.74087704e+01, 7.81921526e+00, 4.49678617e+00, 3.63119688e+00, -2.26890289e+01, -2.84009231e+01, 3.23371964e+01, 1.91208369e+01, -2.44897089e+01, 7.46259913e+01, -2.38149164e+01, 2.48568302e-01, -3.99641863e+01, 3.86644536e+01, -6.38415992e+01, -5.17870408e+01, -3.71376919e+00, -1.17703816e+01, 2.64472312e+00, 6.32288825e+01, 3.97596463e+01, 3.51485983e+01, 2.36986741e+01, 8.29969069e+01, 6.57221056e+01, 5.66973933e+01, -4.91373011e+01, -3.53305374e+01, 3.11601385e-01, 4.68570274e+01, -3.72473578e+01, 4.83743186e+01, 4.17777697e+01, -7.28456907e+01, -3.00959607e+01, -7.09342497e+01, -1.99241552e+01, -2.22985372e+01, 4.22244278e+01, 5.06620686e+01, -2.03395320e+01, -4.94454753e+01, 2.24276924e+01, 3.28528779e+01, -1.14344473e+01, 3.40705535e+01, 9.61218459e+00, -6.92774756e+01, 2.95207826e+01, -2.08647073e+01, 2.95953805e+01, -4.43388557e+01, -6.39870880e+01, -4.21340925e+01, 3.62144143e+01, 5.05610873e+01, -4.22013971e+01, 2.84955409e+01, 4.84478757e+01, -7.63574935e+00, 8.22856982e+00, 4.39092075e+01, 7.31381622e+00, 6.73638892e+01, -1.28660958e+00, 2.70667645e+01, 5.54110034e+00, 1.63046844e+01, -5.43124934e+01, 4.09660663e+01, -3.44332596e+00, -8.42487965e+01, 8.43039733e+00, 4.41535960e+01, 6.30596662e+01, -1.30537712e+01, 1.50597577e+00, 1.93395101e+00, 7.61290617e+00, 4.58932463e+01, -5.30655818e+01, -4.66914600e+01, 3.47048757e+01, -8.04621697e+00, 1.92666699e+01, 4.04870025e+01, -4.52657154e+01, 5.95008315e+01, 5.67428704e+00, 2.54961371e+01, -1.84834954e+01, 3.21242107e+01, -2.83144954e+00, 1.93021120e+01, 5.97839381e+01, 3.99956881e+01, -1.47456245e+01, 3.93797281e+01, 6.24160961e+00, -2.59544584e+01, -4.06433192e+01, 3.17429119e+01, -1.02357224e+01, 5.25085461e+01, -2.09447887e+01, 7.01289285e+01, 5.27018312e+01, -2.10328509e+01, 3.90187465e+01, -2.96060517e+01, -6.49142030e+00, 2.25768058e+01, 3.88084062e+01, 4.96482749e+01, 3.21382053e+00, 3.92670201e+01, 5.98175240e+01, 1.98644486e+01, -3.23045556e+01, 1.96066166e+01, -3.15486772e+01, -2.81797203e+01, 4.55984719e-02, 1.60872912e+01, 1.66652668e+01, -4.10354163e+01, 2.44612414e+00, 7.64596919e+01, 1.09699251e+01, -4.36282573e+01, 3.87327049e+00, -4.09048548e+01, 1.54251200e+01, 4.56836716e+01, -4.99090975e+01, -1.81605416e+01, 1.13210121e+01, 3.08327667e+01, 2.11981433e+00, -8.06851034e+01, 2.91102162e+01, 3.66793219e+01, 4.75283793e+01, -2.65723185e+01, 1.13954664e+01, -4.09662470e+01, -1.75310556e+01, 4.17942840e+01, -1.70905922e+01, 6.54567474e+01, 5.76127841e+01, -2.98993911e+01, 4.07273907e+01, 2.16382950e+01, -5.47869559e+01, -1.69042697e+01, 6.96120382e+00, 1.22533935e+01, 2.53579755e+01, -3.21137878e+00, -5.85250386e+01, -2.71478244e+01, -2.77392927e+01, -4.82489434e+01, 2.62447103e+01, -4.55942570e+01, -8.77942340e+00, -2.96748060e+01, -3.69881246e+01, 3.01849634e+01, -1.97306140e+01, 2.31536191e+01, -5.85510753e+01, -4.75311123e+01, 2.31012468e+01, -5.58106779e+00, -3.31783670e+01, 2.99491394e+01, -4.22057494e+01, 4.44050017e+00, 3.23341467e+01, 9.97139006e+00, -4.93854139e+01, 2.44995972e+00, -4.59603214e+01, -2.22717314e+01, 3.99490093e+01, 5.57418828e+01, -2.59568351e+01, 3.44383646e+01, -6.48042115e+00, 3.89384226e+01, -2.30356468e+01, 6.38892115e+01, 4.87261427e+01, -4.50504251e+01, 3.56583210e+01, 5.68295211e+00, 4.17932035e+01, 5.60038229e+01, 6.19988646e+01, -4.42543740e+01, 2.60462373e+01, -6.04652776e+01, -3.55127108e+01, -1.85642006e+01, -6.38233283e+00, -5.50728719e+00, 3.97134244e+01, -4.24416261e+01, 4.71225211e+01, -4.85957227e+01, -9.40385223e+00, 5.08152119e+01, -6.27751484e+01, 3.09461004e+01, 8.13536942e+01, -3.45923414e+01, 4.02403972e+01, 9.00223297e+00, -5.29531080e+01, 9.18495341e+00, 4.39460860e+01, 4.42778299e+01, -2.71346699e+01, 3.39876315e+01, -3.45530129e+00, 4.17206567e+01, 5.00399888e+01, -4.76904750e+01, 6.27492970e+01, -2.82404656e+01, 1.79266472e+01, -3.60026616e+01, 4.98079916e-01, -5.06782389e+01, -4.11499315e+00, -1.15058378e+01, -1.91395586e+00, -3.37179524e+01, -5.27154404e+01, 7.75764323e+01, -9.29509237e+00, -4.45915628e+01, 5.64556562e+01, -4.65592762e+01, -1.61274927e+00, -2.13511804e+01, 4.42014762e+01, -7.92621922e+01, -3.40368372e+01, 2.23871821e+01, -4.34745043e+01, -4.46217218e+00, -2.08637492e+01, 2.36757122e+01, -4.87035059e+01, -4.96998833e+01, -4.78061470e+01, 6.39280241e+01, -4.21578888e+01, -8.46307594e+00, 5.35381813e+01, -2.26204330e+01, 4.37090619e+01, 4.59054221e+01, 4.30214313e+01, -4.46029036e+01, 1.54833021e+01, -6.88059844e+01, 6.52437528e+01, 5.19678551e+01, -2.37111719e+01, -6.23278879e+01, 5.69509064e+01, 5.25938119e+01, 5.78969947e+00, -3.29675759e+01, 1.30875505e+01, 1.72392370e+01, -3.71711049e+01, -4.22161596e+01, 8.06401157e+00, -1.10652111e+01, -4.13167373e+01, -4.42725888e+01, 1.65148677e+01, -4.86899368e+01, 8.54954920e-01, -5.16773816e+01, -5.88141463e+01, -4.20033465e+00, -4.10048271e+01, -5.19688128e+01, -5.81010657e+01, -1.44877176e+01, 1.71746761e+01, 1.04074249e+01, -4.55988515e+01, 4.21543115e+01, 4.44247435e+01, -5.12820714e+01, 5.38055154e+01, 5.48127205e+01, -4.15142333e+01, 7.08272975e+01, 1.92483142e+01, -6.54021043e+01, 9.30258894e+00, 3.36052914e+01, -2.04746657e+01, 2.93697325e+01, 4.44164042e+01, -3.59524700e+01, -4.89562401e+01, -3.01810635e+01, 6.02575523e+00, -5.04858252e-01, 1.29007531e+01, 2.95055745e+01, -3.16714473e+01, -4.16134766e+01, -5.18180803e+01, -5.90771407e+01, -4.22144810e+01, -3.30533542e+01, 4.40508479e+01, 1.79207662e+01, 6.53538829e+01, -2.52922537e+01, 1.77908993e+01, 1.49023279e+01, 1.62642066e+01, -4.03074444e+01, -4.12941469e+01, -4.94174905e+00, 4.61780742e+01, -1.98186408e+01, 3.92315702e+01, 7.57264398e+01, -7.33530693e+01, -4.73023705e+01, 3.17487191e+01, 3.61854106e+00, -5.22702665e+01, -5.63914988e+01, 4.65673073e+01, -2.19846038e+01, 4.29921260e+01, -3.76636593e+01, 3.93516607e+01, 1.64873445e+01, 2.17400840e+00, -4.25508021e+01, 1.14064444e+00, -1.94951073e+01, -2.76850464e+01, 3.87417900e+01, 5.66114572e+01, -3.72799280e+01, 1.31485111e+01, 4.52215606e+01, -4.51713611e+01, 3.24104259e+01, 3.80321931e+01, 4.65934092e+01, 6.30262692e+01, 1.19142455e+01, -4.99585580e+01, -5.53661299e+00, -1.28443492e+01, -3.95830360e+01, 4.26062408e+01, -4.47029879e+01, -1.81376379e+01, 3.14132302e+01, 2.48533048e+01, 1.89552498e+01, 5.70941907e+01, -2.96981652e+01, 5.46523381e+01, 5.09382100e+01, -3.09381578e+01, -3.70611901e+01, -1.76248414e+01, -5.53227470e+01, 4.66117085e+01, -3.43959245e+01, -1.92152570e+01, -2.27296398e+01, 3.93881984e+01, -3.05495112e+01, -2.91958159e+01, 4.81049796e+01, 5.45268130e+01, 4.67769162e+01, 4.47545292e+01, 7.72526577e+01, 3.41004451e+01, -5.54566667e+01, -3.75752478e+01, 3.97099661e+01, 1.99998060e+00, 4.27571669e+01, -3.71834191e+01, -2.87013178e+00, -3.26445067e+01, -5.05373411e+01, -2.03130204e+01, 2.55266270e+01, -2.69590294e+01, -3.78033497e+01, 4.37443340e+01, -1.67056966e+01, -3.73899986e+01, 1.16100917e+01, -4.90303015e+01, 2.14568706e+01, -5.81512608e+01, 6.51048040e+01, 1.13531778e+01, -1.00062522e+01, 1.70756219e+01, -3.67657353e+01, 3.96522164e+01, 6.69222547e+01, 5.10242506e+01, 5.85878959e+01, 1.15967790e+01, 1.89934394e+01, 3.16340424e+01, -2.68658045e+01, -4.19194028e+01, 5.82233467e+01, 2.50893269e+01, -1.18489418e+01, 9.52874054e+00, 5.35850468e+01, -6.83633219e+01, -3.36344719e+01, 2.55962795e+01, -9.36530176e+00, -4.28548389e+01, 6.07347106e+00, 4.12718302e+01, -4.47472889e+01, 1.87685068e+01, -1.65839869e+01, 4.25908138e+01, 7.03530182e+01, -3.90096323e+01, -7.17480683e+01, 5.59492559e+01, -4.84643520e+00, -4.33011397e+01, -3.15363551e+01, -3.74345409e+01, -2.25473132e+01, -6.17433318e+01, 6.44359078e+01, -1.11398352e+01, -1.45576459e+00, 3.08659436e+01, -1.90617459e+01, -1.89033575e+01, -6.94485845e+01, -2.01825308e+01, 1.00178371e+01, -5.12601177e+01, -2.06520615e+01, 2.84872437e+01, 5.19661522e+01, 4.62289080e+01, 2.25440021e+01, 3.26886205e+01, 4.96949495e+01, 2.79317199e+01, -5.93735111e+01, -2.92293661e+01, 3.88431899e+01, -3.72351411e+01, -4.43654410e+01, 5.68488196e+01, -8.05948952e+01, 6.70951985e+00, 1.35498170e+01, -9.33437727e+00, -1.47084984e+01, 4.32839350e+01, -3.48494809e+01, -1.11092735e+01, -3.97996683e+01, -3.87840674e+01, 2.24696843e+01, -1.54338872e+01, 4.90668342e+01, 5.30985205e+01, -1.23291087e+01, -2.64233006e+01, -3.58642098e+01, -4.12334885e+01, 2.29366687e+01, -2.94146288e+01, 5.19883269e+01, -8.15426340e+01, -2.79192651e+01, 4.49717105e+01, 1.28183537e+01, 2.72251060e+01, 4.36111580e+01, -6.83541942e+01, -2.78701795e+01, 3.30655792e+01, 5.42134773e+00, -1.95942439e+01, -3.42237548e+01, 1.85801415e+01, -1.52667943e+01, 6.26835694e+01, -5.92633919e+00, -2.70858925e+00, 5.00879784e+01, -6.70182625e+01, 3.47563900e+01, 2.20783840e+01, 4.87113422e+01, -4.07231189e+01, 5.58580159e+01, -1.05922050e+00, -3.73203747e+01, 2.12559923e+01, -4.74949801e+01, -1.25438069e+01, 6.02168321e+01, 4.36263769e+01, -1.62426213e+00, 3.04908968e+01, 8.46784377e+01, -1.10958805e+01, -4.93197944e+01, 9.60546542e+00, 1.01685091e+01, -4.44046814e+01, 7.86175004e+00, -3.05305312e+00, 6.13573163e+01, 4.62828695e+01, -6.39115461e+01, 4.17789109e+01, -3.12167913e+01, -6.74448267e+01, 3.87345152e+01, -4.01318460e+01, -7.02150702e+01, -5.36836342e+00, 4.06942212e+01, -4.50341563e+01, -2.93019294e+01, 4.84010686e+01, 2.48706069e+01, 4.22263049e+01, 3.45776742e+01, 3.87822179e+01, -2.24723177e+01, 5.32090475e+01, -4.88400563e+01, 6.73911452e+01, -3.12952902e+01, 2.30673781e+01, 2.41136170e+01, 3.67416645e+01, 1.73499924e+01, -4.52251746e+01, 4.39152121e+01, 5.19435016e+01, 1.51106138e+01])
    • local_datetime
      (location, local_time)
      datetime64
      s
      2021-06-01T18:00:00, 2021-06-01T19:00:00, ..., 2021-06-05T11:00:00, 2021-06-05T12: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-02T08:00:00', '2021-06-02T09:00:00', '2021-06-02T10:00:00', ..., '2021-06-05T05:00:00', '2021-06-05T06:00:00', '2021-06-05T07:00:00'], ['2021-06-01T20:00:00', '2021-06-01T21:00:00', '2021-06-01T22:00:00', ..., '2021-06-04T17:00:00', '2021-06-04T18:00:00', '2021-06-04T19: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-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-02T13:00:00', '2021-06-02T14:00:00', '2021-06-02T15:00:00', ..., '2021-06-05T10:00:00', '2021-06-05T11:00:00', '2021-06-05T12:00:00']], dtype='datetime64[s]')
    • local_time
      (location, local_time)
      float64
      s
      6.480e+04, 6.840e+04, ..., 3.960e+04, 4.320e+04
      Values:
      array([[64800., 68400., 72000., ..., 54000., 57600., 61200.], [28800., 32400., 36000., ..., 18000., 21600., 25200.], [72000., 75600., 79200., ..., 61200., 64800., 68400.], ..., [39600., 43200., 46800., ..., 28800., 32400., 36000.], [43200., 46800., 50400., ..., 32400., 36000., 39600.], [46800., 50400., 54000., ..., 36000., 39600., 43200.]])
    • location
      (location)
      vector3
      km
      [-6165.33371683 -670.5502179 -1458.99402516], [1951.17118809 2300.34204199 5611.68410413], ..., [-1196.52156821 3740.62034681 5016.54627786], [-3922.92215559 4737.30100145 1660.81365085]
      Values:
      array([[-6165.33371683, -670.5502179 , -1458.99402516], [ 1951.17118809, 2300.34204199, 5611.68410413], [-5148.41772949, -3752.27990129, -61.89850632], ..., [ -816.88483536, 4516.17366728, 4418.88171065], [-1196.52156821, 3740.62034681, 5016.54627786], [-3922.92215559, 4737.30100145, 1660.81365085]])
    • longitude
      (location)
      float64
      deg
      -173.793, 49.695, ..., 107.738, 129.628
      Values:
      array([-173.79283004, 49.69508512, -143.9146126 , 66.82211085, 151.08141289, -35.26994177, -55.27704111, -71.58077733, 43.78612471, 20.9016662 , 108.87314659, -46.00895993, -138.9588436 , -68.27273726, 115.40392346, -22.82327356, 143.91048752, 72.93272775, -144.125188 , 33.69453841, 169.30632499, 116.09170026, -147.7114671 , -27.54582147, 176.58428667, -170.57721442, 34.44116088, 121.74848308, -54.40397431, 162.47124604, -79.50612852, 163.10893484, -42.66465187, 120.19760063, 130.40827029, -148.79346086, -13.05487108, 47.30822481, -69.2739144 , -32.53804878, 77.63065435, -168.29256664, 127.79083225, 94.82325957, -101.16126052, 51.36801377, 124.56245732, 96.91112896, 36.54245064, -65.27616597, 162.32278499, 74.82553752, 141.89741784, 39.3357495 , 43.23040301, 5.53715463, -39.70605988, 52.72883326, -25.96896221, -113.27507346, -23.13899191, -132.26378446, -71.37871045, -41.22644253, 92.30863318, -76.28892166, 66.22631312, 159.05482373, -16.52096746, 139.40504484, -52.43161155, 21.96220126, -53.70211434, 47.25210191, 29.18616116, 35.51970713, -48.45228855, -111.85991955, 154.30386832, 97.69382734, 117.20580347, -141.73677588, 164.62352318, 90.45327182, -141.66381494, -142.58636904, -58.91322444, 35.10344068, 127.44824683, -154.66894821, -160.36858036, 91.33778301, 172.16962676, 134.67051475, -127.91162236, 96.05390977, 36.27159486, 109.41160225, 65.1418291 , -14.0883279 , 115.27529758, 135.77523357, -101.35965094, -121.47873585, -16.23947774, 135.21269384, 117.18856888, 169.52759257, 107.0626998 , 62.10271694, -41.07030111, -53.5886993 , 172.57543854, -62.45819294, -3.58000423, -117.52124169, -114.95488205, -24.07010215, 94.5049159 , -105.44909382, -140.6231865 , -77.07558165, -59.96639684, -122.99792547, 32.57955645, -41.28454073, 38.85351835, 40.97371007, 155.24281245, 36.31263137, -57.25115499, -90.3538205 , -24.13360527, 7.25010539, -72.80967177, -41.80154678, -159.85230538, -134.35529993, 51.04174464, -141.68397333, -138.45031497, 126.23090101, 157.28664414, 71.86446912, -4.03223327, 137.55935172, 126.73098546, -129.86278577, -149.58360081, -34.71365173, -39.98771019, 83.85539 , -164.83889182, -159.25487223, -126.57321175, -151.50775736, -0.91909665, 68.95531574, 152.37638603, 144.49534869, -121.37698516, 43.81047604, -75.19579648, 110.26983791, -45.17380452, -146.80625105, 158.59680034, -82.96803285, -139.23249492, -161.59837056, -26.36637674, 114.0703671 , 26.3475423 , -33.11748393, 125.84196426, 76.39746723, 162.13085935, 75.69659085, -123.80480622, -127.09268656, -9.50173958, -57.88863404, 116.24593963, -90.02714052, 146.76162521, -122.06146154, 68.06379256, 152.74453494, 7.94844866, -159.31947398, -58.1872782 , 40.17259543, 106.0011114 , 173.61825645, -147.04445728, 131.81906315, 155.9764448 , 122.09009887, 160.44787399, -137.23623419, 40.34293072, -3.97209878, -62.52938038, 137.87568718, 16.23386001, -169.00737211, -99.87115492, 128.47418691, -174.08281787, -46.90216822, 36.72956554, 147.65909195, -137.03815178, 170.89325327, 86.80596876, -178.19936387, -46.03638436, 112.05729217, -36.05849968, -46.16417339, -69.55023078, 162.04005881, -175.10836574, -41.87524124, -54.67911125, -99.51182267, -103.72382925, -121.01691167, 36.49839985, 72.87761079, 96.18126496, 123.83944539, 116.74467551, 8.56424896, 59.9943759 , 38.00118109, -2.17190726, 47.60533727, -74.05373404, 50.10044638, 55.8082475 , 18.28831698, -42.89200814, -38.20361288, 146.11176175, 113.46006008, -119.1534856 , 120.71063703, -119.81034971, 173.06756357, 12.65149318, 128.39485057, -63.71467814, 132.47858486, 98.14435735, -114.85088079, 51.64277038, 113.20206204, -50.77074216, 69.5563199 , -179.46929954, -97.95427979, 46.56000954, -141.53678309, 42.39881049, -127.92902637, 154.65018109, 56.534356 , -150.62685536, -87.38982257, 65.58542711, -91.97703814, 50.15380874, 145.84363033, 61.60260105, 22.08536494, 134.64660071, -34.24732486, 89.9522075 , 113.13030091, 2.48520352, -146.00520062, -86.1716822 , -73.6085652 , -75.44630318, -24.14013078, -84.64880399, -146.03051689, 151.21158678, 49.06256975, 58.21902645, 66.61373514, -129.28156507, -133.58607334, -141.62231286, 147.99812479, -162.20869465, -2.09236923, 160.08951657, 126.04577667, 75.16802909, 123.9379071 , -79.19323361, -98.26767385, -109.79326887, 32.62481283, 66.73711095, 147.26985771, -16.49662528, 62.38263815, -37.88625359, 46.41089434, -62.56373356, 88.86270835, 97.40951886, 133.70234025, 151.12543715, 152.50628581, 143.45647305, 53.82755004, 35.88355491, -31.12749291, -143.4994354 , 43.86724886, 104.50318128, -30.86804302, 75.25895842, -126.66408516, 22.95652719, -39.22037536, -123.72349422, 163.71782422, -54.41315345, 15.59315337, 89.12142542, 54.27272798, 77.36457635, -123.20007777, 162.90489118, -24.0051859 , 137.24087918, -72.36828079, -137.87211032, 135.09046713, -11.51642079, -20.91054107, 25.65276871, -136.67432399, 112.63532046, -172.81365756, -115.00702209, -165.79365066, -154.44964122, -86.11239697, -156.36065969, 51.57073337, 8.64997996, -34.3159769 , -31.12286796, 152.81689178, -36.21667444, -28.87327181, -53.51537141, 150.19790733, -130.43345798, 136.12207267, -46.82048413, -171.15956214, -110.12378855, -39.0796101 , 40.68085178, -133.56054081, -4.23095578, 60.38165878, 140.09422931, 174.94947485, 30.32318716, 87.0673272 , 22.92511006, -119.71477041, -14.13664915, 72.1043301 , 104.16415751, 104.27029209, 39.53795636, 66.32606778, 175.14523044, 97.5218145 , 92.30042686, 59.5034686 , -39.42396264, 2.11573876, 135.2505743 , -55.40953732, 139.11464078, 111.88759068, 74.99846472, 47.7248442 , 96.64434029, -108.60531852, -35.63036987, 79.29830332, 138.62225714, -6.087121 , -113.73350429, -127.17353928, -9.15937273, -142.14302689, -18.6225525 , 134.11931774, 33.19033767, -31.9812924 , -33.4595532 , -86.87275485, -57.34599659, 142.17926148, -69.49687817, 52.98584425, 136.70501295, -168.25769387, -43.80220944, -176.75187691, -114.35724359, 72.25987531, 168.45941924, 59.37570173, 83.31162089, 149.52432187, -145.95630699, 131.10119069, 48.12550426, 24.30234282, -110.54592222, -61.47029262, -51.84358372, -8.4891272 , 67.76382277, 149.14610028, -162.70808399, -55.07949908, 22.71767204, 75.3079166 , -30.16963613, -47.19294159, 126.44677463, -134.99397361, 81.05676854, 30.25374472, 101.98463981, 171.83110253, 117.65756543, -14.04628266, 17.27156759, 77.00901961, 86.39751865, 6.15929587, -60.31898448, -110.09193271, 40.05283007, -81.05916321, 58.31258315, -110.78451131, -118.96147113, -45.38592168, 73.09200146, -155.47075078, 77.42505714, -43.76482999, 135.08638184, 151.75467034, -46.49201302, 10.42221058, -26.12604871, 81.67704348, 143.0331419 , 105.27922695, -47.71345026, 34.77580104, 49.31355215, 21.74695072, -163.73895396, 60.05739906, 61.7210206 , -143.0816816 , -40.44688699, -6.7546215 , -91.92527032, -54.33014363, -51.91060748, -46.34627835, 126.92661302, -137.8726063 , -167.2885732 , -133.27479998, -40.22995027, 125.07432747, -120.80409351, 4.28512566, 118.16641819, -0.67829328, 31.2006905 , 127.00602986, -11.45516764, -74.40207362, 174.38714379, 156.67052012, 12.09265635, 154.22087372, 114.53053343, -79.68078529, 1.56908592, 36.1894861 , -150.20761216, -77.29848002, -160.91243638, -83.24165831, 128.3480714 , -31.73527781, 128.17504492, 161.69552807, -140.56838573, -63.49704745, 49.59199319, 20.22512207, 153.02529511, -61.44835217, -51.70501977, -59.3900074 , 25.84238406, 93.03358712, 114.96926396, 43.36714436, -32.81364471, -9.83631674, -33.34474771, 33.34131388, 25.90511748, -126.20199727, -49.84590491, 126.06777098, -17.05717035, -131.61963307, -115.36209956, 167.74949805, 171.02593847, 26.00375946, 28.95162375, 137.42602675, -85.30688494, -153.75870201, -12.35705011, 125.43892798, 2.35970392, 13.79628016, 61.27153642, 121.92527351, 143.20849316, -135.94058901, 54.33770142, 64.05794144, -41.21106219, -123.22556666, 72.53074325, -11.15139136, -39.56657687, -62.0451653 , 10.31669922, -34.23097921, -147.03255946, 153.456624 , -122.76679011, -62.86187576, 177.55573804, -168.97390644, -174.80514675, -117.97506302, -45.87296731, -171.82615774, 104.86918596, -20.92314471, 54.58948848, -111.09830694, -65.81911328, 95.84336268, -52.50437208, 165.34157316, 132.34857055, 112.19456841, -120.4291425 , -176.51927415, 127.15919531, -18.65353394, -86.44333933, -152.5432261 , -84.01114068, -51.04014903, 4.33534553, 78.07576148, 111.16876051, 40.98330603, 153.88354804, 45.51561022, -44.12158672, 170.16638297, -49.12322165, -32.41016604, -111.09234466, -140.55760878, 153.19179416, 82.98068052, -50.19339045, 4.89742891, -94.38731043, -27.55486522, -132.84867021, -28.30803836, -144.00611904, 176.29619606, -80.35355868, -27.1840374 , 25.32781191, -131.02863816, 113.57951361, -152.66932213, -75.43460775, -1.31428547, -109.37913701, 114.97307717, 163.69015393, -164.37619969, 76.30754695, 147.56691161, -130.10068944, 98.56391664, -66.62536504, -177.29622295, -143.98166486, -153.93223609, -37.47742065, 127.69853409, 39.90201874, -55.14876814, 170.29658189, -7.82138413, 99.07104832, 24.98243808, 115.9697807 , -65.87143251, -164.50036776, 177.29137033, 4.91601624, -57.45233458, 131.57297956, 51.61221621, -34.67632694, 117.58755236, -10.63856477, 143.58521875, 178.14987525, 112.29102983, 97.85557574, 39.06265568, -25.44032102, -85.73050649, -101.94764597, -47.86965852, -120.02140664, 13.93274823, -1.76760578, 29.50329834, -150.46309537, -39.6287533 , 171.27154396, 19.23635069, -153.94543962, 1.68143519, -46.16803301, -107.98260854, 155.70396082, -56.54322753, -1.72360433, -153.10034586, 23.455608 , 174.85942125, 85.78930507, -172.21151846, -21.25127293, 55.75970212, -94.18240889, -178.58925287, 178.21360478, -65.84637888, -153.70583674, -122.61729973, -155.41292831, -82.89223267, -60.88975465, -25.29353769, -37.65379816, -175.18355451, 44.23792574, 144.25958088, 131.06484469, 160.22072505, -150.97348571, 89.15582766, -101.48705029, 127.41847991, -7.94530791, -127.45638931, -133.01895756, -170.93484449, 143.4109824 , -164.34984005, -125.81221693, 30.33959895, 59.64147154, 85.0961651 , 177.3380409 , 105.3291301 , -50.03540675, 87.2453927 , 70.55867896, 20.36401111, -93.21429524, 74.24393876, -3.38321887, 91.93614008, -90.62917587, -92.95353693, -48.12309758, -151.39704696, 40.68399095, -113.65381095, -6.85578523, 159.48775964, -103.17000299, 135.09545829, -179.1497536 , -69.56962444, 15.39666603, 22.50270505, 162.40957782, 144.64548254, -63.6068109 , -21.64997578, 114.67765102, -66.43628103, 48.29314388, 178.81145676, -171.5117816 , -89.07971221, 35.24346022, -144.66843485, 55.46978739, 117.98312086, 60.97999424, -164.17213439, 47.11162821, 120.99690395, -139.28274034, 174.66824526, 13.8297635 , 174.01140852, 85.26399927, 106.43073723, -43.14760762, 148.68772803, 118.96024557, 115.38860018, 10.27622279, -3.14552605, 17.18018702, 43.09352564, 171.27487599, -53.43559225, 23.64978235, 61.05430246, -89.02419395, 76.40074337, -128.78333421, -130.71898261, -3.61053349, -21.47798922, -10.31673467, -130.77851673, -157.86332443, 38.4428129 , -142.50157564, -86.53973529, 1.33823765, -134.14473772, -87.41065779, -151.52760531, -61.91451536, 138.61728047, 63.91745653, 93.59507787, 111.4238967 , 91.88479631, -158.00402626, -51.313304 , 92.38266381, -42.57825685, 33.96223678, 148.77975082, 51.22433604, 29.23261742, -117.43553044, 51.74163918, 128.58415375, -121.77283458, -29.67644459, -29.42495666, 62.64253671, 52.35415485, -52.99078939, -66.1721065 , 86.62732171, -130.43248063, 176.16682198, 83.21036611, 140.53422091, -73.21980927, 94.00051855, 141.17960127, 139.36870897, 168.56674064, 70.38721702, 120.60055947, -130.01714655, -6.81321488, -61.169542 , 48.49551257, -66.94520483, 35.15895379, 90.45371877, -143.1020803 , -77.33594971, 59.40879966, 137.50684143, -122.40036872, 61.42244239, 51.68355338, 56.71029828, -79.52829064, -136.63936698, 137.9489043 , -138.19988845, 65.83822671, 140.00049789, -129.46212615, 51.92484387, -108.21646711, 129.54300754, -44.13108951, -16.3019911 , -82.43132754, 173.31019013, 100.57348043, 133.25723896, 154.24670023, -58.34974587, -33.05974196, -100.73442958, 52.27011035, -146.01681546, 4.52521215, -132.67511746, -77.81731677, -8.23466569, 30.52475386, 72.60384987, -139.2996513 , 156.08111042, -65.03021612, -6.35743816, -171.22078267, 82.46646713, -88.06986452, 93.44966805, 107.80702025, 89.12790039, -41.99883314, -46.80706289, -147.02130653, -33.75216503, 103.10025633, 31.58987454, -108.89393125, 22.15575934, 138.61556316, -137.89733822, 162.78200285, -118.00003425, -98.32186743, 107.0864825 , 66.03564226, -150.2819491 , -148.14237324, 130.70677122, 33.12105323, 130.70841333, 152.15145112, -32.93053699, 10.17391452, -83.98599134, -141.78773725, -128.86592866, 165.57203834, -132.41862994, 147.34317913, -104.60010524, 125.50837344, -104.2316217 , 102.35420858, -165.34873719, 23.09041054, 151.75570486, -164.89557229, -144.36040033, -32.56424142, -109.66835183, 98.36159068, 92.40098225, -7.44627455, -10.2728754 , -15.23359751, -152.09847377, 124.16262792, 110.65663398, 164.04664251, 132.59396545, 90.14111435, 92.10460741, -47.70160417, -29.81877741, -18.47673065, -6.82894195, 116.94937021, -100.53728301, 64.91997012, 104.52393867, -75.06370192, 31.98823476, -10.14821654, -25.13764288, -136.33244486, 63.503448 , 137.91228288, 95.44379067, -67.29053619, 49.0500531 , -125.910875 , -168.47584405, 69.31438819, -68.12707788, 118.94877663, 165.40939764, 105.71000756, -130.09994725, -129.26499969, -71.65323676, -91.1615971 , 49.12040677, -127.70207213, 24.88412067, 147.74490546, 48.31522332, -63.29657072, -87.75507788, 166.73886279, -121.86476707, 154.05150756, 129.87787746, 130.5740098 , 56.795986 , 72.79095119, -167.8446116 , -144.09995333, -130.32598776, -129.09155075, 107.83946047, -55.50638548, -160.77829875, -177.53564762, -125.55206444, -50.98193295, 93.67099111, -99.64029416, -46.18075618, 46.23872875, -8.15580445, 57.24743482, 121.93707624, 178.12965562, -16.4238255 , 100.25279608, 107.73804455, 129.62789155])
    • (location, local_time)
      float64
      counts
      4.812, 4.207, ..., 5.238, 5.321
      Values:
      array([[4.81225579, 4.20724141, 4.34063877, ..., 4.42298981, 4.41200631, 4.75514249], [2.92951832, 4.03897211, 4.12054987, ..., 2.50591396, 2.62969441, 3.56034441], [4.3660348 , 3.44432132, 2.85860647, ..., 4.63940706, 4.33848381, 4.29951815], ..., [4.53917894, 5.12976627, 5.32374029, ..., 3.42129015, 4.13336022, 4.64065341], [5.197703 , 5.11205354, 5.9545098 , ..., 3.57835021, 4.1780514 , 4.77331352], [5.8634951 , 6.22655871, 6.59822089, ..., 5.24535465, 5.23757166, 5.320753 ]])

In the above:

  • latitude and local_time coordinates have been computed as requested.

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

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

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

Post-processing#

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

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

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

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

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

Renaming of Dimensions#

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

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

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

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

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

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

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

base rules

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

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

cycle rules

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

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

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

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

larger examples

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