diff --git a/Dockerfile b/Dockerfile index 583973e..5beb2be 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11 +FROM python:3.9 RUN apt-get update -y ; apt-get install -y nano netcdf-bin -RUN pip install xarray netcdf4 numpy scipy pymongo shapely geopy +RUN pip install xarray netcdf4 numpy scipy pymongo shapely geopy argovisHelpers diff --git a/gridtools.py b/gridtools.py deleted file mode 100644 index 3671a5b..0000000 --- a/gridtools.py +++ /dev/null @@ -1,296 +0,0 @@ -import scipy, numpy, copy, math - -def label_features(feature_map, structure=[[1,1,1],[1,1,1],[1,1,1]], connected_poles=True, periodic_dateline=True): - # given a 2D numpy array feature_map[latitude][longitude] labeling features with 1 and voids with 0, - # label distinct isolated features. - # periodic_dateline = True makes a periodic boundary on the inner index - # connected_poles = True makes all features touching a pole connected - - labeled_map = scipy.ndimage.label(feature_map, structure=structure)[0] - - # periodic boundary - if periodic_dateline: - if structure == [[0,1,0],[1,1,1],[0,1,0]]: - # no diag - for y in range(labeled_map.shape[0]): - if labeled_map[y, 0] > 0 and labeled_map[y, -1] > 0: - labeled_map[labeled_map == labeled_map[y, -1]] = labeled_map[y, 0] - elif structure == [[1,1,1],[1,1,1],[1,1,1]]: - # diagonally connected - for y in range(labeled_map.shape[0]): - if labeled_map[y, 0] > 0 and labeled_map[y, -1] > 0: - labeled_map[labeled_map == labeled_map[y, -1]] = labeled_map[y, 0] - elif labeled_map[y, 0] > 0 and labeled_map[max(y-1,0), -1] > 0: - labeled_map[labeled_map == labeled_map[max(y-1,0), -1]] = labeled_map[y, 0] - elif labeled_map[y, 0] > 0 and labeled_map[min(y+1,labeled_map.shape[0]-1), -1] > 0: - labeled_map[labeled_map == labeled_map[min(y+1,labeled_map.shape[0]-1), -1]] = labeled_map[y, 0] - - # connected poles - if connected_poles: - spole_features = [x for x in numpy.unique(labeled_map[0]) if x > 0] - if len(spole_features) > 1: - for feature in spole_features[1:]: - labeled_map[labeled_map == feature] = spole_features[0] - npole_features = [x for x in numpy.unique(labeled_map[-1]) if x > 0] - if len(npole_features) > 1: - for feature in npole_features[1:]: - labeled_map[labeled_map == feature] = npole_features[0] - - return labeled_map - -def trace_shape(labeled_map, label, winding='CCW'): - # trace the shape labeled with