Skip to content

Commit f1dd82c

Browse files
assorted cleanup ...
1 parent ccb6428 commit f1dd82c

8 files changed

Lines changed: 15164 additions & 9491 deletions

File tree

.github/workflows/conda_test.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.gitignore

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# generated test files
2-
*noncompliant_sgrid.nc
3-
*sgrid_deltares.nc
4-
*sgrid_deltares_no_opt_attr.nc
5-
*sgrid_roms.nc
6-
*sgrid_wrf.nc
7-
*sgrid_wrf_2.nc
2+
# NOTE: if we need these, they should be in a
3+
# defined place, and ignored in a tests/.gitignore file
4+
# *noncompliant_sgrid.nc
5+
# *sgrid_deltares.nc
6+
# *sgrid_deltares_no_opt_attr.nc
7+
# *sgrid_roms.nc
8+
# *sgrid_wrf.nc
9+
# *sgrid_wrf_2.nc
10+
11+
# version file (auto-generated)
12+
gridded/_version.py
813

914
# OS-X stuff
1015
.DS_Store

docs/source/api_reference.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ The user can now plot the time series for a given location and times, without ha
6565
Duck Typing
6666
-----------
6767

68-
The Grid objects (Grid, Time, Depth) are for the most part "duck typed", rather than strict subclassing. Though there are base classes that provide shared functionality.
68+
The Grid objects (Grid, Time, Depth) are for the most part "duck typed", rather than strict subclassing, though there are base classes that provide shared functionality.
6969

70-
We are trying to be clear about the "public" vs "private" API by using leading underscores for methods and attributes not intended for external use.
70+
We are trying to be clear about the "public" vs "private" API by using leading underscores for methods and attributes not intended for external use, but it's not as consitent as it should be.
7171

7272

7373
Lazy loading / data arrays
7474
--------------------------
7575

7676
Many of the datasets users need to work with can be quite large. As a result it is impractical to load entire datasets into memory at once. ``gridded`` for the most part shifts the burden of handling lazy loading to external libraries, and does this by keeping data stored in a "numpy array-like" objects. Users can use pure numpy arrays, or any object that "acts" like a numpy array. This should allow ``gridded`` to work with netcdf variables, hdf5 arrays, dask arrays, etc.
7777

78-
In practice, there is no clear definition of "array-like", so ``gridded`` has defined its own definition, based on features we know we need. But it is assumed that nd indexing behaves that same as numpy arrays -- as there is no way to easily confirm that. This is a goal, but in fact, only numpy arrays and ``netCDF4 Variables`` have been implimented and tested. In the future, we may use ``xarray`` as a single abstration layer, rather than rolling our own.
78+
In practice, there is no clear definition of "array-like", so ``gridded`` has defined its own definition, based on features we know we need. But it is assumed that nd indexing behaves that same as numpy arrays -- as there is no way to easily confirm that. This is a goal, but in fact, only numpy arrays and ``netCDF4 Variables`` have been implemented and tested. In the future, we may use ``xarray`` as a single abstraction layer, rather than rolling our own.
7979

8080
To support that, we support converting and testing for array-like with:
8181

@@ -85,7 +85,7 @@ and
8585

8686
``gridded.utils.isarraylike()``
8787

88-
Those utilities will be updated as new needs arrise.
88+
Those utilities will be updated as new needs arise.
8989

9090
Reference
9191
=========

