File tree Expand file tree Collapse file tree
pycurrents_ADCP_processing Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import json
33import numpy as np
44import xarray as xr
5+ import os
56
67
78# general utility functions common to multiple classes
@@ -75,6 +76,15 @@ def find_geographic_area(poly_dict, point):
7576 return name_str
7677
7778
79+ def find_geographic_area_attr (lon : float , lat : float ):
80+ # Geojson definitions for IOS
81+ json_file = 'ios_polygons.geojson'
82+ json_file = os .path .join (os .path .abspath (os .path .dirname (__file__ )), json_file )
83+ # json_file = os.path.realpath(json_file)
84+ polygons_dict = read_geojson (json_file )
85+ return find_geographic_area (polygons_dict , Point (lon , lat ))
86+
87+
7888def parse_processing_history (processing_history : str ):
7989 """
8090 Get number of leading and trailing ensembles cut from an ADCP dataset
@@ -174,3 +184,14 @@ def calculate_depths(dataset: xr.Dataset):
174184 return dataset .instrument_depth .data - dataset .distance .data
175185 else :
176186 return dataset .instrument_depth .data + dataset .distance .data
187+
188+
189+ def mean_orientation (o : list ):
190+ # orientation, o, is a list of bools with True=up and False=down
191+ if sum (o ) > len (o ) / 2 :
192+ return 'up'
193+ elif sum (o ) < len (o ) / 2 :
194+ return 'down'
195+ else :
196+ ValueError ('Number of \" up\" orientations equals number of \" down\" '
197+ 'orientations in data subset' )
You can’t perform that action at this time.
0 commit comments