Skip to content

Commit c70562c

Browse files
committed
update news about 0.8.6
1 parent 62e5563 commit c70562c

File tree

3 files changed

+66
-45
lines changed

3 files changed

+66
-45
lines changed

docs/source/news.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
News
22
============
33

4+
Release of v0.8.6
5+
---------------
6+
7+
Version 0.8.6 was released on 23rd December 2022. This is a minor releases that tidies up some issues and has some method enhancements.
8+
9+
The `regrid` and `to_latlon` methods can now be more efficient for multi-file datasets where all files have the same grid. Previously, the methods identified the grids for all methods. You
10+
can now set the `one_grid` argument to `True`, which will result in the methods assuming all files have the same grid, and only the first file being checked.
11+
12+
There was an issue with multi-file datasets in parallel in Python 3.8 and 3.9. A confusing TypeError was being thrown due to signalling issues by multiprocessing. This gave the impression there was
13+
a problem with processing when there wasn't one. This problem is now fixed.
14+
15+
416
Release of v0.8.5
517
---------------
618

nctoolkit/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
from nctoolkit.cleanup import cleanup, clean_all, deep_clean, temp_check
2222

2323
import atexit
24-
atexit.register(clean_all)
2524
import signal
2625

26+
atexit.register(clean_all)
27+
2728
signal.signal(signal.SIGTERM, clean_all)
28-
signal.signal(signal.SIGINT, clean_all)
2929

3030
from nctoolkit.create_ensemble import create_ensemble
3131
from nctoolkit.session import session_files
@@ -42,7 +42,7 @@
4242
try:
4343
from importlib.metadata import version as _version
4444
except ImportError:
45-
from importlib_metadata import version as _version
45+
from importlib_metadata import version as _version
4646

4747
try:
4848
__version__ = _version("nctoolkit")

nctoolkit/runthis.py

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import platform
66
import warnings
77
import multiprocessing
8+
import signal
89

910
from nctoolkit.cleanup import cleanup
1011
from nctoolkit.flatten import str_flatten
@@ -327,22 +328,26 @@ def run_cdo(command=None, target=None, out_file=None, overwrite=False, precision
327328
f"Please check dates supplied to nctoolkit".replace(" ", " ")
328329
)
329330

330-
331331
if "gridcell_areas" in error:
332332
if "Cell corner coordinates missing!" in error:
333-
raise ValueError("CDO was uanable to calculate cell areas because cell corner coordinates are missing")
333+
raise ValueError(
334+
"CDO was uanable to calculate cell areas because cell corner coordinates are missing"
335+
)
334336

335337
if "genbil" in error:
336338
if "support unstructured source grids" in error:
337-
raise ValueError("Unable to regrid an unstructured grid. Considering using nearest neighbour!")
339+
raise ValueError(
340+
"Unable to regrid an unstructured grid. Considering using nearest neighbour!"
341+
)
338342

339343
if "Unsupported grid" in error:
340344
if "unstructured" in error.lower():
341345
raise ValueError("This method does not supported unstructured grids!")
342-
346+
343347
if "Too many different grids" in error:
344-
raise ValueError("Error in internal CDO processing. Too many different grids for method. Consider subsetting to specific variables!")
345-
348+
raise ValueError(
349+
"Error in internal CDO processing. Too many different grids for method. Consider subsetting to specific variables!"
350+
)
346351

347352
text = re.compile(r"Variable >.*< not found!")
348353
errors = text.findall(error)
@@ -383,7 +388,6 @@ def run_cdo(command=None, target=None, out_file=None, overwrite=False, precision
383388
f"The following seasons were not available: {error}. Please check season supplied to nctoolkit methods!"
384389
)
385390

386-
387391
text = re.compile(r"Month [0-9]* not found")
388392
errors = text.findall(error)
389393
if len(errors) > 0:
@@ -392,7 +396,6 @@ def run_cdo(command=None, target=None, out_file=None, overwrite=False, precision
392396
f"None of the months supplied are in the dataset. Please check months supplied to nctoolkit methods!"
393397
)
394398

395-
396399
text = re.compile(r"Year [0-9]* not found")
397400
errors = text.findall(error)
398401
if len(errors) > 0:
@@ -536,10 +539,6 @@ def run_cdo(command=None, target=None, out_file=None, overwrite=False, precision
536539
)
537540
warned = True
538541

539-
540-
541-
542-
543542
else:
544543
messages = str(result).split("\\n")
545544

