Home > reduc > get_days_observed_els.m

get_days_observed_els

PURPOSE ^

SYNOPSIS ^

function elevation_list =get_days_observed_els(file,date)

DESCRIPTION ^

 JL

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function elevation_list =get_days_observed_els(file,date)
0002 %
0003 % JL
0004 %
0005 
0006 %Assumes the schedules increment from a base of 37.0
0007 %if not change this
0008 
0009 elevation_base = 37.0;
0010 
0011 %pwd
0012 %disp(['get_days_observed_els:: Opening file: ',file]);
0013 
0014 fid = fopen(file,'r');
0015 
0016 if fid < 0
0017     disp(['get_days_observed_els:: File failed to open: ',file]);
0018 end
0019 
0020 
0021 start_dates = {};
0022 end_dates = {};
0023 schedule = {};
0024 
0025 i=0;
0026 
0027 elevation_map = containers.Map();
0028 
0029 while 1
0030     
0031     tline = fgetl(fid);
0032 
0033     if(~ischar(tline))
0034         %disp(['get_days_obs:: Closing file']);
0035         ST = fclose(fid);
0036         break;
0037     end;
0038     
0039     % Modified to ensure that the date appears in the START time.
0040     dloc = regexp(tline,date);
0041 
0042     if isempty(dloc)
0043         continue
0044     end
0045 
0046     
0047 
0048     % Well, is it?
0049     if (dloc(1) < 10)       
0050          i=i+1;
0051         % disp(tline);
0052         % Need to get second parameter in this form
0053         % 05-Nov-2010:07:48:27      05-Nov-2010:09:33:02      /home/cbass/gcpCbass/control/sch/cbass_survey_0.2.sch( 7:45:00, 0:00:00 )
0054         % Need to get first parameter if it is off this form.
0055         % 13-May-2013:14:06:01      13-May-2013:15:40:20      /home/cbass/gcpCbass/control/sch/cbass_survey_5speed.sch( 0:00:00, 4 )
0056     %disp(num2str(i));
0057     if((strfind(tline,'cbass_survey_')))
0058          % is a cbass_survey
0059      %disp(tline)
0060      %disp('Found a survey')
0061          if((strfind(tline,'5speed'))) 
0062         % disp('Found a 5 speed survey');
0063             % split the line at the first bracket + 1 or more whitespace
0064             the_match = regexp(tline, '\(\s*\d{1,2}:\d{2}:\d{2},', 'match');
0065          else
0066             % disp('Found an other format survey');
0067             % assume its the other format so we need to get the second parameter.
0068             the_match = regexp(tline, ',\s*\d{1,2}:\d{2}:\d{2}\s*\)', 'match');  
0069          end
0070           % at this point we have either ( 0:00:00, or 0:00:00 )
0071           % Need to get just digit colon bit.
0072 
0073           % MATLAB fucknuttery means the following returns a cell rather than
0074           % a string for some reason.
0075           stripped_match = regexp(the_match, '\d{1,2}:\d{2}:\d{2}', 'match');
0076           % so convert it back.
0077       %keyboard;
0078           stripped_match_string = char(stripped_match{1});
0079           %disp(['The string is ',stripped_match_string]);
0080           % keyboard;
0081         if (~isKey(elevation_map,stripped_match_string))
0082        %disp('Initial');
0083        elevation_map(stripped_match_string)= 1;
0084     else
0085            %disp('Incrementing...');
0086            elevation_map(stripped_match_string)= elevation_map(stripped_match_string) + 1;
0087         end
0088 
0089      end   
0090 end
0091 end
0092 
0093 %disp('done');
0094 
0095 the_keys = keys(elevation_map);
0096 elevation_list = [];
0097 for i=1:length(keys(elevation_map));   
0098 
0099   %disp (the_keys(i))
0100   [rajunk,elevation_no]=str2deg('00:00:00',the_keys(i));
0101   %disp(num2str(elevation_no));
0102   elevation_no=elevation_base + elevation_no;
0103   elevation_list = [elevation_list,elevation_no];
0104 end
0105 
0106 %keys(elevation_map)
0107 %values(elevation_map)
0108 
0109 
0110 
0111 %        splitline = regexp(tline, '\s+', 'split');
0112         % If the second element contains a / it is a pathname rather than a time
0113         % i.e. no end time was written becuase the control system crashed.
0114 %        if (~isempty(strfind(char(splitline(2)), '/')) )
0115 %            start_dates(i) =  {'Error'};
0116 %            end_dates(i) =  {'Error'};
0117 %            schedule(i)  =  {'Error'};
0118 %            source_name(i)={'Error'};
0119 %        else
0120 %            start_dates(i) =  splitline(1);
0121 %            end_dates(i)  =  splitline(2);
0122 %            schedule(i)  =  splitline(3);
0123             % Grab source name if it is a raster or source scan
0124 %            if((strfind(char(schedule(i)),'source')))
0125 %                source_name(i) = splitline(6);
0126 %            else
0127 %                source_name(i) = schedule(i);% Just use sched name
0128 %            end
0129             
0130 %        end
0131 %    end
0132     
0133 %end
0134 
0135 %fclose(fid);
0136 
0137 end

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005