nctoolkit 1.1.11__tar.gz → 1.2.0__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.
Files changed (97) hide show
  1. nctoolkit-1.2.0/CONTRIBUTIONS.md +39 -0
  2. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/PKG-INFO +1 -1
  3. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/cheatsheet/nctoolkit_cheatsheet.pdf +0 -0
  4. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/cheatsheet/nctoolkit_cheatsheet.pptx +0 -0
  5. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/assign.py +2 -0
  6. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/cleanup.py +4 -4
  7. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/subset.py +11 -5
  8. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/toxarray.py +11 -2
  9. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/verticals.py +3 -2
  10. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit.egg-info/SOURCES.txt +1 -0
  11. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/setup.py +1 -1
  12. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/CITATION.cff +0 -0
  13. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/CODE_OF_CONDUCT.md +0 -0
  14. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/LICENSE +0 -0
  15. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/MANIFEST.in +0 -0
  16. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/README.md +0 -0
  17. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/benchmarks/benchmark_nctoolkit_versus_xarray.ipynb +0 -0
  18. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/checklists/api_checker.ipynb +0 -0
  19. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/data/geotiff.tif +0 -0
  20. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/data/pubplot_test.png +0 -0
  21. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/data/test1.html +0 -0
  22. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/data/test2.html +0 -0
  23. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/__init__.py +0 -0
  24. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/add_etc.py +0 -0
  25. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/anomaly.py +0 -0
  26. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/api.py +0 -0
  27. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/append.py +0 -0
  28. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/cdo_command.py +0 -0
  29. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/cellareas.py +0 -0
  30. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/centres.py +0 -0
  31. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/checks.py +0 -0
  32. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/clear.py +0 -0
  33. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/compare.py +0 -0
  34. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/compare_data.py +0 -0
  35. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/corr.py +0 -0
  36. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/create_ensemble.py +0 -0
  37. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/crop.py +0 -0
  38. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/deprecated.py +0 -0
  39. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/distgrid.py +0 -0
  40. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/drop.py +0 -0
  41. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/ensembles.py +0 -0
  42. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/esoteric.py +0 -0
  43. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/experimental.py +0 -0
  44. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/fill.py +0 -0
  45. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/flatten.py +0 -0
  46. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/fldstat.py +0 -0
  47. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/format.py +0 -0
  48. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/generate_grid.py +0 -0
  49. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/inttime.py +0 -0
  50. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/invert.py +0 -0
  51. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/masking.py +0 -0
  52. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/matchpoint.py +0 -0
  53. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/mergers.py +0 -0
  54. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/meridonials.py +0 -0
  55. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/mp_adders.py +0 -0
  56. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/mp_matchers.py +0 -0
  57. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/mp_matchups.py +0 -0
  58. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/nco_command.py +0 -0
  59. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/phenology.py +0 -0
  60. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/plot.py +0 -0
  61. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/reduce.py +0 -0
  62. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/reduce_grid.py +0 -0
  63. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/regrid.py +0 -0
  64. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/remove.py +0 -0
  65. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/rename.py +0 -0
  66. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/resample.py +0 -0
  67. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/rollstat.py +0 -0
  68. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/run.py +0 -0
  69. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/runners.py +0 -0
  70. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/runthis.py +0 -0
  71. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/session.py +0 -0
  72. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/set.py +0 -0
  73. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/setters.py +0 -0
  74. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/shape.py +0 -0
  75. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/shift.py +0 -0
  76. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/show.py +0 -0
  77. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/split.py +0 -0
  78. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/static_plot.py +0 -0
  79. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/strip_vars.py +0 -0
  80. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/sumall.py +0 -0
  81. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/temp_file.py +0 -0
  82. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/temporal_stat.py +0 -0
  83. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/temporals.py +0 -0
  84. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/thresholds.py +0 -0
  85. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/to_lonlat.py +0 -0
  86. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/to_nc.py +0 -0
  87. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/tozlev.py +0 -0
  88. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/unify.py +0 -0
  89. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/utils.py +0 -0
  90. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/validator.py +0 -0
  91. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/validator_funs.py +0 -0
  92. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/zip.py +0 -0
  93. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/nctoolkit/zonals.py +0 -0
  94. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/requirements.txt +0 -0
  95. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/setup.cfg +0 -0
  96. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/testing/test_parallel.py +0 -0
  97. {nctoolkit-1.1.11 → nctoolkit-1.2.0}/testing/test_scripting.py +0 -0