@@ -654,20 +653,30 @@ def run_cdo(command=None, target=None, out_file=None, overwrite=False, precision
654653
sel_level.append(int(re.findall(r"\d+", all_text[0])[0]))
655654
ignore = True
656655
if "grid latitudes differ" in x:
657-
warnings.warn(message = "Grid latitudes differ in operation. Check if this is acceptable!")
656+
warnings.warn(
657+
message="Grid latitudes differ in operation. Check if this is acceptable!"
658+
)
658659
ignore = True
659660

660661
if "grid longitudes differ" in x:
661-
warnings.warn(message = "Grid longitudes differ in operation. Check if this is acceptable!")
662+
warnings.warn(
663+
message="Grid longitudes differ in operation. Check if this is acceptable!"
664+
)
662665
ignore = True
663666

664667
if "found more than one time variable, skipped variable" in x:
665-
message = x.split( "found more than one time variable, skipped variable ")[1].replace("!", "")
666-
warnings.warn(message = f"CDO found more than one time variable. Only one is allowed. {message} was skipped")
668+
message = x.split("found more than one time variable, skipped variable ")[
669+
1
670+
].replace("!", "")
671+
warnings.warn(
672+
message=f"CDO found more than one time variable. Only one is allowed. {message} was skipped"
673+
)
667674
ignore = True
668675

669676
if "Using constant grid cell area weights!" in x:
670-
warnings.warn(message = "Using constant grid cell area weights! If you need weighted cell areas, please fix the dataset grid!")
677+
warnings.warn(
678+
message="Using constant grid cell area weights! If you need weighted cell areas, please fix the dataset grid!"
679+
)
671680
ignore = True
672681

673682
if "selmonth" in x:
@@ -721,60 +730,55 @@ def run_cdo(command=None, target=None, out_file=None, overwrite=False, precision
721730
)
722731
warned = True
723732
if "warning" in x:
724-
text = re.compile("unknown units \[.*\] supplied for grid cell corner .*; proceeding assuming .*!")
725-
text_find = text.findall("CDO warning: cdo(1) gridarea (warning): unknown units [degrees] supplied for grid cell corner longitudes; proceeding assuming radians!")
733+
text = re.compile(
734+
"unknown units \[.*\] supplied for grid cell corner .*; proceeding assuming .*!"
735+
)
736+
text_find = text.findall(
737+
"CDO warning: cdo(1) gridarea (warning): unknown units [degrees] supplied for grid cell corner longitudes; proceeding assuming radians!"
738+
)
726739
if len(text_find) > 0:
727740
message = text_find[0]
728741
message = "Warning for grid area calculations: " + message
729742
warnings.warn(message)
730743
warned = True
731744

732-
733-
734745
## Unsupported array structure message
735746
if "unsupported" in x and "skipped variable" in x:
736747
text = re.compile("skipped variable .*!")
737-
bad_var = text.findall("CDO warning: warning (cdfscanvarattr): time must be the first dimension! unsupported array structure, skipped variable fgco2_reg!")[0].split(" ")[2].replace("!", "")
748+
bad_var = (
749+
text.findall(
750+
"CDO warning: warning (cdfscanvarattr): time must be the first dimension! unsupported array structure, skipped variable fgco2_reg!"
751+
)[0]
752+
.split(" ")[2]
753+
.replace("!", "")
754+
)
738755
message = f"This variable's structure is not supported by CDO: {bad_var}. Full CDO warning: {x}"
739756
warnings.warn(message)
740757
warned = True
741758

742-
743759
if "warning" in x:
744-
if (
745-
"day 29feb not found"
746-
in x
747-
):
748-
warnings.warn(
749-
"No leap years found in data!"
750-
)
760+
if "day 29feb not found" in x:
761+
warnings.warn("No leap years found in data!")
751762
warned = True
752763

753-
text = re.compile("grids have different types! first grid: .*; second grid: .*")
764+
text = re.compile(
765+
"grids have different types! first grid: .*; second grid: .*"
766+
)
754767
checks = text.findall(x)
755768
if len(checks) > 0:
756769
i_out = checks[0].replace("grids have", "Grids have")
757770
warnings.warn(i_out)
758771
warned = True
759772

760773
if "warning" in x:
761-
if (
762-
"input parameters have different levels!"
763-
in x
764-
):
765-
warnings.warn(
766-
"Input parameters have different levels!"
767-
)
774+
if "input parameters have different levels!" in x:
775+
warnings.warn("Input parameters have different levels!")
768776
warned = True
769777

770778
if not warned:
771779
if "arning" in x:
772780
warnings.warn(f"CDO warning: {x}")
773781

774-
775-
776-
777-
778782
if len(sel_timestep) > 0:
779783
len_sel = len(sel_timestep)
780784
# first, figure out if this is a timestep range
@@ -917,7 +921,12 @@ def run_this(os_command, self, output="one", out_file=None, suppress=False):
917921
os_command = os_command.replace(" ", " ")
918922

919923
if cores > 1:
924+
original_sigint_handler = signal.signal(
925+
signal.SIGTERM, signal.SIG_IGN
926+
)
920927
pool = multiprocessing.Pool(cores)
928+
signal.signal(signal.SIGTERM, original_sigint_handler)
929+
921930
target_list = []
922931
results = dict()
923932
else:

0 commit comments

Comments
 (0)