function data = quicklook_UH(expname,trialname,m)

% QUICKLOOK_UH
%
% quicklook_uh(expname,trialname, m);
% m = 0 to plot
% m = 1 to not plot
% Generates a quick plot and statistics for the specified raw trial.
%
% SEE ALSO: PROCESS_RAW_TRIAL, PROCESS_RAW_EXPERIMENT
% 

% setup
sharename = 'C:\Users\ulmn\Documents\MATLAB\';  % change for your OS
year = '2021';
projname = 'TEAMERUHOWC';
disp(['quicklook_raw_trial for project ',projname,', experiment ',expname,', ',trialname]);
close all

% load instrument locations
instr_loc = load_instrument_locations(sharename,year,projname);

% load calibration slopes offsets and units
calibrations = load_calibrations(sharename,year,projname);

% load trial
data = load_raw_trial(sharename,year,projname,expname,trialname);

% make sure we got data
if isstruct(data)
    % process analog
    disp('   process_raw_trial: processing analog data')
    uswgchannels = find_uswgs(data); % find uswgs for cleanup
    wgchannels = find_wgs(data); % find wgs for zero offset removal
    data = find_wmstart(data); % find zero_range, waves_running_range
    
    % remove offsets on wgchannels from still water period
    if ~isempty(wgchannels)
        disp('   process_raw_trial: removing wave gage still water offsets')
        Nwg = length(wgchannels);
        for nwg = 1:Nwg
            nc = wgchannels(nwg);
            channelname = data.channelnames{nc};
            zero_offset = mean(data.(channelname).analog(data.(channelname).zero_range)); % average value during zero_range
            data.(channelname).analog = data.(channelname).analog - zero_offset; % subtract from full timeseries
        end
    end
    
    % clean up any uswgs
    if ~isempty(uswgchannels)
        disp('   process_raw_trial: cleaning up sonic gages')
        Nuswg = length(uswgchannels);
        for nuswg = 1:Nuswg
            nc = uswgchannels(nuswg);
            channelname = data.channelnames{nc};
            disp(['   process_raw_trial: cleaning up ',channelname])
            zero_offset = mean(data.(channelname).analog(data.(channelname).zero_range)); % average value during zero_range
            data.(channelname).analog = data.(channelname).analog - zero_offset; % subtract from full timeseries
            data.(channelname) = cleanup_uswg(data.(channelname));
        end
    end
    
    % calibrate
    data = calibrate_raw_data(data,calibrations,'WG_AND_USWG');
    
    % locate
    data = locate_raw_data(data,instr_loc);
    
    % still water depth
    h = find_still_water(data);
    
    % process advs
    if isfield(data,'advnames') && ~isempty(data.advnames)
        % check adv temperatures
        data = check_adv_temperatures(data);
        
        % process advs
        Nadv = length(data.advnames);
        for nadv = 1:Nadv
            % setup for this adv
            advname = data.advnames{nadv};
            disp(['   process_raw_trial: processing ',advname])
                        
            % clean up
            if data.(advname).z < h
                % advs are in water
                flags.use_amp = 0;
                flags.use_snr = 0;
            else
                % advs are in and out of water
                flags.use_amp = 1;
                flags.use_snr = 1;
            end
            flags.use_corr = 1; % correlation to identify bad points
            flags.use_phase = 0; % tsunami waves; no phasespace despiking
            flags.smoothing = 1; % smooth data after replacing bad points
            cleanadv = cleanup_adv(data.(advname),flags);
            
            % rotate into HWRL coordinates
            % downlooking probe oriented horizontally
            data.(advname).u = cleanadv.u;
            data.(advname).v = -cleanadv.w;
            data.(advname).w = cleanadv.v;
            
            % done
            disp(['   process_raw_trial: done with ',advname])
        end
    end
    
    % so far the above is the same as process_raw_trial.m
    % from here below we just make some plots
if m == 0
    % plot standard, led, wmstart, sinewave, wmdisp, level
    figure
    subplot(3,1,1)
    plot(data.standard.time,data.standard.analog);
    hold on;
    plot(data.led.time,data.led.analog);
    plot(data.wmstart.time,data.wmstart.analog);
%     plot(data.sinewave.time,data.sinewave.analog);
    title('Voltages, water level, board displacement');
    ylabel('V');
    legend('standard','led','wmstart','sinewave');
    subplot(3,1,2);
    plot(data.level.time,data.level.analog+data.level.z,data.depth.time,data.depth.analog);
    ylabel('h (m)');
    legend('level','depth');
    subplot(3,1,3);
    plot(data.wmdisp15.time,data.wmdisp15.analog);
    ylabel('s (m)');
    legend('wmdisp');
    xlabel('time (s)');
    
    % plot wave gauges from offshore to onshore
    figure
    subplot(4,1,1);
    plot(data.wmwg15.time,data.wmwg15.analog);
    hold on
    plot(data.wg1.time,data.wg1.analog);
    plot(data.wg2.time,data.wg2.analog);
    title('Wave gauges');
    ylabel('\eta (m)');
    legend('wmwg15','wg1','wg2');
    subplot(4,1,2);
    plot(data.wg3.time,data.wg3.analog);
    hold on
    plot(data.wg4.time,data.wg4.analog);
    ylabel('\eta (m)');
    legend('wg3','wg4');
    subplot(4,1,3);
    plot(data.wg5.time,data.wg5.analog);
    hold on
    plot(data.wg6.time,data.wg6.analog);
    plot(data.wg7.time,data.wg7.analog);
    ylabel('\eta (m)');
    legend('wg5','wg6','wg7');
    subplot(4,1,4)
    plot(data.wg8.time,data.wg8.analog);
    hold on
    plot(data.wg9.time,data.wg9.analog);
    plot(data.wg9.time,data.wg10.analog);
    ylabel('\eta (m)');
    legend('wg8','wg9','10');
    xlabel('time (s)')

    % plot remaining wave gauges
    figure
    plot(data.wg11.time,data.wg11.analog);
    hold on
    plot(data.wg12.time,data.wg12.analog);
    plot(data.wg13.time,data.wg13.analog);
    plot(data.wg14.time,data.wg14.analog);
    title('Wave gauges');
    ylabel('\eta (m)');
    legend('wg11','wg12','wg13','wg14');    
    
    % plot wave gauge inside OWC
    figure
    plot(data.wg15.time,data.wg15.analog);
    title('Wave gauges');
    ylabel('\eta (m)');
    legend('wg15');    
    
    % plot mooring load cells
    figure
    plot(data.load1.time,data.load1.analog);
    hold on
    plot(data.load2.time,data.load2.analog);
    plot(data.load3.time,data.load3.analog);
    plot(data.load4.time,data.load4.analog);
    title('Mooring line load cells');
    ylabel('Force (N)');
    legend('mooring1','mooring2','mooring3','mooring4');
    xlabel('time (s)');
    
    % plot pressure sensors
    figure
    plot(data.press1.time,data.press1.analog);
    hold on
    plot(data.press2.time,data.press2.analog);
    plot(data.press3.time,data.press3.analog);
    plot(data.press4.time,data.press4.analog);
    title('Pressure sensors');
    ylabel('?');
    legend('press1','press2','press3','press4');
    xlabel('time (s)');
end
end  
    
% done
disp('quicklook_raw_trial done')

end