gridded/gridded.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def __init__(self, ncfile=None, grid=None, variables=None, grid_topology=None, a
7777
else: # Create from grid and variables -- this is what should usually happen.
7878
self.filename = None
7979
self.grid = grid
80+
self.time = None
81+
self.depth = None
8082
self.variables = {} if variables is None else variables
8183
self.attributes = {} if attributes is None else attributes
8284

@@ -93,7 +95,9 @@ def _init_from_netCDF(self, filename=None, grid_file=None, variable_files=None,
9395

9496
self.nc_dataset = get_dataset(filename)
9597
self.filename = self.nc_dataset.filepath()
96-
self.grid = Grid.from_netCDF(filename=self.filename, dataset=self.nc_dataset, grid_topology=grid_topology)
98+
self.grid = Grid.from_netCDF(filename=self.filename,
99+
dataset=self.nc_dataset,
100+
grid_topology=grid_topology)
97101
# fixme: this should load the depth and time, and then the variables.
98102
self.variables = self._variables_from_netCDF(self.nc_dataset)
99103
self.attributes = get_dataset_attrs(self.nc_dataset)
@@ -102,7 +106,7 @@ def _init_from_netCDF(self, filename=None, grid_file=None, variable_files=None,
102106
def from_netCDF(cls, filename=None, grid_file=None, variable_files=None, grid_topology=None):
103107
"""
104108
NOTE: only loading from a single file is currently implemented.
105-
you can create a DATaset by hand, by loading the grid and
109+
you can create a Dataset by hand, by loading the grid and
106110
variables separately, and then adding them
107111
108112
load a gridded.Dataset from a netCDF file

gridded/tests/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
temp_data/
22
test_data/cdl/*.cdl.nc
33
test_io/output
4-
example_data/*.nc

gridded/tests/utilities.py

Lines changed: 2 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
HERE = Path(__file__).parent
1616
EXAMPLE_DATA = HERE / "example_data"
17+
TEMP_DATA = HERE / "temp_data"
1718
TEST_DATA = HERE / "test_data"
1819

1920
TEST_CDL_FILES = list((TEST_DATA / "cdl").glob("*.cdl"))
@@ -23,7 +24,7 @@
2324
data_file_cache = pooch.create(
2425
# Use a local cache folder for the operating system
2526
# path=pooch.os_cache("plumbus"),
26-
path=EXAMPLE_DATA,
27+
path=TEMP_DATA,
2728
# The remote data is on the pygnome server
2829
base_url="https://gnome.orr.noaa.gov/py_gnome_testdata/gridded_test_files/",
2930
# version=version,
@@ -38,133 +39,6 @@
3839
},
3940
)
4041

41-
42-
# def get_temp_test_file(filename):
43-
# """
44-
# returns the path to a temporary test file.
45-
46-
# If it exists, it will return it directly.
47-
48-
# If not, it will attempt to download it.
49-
50-
# If it can't download, it will return None
51-
# """
52-
# print("getting temp test file")
53-
# filepath = os.path.join(os.path.dirname(__file__),
54-
# 'temp_data',
55-
# filename)
56-
# if os.path.isfile(filepath):
57-
# print("already there")
58-
# return filepath
59-
# else:
60-
# # attempt to download it
61-
# print("trying to download")
62-
# try:
63-
# get_datafile(filepath)
64-
# except urllib_request.HTTPError:
65-
# print("got an error trying to download {}:".format(filepath))
66-
# return None
67-
# return None
68-
69-
70-
# @pytest.fixture
71-
# def two_triangles():
72-
# """
73-
# Returns a simple triangular grid: 4 nodes, two triangles, five edges.
74-
75-
# """
76-
# nodes = [(0.1, 0.1),
77-
# (2.1, 0.1),
78-
# (1.1, 2.1),
79-
# (3.1, 2.1)]
80-
81-
# faces = [(0, 1, 2),
82-
# (1, 3, 2), ]
83-
84-
# edges = [(0, 1),
85-
# (1, 3),
86-
# (3, 2),
87-
# (2, 0),
88-
# (1, 2)]
89-
90-
# return ugrid.UGrid(nodes, faces, edges)
91-
92-
93-
# @pytest.fixture
94-
# def twenty_one_triangles():
95-
# """
96-
# Returns a basic triangular grid: 21 triangles, a hole, and a tail.
97-
98-
# """
99-
# nodes = [(5, 1),
100-
# (10, 1),
101-
# (3, 3),
102-
# (7, 3),
103-
# (9, 4),
104-
# (12, 4),
105-
# (5, 5),
106-
# (3, 7),
107-
# (5, 7),
108-
# (7, 7),
109-
# (9, 7),
110-
# (11, 7),
111-
# (5, 9),
112-
# (8, 9),
113-
# (11, 9),
114-
# (9, 11),
115-
# (11, 11),
116-
# (7, 13),
117-
# (9, 13),
118-
# (7, 15), ]
119-
120-
# faces = [(0, 1, 3),
121-
# (0, 6, 2),
122-
# (0, 3, 6),
123-
# (1, 4, 3),
124-
# (1, 5, 4),
125-
# (2, 6, 7),
126-
# (6, 8, 7),
127-
# (7, 8, 12),
128-
# (6, 9, 8),
129-
# (8, 9, 12),
130-
# (9, 13, 12),
131-
# (4, 5, 11),
132-
# (4, 11, 10),
133-
# (9, 10, 13),
134-
# (10, 11, 14),
135-
# (10, 14, 13),
136-
# (13, 14, 15),
137-
# (14, 16, 15),
138-
# (15, 16, 18),
139-
# (15, 18, 17),
140-
# (17, 18, 19), ]
141-
142-
# # We may want to use this later to define just the outer boundary.
143-
# boundaries = [(0, 1),
144-
# (1, 5),
145-
# (5, 11),
146-
# (11, 14),
147-
# (14, 16),
148-
# (16, 18),
149-
# (18, 19),
150-
# (19, 17),
151-
# (17, 15),
152-
# (15, 13),
153-
# (13, 12),
154-
# (12, 7),
155-
# (7, 2),
156-
# (2, 0),
157-
# (3, 4),
158-
# (4, 10),
159-
# (10, 9),
160-
# (9, 6),
161-
# (6, 3), ]
162-
163-
# grid = ugrid.UGrid(nodes, faces, boundaries=boundaries)
164-
# grid.build_edges()
165-
# return grid
166-
167-
16842
@contextlib.contextmanager
16943
def chdir(dirname=None):
17044
curdir = os.getcwd()

0 commit comments

Comments
 (0)