nctoolkit 1.1.6__tar.gz → 1.1.7__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 (96) hide show
  1. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/PKG-INFO +2 -2
  2. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/cheatsheet/nctoolkit_cheatsheet.pdf +0 -0
  3. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/cheatsheet/nctoolkit_cheatsheet.pptx +0 -0
  4. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/meridonials.py +1 -3
  5. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/mp_adders.py +1 -1
  6. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/static_plot.py +71 -24
  7. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/zonals.py +1 -1
  8. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/setup.py +2 -2
  9. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/CITATION.cff +0 -0
  10. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/CODE_OF_CONDUCT.md +0 -0
  11. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/LICENSE +0 -0
  12. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/MANIFEST.in +0 -0
  13. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/README.md +0 -0
  14. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/benchmarks/benchmark_nctoolkit_versus_xarray.ipynb +0 -0
  15. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/checklists/api_checker.ipynb +0 -0
  16. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/data/geotiff.tif +0 -0
  17. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/data/pubplot_test.png +0 -0
  18. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/data/test1.html +0 -0
  19. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/data/test2.html +0 -0
  20. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/__init__.py +0 -0
  21. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/add_etc.py +0 -0
  22. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/anomaly.py +0 -0
  23. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/api.py +0 -0
  24. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/append.py +0 -0
  25. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/assign.py +0 -0
  26. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/cdo_command.py +0 -0
  27. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/cellareas.py +0 -0
  28. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/centres.py +0 -0
  29. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/checks.py +0 -0
  30. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/cleanup.py +0 -0
  31. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/clear.py +0 -0
  32. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/compare.py +0 -0
  33. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/compare_data.py +0 -0
  34. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/corr.py +0 -0
  35. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/create_ensemble.py +0 -0
  36. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/crop.py +0 -0
  37. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/deprecated.py +0 -0
  38. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/distgrid.py +0 -0
  39. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/drop.py +0 -0
  40. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/ensembles.py +0 -0
  41. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/esoteric.py +0 -0
  42. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/experimental.py +0 -0
  43. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/fill.py +0 -0
  44. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/flatten.py +0 -0
  45. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/fldstat.py +0 -0
  46. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/format.py +0 -0
  47. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/generate_grid.py +0 -0
  48. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/inttime.py +0 -0
  49. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/invert.py +0 -0
  50. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/masking.py +0 -0
  51. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/matchpoint.py +0 -0
  52. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/mergers.py +0 -0
  53. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/mp_matchers.py +0 -0
  54. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/mp_matchups.py +0 -0
  55. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/nco_command.py +0 -0
  56. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/phenology.py +0 -0
  57. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/plot.py +0 -0
  58. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/reduce.py +0 -0
  59. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/reduce_grid.py +0 -0
  60. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/regrid.py +0 -0
  61. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/remove.py +0 -0
  62. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/rename.py +0 -0
  63. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/resample.py +0 -0
  64. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/rollstat.py +0 -0
  65. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/run.py +0 -0
  66. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/runners.py +0 -0
  67. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/runthis.py +0 -0
  68. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/session.py +0 -0
  69. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/set.py +0 -0
  70. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/setters.py +0 -0
  71. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/shape.py +0 -0
  72. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/shift.py +0 -0
  73. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/show.py +0 -0
  74. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/split.py +0 -0
  75. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/strip_vars.py +0 -0
  76. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/subset.py +0 -0
  77. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/sumall.py +0 -0
  78. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/temp_file.py +0 -0
  79. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/temporal_stat.py +0 -0
  80. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/temporals.py +0 -0
  81. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/thresholds.py +0 -0
  82. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/to_lonlat.py +0 -0
  83. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/to_nc.py +0 -0
  84. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/toxarray.py +0 -0
  85. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/tozlev.py +0 -0
  86. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/unify.py +0 -0
  87. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/utils.py +0 -0
  88. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/validator.py +0 -0
  89. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/validator_funs.py +0 -0
  90. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/verticals.py +0 -0
  91. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit/zip.py +0 -0
  92. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/nctoolkit.egg-info/SOURCES.txt +0 -0
  93. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/requirements.txt +0 -0
  94. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/setup.cfg +0 -0
  95. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/testing/test_parallel.py +0 -0
  96. {nctoolkit-1.1.6 → nctoolkit-1.1.7}/testing/test_scripting.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nctoolkit
