function [] = calcPBLH_Profile(campaign,mlh_type) 

    %campaign = 'DAQ_California';
    %pathname_merge = sprintf('/data2/juliechristo/%s/profiles/P3B_merge_mat_files/',campaign);
    %myFiles_merge = dir(fullfile(pathname_merge,'*20130904_R0_UHSAS_AS_equiv.mat'));
    %myFiles_merge = dir(fullfile(pathname_merge,'*.mat'));
    %pathname_coin = sprintf('/data2/juliechristo/%s/profiles/Coincidence_idx_files/',campaign); 
    %myFiles_coin = dir(fullfile(pathname_coin,'*20130904_P3B_HSRL_idx.mat'));
    %myFiles_coin = dir(fullfile(pathname_coin,'*.mat'));

    current_date = '';

    % -- Iterate through in-situ data  -- 
    for k = 1:length(myFiles_merge)
        subfilename_merge = myFiles_merge(k).name
        subfilename_coin = myFiles_coin(k).name
        date = subfilename_merge(1:8)
        merge_path = fullfile(pathname_merge,subfilename_merge);
        coin_file = fullfile(pathname_coin,subfilename_coin);
        merge_data = read_merge(campaign,merge_path,coin_file,'stripnan');

       %Initialize mlh for current day
       mlh_parcel_day = [];
       prof_num = [];
       time_prof = [];
       lat_prof = [];
       lon_prof = [];
       
        
        % -- Iterate through profiles for one day --
        num_profiles = length(merge_data.idx_start);
        for prof = 1:num_profiles
        %for prof = 7 
            land = 0; %all profiles conducted over land
            idx_start = merge_data.idx_start(prof);
            idx_end = merge_data.idx_end(prof);
            alt_prof = merge_data.Altitude(idx_start:idx_end);
            time_profile = merge_data.time_merge(idx_start:idx_end);
            time = mean(time_profile);
            %Profile locations
            lat_profile = merge_data.Latitude(idx_start);
            lon_profile = merge_data.Longitude(idx_start);
            %figure;
           % plot(time_prof,alt_prof)
            %Check if profile is increasing or decreasing
            if alt_prof(end) > alt_prof(1)
                order = "increasing";
       
            %need to reverse order of variables
            elseif alt_prof(end) < alt_prof(1)
                order = "decreasing";
            end 
            %plot(time_profile,alt_prof)
            [mlh_parcel_profile,Theta_ss,RH_ss,Altitude_ss,Temp_ss] = mlh_profile(merge_data,order,idx_start,idx_end,land,'parcel');
            mlh_parcel_day = [mlh_parcel_day;mlh_parcel_profile];
            prof_num = [prof_num; prof];
            time_prof = [time_prof;time];
            lat_prof = [lat_prof;lat_profile];
            lon_prof = [lon_prof;lon_profile];

        end
        
        % -- Write the results to .csv file -- 
        csv_filename = fullfile('/home/juliechristo/PBL_Project/PBL/land_model/drop/dropsondes/', [sprintf('%s_MLH_',campaign) date '.csv']);
        column_labels = {'Time','MLH_Parcel','Profile_#','Lat_Profile','Lon_Profile'};
        data_matrix = [time_prof,mlh_parcel_day,prof_num,lat_prof,lon_prof];
        data_with_labels = [column_labels;num2cell(data_matrix)];
        writecell(data_with_labels, csv_filename, 'WriteMode', 'append');


    end
        













