Skip to content
Snippets Groups Projects
Commit ed16ca4a authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Move function `get_slice` to method of SHPC class

parent 4ad79fc0
Branches
Tags
No related merge requests found
......@@ -3,6 +3,7 @@ import math
from os import path
import numpy as np
import sys
import bisect
class SHPC_class:
def __init__(self, SHPC_dir, def_orient):
......@@ -117,6 +118,11 @@ class SHPC_class:
"ishape_last.txt")
np.savetxt(fname, self._ishape_last[i_slice][orientation], fmt = "%.0d")
def get_slice(self, date_index):
i_slice = bisect.bisect(self.d_init, date_index) - 1
assert i_slice >= 0
return i_slice
def comp_ishape(date, eddy_index, SHPC, i_slice, orientation):
"""Compute the location in the shapefiles."""
......
......@@ -23,7 +23,6 @@ import json
import math
import report_graph
import util_eddies
import bisect
import argparse
Omega = 2 * math.pi / 86164.
......@@ -54,11 +53,6 @@ def calculate_radii_rossby(properties):
if n_valid_Rossby != 0: avg_Rossby /= n_valid_Rossby
return avg_rad, avg_Rossby
def get_slice(array_d_init, date_index):
i_slice = bisect.bisect(array_d_init, date_index) - 1
assert i_slice >= 0
return i_slice
def node_to_prop(node_list, e_overestim, SHPC):
"""node_list is a list of node identification numbers for
instantaneous eddies. This function returns some properties of the
......@@ -72,7 +66,7 @@ def node_to_prop(node_list, e_overestim, SHPC):
for n in node_list:
date_index, eddy_index = report_graph.node_to_date_eddy(n, e_overestim)
i_slice = get_slice(SHPC.d_init, date_index)
i_slice = SHPC.get_slice(date_index)
ishape = util_eddies.comp_ishape(date_index, eddy_index, SHPC, i_slice,
SHPC.def_orient)
shapeRec = SHPC.get_reader(i_slice, "extremum").shapeRecord(ishape)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment