<jupyter_start><jupyter_text>CoordinatesContainer for describing the coordinates of a PODPAC datasource.Coordinates are created from a list or dict containing BaseCoordinates1d objects (Coordinates1d or StackedCoordinates).Constructors:- `Coordinates()`- `Coordinates([coords1d, coords1d])`- `Coordinates([StackedCoordinates([coords1d, coords1d]), coords1d])`- `Coordinates([(coords1d, coords1d), coords1d])`- `Coordinates([array1d, array1d], dims=['lat', 'lon'])`- `Coordinates([(array1d, array1d), array], dims=['lat_lon', 'time'])`- `Coordinates([array2d, array1d], dims=['lat_lon', 'time'])`Advanced Contructors:- `Coordinates.from_xarray(xcoords)`: maps multi-dimensional xarray `DataArrayCoordinates` to podpac `Coordinates`- `Coordinates.grid(...)`- `Coordinates.points(...)`<jupyter_code>import numpy as np
from podpac import Coordinates<jupyter_output><empty_output><jupyter_text>Grid Coordinates<jupyter_code># coordinates specifying a n x n grid
grid_coords = Coordinates([np.linspace(-10, 10, 21), np.linspace(-10, 10, 21)], dims=['lat', 'lon'])
# get tuple of dimensions 
grid_coords.dims
# get tuple of unstacked dimensions (all individual dimensions)
grid_coords.udims
# ArrayCoordinates1d within the main Coordinates container
grid_coords['lat']
# get array of coordinate values
grid_coords['lat'].coordinates
# get ndims and size of coordinates
print(grid_coords.ndim)
print(grid_coords.size)<jupyter_output>2
441<jupyter_text>Stacked Coordinates<jupyter_code># stacked coordinates specifying n data points
stacked_coords = Coordinates([(np.linspace(-10, 10, 21), np.linspace(-10, 10, 21))], dims=[['lat', 'lon']])
# get tuple of dimensions 
stacked_coords.dims
# get tuple of unstacked dimensions (all individual dimensions)
stacked_coords.udims
# StackedCoordinates within main Coordinates container
stacked_coords['lat_lon']
# multi-index array of values
stacked_coords['lat_lon'].coordinates
# ArrayCoordinates1D within StackedCoordinates
stacked_coords['lat']
# Individual coordinate values within StackedCoordinates
stacked_coords['lat'].coordinates<jupyter_output><empty_output><jupyter_text>Stacked and Grid Coordinates<jupyter_code># stacked coordinates specifying n data points
hybrid_coords = Coordinates([(np.linspace(-10, 10, 21), np.linspace(-10, 10, 21)), np.linspace(0, 10, 11)], dims=[['lat', 'lon'], 'time'])
# get tuple of dimensions 
hybrid_coords.dims
# get tuple of unstacked dimensions (all individual dimensions)
hybrid_coords.udims<jupyter_output><empty_output><jupyter_text>Advanced Coordinate Types  Dependent CoordinatesDependent coordinates are coordinates defined at a set of N-d input indexes.<jupyter_code>from podpac.core.coordinates import RotatedCoordinates

lat = np.linspace(0, 1, 12).reshape(3, 4)
lon = np.linspace(10, 20, 12).reshape(3, 4)

# coerce into DependentCoordinates
c = Coordinates([[lat, lon]], dims=['lat,lon'])
c
c['lat'].coordinates
c['lon'].coordinates
# indexing dimensions
c.idims<jupyter_output><empty_output><jupyter_text>Rotated CoordinatesRotated Coordinates define a gridded coordinate system rotated around an axis.<jupyter_code># using upper left corner and a step/scale
rc = RotatedCoordinates(shape=(4, 3), theta=np.pi/8, origin=[10, 20], step=[2.0, 1.0], dims=['lon', 'lat'])
c = Coordinates([rc], dims=['lon,lat'])
c
x, y = rc.coordinates
ox, oy = rc.origin
cx, cy = rc.corner
figure()
plot(x, y, 'r.')
plot(ox, oy, 'bo')
plot(cx, cy, 'bx')
xlabel(rc.dims[0])
ylabel(rc.dims[1])
axis('scaled')
show()
# indexing dimensions
c.idims
# using upper left corner and lower right corner
rc = RotatedCoordinates(shape=(3, 4), theta=np.pi/4, origin=[10, 20], corner=[15, 17], dims=['lat', 'lon'])
c = Coordinates([rc], dims=['lat,lon'])
c
# using upper left corner and lower right corner
rc = RotatedCoordinates(shape=(3, 4), theta=np.pi/4, origin=[10, 20], corner=[15, 17], dims=['lat', 'lon'])
c = Coordinates([rc], dims=['lat,lon'])
# to / from gdal geotransform
rc = RotatedCoordinates(shape=(3, 4), theta=np.pi/4, origin=[10, 20], step=[1.0, 2.0], dims=['lat', 'lon'])
c = RotatedCoordinates.from_geotransform(rc.geotransform, rc.shape, dims=rc.dims)
c<jupyter_output><empty_output><jupyter_text>Polar Coordinates<jupyter_code>from podpac.core.coordinates.polar_coordinates import PolarCoordinates
pc = PolarCoordinates(center=[10, 10], radius=[1, 2, 3, 5], theta_size=8, dims=['lat', 'lon'])
pc
# indexing dimensions
pc.idims
y, x = pc.coordinates
cy, cx = pc.center
figure()
plot(x, y, 'r.')
plot(cx, cy, 'bo')
xlabel(pc.dims[1])
ylabel(pc.dims[0])
axis('scaled')
show()<jupyter_output><empty_output><jupyter_text>Coordinate Operations  Coordinate Indexing<jupyter_code>lat = [0, 1, 2, 3, 5]
lon = [10, 20, 30, 40]
time = ['2018-01-01', '2018-01-02', '2018-01-03']

c = Coordinates([lat, lon, time], dims=['lat', 'lon', 'time'])
c
# select subset of coordinates by index within dimension
# elements 1 and 3 of lat
# slice 0 to 2 of lon
# element 2 of time
c[[1, 3], slice(0,2), 2]
# works for stacked coordinates
lat_lon = (np.linspace(0, 10, 11), np.linspace(10, 20, 11))
time = ['2018-01-01', '2018-01-02', '2018-01-03']

c = Coordinates([lat_lon, time], dims=['lat_lon', 'time'])
c
# select the 1st and 3rd element from the stacked coordinates
# select the 2nd element of time
c[[1, 3], 2]<jupyter_output><empty_output><jupyter_text>Coordinate Selection<jupyter_code>lat = [0, 1, 2, 3, 5]
lon = [10, 20, 30, 40]
time = ['2018-01-01', '2018-01-02', '2018-01-03']

c = Coordinates([lat, lon, time], dims=['lat', 'lon', 'time'])
c
c.select({'lat': [1, 3]})
c.select({'lat': [1, 3]})
c.select({'lat': [1, 3], 'lon': [15, 25]})
c.select({'alt': [1, 3]}) # no affect<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1624383368569415, 'fraction_numerical': 0.04774489076814658, 'mean_word_length': 6.906685236768802, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '305273', 'license': 'Apache-2.0', 'n_tokens_mistral': 2250, 'n_tokens_neox': 2053, 'n_words': 531, 'path': 'notebooks/4-advanced/coordinates.ipynb', 'repo_name': 'creare-com/podpac_examples', 'size': '5676'}