3
- Version: 1.1.6
3
+ Version: 1.1.7
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,7 +42,7 @@ Requires-Dist: geopandas; extra == "complete"
42
42
 
43
43
  Core abilities of nctoolkit include:
44
44
 
45
- - Clipping to spatial regions
45
+ - Clipping to spatial region
46
46
  - Calculating climatologies
47
47
  - Subsetting to specific time periods
48
48
  - Calculating spatial statistics
@@ -5,9 +5,7 @@ def zonstat(self, stat="mean"):
5
5
  """Method to calculate the meridonial statistic from a netCDF file"""
6
6
  for ff in self:
7
7
  if is_curvilinear(ff):
8
- raise TypeError(
9
- f"meridonal_{stat} cannot be calculated for curvilinear grids."
10
- )
8
+ raise TypeError(f"meridonial_{stat} cannot be calculated for this grid type. Please consider using to_latlon to convert to a regular grid.")
11
9
  cdo_command = f"-mer{stat}"
12
10
 
13
11
  self.cdo_command(cdo_command, ensemble=False)
@@ -41,7 +41,7 @@ def match_points(
41
41
  monthly dataset.
42
42
  This is equivalent to apply `ds.tmean(..)` to the dataset.
43
43
  nan: float or list
44
- Value or range of values to set to nan. Defaults to 0.
44
+ Value or range of values to set to nan. Defaults to None, so no values will bre reset to nan.
45
45
  Only required if values in dataset need changed to missing
46
46
  top: bool
47
47
  Set to True if you want only the top/surface level of the dataset to be selected for matching.
@@ -84,7 +84,6 @@ def pub_plot(
84
84
  norm=None,
85
85
  limits=None,
86
86
  projection="auto",
87
- mid_point=None,
88
87
  coast="auto",
89
88
  scale="auto",
90
89
  grid=True,
@@ -120,10 +119,13 @@ def pub_plot(
120
119
  Character string with colour map to use. Set to None if you do not want to use a colour map.
121
120
  norm: str or matplotlib.colors norm
122
121
  Norm to use for colour bar
122
+ limits: list
123
+ List with [min, max] for colour bar limits.
124
+ Please note that if the colour scale passes through zero, the colour scale will be symmetrical around zero.
125
+ So the limits will be reset to the maximum absolute value of the data.
126
+
123
127
  projection: cartopy projection
124
128
  Cartopy projection to use.
125
- mid_point: float
126
- Mid-point to use for colour bar
127
129
  coast: str
128
130
  Set to "coarse", "low", "intermediate", "high" or "full" if you want to use GSHHS coastlines
129
131
  scale: str
@@ -144,6 +146,7 @@ def pub_plot(
144
146
 
145
147
  -------------
146
148
  """
149
+ mid_point = None
147
150
 
148
151
  relief = False
149
152
  # check if relief is in kwargs
@@ -239,10 +242,10 @@ def pub_plot(
239
242
  norm = kwargs[kk]
240
243
  fixed = True
241
244
 
242
- if kk.lower().startswith("mid") and kk.lower().endswith("nt"):
243
- if mid_point is None:
244
- mid_point = kwargs[kk]
245
- fixed = True
245
+ #if kk.lower().startswith("mid") and kk.lower().endswith("nt"):
246
+ # if mid_point is None:
247
+ # mid_point = kwargs[kk]
248
+ # fixed = True
246
249
 
247
250
  if kk.lower().startswith("proj"):
248
251
  if projection == "auto":
@@ -459,23 +462,6 @@ def pub_plot(
459
462
  if r_max is not None:
460
463
  max_value = np.nanpercentile(np.ma.filled(values, np.nan), r_max)
461
464
 
462
- if limits is not None and colours == "auto":
463
- try:
464
- if limits[0] < 0 and limits[1] > 0:
465
- min_value = limits[0]
466
- max_value = limits[1]
467
- if mid_point is None:
468
- mid_point = 0
469
- if colours == "auto":
470
- colours = "RdBu_r"
471
- if land_auto and land is not None:
472
- if land != "auto":
473
- land = "grey"
474
- except:
475
- pass
476
-
477
- if colours == "auto":
478
- colours = "viridis"
479
465
 
480
466
  # generate the figure and the axes where to plot the map. When the axes are generated (either with add_subplot or add_axes, or any other way), the projection to be used need to be specified
481
467
  # the axes generated show the entire globe up to the cutoff latitude
@@ -522,6 +508,37 @@ def pub_plot(
522
508
  vmin = np.nanpercentile(np.ma.filled(values, np.nan), r_min)
523
509
  if r_max is not None:
524
510
  vmax = np.nanpercentile(np.ma.filled(values, np.nan), r_max)
511
+
512
+ if mid_point is None:
513
+ if vmin < 0 and vmax > 0:
514
+ mid_point = 0
515
+ limits[0] = vmin
516
+ limits[1] = vmax
517
+ try:
518
+ if limits[0] < 0 and limits[1] > 0:
519
+ min_value = limits[0]
520
+ max_value = limits[1]
521
+ if mid_point is None:
522
+ mid_point = 0
523
+ if colours == "auto":
524
+ colours = "RdBu_r"
525
+ if land_auto and land is not None:
526
+ if land != "auto":
527
+ land = "grey"
528
+ except:
529
+ pass
530
+
531
+ if mid_point is not None and limits is not None:
532
+ try:
533
+ if colours == "auto":
534
+ colours = "RdBu_r"
535
+ if land_auto and land is not None:
536
+ if land != "auto":
537
+ land = "grey"
538
+ except:
539
+ pass
540
+
541
+
525
542
 
526
543
  if mid_point is not None:
527
544
  val_min = values.min()
@@ -541,6 +558,10 @@ def pub_plot(
541
558
  adjustment = max(val_max - mid_point, mid_point - val_min)
542
559
  vmin = mid_point - adjustment
543
560
  vmax = mid_point + adjustment
561
+ # else:
562
+ # print(limits)
563
+ # vmin = limits[0]
564
+ # vmax = limits[1]
544
565
 
545
566
  norm_plot = False
546
567
  if norm in ["log", "log10"]:
@@ -550,6 +571,31 @@ def pub_plot(
550
571
  vmin = None
551
572
  vmax = None
552
573
 
574
+ if limits is not None and colours == "auto":
575
+ try:
576
+ if limits[0] < 0 and limits[1] > 0:
577
+ min_value = limits[0]
578
+ max_value = limits[1]
579
+ if mid_point is None:
580
+ mid_point = 0
581
+ if colours == "auto":
582
+ colours = "RdBu_r"
583
+ if land_auto and land is not None:
584
+ if land != "auto":
585
+ land = "grey"
586
+ else:
587
+ colours = "viridis"
588
+ except:
589
+ pass
590
+
591
+ if colours == "auto":
592
+ colours = "viridis"
593
+
594
+ if vmin < 0 and vmax >0:
595
+ # ensure vmin and vmax are symmetric
596
+ vmax = max(abs(vmin), abs(vmax))
597
+ vmin = -vmax
598
+
553
599
  im = ax.pcolormesh(
554
600
  lon,
555
601
  lat,
@@ -562,6 +608,7 @@ def pub_plot(
562
608
  vmax=vmax,
563
609
  )
564
610
 
611
+
565
612
  # add coastline and land colour. More options, including about resolution of coastline, colour and so on can be found here
566
613
  # https://scitools.org.uk/cartopy/docs/v0.14/matplotlib/feature_interface.html
567
614
  #
@@ -7,7 +7,7 @@ def zonstat(self, stat="mean"):
7
7
 
8
8
  for ff in self:
9
9
  if is_curvilinear(ff):
10
- raise TypeError(f"zonal_{stat} cannot be calculated for curvilinear grids.")
10
+ raise TypeError(f"zonal_{stat} cannot be calculated for this grid type. Please consider using to_latlon to convert to a regular grid.")
11
11
 
12
12
  cdo_command = f"-zon{stat}"
13
13
 
@@ -8,7 +8,7 @@ LONG_DESCRIPTION = """
8
8
 
9
9
  Core abilities of nctoolkit include:
10
10
 
11
- - Clipping to spatial regions
11
+ - Clipping to spatial region
12
12
  - Calculating climatologies
13
13
  - Subsetting to specific time periods
14
14
  - Calculating spatial statistics
@@ -47,7 +47,7 @@ extras_require["complete"] = ["geoviews", "rioxarray", "cfchecker", "geocube", "
47
47
  REQUIREMENTS = [i.strip() for i in open("requirements.txt").readlines()]
48
48
 
49
49
  setup(name='nctoolkit',
50
- version='1.1.6',
50
+ version='1.1.7',
51
51
  description=DESCRIPTION,
52
52
  long_description=LONG_DESCRIPTION,
53
53
  python_requires='>=3.6.1',
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