kval 0.3.0__py3-none-any.whl

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 (45) hide show
  1. kval/__init__.py +1 -0
  2. kval/calc/number.py +68 -0
  3. kval/data/__init__.py +0 -0
  4. kval/data/ctd.py +1103 -0
  5. kval/data/dataset.py +287 -0
  6. kval/data/edit.py +850 -0
  7. kval/data/moored.py +1901 -0
  8. kval/data/moored_tools/_compare_moored_prof.py +220 -0
  9. kval/data/moored_tools/_moored_decorator.py +81 -0
  10. kval/data/moored_tools/_moored_tools.py +507 -0
  11. kval/data/ship_ctd_tools/__init__.py +0 -0
  12. kval/data/ship_ctd_tools/_ctd_decorator.py +79 -0
  13. kval/data/ship_ctd_tools/_ctd_edit.py +618 -0
  14. kval/data/ship_ctd_tools/_ctd_tools.py +719 -0
  15. kval/data/ship_ctd_tools/_ctd_visualize.py +600 -0
  16. kval/data/ship_ctd_tools/qc_salt.py +553 -0
  17. kval/file/__init__.py +1 -0
  18. kval/file/_variable_defs.py +274 -0
  19. kval/file/matfile.py +416 -0
  20. kval/file/rbr.py +261 -0
  21. kval/file/sbe.py +2196 -0
  22. kval/geo/geocalc.py +114 -0
  23. kval/maps/quickmap.py +60 -0
  24. kval/metadata/__init__.py +0 -0
  25. kval/metadata/_standard_attrs.py +454 -0
  26. kval/metadata/_standard_attrs_org.py +20 -0
  27. kval/metadata/check_conventions.py +100 -0
  28. kval/metadata/conventionalize.py +598 -0
  29. kval/ocean/empirical.py +30 -0
  30. kval/ocean/uv.py +131 -0
  31. kval/signal/despike.py +145 -0
  32. kval/signal/filt.py +141 -0
  33. kval/signal/interp.py +26 -0
  34. kval/signal/spec.py +205 -0
  35. kval/util/era5.py +217 -0
  36. kval/util/index.py +56 -0
  37. kval/util/internals.py +60 -0
  38. kval/util/magdec.py +182 -0
  39. kval/util/time.py +373 -0
  40. kval/util/user_input.py +249 -0
  41. kval/util/xr_funcs.py +258 -0
  42. kval-0.3.0.dist-info/METADATA +185 -0
  43. kval-0.3.0.dist-info/RECORD +45 -0
  44. kval-0.3.0.dist-info/WHEEL +4 -0
  45. kval-0.3.0.dist-info/licenses/LICENSE +21 -0
kval/__init__.py ADDED
@@ -0,0 +1 @@
1
+ # oceanograPy
kval/calc/number.py ADDED
@@ -0,0 +1,68 @@
1
+ """
2
+ ctd.calc.numbers
3
+
4
+ Various functions useful for numerical operations:
5
+
6
+ - Calculating the order of magnitude (OOM) of a float.
7
+ - Rounding while controlling floor/ceil for the last digit.
8
+ """
9
+
10
+ import numpy as np
11
+ from typing import Literal
12
+
13
+
14
+ def order_of_magnitude(number: float) -> int:
15
+ """
16
+ Calculate the order of magnitude of a given number.
17
+
18
+ Parameters:
19
+ - number: The input number for which to determine the order of magnitude.
20
+
21
+ Returns:
22
+ - The order of magnitude of the input number.
23
+ """
24
+ if number == 0:
25
+ return 0
26
+
27
+ order = 0
28
+ while abs(number) < 1:
29
+ number *= 10
30
+ order -= 1
31
+ while abs(number) >= 10:
32
+ number /= 10
33
+ order += 1
34
+
35
+ return order
36
+
37
+
38
+ def custom_round_ud(number: float,
39
+ decimals: int,
40
+ ud: Literal['up', 'down', 'dn']) -> float:
41
+ """
42
+ Round a number to a specified number of decimal places, with control
43
+ over the direction of rounding (up or down).
44
+
45
+ Parameters:
46
+ - number: The number to be rounded.
47
+ - decimals: The number of decimal places.
48
+ - ud: Rounding direction. Use 'up' for rounding up or 'down' for rounding
49
+ down.
50
+
51
+ Returns:
52
+ - The rounded number.
53
+
54
+ Raises:
55
+ - ValueError: If an invalid direction is provided.
56
+ """
57
+ factor = 10 ** decimals
58
+ if ud == 'up':
59
+ rounded_number = np.ceil(number * factor) / factor
60
+ elif ud in ['down', 'dn']:
61
+ rounded_number = np.floor(number * factor) / factor
62
+ else:
63
+ raise ValueError(
64
+ f"Invalid direction argument ('{ud}'). Use 'up' for rounding up "
65
+ "or 'down' for rounding down."
66
+ )
67
+
68
+ return rounded_number
kval/data/__init__.py ADDED
File without changes