nctoolkit 1.2.1__tar.gz → 1.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/PKG-INFO +3 -2
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/add_etc.py +11 -5
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/fldstat.py +2 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/runthis.py +14 -8
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/show.py +7 -1
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/tozlev.py +5 -3
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/verticals.py +20 -8
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit.egg-info/SOURCES.txt +1 -0
- nctoolkit-1.2.3/pyproject.toml +5 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/setup.py +1 -1
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/CITATION.cff +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/CODE_OF_CONDUCT.md +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/CONTRIBUTIONS.md +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/LICENSE +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/MANIFEST.in +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/README.md +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/benchmarks/benchmark_nctoolkit_versus_xarray.ipynb +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/cheatsheet/nctoolkit_cheatsheet.pdf +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/cheatsheet/nctoolkit_cheatsheet.pptx +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/checklists/api_checker.ipynb +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/data/geotiff.tif +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/data/pubplot_test.png +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/data/test1.html +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/data/test2.html +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/__init__.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/anomaly.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/api.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/append.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/assign.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/cdo_command.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/cellareas.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/centres.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/checks.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/cleanup.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/clear.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/compare.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/compare_data.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/corr.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/create_ensemble.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/crop.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/deprecated.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/distgrid.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/drop.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/ensembles.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/esoteric.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/experimental.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/fill.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/flatten.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/format.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/generate_grid.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/inttime.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/invert.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/masking.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/matchpoint.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/mergers.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/meridonials.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/mp_adders.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/mp_matchers.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/mp_matchups.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/nco_command.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/phenology.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/plot.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/reduce.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/reduce_grid.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/regrid.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/remove.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/rename.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/resample.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/rollstat.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/run.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/runners.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/session.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/set.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/setters.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/shape.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/shift.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/split.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/static_plot.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/strip_vars.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/subset.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/sumall.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/temp_file.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/temporal_stat.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/temporals.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/thresholds.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/to_lonlat.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/to_nc.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/toxarray.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/unify.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/utils.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/validator.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/validator_funs.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/zip.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/nctoolkit/zonals.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/requirements.txt +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/setup.cfg +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/testing/test_parallel.py +0 -0
- {nctoolkit-1.2.1 → nctoolkit-1.2.3}/testing/test_scripting.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: nctoolkit
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.3
|
|
4
4
|
Summary: A Python package for netCDF analysis and post-processing
|
|
5
5
|
Home-page: https://github.com/pmlmodelling/nctoolkit
|
|
6
6
|
Author: Robert Wilson
|
|
@@ -42,6 +42,7 @@ Dynamic: classifier
|
|
|
42
42
|
Dynamic: description
|
|
43
43
|
Dynamic: description-content-type
|
|
44
44
|
Dynamic: home-page
|
|
45
|
+
Dynamic: license-file
|
|
45
46
|
Dynamic: maintainer
|
|
46
47
|
Dynamic: project-url
|
|
47
48
|
Dynamic: provides-extra
|
|
@@ -145,11 +145,17 @@ def operation(self, method="mul", ff=None, var=None):
|
|
|
145
145
|
else:
|
|
146
146
|
ff_times_df = (
|
|
147
147
|
pd.DataFrame({"time": ff_times})
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
)
|
|
149
|
+
ff_times_df["year"] = [x.year for x in ff_times]
|
|
150
|
+
ff_times_df["month"] = [x.month for x in ff_times]
|
|
151
|
+
ff_times_df["day"] = [x.day for x in ff_times]
|
|
152
|
+
# .assign(
|
|
153
|
+
# year=lambda x: x.time.dt.year,
|
|
154
|
+
# month=lambda x: x.time.dt.month,
|
|
155
|
+
# day=lambda x: x.time.dt.day,
|
|
156
|
+
# )
|
|
157
|
+
ff_times_df = (
|
|
158
|
+
ff_times_df
|
|
153
159
|
.drop(columns="time")
|
|
154
160
|
)
|
|
155
161
|
|
|
@@ -128,6 +128,10 @@ def run_this(os_command, self, output="one", out_file=None, suppress=False):
|
|
|
128
128
|
|
|
129
129
|
cores = session_info["cores"]
|
|
130
130
|
|
|
131
|
+
# if len(self) == 1:
|
|
132
|
+
# if cores > 1:
|
|
133
|
+
# os_command = os_command.replace("cdo ", f"cdo -P {cores} ")
|
|
134
|
+
|
|
131
135
|
if len(self) == 1:
|
|
132
136
|
output = "ensemble"
|
|
133
137
|
|
|
@@ -243,12 +247,16 @@ def run_this(os_command, self, output="one", out_file=None, suppress=False):
|
|
|
243
247
|
if self._zip:
|
|
244
248
|
ff_command = ff_command.replace("cdo ", "cdo -z zip ")
|
|
245
249
|
|
|
250
|
+
if session_info["cores"] > 1:
|
|
251
|
+
if len(self) == 1:
|
|
252
|
+
ff_command = ff_command.replace("cdo ", f"cdo -P {session_info['cores']} ")
|
|
246
253
|
new_history.append(ff_command)
|
|
247
254
|
|
|
248
255
|
#warnings.simplefilter("ignore")
|
|
249
256
|
|
|
250
257
|
#with patch('sys.warnoptions', []):
|
|
251
258
|
|
|
259
|
+
|
|
252
260
|
if cores > 1:
|
|
253
261
|
temp = pool.apply_async(
|
|
254
262
|
run_cdo,
|
|
@@ -288,13 +296,6 @@ def run_this(os_command, self, output="one", out_file=None, suppress=False):
|
|
|
288
296
|
warnings.warn(mm)
|
|
289
297
|
if mm in session_warnings:
|
|
290
298
|
session_warnings.remove(mm)
|
|
291
|
-
# remove element from session_warnings
|
|
292
|
-
|
|
293
|
-
#session_warnings.remove(ff)
|
|
294
|
-
#tidy_warnings(w)
|
|
295
|
-
#if cores > 1:
|
|
296
|
-
# pool.close()
|
|
297
|
-
|
|
298
299
|
|
|
299
300
|
self.history = copy.deepcopy(new_history)
|
|
300
301
|
self.current = copy.deepcopy(target_list)
|
|
@@ -324,6 +325,7 @@ def run_this(os_command, self, output="one", out_file=None, suppress=False):
|
|
|
324
325
|
|
|
325
326
|
return None
|
|
326
327
|
|
|
328
|
+
|
|
327
329
|
if ((output == "one") and (len(self) > 1)) or self._zip is False:
|
|
328
330
|
new_history = copy.deepcopy(self._hold_history)
|
|
329
331
|
|
|
@@ -417,11 +419,15 @@ def run_this(os_command, self, output="one", out_file=None, suppress=False):
|
|
|
417
419
|
warnings.warn(
|
|
418
420
|
f"The following variables are not in all files, so were ignored when merging: {removed}"
|
|
419
421
|
)
|
|
420
|
-
|
|
422
|
+
|
|
421
423
|
target = run_cdo(
|
|
422
424
|
os_command, target, out_file, precision=self._precision
|
|
423
425
|
)
|
|
424
426
|
else:
|
|
427
|
+
if session_info["cores"] > 1:
|
|
428
|
+
if len(self) == 1:
|
|
429
|
+
os_command = os_command.replace("cdo ", f"cdo -P {session_info['cores']} ")
|
|
430
|
+
|
|
425
431
|
target = run_cdo(
|
|
426
432
|
os_command, target, out_file, precision=self._precision
|
|
427
433
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import subprocess
|
|
2
2
|
from dateutil.parser import parse
|
|
3
|
+
import xarray as xr
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
def nc_times(ff):
|
|
@@ -31,7 +32,12 @@ def nc_times(ff):
|
|
|
31
32
|
cdo_result = [parse(x) for x in cdo_result]
|
|
32
33
|
return cdo_result
|
|
33
34
|
except:
|
|
34
|
-
|
|
35
|
+
try:
|
|
36
|
+
ds = xr.open_dataset(ff)
|
|
37
|
+
times = list(ds.time.values)
|
|
38
|
+
return times
|
|
39
|
+
except:
|
|
40
|
+
return cdo_result
|
|
35
41
|
|
|
36
42
|
|
|
37
43
|
def nc_format(ff):
|
|
@@ -55,9 +55,11 @@ def to_zlevels(self, levels=None, thickness=None, depths=None, surface=None):
|
|
|
55
55
|
# Set up the thickness
|
|
56
56
|
|
|
57
57
|
ds = self.copy()
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
|
|
59
|
+
var_select = list(ds.contents.query("nlevels > 1").variable)
|
|
60
|
+
if len(var_select) > 1:
|
|
61
|
+
ds.subset(variables=ds.contents.query("nlevels > 1").variable)
|
|
62
|
+
ds.run()
|
|
61
63
|
vars = ds.variables
|
|
62
64
|
|
|
63
65
|
sorted = False
|
|
@@ -32,32 +32,44 @@ def generate_level_bounds(self):
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
def bottom(self):
|
|
35
|
+
def bottom(self, choice = "level"):
|
|
36
36
|
"""
|
|
37
|
-
bottom: Extract the bottom level from a dataset
|
|
37
|
+
bottom: Extract the bottom level or value from a dataset
|
|
38
38
|
|
|
39
|
-
This extracts the bottom level from each netCDF file. Please note that for
|
|
39
|
+
This extracts the bottom level or value from each netCDF file. Please note that for
|
|
40
40
|
ensembles, it uses the first file to derive the index of the bottom level.
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
Parameters
|
|
43
|
+
-------------
|
|
44
|
+
choice : str
|
|
45
|
+
Set to 'level' to extract the bottom level, or 'value' to extract the bottommost non-missing value.
|
|
46
46
|
|
|
47
47
|
Examples
|
|
48
48
|
------------
|
|
49
49
|
|
|
50
50
|
If you wanted to extract the bottom vertical level of a dataset, do the following:
|
|
51
51
|
|
|
52
|
-
>>> ds.bottom()
|
|
52
|
+
>>> ds.bottom(choice = 'level')
|
|
53
53
|
|
|
54
54
|
This method is most useful for things like oceanic model data, where the bottom cell corresponds to the bottom of the ocean.
|
|
55
55
|
|
|
56
|
+
If you wanted to find the deepest non-missing value in a dataset, you would do the following:
|
|
57
|
+
|
|
58
|
+
>>> ds.bottom(choice = 'value')
|
|
59
|
+
|
|
56
60
|
"""
|
|
57
61
|
|
|
58
62
|
# extract the number of the bottom level
|
|
59
63
|
# Use the first file for an ensemble
|
|
60
64
|
# pull the cdo command together, then run it or store it
|
|
65
|
+
|
|
66
|
+
if choice not in ["level", "value"]:
|
|
67
|
+
raise ValueError("Choice must be either 'level' or 'value'")
|
|
68
|
+
|
|
69
|
+
if choice == "value":
|
|
70
|
+
self.cdo_command("bottomvalue")
|
|
71
|
+
return None
|
|
72
|
+
|
|
61
73
|
if len(self) > 1:
|
|
62
74
|
ff = self.current[0]
|
|
63
75
|
warnings.warn(
|
|
@@ -46,7 +46,7 @@ extras_require["complete"] = ["geoviews", "rioxarray", "cfchecker", "geocube", "
|
|
|
46
46
|
REQUIREMENTS = [i.strip() for i in open("requirements.txt").readlines()]
|
|
47
47
|
|
|
48
48
|
setup(name='nctoolkit',
|
|
49
|
-
version='1.2.
|
|
49
|
+
version='1.2.3',
|
|
50
50
|
description=DESCRIPTION,
|
|
51
51
|
description_content_type='text/plain',
|
|
52
52
|
long_description=LONG_DESCRIPTION,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|