function [Struct_new] = PickupNOPCs(Struct, Struct_time, N)
% function [Struct_new] = PickupNOPCs(Struct, Struct_time, N)
% Given a measurement days' Struct, pick up data with at least N sensor
% simutaneously

z_matrix = [];

OPC_ID = {'9284','9290','9281','9278','9287'};

for i = 1:length(OPC_ID)
   temp_z = Struct.(['OPC',OPC_ID{i}]).z;
   z_matrix = [z_matrix, temp_z];   
end

index_z = [];
for i = 1:size(z_matrix,1)
   if sum(~isnan(z_matrix(i,:)))>= N
       index_z = [index_z;i];
   end    
end

% apply the index_z unning
for i = 1:length(OPC_ID)
   for j = 1:7
      temp_x = Struct.(['OPC',OPC_ID{i}]).(['x_bin',num2str(j)]);
      temp_y = Struct.(['OPC',OPC_ID{i}]).(['y_fit_bin',num2str(j)]);
      temp_yerr = Struct.(['OPC',OPC_ID{i}]).(['yerr_fit_bin',num2str(j)]);
      
      Struct_new.(['OPC',OPC_ID{i}]).(['x_bin',num2str(j)]) = temp_x(index_z);
      Struct_new.(['OPC',OPC_ID{i}]).(['y_fit_bin',num2str(j)]) = temp_y(index_z);
      Struct_new.(['OPC',OPC_ID{i}]).(['yerr_fit_bin',num2str(j)]) = temp_yerr(index_z);      
   end
   temp_z_z = Struct.(['OPC',OPC_ID{i}]).z;
   Struct_new.(['OPC',OPC_ID{i}]).z = temp_z_z(index_z);    
end

Struct_new.SaltationSand.StartTimes = Struct_time.StartTimes(index_z);
Struct_new.SaltationSand.EndTimes = Struct_time.EndTimes(index_z);
Struct_new.SaltationSand.Q = Struct_time.Q(index_z);
Struct_new.SaltationSand.sigma_Q = Struct_time.sigma_Q(index_z);
Struct_new.SaltationSand.ustRe = Struct_time.ustRe(index_z);
Struct_new.SaltationSand.sigma_ustRe = Struct_time.sigma_ustRe(index_z);
Struct_new.SaltationSand.theta = Struct_time.theta(index_z);    


display('%--- function PickupNOPCs() complete ----%');


end