Commit 7badef0f authored by hugocruzz's avatar hugocruzz
Browse files

Adjusted Gradient QC and L2 visu

parent 9f8f1ea9
Pipeline #342146 passed with stage
in 4 minutes and 29 seconds
This diff is collapsed.
This diff is collapsed.
......@@ -23,7 +23,6 @@ def interp_nan_grid(time,depth,temp, method='linear'):
return temp_interp
def interp_rescale(time, depth, time_grid, depth_grid, temp, method='linear'):
time_index = np.arange(0,len(time),1)
time_mesh, depth_mesh = np.meshgrid(time_index,depth)
time_grid_index=np.arange(0,len(time_grid),1)
......@@ -33,11 +32,12 @@ def interp_rescale(time, depth, time_grid, depth_grid, temp, method='linear'):
return temp_rescaled
def quality_assurance_tchain(depth_vec, dfplot, dfqual):
def quality_assurance_tchain(depth_vec, df, df_qual, time_epilimnion_grad_threshold = 1.5,
time_hypolimnion_grad_threshold = 0.4 ,depth_grad_threshold = 1):
log("Performing gradient check along time and depth")
dfplot = df.copy()
dfqual = df_qual.copy()
ndepth = dfplot.shape[0]
time_epilimnion_grad_threshold = 0.7
time_hypolimnion_grad_threshold = 0.05
depth_grad_threshold = 0.1
for depth in range(0, 30):
vec = np.copy(dfplot[depth, :])
......@@ -110,6 +110,10 @@ def quality_assurance_tchain(depth_vec, dfplot, dfqual):
dfqual[depth, vec_index] = 0
ntime = dfplot.shape[1]
for depth in range(0, ndepth):
if np.quantile(dfqual[depth,:], 0.2)==1:
dfqual[depth,:] = np.ones(ntime)
for time in range(0, ntime):
vec = np.copy(dfplot[:, time])
vec_depth = np.copy(depth_vec)
......@@ -128,13 +132,20 @@ def quality_assurance_tchain(depth_vec, dfplot, dfqual):
indremove_vertical = np.where(vec_diff > depth_grad_threshold)[0]
if len(indremove_vertical) > 0:
indremove_vertical = np.unique(indremove_vertical) + 1
for layer in range(0,len(indremove_vertical)):
if vec[indremove_vertical[layer] +1] > vec[indremove_vertical[layer]]:
indremove_vertical = np.unique(indremove_vertical)
else:
indremove_vertical = np.unique(indremove_vertical)+1
vec_index = np.delete(vec_index, indremove_vertical)
dfqual[:, time] = 1
dfqual[vec_index, time] = 0
return dfqual
def copy_variables(variables_dict):
......
......@@ -13,4 +13,4 @@ Level1_dir: "data/Level1/"
Level2_dir: "data/Level2/"
# Processing directory used to temporarily store files during Level 0 --> Level 1 processing
process_dir: "C:/Users/Seatronic 1147/Documents/Data_Lexplore/git/temperaturechain_v2/data/unprocessed/"
#process_dir: "C:/Users/Seatronic 1147/Documents/Data_Lexplore/git/temperaturechain_v2/data/unprocessed/"
......@@ -10,7 +10,6 @@ from datetime import datetime
from functions import json_converter, log, copy_variables, quality_assurance_tchain, interp_rescale, interp_nan_grid
from envass import qualityassurance
import json
import matplotlib.pyplot as plt
from dateutil.relativedelta import relativedelta
class temperaturechain_data(object):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment