# 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))


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]:

scipp.DataArray (2.34 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))


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]:


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]:

scipp.DataArray (2.34 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]:


### 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(
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]:

scipp.DataArray (586.50 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
[-2685.88357732 5764.38832693 -384.05419595], [-1984.81551222 -1451.26779695 5877.41185931], ..., [-4262.94877647 -2150.22360291 -4218.22796761], [6316.53035286 -820.9087629 -131.12629194]
Values:array([[-2685.88357732,  5764.38832693,  -384.05419595],
[-1984.81551222, -1451.26779695,  5877.41185931],
[-4530.94927115,  3169.49074304, -3164.56444587],
...,
[-2572.86396663, -3159.00950441, -4898.02725189],
[-4262.94877647, -2150.22360291, -4218.22796761],
[ 6316.53035286,  -820.9087629 ,  -131.12629194]])
• (location, datetime)
float64
counts
3.657, 3.503, ..., 0.619, 0.242
Values:array([[3.65672404, 3.50315665, 4.58943503, ..., 2.69731269, 3.21000629,
3.22964436],
[5.67432934, 6.04131593, 4.84671921, ..., 6.1314319 , 6.52571224,
6.59655281],
[3.99496339, 3.91945609, 4.75807158, ..., 3.45695323, 3.40010027,
4.16049066],
...,
[4.09503714, 3.15655376, 3.06005714, ..., 4.79402296, 3.91558405,
3.78960743],
[4.13243143, 3.63441325, 3.80483276, ..., 4.93664686, 4.52001827,
4.55739284],
[0.53633371, 0.81414023, 0.46943021, ..., 0.96657629, 0.61886597,
0.24196094]])

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]:

da.plot(projection='3d', positions='location')


### 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]:

