Skip to content

Commit

Permalink
Merge branch 'edsmall/nan-data' into 'master'
Browse files Browse the repository at this point in the history
Bug fix: NaN data

See merge request bodc/owc-software-python!27
  • Loading branch information
edsmall-bodc committed May 12, 2020
2 parents 350008a + 624f684 commit 7a0ebbe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions ow_calibration/get_region/get_region_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,24 @@ def get_region_data(pa_wmo_numbers, pa_float_name, config, index, pa_float_pres)
except:
raise Exception("NO DATA FOUND")

# we have encountered a problem where some data coming in is all NaN
# these columns need to be removed from the data set
nans = 0
for column in range(grid_sal.shape[1]):

if np.all(np.isnan(grid_sal[:, column - nans])) or \
np.all(np.isnan(grid_pres[:, column - nans])):

grid_sal = np.delete(grid_sal, column - nans, 1)
grid_ptmp = np.delete(grid_ptmp, column - nans, 1)
grid_pres = np.delete(grid_pres, column - nans, 1)
grid_lat = np.delete(grid_lat, column - nans)
grid_long = np.delete(grid_long, column - nans)
grid_dates = np.delete(grid_dates, column - nans)
nans += 1

if nans > 0:
print("Warning: found ", nans,
" all NaNs in your dataset. These water columns have been removed")

return grid_sal, grid_ptmp, grid_pres, grid_lat, grid_long, grid_dates
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def update_salinity_mapping(float_dir, float_name, config):
and np.argwhere(np.isnan(float_pres) == 0).any():

# tbase.int file requires longitudes from 0 to +/-180
float_long_tbase = float_long
float_long_tbase = copy.deepcopy(float_long)
if float_long_tbase > 180:
float_long_tbase -= 360

Expand All @@ -290,7 +290,7 @@ def update_salinity_mapping(float_dir, float_name, config):
float_name,
config)

# if we have data in the surrouding area, find depths at these points
# if we have data in the surrounding area, find depths at these points
if grid_lat.__len__() > 0:
# tbase.int file requires longitudes from 0 to +/-180
grid_long_tbase = copy.deepcopy(grid_long)
Expand Down

0 comments on commit 7a0ebbe

Please sign in to comment.