% MATALB CODE for Lidar Data Reduction. %

% MATALB CODE for Lidar Data Reduction. %

<p>%************************************************************************** %************************************************************************** % MATALB CODE for lidar data reduction. % [email protected] % Last modified 26 Feb. 2007 function [Ns_process, altitude_kmb]= Proj4(go_func_go); clear all; clc; close all; bin_res = 7; % bin resolution t_bin = 160e-9; % bin width [nsec] c = 2.99792458e8; % speed of light [m/s] file_ii = 1; % file step counter for file_num =1:8:9</p><p>%********************************************************************** % Read the raw data for both files</p><p>% File and data path construction file_name = strcat('AR1102.00', int2str(file_num)); dir = 'C:\Program Files\MATLAB704\work\Lidar\proj4\Data\'; </p><p> file_dir = strcat(dir, file_name);</p><p>% Read Lidar Data File, Data is indexed as: Ns(10240,3) = Ns(bins,freq) [Ns, tot_bins, low_bin, freq_tot, set_num, prof_num, shot_num, month,... day, year, UT_time, hour, minute, second, az_ang, bin_res, zen_ang, ... base_alt, lat, lon] = ReadLidarData(file_dir);</p><p>% Convert Bins to Ranges, this is common for all three frequencies. n_bin = [low_bin(1):tot_bins(1)]; % Create the bin array delta_R = t_bin*c/2; % [m] Compute range resolution, ie. Bin width in terms of range range = n_bin .* delta_R; %[m] Convert bin array to range array bin_bas = round((base_alt(1)*1e3) / delta_R);% Convert base altitude of lidar instrument into number of bins</p><p>%********************************************************************** % Convert Range to Height over sea level, account for the zenith angle</p><p> height = (range .* cosd(zen_ang(1))) + base_alt(1)*1e3; % [m] altitude_km =height./1e3; all_bin =n_bin + bin_bas;</p><p>% plot raw photon counts vs. bin number and altitude figure(1) [AX,H1,H2] =plotyy(Ns,all_bin, 0,altitude_km,'plot'); set(get(AX(1),'Ylabel'),'String','Bin number') set(get(AX(2),'Ylabel'),'String','Altitude [km]') title('2) Raw photon counts vs. altitude and bin number') xlabel('Photon Counts') legend('f_a','f_+','f_-')</p><p>%********************************************************************** % PMT/discriminator saturation correction .Do the photon count % correction one profile at the time.</p><p> for profile=1:3</p><p>% Flatten the photon counts array Ns_flat = Ns(:,profile);</p><p>% PMT Saturation Correction using Newtonian method (function given) Ns_corr = SaturationCorrectionVector(Ns_flat, delta_R, tot_bins(profile), shot_num(profile));</p><p>% Plot PMT Staturation Corrected Data if profile == 1 figure(2) plot(Ns_corr,altitude_km,'m') title('3) PMT Saturation Corrected Data') ylabel('Altitude [km]') xlabel('Photon Counts') legend('f_a (profile 1)') axis tight end</p><p>%****************************************************************** % Chopper Correction</p><p>% Read in chopper profiles from data files chop_open_file = 'chopperopen.dat';</p><p>% Data is ordered as: chopdata(bin, count, Hamming) chop_open = ReadChopperData(dir, chop_open_file);</p><p>% Divide the profile bins that actually needs to be chopper corrected % with the chopper function data Ns_corr(chop_open(:,1))= Ns_corr(chop_open(:,1))./chop_open(:,3)';</p><p>% Plot chopper corrected peak frequency vs. height if profile == 1 figure(3) plot(Ns_corr,altitude_km, 'k') title('Corrected Data for Chopper') ylabel('Altitude [km]') xlabel('Photon Counts') axis tight end</p><p>%****************************************************************** % Subtract background and plot peak-freq profile % Good background is assumed to be 138-180 km (J.F). From here a % mean is derived and subtracted from all altitudes. </p><p>%find index possition at 130 km and 180 km [trash array_pos_bot] = min(abs(altitude_km -130)); [trash array_pos_top] = min(abs(altitude_km -180));</p><p>% Take mean of the signal at the back ground range indicated above % as the back ground signal for all altitudes Nb_corr = (Ns_corr - (mean(Ns_corr(array_pos_bot:array_pos_top))));</p><p>% Plot background corrected peak frequency vs. height if profile == 1 figure(4) plot(Nb_corr, altitude_km, 'k') title('5) Data with backgound noise removed') ylabel('Altitude [km]') xlabel('Photon Counts') axis tight end</p><p>%****************************************************************** % Remove range dependence, ie multiply by range squared range_corr = Nb_corr.*(range.^2);</p><p>% Plot range corrected peak frequency vs. height if profile == 1 figure(5) plot(range_corr, altitude_km) title('6)Data (Range Corrected)') ylabel('Altitude [km]') xlabel('Photon Counts') axis tight end</p><p>%****************************************************************** % Add base altitude (to the bins)and take the Rayleigh % signal at 40km as the Rayleigh normalization signal. % Plot Rayleigh fitting and Rayleigh signal for the peak-freq data % profiles.</p><p>% Rayleigh fit (35-40) & Rayleigh signal @ 40 km [trash ray_pos_bot] = min(abs(altitude_km -35)); [trash ray_pos_cen] = min(abs(altitude_km -40)); [trash ray_pos_top] = min(abs(altitude_km -45)); logfit = polyfit(altitude_km(ray_pos_bot:ray_pos_top),... log(range_corr(ray_pos_bot:ray_pos_top)),1); fit_pts_log =polyval(logfit,altitude_km((ray_pos_bot:ray_pos_top)),1); fit_pts_lin = exp(fit_pts_log); Ray_Ns = exp(mean(fit_pts_log));</p><p>% Plot data with Rayligh fit @ 40 km if profile == 1 figure(6) plot(range_corr, altitude_km,'c', Ray_Ns,altitude_km(ray_pos_cen),... 'kp',fit_pts_lin, altitude_km(ray_pos_bot:ray_pos_top),'r') title('7) Rayleigh signal @ 40 km & Rayleigh fit(35-40 km)') ylabel('Altitude [km]') xlabel('Photon Counts') axis tight end</p><p>%****************************************************************** % Normalized signal with Ray_Ns Ns_norm = range_corr ./Ray_Ns;</p><p>%Plot normalized data if profile == 1 figure(7) plot(Ns_norm, altitude_km) title('8) Normalized signal with Ray_Ns') ylabel('Altitude [km]') xlabel('Photon Counts') axis tight end</p><p>% Save the different profile Ns_norm_profile(profile,:) = Ns_norm;</p><p>%****************************************************************** % Rebin. 24m => 480m each bin rep. 24 m. (10 240 bins)</p><p>%Create the binner array to use with function accumarray when binning rebinX = 20; binner = ones(1, rebinX); for bc=2:(tot_bins(1)/rebinX) binner = [binner ones(1, rebinX).*bc]; end binner = binner';</p><p>% rebin altitude bindex = [rebinX/2:rebinX:tot_bins(1)]; altitude_kmb = altitude_km(bindex);</p><p>Ns_norm = accumarray(binner, Ns_norm)'; if profile == 1 figure(8) plot(Ns_norm, altitude_kmb) title('Re Binned Ns_ norm') ylabel('Altitude [km]') xlabel('Photon Counts') axis tight end </p><p>% Save the different profile Ns_norm_rebin_profile(profile,:) = Ns_norm;</p><p> end %of for profile</p><p>Ns_process(file_ii,:,:)= Ns_norm_rebin_profile; file_ii = file_ii+1; end</p><p>%End of file</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us