scipp.DataArray (1.69 MB)
• location: 1000
• local_time: 72
• latitude
(location)
float64
deg
-3.456, 67.298, ..., -41.460, -1.179
Values:array([ -3.45597762,  67.29817515, -29.78283243, -38.65622907,
50.15264293, -29.73683988, -15.33811453, -30.34771584,
-54.89587593, -31.10839004,  46.30923648, -70.86280508,
-57.98902594,  31.74441868,  34.66414438, -32.69381492,
-43.06272364, -55.73141648, -16.77683669, -10.88345416,
-41.00305286,  35.8678369 ,  28.27380339,  49.34516553,
-12.22672164,  40.02699439,  31.58944703,  23.21714219,
39.25883588, -23.89986581,  25.61775503, -48.55275711,
64.91043076,  21.10485372,  20.63213937,   1.53265356,
-17.08416104,  45.65523281, -13.60590767,  82.59512996,
-18.29124709,  40.56343023, -57.25258891,   1.39995989,
-41.39871588, -42.56534845,  31.306535  ,  18.15772304,
22.04162965, -28.0535587 ,  47.97054453, -11.29605972,
-43.17929578,  39.49103239,  46.38765076,  -4.53678698,
-37.54608395, -55.4340207 ,  -4.12727454, -39.527591  ,
65.26451584, -33.36295379,  42.2500128 ,  15.2649274 ,
-82.88916454, -39.86718783, -42.54370368,  41.31587046,
38.2486639 , -23.34421327,  38.54745121,   2.10574858,
42.10306942,   4.26488034,   8.98678019,  19.62880703,
-54.16724379, -47.18448077, -59.35178693, -10.78778303,
18.37194586, -44.87813884, -49.02725903, -16.56104665,
-58.94300887,  -1.55636205, -48.1152365 , -27.63199219,
14.14767448,  10.06031493,  19.07086451,  44.55933668,
-76.01204879,   5.09179659,  33.74279702,  40.44657557,
-44.02324243,  35.32591439,  -1.48555468,  37.51321805,
-40.64150594,  -9.65842753, -38.23863591, -10.11851134,
-35.72801684,  55.75074993, -19.64076244,   3.94827217,
37.85994446,  48.52148376,  15.99339887,  -0.59208317,
40.48402771,  -1.23875907,  -1.41144185, -43.92911572,
-3.07178246,  68.83022962,  12.17671944, -11.60354458,
59.34319266,  54.48264335,   9.30000452,  43.1272599 ,
-4.80896122, -12.68661642,  42.36020747, -24.63591501,
-46.2873341 ,  18.99503644, -55.59987155,   3.33526763,
-41.89556215,   2.25973133,  49.96078057, -32.78864056,
-7.40123208,   2.48937279,  -2.17959569,   3.39481365,
-31.6853141 , -37.8474184 ,  46.5886118 , -45.29304793,
62.96083642,  33.56251615, -14.82424623, -25.80837242,
82.26221977, -24.24599346, -39.52222319,   0.32757909,
-42.73923011, -60.48286455,  17.61972745,  37.67976194,
17.46865384,  -4.40196251,  21.33898464,  43.11166463,
-39.00466925,  -4.730662  ,  12.22999871,  47.63257985,
-41.91202071,   1.43748676, -20.3728713 ,  -5.00625994,
36.50769799,  28.60475121, -45.45304311,  -3.98420374,
40.44446539,  45.72165547, -15.01714353,  -8.27508878,
-58.27971444,  40.24787983,   9.12920661,   8.6731057 ,
30.52426908,  62.09801565,   5.48366955,   5.93560309,
-38.59701447,  37.76269857, -15.91119659,  -5.8530475 ,
-25.27062758,  43.86763083,  45.94599231, -46.12657668,
-36.94090621, -23.18480367,  26.50426693,  65.23596314,
-44.52251356,  -4.60554715,  59.1102581 , -38.36796099,
19.71791782, -70.19769643, -27.94100174,  52.56203121,
26.82979541, -10.02152238, -33.10364889, -55.42723127,
-12.98106343,   5.72565827,  28.23304776, -44.3453819 ,
27.46415341, -18.21681404, -66.66454887, -28.43400648,
29.41430551,  42.21094275,   6.14681187, -52.89940908,
-30.79150386, -10.69375638,  26.9504281 , -63.7245726 ,
-18.50071602,  35.6310264 ,  -8.79031204,  31.0277904 ,
-8.61268388,   5.86156797, -37.8615757 , -51.79401064,
-1.34368626,  51.03542061,  31.46008292,   9.78085828,
-36.56487682,  32.30151511,  72.04595467,  39.0156813 ,
60.73012847, -24.12979473, -28.85376742, -43.39369155,
14.16849453, -54.02532811,  40.41731255, -57.36530373,
81.08534602, -43.8327399 ,  27.36511244,  51.46416448,
-20.46685433, -66.22116932,   1.12333436, -40.18698309,
-12.71255316,  12.57922303,  13.77085787,  15.83642061,
-47.98377877,  -9.61851165,  -5.46230404, -17.4983442 ,
-14.12207584, -57.71842193, -43.17570376,  22.28310615,
58.92267227,  -6.75887897, -40.20191002, -40.9229734 ,
-2.53837983,  58.71921639, -27.26330412,  38.91610584,
18.40734647, -77.08804601, -46.43009405, -25.10062511,
54.04705697,  35.00190453,  38.84511213,  39.62968482,
63.85528886, -49.88673925,  66.17706977,  41.40579788,
46.32265827, -44.39221111,  15.27587371, -35.50667521,
64.6790268 ,  49.00305367,  24.71292258,  28.550425  ,
-39.46984842,  22.66784736,  -3.57981181,  14.92621656,
-28.88509972, -53.68629072,  25.17192261,  21.11834137,
-17.38080312,  -5.55529414, -27.57245368, -26.9513127 ,
61.0543869 ,  61.35230836, -39.72796174,  47.18268914,
37.87247235,  42.53288738,   7.44130776, -67.36814273,
-28.1417507 , -35.38919739, -29.52945354, -34.76178863,
-7.57275106,  27.29260138, -34.70848551, -28.6324829 ,
-19.9076033 ,  43.83575984,   7.0279153 , -60.77077833,
23.27793259, -26.15331305, -36.1097839 ,  34.80807827,
-42.92893353,  19.81046661,  -9.78543032, -55.15531918,
10.64971213, -11.45583477,  16.59921192,  34.71667744,
34.15780936, -14.53140607, -22.57794331,   5.73289457,
-45.32262832, -72.83839265,   2.14700641,  -8.82045882,
27.59957986, -37.55339307,   3.28112183, -14.95108254,
-18.10708499,  51.15295172, -39.49678171,  54.87645292,
36.65285562,  24.26582045,  36.10937634,  25.65512902,
-10.98028851, -20.50276087, -33.26511675,  -4.77216772,
47.36700138,  26.67887271,  41.25920814,  46.9888746 ,
65.53386372, -41.67257359,  17.84274062, -31.08558699,
8.70983316, -11.38480603,  52.30963882,  21.9736119 ,
-41.83851074,  37.86161789,  -3.98015135,  -0.2138704 ,
-40.48815615,  -4.27291742,  37.38677099,  43.58410838,
-42.78885124,  45.23092945,  15.66774315, -45.96604595,
49.06006694, -35.81609024, -11.93924636,  46.88444422,
12.72504883,  56.37643504,  38.10352064, -32.27902144,
-51.96605517,  23.97812546, -36.35136164, -10.76747206,
-63.39636322, -42.04714171, -51.4871308 , -64.36814351,
-39.74766652, -27.4060811 ,  20.86198247, -21.9485411 ,
28.08656914,  41.71341936,  32.78699537,  18.88780535,
-10.85274101,  48.48685399,  41.05340968, -24.32229912,
42.93558851,  80.62031736,  30.79622529,  18.00474468,
-42.03765947, -42.13363541, -21.80806801,  22.40641963,
-45.45634938,  51.16952452,  39.99589608,  45.71287688,
-57.10623971,  -0.67758895,  -1.22268321, -32.58268676,
14.96341513, -26.4725081 , -83.52750051, -19.64802818,
-59.8755851 ,  15.68123166, -64.52191775,  15.91404525,
29.32809623, -43.25928325, -26.16314014,  -8.18053283,
81.78259703, -13.95226181, -46.30987379, -12.37112806,
71.21700154,  49.82043233,  19.6180245 , -51.28014676,
2.3064576 , -28.27899208,   5.5872954 , -53.8575038 ,
-40.04495496, -64.40488747,  -6.10368479,  -7.63678884,
39.55678327,  -2.41950432,  26.94277774,  43.54538843,
40.31976189,  42.22101988,  40.38372333,  80.76487275,
-45.82504729,   9.1145224 ,  31.6307608 , -55.73031931,
-16.76386427, -38.27958622,  30.26546759, -41.84335751,
68.07325776, -13.41968979,  19.56821614,  -6.24159952,
27.70078326,  31.42966299, -25.81567142, -26.70132214,
25.34686627,   3.80482539,  41.67129522,  16.04416958,
16.70087401,  15.42152935, -29.3386387 , -57.66726695,
44.93026198,   4.21293601, -28.35322333, -45.72420958,
-9.6344821 , -12.74781886, -56.57919361, -31.93400306,
54.70500682, -56.4411967 , -32.70514095,  67.65714705,
-11.98594799,  57.74149138,  33.19922414, -37.81266086,
51.15547994,   6.59817379,  -1.22377273, -30.64289491,
40.65517216,  54.70338529,  52.56421124, -18.09029972,
-1.11837178,  37.76966404,  45.20816531,  28.91418525,
42.13709205,  52.77617095, -40.68577182,  19.3468949 ,
-44.72264154, -61.35874643,  42.76630424,  49.48914963,
-44.50916874, -49.92342968, -30.54133678,  18.98196442,
32.08618843, -34.76889515, -26.09318457, -33.49972184,
43.82511975, -37.14826114,  51.90971005,  -1.67915881,
28.60889314, -35.03395296,  19.64840831,  49.87761684,
-10.0548481 , -50.71223605,  -4.72227706,  -2.97199207,
-17.16014101, -35.08483934,  33.98391773, -20.94722345,
43.75028725,  45.4336301 , -24.33743556,  48.4328073 ,
-36.30221133, -33.86963151,  29.5706399 ,  62.07195946,
69.43224741,  -3.79598781, -76.31866257,  11.61875315,
-25.66598549,  23.67407453, -43.86811378, -65.57290764,
-22.36250472,  18.60781626, -39.87059918, -38.18435305,
-34.24399368,  22.92839293,  35.281582  , -35.42697924,
-29.18021122, -39.50316839,  13.82626219,  24.84442914,
55.48820084, -43.77356234,   6.42682494, -29.58467595,
81.27008849, -39.62027707,  55.71327134, -68.06730419,
-40.94831637,  37.81944659, -19.53735095, -18.98271548,
-37.05876282,  32.40273204, -41.15993451,  43.36689979,
-49.06054821,  63.99571987, -36.94506025, -57.70590876,
41.35888815, -57.5781973 ,  38.2264    ,  20.74611837,
38.50983989,  43.31464268,  -7.42928125, -14.48313086,
-57.85788431,  58.02319337,  11.9113112 ,  -4.15593946,
-55.05448311,   8.46436412,  13.51925686,  27.61595694,
-29.32667648,  27.35114497, -37.76809328, -21.26434355,
-46.73383621,   6.60867563, -39.42501156,  -9.4464586 ,
-52.23307775,  11.94447075,  18.45262352, -54.30871843,
-8.16630019, -17.6886211 ,  -1.83506439,  -3.73873676,
70.75410166, -23.51686015, -15.78689792, -25.4730499 ,
44.0907517 , -42.58011536,   2.19731386,  68.96441769,
-35.1243705 , -16.44837221,  40.00299508,  32.66935613,
-67.52193816, -43.66596705,  -6.13876714,  29.19238298,
-30.21014604, -42.46882045,  45.46965166,   6.85692866,
-20.4164212 , -80.16271428, -83.58048292,  17.48837963,
11.51710026, -37.04826558,  53.5668228 , -55.49430966,
-42.25770059,  49.09083414, -17.97654996, -66.75950449,
57.4120325 ,  37.4329139 ,  28.10827348, -28.69909105,
-19.43892261, -38.61687566,  39.45984158,  14.85865951,
30.34914712, -19.82558646, -18.70237737,   6.0225554 ,
20.97676839, -18.04115838,  27.29867625, -35.97626451,
-46.91259639,  51.6399537 ,   9.12370349,  15.57349623,
4.49132485, -50.19618865,  64.03776982, -61.74971264,
-21.63762458, -16.19345162,  53.34750588,   2.37158789,
-6.72377596, -34.46465957, -42.09370673,  44.53306169,
53.74716089, -58.61249415,  49.0657043 , -37.07764474,
-24.4901343 ,  44.50517183,  33.80403905,  24.44726111,
-7.10616769, -34.07759863, -12.62566348,   7.83889082,
28.53209027,  25.81987558,  -5.99518561,  11.26136079,
-59.72955488, -36.19060771, -29.35986363, -22.24334706,
-56.78127001, -29.16328264,   4.24904029, -55.82935091,
-28.24116228, -30.44363937, -30.73996557, -58.30189025,
-63.61302028,  14.17963932,  46.8668976 , -45.72028582,
2.55506786,  66.77471599, -24.93021774,  28.20074295,
-2.84579411,  72.56885433,  18.1741952 , -25.08142943,
-36.0665845 , -69.89568493, -27.65075056, -41.72795463,
-43.70670412, -36.56945414, -45.37403995, -36.98896862,
2.87364773,  53.90149309, -37.87955062,  44.83559017,
17.74140723,  43.47179462, -28.72626321, -34.74527108,
38.65428881,  33.50133826, -38.28276072, -67.96403443,
-6.20333797, -38.44220779, -30.39859971,   1.1698025 ,
-10.1701336 , -46.89346778,   1.37023932, -34.78923616,
55.17941636,  -1.78810866,  10.03442994,  22.38436428,
-23.95703484, -29.94874853, -46.1716045 ,  36.26699129,
-69.87208653, -60.08129607, -45.40823726, -42.95406988,
26.90635789,  22.80521183, -51.80388325,  42.57176431,
31.05523343,  36.09684744,  12.06564913,  25.97766151,
-41.07095764,   8.54745327, -15.29230337,  44.81294937,
60.43434218,  46.30467631, -40.6640038 ,   6.05118425,
-9.93472378,  13.52682551,  56.82914678,  35.78848925,
-59.23710084, -42.96530712, -29.79573273,   8.74722932,
-38.61273291,  61.63676483, -15.121231  ,  61.05379933,
-77.25507428,  25.48526451,  58.26851123,  17.16663892,
13.78532839,  32.13135   , -33.48164502, -31.10259727,
50.23832014,  23.82177466,   2.65903921,  -0.20874327,
74.84571056,  31.05034021,  68.70219073, -25.70579608,
-19.64271054,  54.18707505,  46.91081086, -78.39456827,
-15.7827759 , -25.04798692,  49.24098276,  -1.8918037 ,
-14.75761378, -20.84489742, -68.84100493,  31.42901626,
-33.41191465,  31.07417708, -19.66365239, -20.27898061,
-35.38595839,  43.71792317, -33.69837955, -48.88688436,
8.93459327, -33.84045547,  52.79683219,  48.04277198,
-25.67311095, -38.4163963 ,  21.27170633,  26.64836488,
-8.98928886,  34.95174035, -31.57466556, -32.65569186,
35.19806769, -21.77026217, -46.60751025,  17.76003626,
48.47258717, -73.98563637,  53.76639174,  29.28185449,
43.40630406,  33.80117048, -42.42726141, -57.8913572 ,
-19.68167986,   3.41644339,  46.17395898,  11.86300761,
21.39023036, -40.93102626, -68.41982335,  37.37397784,
46.83820527, -29.96146159,  26.15062238,  31.57813036,
-11.5860174 ,  33.89960592, -30.38893001, -61.13988077,
38.49175072, -21.97326293, -72.96380897,  11.46696406,
-41.80938486, -60.07440461,  -1.6833393 ,  22.58518267,
-10.13418699, -42.3201724 , -54.09217272, -28.21982236,
-12.19479235, -33.33464715, -24.82866321,  17.71296479,
16.84946067, -36.17786249,  -5.77994551,   2.24858415,
50.52889651, -31.68878195, -20.63925327,  24.67311576,
-46.61687989,  33.48606246,  48.84428815,   9.60876196,
27.96077002,  30.40712926, -56.23571483,  20.43294346,
-37.29187314,  65.7676055 , -68.42400355,   5.77311937,
17.95922735, -35.86222232, -44.64366604, -10.84378707,
-37.88223207, -24.50313512,  65.38654157, -34.28376005,
49.31532337, -16.21755936,  31.40665579, -19.97014548,
-34.73039748,   5.60439452, -17.34790608, -42.00623515,
-34.68812128,  62.32986784,  38.92901176, -28.31816627,
-38.58738434,  19.7048018 ,  -6.19083178,  12.55365423,
51.7921728 ,  34.60519228, -26.99104609, -44.65454452,
15.08606628,  -5.34755576,   9.71130403, -14.93315296,
-15.28455532,  24.02427694,   0.86875135, -86.49613781,
-16.84199406,  20.8485293 ,  46.1905948 ,  39.24123733,
-36.71088124,  17.981512  , -47.9901478 , -15.88877093,
6.81729356, -32.02411259,  35.37550006, -46.72950965,
41.0249512 , -28.71557001, -50.75019967, -24.69597427,
-50.93743378,  -1.12923774, -37.10607026, -57.93840522,
-52.83618156,  59.80063105, -52.20433641,  40.69914643,
-43.84841053, -17.04749213,  -4.36923074,  -5.71584561,
-4.44838779, -43.55883286, -40.87585695, -20.676778  ,
-11.80819154,  -1.87858211,  38.10436799, -22.52730422,
-5.74010666,   6.70928475, -10.88018575,  33.81673317,
35.42628845,  73.90016592,  42.6920442 ,  71.08323556,
48.15404803, -50.24628634, -41.46009447,  -1.17933035])
• local_time
(location, local_time)
float64
s
4.320e+04, 4.680e+04, ..., 1.080e+04, 1.440e+04
Values:array([[43200., 46800., 50400., ..., 32400., 36000., 39600.],
[72000., 75600., 79200., ..., 61200., 64800., 68400.],
[50400., 54000., 57600., ..., 39600., 43200., 46800.],
...,
[75600., 79200., 82800., ..., 64800., 68400., 72000.],
[68400., 72000., 75600., ..., 57600., 61200., 64800.],
[18000., 21600., 25200., ...,  7200., 10800., 14400.]])
• (location, local_time)
float64
counts
3.657, 3.503, ..., 0.619, 0.242
Values:array([[3.65672404, 3.50315665, 4.58943503, ..., 2.69731269, 3.21000629,
3.22964436],
[5.67432934, 6.04131593, 4.84671921, ..., 6.1314319 , 6.52571224,
6.59655281],
[3.99496339, 3.91945609, 4.75807158, ..., 3.45695323, 3.40010027,
4.16049066],
...,
[4.09503714, 3.15655376, 3.06005714, ..., 4.79402296, 3.91558405,
3.78960743],
[4.13243143, 3.63441325, 3.80483276, ..., 4.93664686, 4.52001827,
4.55739284],
[0.53633371, 0.81414023, 0.46943021, ..., 0.96657629, 0.61886597,
0.24196094]])
• 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-02T12:00:00, 2021-06-02T13:00:00, ..., 2021-06-05T03:00:00, 2021-06-05T04:00:00
Values:array([['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-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-02T14:00:00', '2021-06-02T15:00:00',
'2021-06-02T16:00:00', ..., '2021-06-05T11:00:00',
'2021-06-05T12:00:00', '2021-06-05T13:00:00'],
...,
['2021-06-01T21:00:00', '2021-06-01T22:00:00',
'2021-06-01T23:00:00', ..., '2021-06-04T18:00:00',
'2021-06-04T19:00:00', '2021-06-04T20:00:00'],
['2021-06-01T19:00:00', '2021-06-01T20:00:00',
'2021-06-01T21:00:00', ..., '2021-06-04T16:00:00',
'2021-06-04T17:00:00', '2021-06-04T18:00:00'],
['2021-06-02T05:00:00', '2021-06-02T06:00:00',
'2021-06-02T07:00:00', ..., '2021-06-05T02:00:00',
'2021-06-05T03:00:00', '2021-06-05T04:00:00']],
dtype='datetime64[s]')
• location
(location)
vector3
km
[-2685.88357732 5764.38832693 -384.05419595], [-1984.81551222 -1451.26779695 5877.41185931], ..., [-4262.94877647 -2150.22360291 -4218.22796761], [6316.53035286 -820.9087629 -131.12629194]
Values:array([[-2685.88357732,  5764.38832693,  -384.05419595],
[-1984.81551222, -1451.26779695,  5877.41185931],
[-4530.94927115,  3169.49074304, -3164.56444587],
...,
[-2572.86396663, -3159.00950441, -4898.02725189],
[-4262.94877647, -2150.22360291, -4218.22796761],
[ 6316.53035286,  -820.9087629 ,  -131.12629194]])
• longitude
(location)
float64
deg
114.983, -143.826, ..., -153.234, -7.405
Values:array([ 114.98289461, -143.82627988,  145.02643225,   42.14221229,
86.32883372,  -52.21485617,   34.97234239,  134.31548838,
-91.35844117,  -52.74084666, -136.3571875 , -117.02141137,
-18.76571831, -146.97021616, -136.38436748, -149.51461632,
-49.95326148,  155.87383971,  -44.56087898,   83.3186463 ,
-43.75673318, -107.12395141,  161.93355468,  147.97817643,
-123.35960438,    5.62740742,   65.77107207,   34.92382923,
-154.29387614,  -37.9651545 ,    8.23805868,   66.89070177,
-86.49397933,  -15.2587959 ,  148.01078823,    4.15364916,
144.04943445,   10.37847468,  -61.68848133, -146.45453435,
104.00228214,  146.42538293,  175.67359062,  -27.14013821,
87.3984282 ,  167.19264741,   -8.46477246,  114.00219278,
91.06640497, -113.82360791, -116.21842249,  115.37207663,
-178.20611388, -144.05942298,  129.09745088,  -22.08485509,
133.3307856 ,  131.27987532,   38.17282057,   83.42595701,
-137.08575083, -113.33798295,  -12.4168061 , -133.12330659,
113.63460274,  139.16961021, -171.33424807,  126.65291098,
65.54481634,  -47.18022356,  -30.61673832,  -31.02952138,
-7.80896866,  117.97060342,  179.56144397, -143.07734229,
-77.29938362,   44.87833401,   27.99671371, -171.8351923 ,
159.59238074, -132.78897545, -154.12227836,   95.10091631,
177.61484725,   44.4815379 ,   25.91823754, -135.53626887,
160.21371602,   36.27871217, -151.97409156,  178.06762995,
69.86349437, -126.27867237,   -8.70418286,   27.34156783,
84.73164288,  128.51226718,   93.36967321,   32.38244747,
157.7050708 ,   39.54016752,  -38.24657868, -116.08499345,
46.37247832,  -25.33550324,  144.85134213,  100.99786898,
140.20130024,  159.93844191, -169.14248942, -150.99961543,
-138.73693981,  -43.74015439,   34.61317316, -179.06555099,
-150.71523595,  -81.39109237,   80.13668921,  177.00398284,
5.67376022,  -14.2667459 ,   -2.34791716,   37.00576467,
-34.80752972,   71.29353378,   36.64048488, -108.0119637 ,
28.27498661,  121.59638314, -129.40713329,  153.47615233,
25.67498248, -112.40842814, -168.4245621 ,   50.73090141,
-28.02131652,   45.75484025,  -52.63386218,   38.36724942,
125.44877616,  137.28779983,   77.73220145,  171.20112839,
-130.89843916,  -46.92139611,  123.76725096,   20.29773748,
-45.76349942,    9.24551867, -102.47812594, -117.79652462,
74.44439023, -159.25375799,  -35.89898271,  176.10515986,
75.07344395, -122.58499607,   83.52949529,  -55.02483214,
-131.99846189,  -29.840165  ,  109.58570656,  107.45076652,
154.95949121,  -53.61450088,  124.37378373,   75.46497187,
140.09050973,   86.9386483 ,  108.1146455 , -122.19668037,
-105.59115011,   88.4639003 ,  -73.7852843 ,   90.98877394,
-13.78299751,  -65.02768028,   36.72370911,  -45.63329108,
-140.30155826,   89.68747156,  -44.23750244, -122.96816659,
-32.95562056,  -40.83383395, -136.20480502,  148.40676118,
-169.58770984, -152.16853546, -120.99086767, -159.08348382,
71.73094286,  142.15210023, -159.87740347,    7.57093695,
-100.11914917,  -75.84425805,  -66.00388739,  -34.32864165,
-20.47371002, -129.10501417,  145.1736645 , -114.59314567,
132.34982949,  -62.8030887 ,  -56.69791866,   20.30727252,
-77.71582182,  -14.30098232,   48.84936523,  -77.05387165,
-41.69701599,   84.54061319,   53.10272266,  109.35088403,
25.76670668,  -94.36424914,   35.72853357,   46.05515212,
42.41414626,  -85.6357622 ,  128.66479016,   68.92247818,
55.54400138,   69.33719614,  132.90018871,  114.40538097,
-34.91984403,  -16.63449208,   76.30265562,   92.4623453 ,
-63.63827933,  -32.28320148,   57.28790612, -108.25920024,
-141.92544018,  155.25346018,  -83.72182974, -102.83440887,
-119.42136556,  123.89166826,  144.90296894,   69.68470508,
147.43594189, -163.20134754,  154.34704239,   46.71627908,
-15.35942119,  158.12161186,  -59.13746913,  168.67427945,
134.12639835,  161.90892734,  -21.22379511,  124.31212666,
54.6842836 , -156.46725653, -130.45074255,  163.78171987,
25.38094898,  138.02225051,  -51.84394946,  115.73727729,
-100.0357475 ,  -22.76046257,    9.16520319,   96.73066659,
-27.19428511,   82.06917843,   85.0943579 ,  113.49118139,
139.55496657, -166.01349177, -138.88051532,  -90.91362544,
-124.71549106,   12.14139772,  165.43373245,   -0.64894632,
-114.36428821,  -53.53977941,  137.85305074, -166.74072248,
91.60839397,   -1.94543636, -134.54866791,  128.71779075,
32.5134856 ,  -64.06153613,  -49.08861014,  -36.58968549,
133.26223584,   66.4896142 ,  -99.54941836,  -37.02822966,
-161.26708006,  -83.88084413,  116.22509305, -134.14027497,
80.35096793,  142.77288254,  -47.46757516,  -99.94705978,
-84.14799417,  100.76639378,   82.34419943,  166.8371291 ,
-143.20779057, -168.08437649,   -1.1648135 ,   17.90157068,
168.00245631, -114.07915415,  -97.58009848,  -91.31105409,
-26.78406211,  -33.02507719,  -32.29253802,   36.25524875,
-77.78579756, -165.79387344,  -47.31935388, -129.40669786,
-81.2618799 ,  154.36910548, -148.64249143,  167.6184103 ,
-109.74812905,  -47.12403246,  -19.94283274,  131.78293746,
151.10213769,  -41.47864586,   31.03853065,  173.46229334,
-161.65081934,  173.79977807,    2.18935293, -163.45973127,
-11.59732644,  125.52733151,  -61.15177828,   15.4718271 ,
14.14245185,    8.18539071,   50.88345098,  129.27326786,
143.55053923,   49.4419185 ,   99.92300279,  118.19769563,
-48.44744018,  -49.07062615,  -54.72410784, -148.66787737,
176.68895271, -138.81316099,   29.8171565 ,   92.31614263,
-47.588434  , -117.52095067,   13.26119264,  -38.25106605,
52.15162326, -153.54765827,  167.01085536,  -14.69370087,
-12.32618621,   16.56789828, -166.27042521,  130.11752375,
39.30444551, -134.08796278,  -35.19382237,  -68.63499701,
-64.57761903,  -11.31195498,  126.69537898, -129.27297298,
-99.63688775,   39.37736089,  -76.08482812,   26.89073298,
117.71268383,   82.34770761,  -46.64724005,  -85.9389749 ,
156.46354437,  167.58095882,  142.37300398,   65.17712935,
140.73053544,   53.40085606, -121.20929723,  -82.68720143,
-116.21888531,   77.97374116,  142.46481362, -172.67044201,
167.94806234, -156.96853701, -105.5997948 ,  166.69644852,
2.60146651,   90.45644443,  -30.6056557 , -115.04097112,
133.14266534,   31.14793138,   76.46096308, -162.09946972,
-11.83828333,  -25.19801805,  -76.3506694 ,   26.12068115,
15.68601328, -145.00004748,  176.66713818,   27.32532496,
-147.36389441,   43.23908162,   58.27145579,  -90.37366801,
-169.9598912 , -121.91830604,  -59.41142387,   78.65318665,
-99.20566212,  -76.37829295,  -69.80503116,  -14.10665163,
129.68627346,   47.97810333,   11.39527824,  -30.00609511,
68.17025924,   -3.64547656,  120.50833878,  136.82448245,
90.70928362,  -21.10374037,  -40.17092614,  -48.90819811,
-23.58723421,    9.55687453,   12.98614133,   36.27778164,
65.1991557 ,  -48.76950182,  -19.36694973, -134.17364731,
73.1731659 ,    2.81578742,   29.37920315,   12.05218114,
-18.07375579,  -17.53388178,   44.32755452,   30.4308561 ,
-112.08715448,   99.69799302,   91.27986914,  101.75739839,
99.34397889,   -5.30422551,  -65.31761238,  -32.14120022,
21.3058202 , -173.12820041,   48.04211577,  141.71387738,
-45.51442696,  143.46114515,  -14.09489858, -145.75386088,
163.3592093 ,  117.4775535 ,  -65.9603653 , -166.40965594,
-30.57267425,  136.72542916, -125.40077805, -146.38378636,
-117.14521854,   61.06153211, -144.07428546,  -99.47997589,
-117.71292295, -124.92371721,  -61.9168856 , -151.95743587,
22.26866518,   48.2265289 ,   51.44454868,  -21.62109199,
85.98157076,   71.30626497,  178.64733004,   53.5757105 ,
-36.31611305,  -82.6928046 , -145.53607885, -115.35350344,
-136.2885176 ,  -23.20938315, -121.4923033 ,  -80.61249934,
49.77942015, -133.11855185,   60.60226732,   46.25636368,
-7.68748765,  101.57500176,  -52.98568497,  161.04308153,
-147.40656698,   24.86289354,  -33.11624091,  -53.58328813,
-125.67795998, -145.00877522,  -89.59048115, -133.25337953,
-123.05638282,   72.0558072 ,   83.20619869,  171.47787495,
-166.49447062, -156.43028561,  -24.69830326,  -78.98070589,
-168.13281011, -150.26572037,  -48.73569871,   84.47016929,
-110.7736375 ,  -65.34437914,   87.20431123,  142.2647581 ,
178.46996964,  168.20461765, -177.37676424,  -37.02546426,
-70.74274104,  -61.02696321,  -69.6984034 ,   30.23622604,
-172.58404516,   55.66887171,  -43.1869266 ,  -58.57335528,
69.42950929, -135.7383348 ,  150.95725019,  136.77669797,
-47.4687729 ,   58.41161509,   41.68454873,    2.43526564,
-111.3824039 , -124.96774429,  113.56415158,  104.01547989,
126.65684121,  -44.96223994,  -35.3845887 ,  -76.4981255 ,
74.9733648 ,  -18.32844743,    4.104605  ,  137.50838986,
-44.04099841,    4.73287031, -114.21662869,   32.82551095,
48.73524281,  -46.61881916,  117.2839007 ,  113.83593477,
1.63009327,  101.64774019,  176.38880823, -123.00978747,
38.37713595,  152.00954123,  -95.28527183,  116.49234611,
50.09036122,  -61.5255263 ,   84.43178684,  168.83099415,
167.69568701,  -70.25255673,   52.39642504, -123.22031892,
32.57405619,  151.87253044,  -41.58258594,  155.72069078,
-129.14432439,  -23.82619769,   -5.44845592,  174.2282399 ,
-138.40115059, -155.48525028, -134.28652869,   75.96168916,
-152.48977397,  -42.78310637,   57.21719532,  128.20138524,
56.8741927 ,   33.59656478,  -79.50187733,  117.43838286,
176.29147737,  -19.50768413,   21.696571  , -123.16842798,
142.50115002,  143.31014873,   34.65918841, -158.37631251,
-135.44477992, -108.99681026,  175.40083217,   80.42158888,
119.41845478, -130.15946463,   45.09487366,  -89.84160453,
121.12970604,   21.07104406,    0.77323704,  114.61483638,
-179.79657106,  -46.35947727,  130.68420925,   35.49091622,
-160.75949722, -149.11634349, -167.02534724,   11.05785878,
-142.89762067,   64.47434162,  -81.51524283,  -59.69468165,
48.00037898, -137.47031214,   35.61426108,  120.1246082 ,
-10.77523732, -117.50595732,  -48.3059614 ,  -50.43801135,
55.06893857,  -46.34467339,  106.19855202,   79.63177736,
14.33498343,  156.48580987, -164.95254912,   74.58905691,
76.36149999,  -29.34701307, -137.36986076,   56.81379697,
-146.88987781,  -49.44871785, -121.30973595,  150.86628471,
86.16964097,  -72.59642676,  -18.26191449,  118.96313801,
66.91946301,  -44.72993648,  -41.63842264,  152.6479733 ,
-38.55452074,  -21.80324981, -128.79621099, -174.97400595,
2.39595695,  -10.65284931,   -3.92372992,  -26.49167737,
-170.89049742,   72.81077913,  124.09188313,  -62.73983032,
-169.98356787, -115.88285973,   84.26755993,  123.93288443,
74.88096956, -168.72277222, -174.89471848,  -44.51553135,
-149.03559127, -121.45352727,   41.50511696,   10.79234112,
57.22409798,  136.16669782,  111.08624201, -166.64043919,
56.99327389,  -57.07836551,   36.85002497,   48.10271176,
155.34310104,  -49.75333678, -124.61914847,  117.0358803 ,
166.19826298,  137.25880881,   28.32315124,  -31.46403579,
-52.02456451, -163.34849599,   60.81021307, -103.03713596,
-19.68789284,  -31.67476835,   14.4809156 ,  133.65292767,
-116.67974452, -100.19402696,  159.21291576,  -43.88422476,
21.24325803, -154.94061155, -141.1154254 , -136.8334099 ,
47.18710637, -102.04869478,   28.6212937 ,  119.49920301,
-25.11422392,  159.99304675, -101.47108361,  -40.52639165,
42.64505216,   65.53990312, -151.310752  ,  -58.56781736,
-144.54258661,   -1.42314682,   26.35779964,   70.41272816,
-91.09648492,  -72.570609  ,  -72.60063868,   42.67165625,
136.28448721,  -38.9610031 ,  142.14752776, -116.13334218,
74.69433828, -135.78883218,  170.26543863, -124.02680178,
-40.18922007, -154.96311401,   61.0217453 , -122.49694481,
8.19751378,  -82.07170993,   90.83887239,  140.90356857,
129.83343258,   94.88777371,   64.85149555,   90.60109587,
-17.74248993,  -52.52994429,  145.90102118, -169.68129057,
47.03281079,  124.51258561,  126.04162373,  -19.32944238,
158.9687318 ,  -34.90817879,  -84.95411729,   81.40602022,
-21.03263236, -120.31788844,  -56.45652148, -135.7404779 ,
38.3675201 ,  135.64930172,  143.40848736,  -84.90773353,
159.71672517,  127.89679244,   12.3136795 ,  -48.46224354,
-140.15500335,   11.19921303, -150.78736183,  -78.11327087,
-65.57043163, -132.04383116, -114.5135913 ,   29.25409396,
11.13706311,  -33.36684324, -164.19423795, -142.60393336,
16.92087659,   73.71968915, -130.84603133,   96.38561634,
100.1023097 ,  -18.82670503,  120.64847442,  101.90679935,
-114.94856261, -113.80981894,  131.42689293,   91.26003857,
-144.01928498, -109.42744317,   42.72085737,  124.31732125,
142.8023833 ,   32.72106702,   18.89767899,  154.567878  ,
22.40073539, -176.9745615 , -130.82692041,  -97.6899324 ,
113.7738823 ,  -48.38919891,  -36.38243397,  138.75042511,
-38.35066496,   48.7102096 ,  110.63228432,  125.56281183,
13.18563468,  -19.45722528,  -41.57704829,   -9.67275133,
-128.91799851,  150.56600843,   19.77424064,  -29.31722537,
51.93472778,  -71.6115546 ,  138.68577002,  -23.94322474,
23.71723602,   78.00803037,   23.98870015,  127.24040898,
-139.9346227 , -137.12693222,  116.55095079,  -55.19016978,
41.63397753,  146.41777536,   89.01104618, -142.71472598,
-61.80388654, -154.77696718,  -22.02662102, -135.54098009,
81.40473323,  152.63252499, -121.38596952, -175.19371113,
52.40079747,  132.80440505,  -44.06184873,  -81.47954367,
58.30693119,  159.52467657, -162.78101245,   -7.83258364,
91.5839112 ,  -52.70537131, -110.26699162,  -49.83849213,
-60.80918755,   92.59917427,  -52.33499301,   82.7981153 ,
94.25554   , -116.29706793,   31.39142993,  -18.25311832,
-104.50926646, -169.83752126, -126.41061471,   43.23690543,
-125.56932719,  164.97097055,   80.29243953,   -9.96285054,
106.05263221,    7.82750298,   93.42180057,  -26.73893669,
19.42239946, -115.36453943, -109.77224699,  119.36828288,
78.43818987,   38.94622044,   49.09109958,   71.77471207,
33.06307837, -117.94338399, -120.3006782 ,  143.94006551,
79.42089678, -120.79393697,  133.57129398,  153.63780581,
-92.03400297,  106.47376838,  179.2944291 ,  169.97215856,
-155.66755816,   66.76002635, -179.36194239,   57.21638741,
-58.97559732,  176.6735722 ,  162.11113517,  -41.30873632,
112.00051603,   86.02490626,  -23.89975137, -120.41650718,
-178.11519389,  140.99142741,  -14.56003771,  147.23170952,
116.69931348,  144.17663602,  139.50137309,  -40.03813408,
-49.3581193 ,   40.05911916, -109.49081776, -115.38698699,
92.03011108,  -21.79580383, -157.42028704,  -59.56129253,
178.84847187,  112.73929857, -106.81230403, -121.59362655,
179.21327459, -138.51816447,   18.2521947 , -127.8480409 ,
-115.02492816,  151.35704112,  -47.74870878, -113.63189045,
-147.28117311, -164.23141125, -157.9936701 ,  108.74056449,
-42.59308848,  165.52306924,  -22.86091108,  -25.17739137,
120.976114  ,   82.25121699,   52.3575624 ,  -81.85262603,
75.74533706,   12.43614249,  -68.54204101,   40.2249648 ,
118.54910828, -168.42449033,  148.89467224,  152.44569604,
-174.28832256, -128.77360407,  133.36980303,  141.58138312,
-41.12885807,  135.29098554,  142.38421776, -144.36449293,
75.62742909, -129.16118824, -153.23370599,   -7.40476968])

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])


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.plot(resolution={'y': 36, 'x': 24})


## 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.

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.

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.

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