You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* see the [ReadTheDocs build](https://ncdata.readthedocs.io/en/latest/index.html)
143
-
144
-
145
-
# Installation
146
-
Install from conda-forge with conda
147
-
```
148
-
conda install -c conda-forge ncdata
149
-
```
150
-
151
-
Or from PyPI with pip
152
-
```
153
-
pip install ncdata
154
87
```
155
88
156
-
# Project Status
157
-
158
-
## Code Stability
159
-
We intend to follow [PEP 440](https://peps.python.org/pep-0440/) or (older) [SemVer](https://semver.org/) versioning principles.
160
-
161
-
Minor release version is at **"v0.1"**.
162
-
This is a first complete implementation, with functional operational of all public APIs.
163
-
164
-
The code is however still experimental, and APIs are not stable (hence no major version yet).
89
+
## Copy selected data to a new file
90
+
```python
91
+
from ncdata.netcdf4 import from_nc4, to_nc4
92
+
ncdata = from_nc4("file1.nc")
165
93
166
-
## Change Notes
167
-
### v0.1.1
168
-
Small tweaks + bug fixes.
169
-
**Note:**[#62](https://github.com/pp-mo/ncdata/pull/62) and [#59](https://github.com/pp-mo/ncdata/pull/59) are important fixes to achieve intended performance goals,
170
-
i.e. moving arbitrarily large data via Dask without running out of memory.
94
+
# Make a list of partial names to select the wanted variables
95
+
keys = ["air_", "surface"]
171
96
172
-
* Stop non-numpy attribute values from breaking attribute printout. [#63](https://github.com/pp-mo/ncdata/pull/63)
173
-
* Stop ``ncdata.iris.from_iris()`` consuming full data memory for each variable. [#62](https://github.com/pp-mo/ncdata/pull/62)
174
-
* Provide convenience APIs for ncdata component dictionaries and attribute values. [#61](https://github.com/pp-mo/ncdata/pull/61)
175
-
* Use dask ``chunks="auto"`` in ``ncdata.netcdf4.from_nc4()``. [#59](https://github.com/pp-mo/ncdata/pull/59)
97
+
# Explicitly add dimension names, to include all the dimension variables
98
+
keys +=+list(ncdata.dimensions)
176
99
177
-
### v0.1.0
178
-
First release
100
+
# Identify the wanted variables
101
+
select_vars = [
102
+
var
103
+
for var in ncdata.variables.values()
104
+
ifany(key in var.name for key in keys)
105
+
]
179
106
180
-
## Iris and Xarray Compatibility
181
-
* C.I. tests GitHub PRs and merges, against latest releases of Iris and Xarray
182
-
* compatible with iris >= v3.7.0
183
-
* see : [support added in v3.7.0](https://scitools-iris.readthedocs.io/en/stable/whatsnew/3.7.html#internal)
107
+
# Add any referenced coordinate variables
108
+
for var inlist(select_vars):
109
+
var = ncdata.variables[varname]
110
+
for coordname in var.attributes.get("coordinates", "").split(""):
111
+
select_vars.append(ncdata.variables[coordname])
184
112
185
-
## Known limitations
186
-
Unsupported features : _not planned_
187
-
* user-defined datatypes are not supported
188
-
* this includes compound and variable-length types
113
+
# Replace variables with only the wanted ones
114
+
ncdata.variables.clear()
115
+
ncdata.variables.addall(select_vars)
189
116
190
-
Unsupported features : _planned for future release_
191
-
* groups (not yet fully supported ?)
192
-
* file output chunking control
117
+
# Save
118
+
to_nc4(ncdata, "pruned.nc")
119
+
```
193
120
194
-
## Known problems
195
-
As-of v0.1.1
196
-
* in conversion from iris cubes with [`from_iris`](https://ncdata.readthedocs.io/en/latest/api/ncdata.iris.html#ncdata.iris.from_iris),
197
-
use of an `unlimited_dims` key currently causes an exception
198
-
*https://github.com/pp-mo/ncdata/issues/43
199
-
* in conversion to xarray with [`to_xarray`](https://ncdata.readthedocs.io/en/latest/api/ncdata.xarray.html#ncdata.xarray.to_xarray),
200
-
dataset encodings are not reproduced, most notably **the "unlimited_dims" control is missing**
* Note : the [PyPI reference](https://github.com/conda-forge/ncdata-feedstock/blob/3f6b35cbdffd2ee894821500f76f2b0b66f55939/recipe/meta.yaml#L9) will normally look after itself
238
-
* Also : make any required changes to [dependencies](https://github.com/conda-forge/ncdata-feedstock/blob/3f6b35cbdffd2ee894821500f76f2b0b66f55939/recipe/meta.yaml#L17-L29) -- normally _no change required_
239
-
1. get PR merged ; wait a few hours ; check the new version appears in `conda search ncdata`
0 commit comments