Skip to content

Commit

Permalink
Merge 0ca7e5c into fcbb909
Browse files Browse the repository at this point in the history
  • Loading branch information
jmilloy committed Apr 20, 2020
2 parents fcbb909 + 0ca7e5c commit fc48ada
Show file tree
Hide file tree
Showing 34 changed files with 1,502 additions and 2,207 deletions.
42 changes: 18 additions & 24 deletions doc/source/coordinates.md
Expand Up @@ -32,13 +32,13 @@ Unstacked multidimensional coordinates form a grid of points. For example, the f
[.] time = ['2018-01-01', '2018-01-02']
[.] Coordinates([lat, lon], dims=['lat', 'lon'])
Coordinates
lat: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3], ctype['midpoint']
lon: ArrayCoordinates1d(lon): Bounds[10.0, 40.0], N[4], ctype['midpoint']
lat: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3]
lon: ArrayCoordinates1d(lon): Bounds[10.0, 40.0], N[4]
[.] Coordinates([lat, lon, time], dims=['lat', 'lon', 'time'])
Coordinates
lat: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3], ctype['midpoint']
lon: ArrayCoordinates1d(lon): Bounds[10.0, 40.0], N[4], ctype['midpoint']
time: ArrayCoordinates1d(time): Bounds[2018-01-01, 2018-01-02], N[2], ctype['midpoint']
lat: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3]
lon: ArrayCoordinates1d(lon): Bounds[10.0, 40.0], N[4]
time: ArrayCoordinates1d(time): Bounds[2018-01-01, 2018-01-02], N[2]
```

You can also create coordinates with just one dimension the same way:
Expand All @@ -47,7 +47,7 @@ You can also create coordinates with just one dimension the same way:
>>> from podpac import Coordinates
>>> Coordinates([time], dims=['time'])
Coordinates
time: ArrayCoordinates1d(time): Bounds[2018-01-01, 2018-01-02], N[2], ctype['midpoint']
time: ArrayCoordinates1d(time): Bounds[2018-01-01, 2018-01-02], N[2]
```

### Stacked Coordinates
Expand All @@ -65,8 +65,8 @@ The following example has a single stacked dimension and a total of 3 points.
[.] c = Coordinates([[lat, lon]], dims=['lat_lon'])
[.] c
Coordinates
lat_lon[lat]: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3], ctype['midpoint']
lat_lon[lon]: ArrayCoordinates1d(lon): Bounds[10.0, 30.0], N[3], ctype['midpoint']
lat_lon[lat]: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3]
lat_lon[lon]: ArrayCoordinates1d(lon): Bounds[10.0, 30.0], N[3]
[.] c['lat_lon'].coordinates[0]
(0.0, 10.0)
```
Expand All @@ -80,9 +80,9 @@ Coordinates can combine stacked dimensions and unstacked dimensions. For example
[.] time = ['2018-01-01', '2018-01-02']
[.] c = Coordinates([[lat, lon], time], dims=['lat_lon', 'time'])
Coordinates
lat_lon[lat]: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3], ctype['midpoint']
lat_lon[lon]: ArrayCoordinates1d(lon): Bounds[10.0, 30.0], N[3], ctype['midpoint']
time: ArrayCoordinates1d(time): Bounds[2018-01-01, 2018-01-02], N[2], ctype['midpoint']
lat_lon[lat]: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3]
lat_lon[lon]: ArrayCoordinates1d(lon): Bounds[10.0, 30.0], N[3]
time: ArrayCoordinates1d(time): Bounds[2018-01-01, 2018-01-02], N[2]
[.] c['lat_lon'].coordinates[0]
(0.0, 10.0)
[.] c['time'].coordinates[0]
Expand Down Expand Up @@ -143,10 +143,6 @@ extremely large number of points.

TODO

### Coordinate Properties

TODO ctype, etc

### Alternate Constructors

Unstacked coordinates can also be created using the `Coordinates.grid` alternate constructor:
Expand All @@ -155,8 +151,8 @@ Unstacked coordinates can also be created using the `Coordinates.grid` alternate
>>> from podpac import Coordinates
>>> Coordinates.grid(lat=[0, 1, 2], lon=[10, 20, 30, 40])
Coordinates
lat: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3], ctype['midpoint']
lon: ArrayCoordinates1d(lon): Bounds[10.0, 40.0], N[4], ctype['midpoint']
lat: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3]
lon: ArrayCoordinates1d(lon): Bounds[10.0, 40.0], N[4]
```

Stacked coordinates can be created using the `Coordinates.points` alternate constructor:
Expand All @@ -165,8 +161,8 @@ Stacked coordinates can be created using the `Coordinates.points` alternate cons
>>> from podpac import Coordinates
>>> Coordinates.points(lat=[0, 1, 2], lon=[10, 20, 30])
Coordinates
lat_lon[lat]: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3], ctype['midpoint']
lat_lon[lon]: ArrayCoordinates1d(lon): Bounds[10.0, 30.0], N[3], ctype['midpoint']
lat_lon[lat]: ArrayCoordinates1d(lat): Bounds[0.0, 2.0], N[3]
lat_lon[lon]: ArrayCoordinates1d(lon): Bounds[10.0, 30.0], N[3]
```

For convenience, a tuple can be used to generate uniformly-spaced coordinates. If the third item is an integer, it
Expand Down Expand Up @@ -197,13 +193,11 @@ from podpac.coordinates import UniformCoordinates1d, ArrayCoordinates1d, Coordin
>>> time = ArrayCoordinates1d(['2018-01-01', '2018-02-03'], name='time')
>>> Coordinates([StackedCoordinates([lat, lon]), time])
Coordinates
lat_lon[lat]: UniformCoordinates1d(lat): Bounds[0.0, 1.0], N[100], ctype['midpoint']
lat_lon[lon]: UniformCoordinates1d(lon): Bounds[10.0, 20.0], N[100], ctype['midpoint']
time: ArrayCoordinates1d(time): Bounds[2018-01-01, 2018-02-03], N[2], ctype['midpoint']
lat_lon[lat]: UniformCoordinates1d(lat): Bounds[0.0, 1.0], N[100]
lat_lon[lon]: UniformCoordinates1d(lon): Bounds[10.0, 20.0], N[100]
time: ArrayCoordinates1d(time): Bounds[2018-01-01, 2018-02-03], N[2]
```