@@ -0,0 +1,39 @@
1
+ Contributing to nctoolkit
2
+
3
+ 🎉 Thank you for your interest in contributing to nctoolkit! Your efforts help improve this tool for the entire community. Whether you're fixing bugs, adding new features, or enhancing documentation, your contributions are invaluable. Let's make this project even better together! 🎉
4
+
5
+ How to Contribute
6
+
7
+ To contribute, please follow these steps:
8
+
9
+ 1. Fork the Repository
10
+ Click the "Fork" button at the top right of this page to create a copy of this repository under your GitHub account.
11
+
12
+ 2. Clone and Set Up the Repository
13
+ After forking, open your terminal, clone the repository to your local machine, and navigate into the project directory:
14
+ git clone https://github.com/your-username/nctoolkit.git
15
+ cd nctoolkit
16
+
17
+ 3. Create a New Branch
18
+ Create a new branch for your contribution to keep your changes organized and separated from the main codebase:
19
+ git checkout -b feature/your-feature-name
20
+
21
+ 4. Make Your Changes
22
+ Add your feature, fix bugs, or improve documentation. Be sure to:
23
+ Keep your changes focused on a single feature or fix for easier review.
24
+ Test your modifications to ensure they work as intended.
25
+ Follow any coding style guidelines noted in the project.
26
+
27
+ 5. Commit Your Changes
28
+ When you’re ready, stage and commit your changes with a clear, descriptive commit message:
29
+ git add .
30
+ git commit -m "Add detailed description of your changes here"
31
+
32
+ 6. Push to Your Fork
33
+ Push your branch to your GitHub repository:
34
+ git push origin feature/your-feature-name
35
+
36
+ 7. Submit a Pull Request (PR)
37
+ Go to the original nctoolkit repository on GitHub.
38
+ Click the "New Pull Request" button and select your branch.
39
+ Include a detailed description of your changes to help reviewers understand your contribution.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nctoolkit
3
- Version: 1.1.11
3
+ Version: 1.2.0
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
@@ -91,6 +91,8 @@ funs = [
91
91
  "exp",
92
92
  "ln",
93
93
  "sin",
94
+ "min",
95
+ "max",
94
96
  "cos",
95
97
  "tan",
96
98
  "int",
@@ -145,12 +145,12 @@ def temp_check():
145
145
  if len(mylist) > 0:
146
146
  if len(mylist) == 1:
147
147
  print(
148
- f"{len(mylist)} file was created by nctoolkit in prior or current "
148
+ f"{len(mylist)} temporary file was created by nctoolkit in prior or current "
149
149
  f"sessions. Consider running deep_clean!"
150
150
  )
151
151
  else:
152
152
  print(
153
- f"{len(mylist)} files were created by nctoolkit in prior or current"
153
+ f"{len(mylist)} temporary files were created by nctoolkit in prior or current"
154
154
  f" sessions. Consider running deep_clean!"
155
155
  )
156
156
 
@@ -163,12 +163,12 @@ def temp_check():
163
163
  if len(mylist) > 0:
164
164
  if len(mylist) == 1:
165
165
  print(
166
- f"{len(mylist)} file was created by nctoolkit in prior or current "
166
+ f"{len(mylist)} temporary file was created by nctoolkit in prior or current "
167
167
  f"sessions. Consider running deep_clean!"
168
168
  )
169
169
  else:
170
170
  print(
171
- f"{len(mylist)} files were created by nctoolkit in prior or "
171
+ f"{len(mylist)} temporary files were created by nctoolkit in prior or "
172
172
  f"current sessions. Consider running deep_clean!"
173
173
  )
174
174
 
@@ -45,24 +45,30 @@ def select_levels(self, levels=None):
45
45
  levels : list
46
46
  List of the form [min_level, max_level]. Levels/depth between the two will be selected
47
47
  """
48
+ ds_levels = self.levels
49
+
48
50
  if not isinstance(levels, list):
49
51
  type(levels)
50
52
  try:
51
53
  levels = float(levels)
52
54
  except:
53
55
  raise ValueError("levels provided are not valid!")
56
+ levels = [float(levels), float(levels)]
54
57
 
55
58
  if isinstance(levels, list):
56
59
  try:
57
- levels[0] = int(np.floor(float(levels[0])))
58
- levels[1] = int(np.ceil(float(levels[1])))
60
+ levels[0] = float(levels[0])
61
+ levels[1] = float(levels[1])
59
62
  except:
60
63
  raise ValueError("levels provided are not valid!")
61
64
  if levels[0] > levels[1]:
62
65
  raise ValueError("levels have the wrong order")
63
- levels = f"{levels[0]}/{levels[1]}"
64
-
65
- cdo_command = f"-sellevel,{levels}"
66
+
67
+ sel_levels = [str(x) for x in ds_levels if levels[0] <= x <= levels[1]]
68
+ if len(sel_levels) == 0:
69
+ raise ValueError("No levels found in the dataset")
70
+ sel_levels = ",".join(sel_levels)
71
+ cdo_command = f"-sellevel,{sel_levels}"
66
72
 
67
73
  self.cdo_command(cdo_command, ensemble=False)
68
74
 
@@ -102,7 +102,7 @@ def to_xarray(self, decode_times=True, **kwargs):
102
102
  return data
103
103
 
104
104
 
105
- def to_dataframe(self, decode_times=True, **kwargs):
105
+ def to_dataframe(self, decode_times=True, drop_bnds = True, **kwargs):
106
106
  """
107
107
  to_dataframe: Convert a dataset to a pandas data frame
108
108
 
@@ -111,6 +111,10 @@ def to_dataframe(self, decode_times=True, **kwargs):
111
111
  decode_times: boolean
112
112
  Set to False if you do not want xarray to decode the times prior to
113
113
  conversion to data frame. Default is True.
114
+ drop_bnds: boolean
115
+ Set to False if you do not want to drop the bounds from the data frame.
116
+ Variables/coordinates with '_bnds' in their names will be dropped.
117
+ Default is True.
114
118
  **kwargs : kwargs
115
119
  Optional arguments to be sent to subset.
116
120
 
@@ -125,4 +129,9 @@ def to_dataframe(self, decode_times=True, **kwargs):
125
129
  >>> ds.to_dataframe()
126
130
 
127
131
  """
128
- return self.to_xarray(decode_times=decode_times, **kwargs).to_dataframe()
132
+ df = self.to_xarray(decode_times=decode_times, **kwargs).to_dataframe()
133
+ df = df.reset_index()
134
+ if drop_bnds:
135
+ df = df.drop(columns=[col for col in df.columns if 'bnds' in col])
136
+ df = df.drop_duplicates().reset_index(drop = True)
137
+ return df
@@ -180,6 +180,9 @@ def vertical_interp(
180
180
  if thickness is not None:
181
181
  fixed = False
182
182
 
183
+ if isinstance(levels, (int, float)):
184
+ levels = [levels]
185
+
183
186
  if fixed is False:
184
187
  self.to_zlevels(
185
188
  levels=levels, thickness=thickness, depths=depths, surface=surface
@@ -191,8 +194,6 @@ def vertical_interp(
191
194
 
192
195
  # first a quick fix for the case when there is only one vertical depth
193
196
 
194
- if isinstance(levels, (int, float)):
195
- levels = [levels]
196
197
 
197
198
  # levels = [float(x) for x in levels]
198
199
 
@@ -1,5 +1,6 @@
1
1
  CITATION.cff
2
2
  CODE_OF_CONDUCT.md
3
+ CONTRIBUTIONS.md
3
4
  LICENSE
4
5
  MANIFEST.in
5
6
  README.md
@@ -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.1.11',
49
+ version='1.2.0',
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