TODO mixed ctypes, etc...

## Coordinate API

TODO
Expand Down
8 changes: 4 additions & 4 deletions doc/source/examples.rst
Expand Up @@ -72,8 +72,8 @@ Note the order of the ``dims`` keyword must match the shape of our data.
In [8]: coords
Out[8]: coords
Coordinates (EPSG:4326)
lat: ArrayCoordinates1d(lat): Bounds[40.0, 50.0], N[11], ctype['midpoint']
lon: ArrayCoordinates1d(lon): Bounds[-10.0, 10.0], N[21], ctype['midpoint']
lat: ArrayCoordinates1d(lat): Bounds[40.0, 50.0], N[11]
lon: ArrayCoordinates1d(lon): Bounds[-10.0, 10.0], N[21]
Create a PODPAC ``Array`` Node from ``data`` and ``coords``.
An ``Array`` Node is a sub-class of ``DataSource`` Node.
Expand All @@ -92,8 +92,8 @@ An ``Array`` Node is a sub-class of ``DataSource`` Node.
0.00474486 0.00650152 0.08999056]
...]]
native_coordinates:
lat: ArrayCoordinates1d(lat): Bounds[40.0, 50.0], N[11], ctype['midpoint']
lon: ArrayCoordinates1d(lon): Bounds[-10.0, 10.0], N[21], ctype['midpoint']
lat: ArrayCoordinates1d(lat): Bounds[40.0, 50.0], N[11]
lon: ArrayCoordinates1d(lon): Bounds[-10.0, 10.0], N[21]
interpolation: nearest
We've successfully created a ``DataSource`` Node that describes an 11 x 21 grid of data values with lat and lon ``Coordinates``.
Expand Down
39 changes: 21 additions & 18 deletions podpac/core/cache/test/test_cache_stores.py
Expand Up @@ -327,24 +327,27 @@ def teardown_method(self):
shutil.rmtree(self.test_cache_dir, ignore_errors=True)

def test_cache_dir(self):
# absolute path
podpac.settings["DISK_CACHE_DIR"] = self.test_cache_dir
expected = self.test_cache_dir
store = DiskCacheStore()
store.put(NODE1, 10, "mykey1")
assert store.find(NODE1, "mykey1").startswith(expected)
store.clear()

# relative path
podpac.settings["DISK_CACHE_DIR"] = "_testcache_"
expected = os.path.join(
os.environ.get("XDG_CACHE_HOME", os.path.join(os.path.expanduser("~"), ".config", "podpac")), "_testcache_"
)
store = DiskCacheStore()
store.clear()
store.put(NODE1, 10, "mykey1")
assert store.find(NODE1, "mykey1").startswith(expected)
store.clear()
with podpac.settings:

# absolute path
podpac.settings["DISK_CACHE_DIR"] = self.test_cache_dir
expected = self.test_cache_dir
store = DiskCacheStore()
store.put(NODE1, 10, "mykey1")
assert store.find(NODE1, "mykey1").startswith(expected)
store.clear()

# relative path
podpac.settings["DISK_CACHE_DIR"] = "_testcache_"
expected = os.path.join(
os.environ.get("XDG_CACHE_HOME", os.path.join(os.path.expanduser("~"), ".config", "podpac")),
"_testcache_",
)
store = DiskCacheStore()
store.clear()
store.put(NODE1, 10, "mykey1")
assert store.find(NODE1, "mykey1").startswith(expected)
store.clear()

def test_size(self):
store = self.Store()
Expand Down
2 changes: 1 addition & 1 deletion podpac/core/compositor/tile_compositor.py
Expand Up @@ -89,7 +89,7 @@ def tile_width(self):


@common_doc(COMMON_DATA_DOC)
class UniformTileMixin(podpac.Node):
class UniformTileMixin(tl.HasTraits):
"""DataSource mixin for uniform tiles in a grid.
Defines the tile coordinates from the grid coordinates using the tile position in the grid.
Expand Down
1 change: 1 addition & 0 deletions podpac/core/coordinates/__init__.py
Expand Up @@ -3,6 +3,7 @@
from podpac.core.coordinates.utils import make_coord_array
from podpac.core.coordinates.utils import make_coord_delta_array
from podpac.core.coordinates.utils import add_coord
from podpac.core.coordinates.utils import VALID_DIMENSION_NAMES

from podpac.core.coordinates.base_coordinates import BaseCoordinates
from podpac.core.coordinates.coordinates1d import Coordinates1d
Expand Down

0 comments on commit fc48ada

Please sign in to comment.