0001 function [sources usn] = get_calobs(date_start,date_end,sched_to_reduce)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 [home,installeddir] = where_am_i();
0022
0023 start_date_num = datenum(date_start);
0024 end_date_num = datenum(date_end);
0025 n_source = 1;
0026 start_date = datestr(start_date_num);
0027 end_date = datestr(end_date_num);
0028 disp(['Will look at all the data from ',start_date, '--> ',end_date]);
0029
0030 for j=0:(end_date_num - start_date_num)
0031 date = datestr(start_date_num + j);
0032 disp(['Will reduce ',date, ' for schedule ',sched_to_reduce]);
0033
0034 file = 'log/obs_log.html';
0035 try
0036 [start_dates,end_dates,schedule] =get_days_obs(file,date);
0037 if strcmp(char(start_dates),'Error')
0038 continue;
0039 end;
0040 catch exception
0041 error_string= ['FAILED TO FIND ANY DATA ON ',char(date)];
0042 disp(error_string);
0043 continue;
0044 end;
0045 disp(['day_reduce: FOUND ',int2str(length(start_dates)),' observations...']);
0046
0047 for i=1:length(start_dates)
0048
0049 sched_bits = regexp(char(schedule(i)), '/', 'split');
0050 sched_name = char(sched_bits(length(sched_bits)));
0051
0052 sched_name = strrep(sched_name, '(','');
0053 disp(['day_reduce: Schedule is ',sched_name]);
0054
0055 if (exist('sched_to_reduce'))
0056 if (~strncmp(sched_name,sched_to_reduce,length(sched_to_reduce)))
0057 disp(['day_reduce: Skipping this observation - does not match the requested schedule i.e. ',sched_to_reduce]);
0058 continue;
0059 end;
0060 end;
0061
0062 start_string = remove_colon_datestring(char(start_dates(i)));
0063 end_string = remove_colon_datestring(char(end_dates(i)));
0064 start_num = datenum(start_string);
0065 end_num = datenum(end_string);
0066
0067 obs_length_mins = (end_num-start_num)*24*60;
0068
0069 if (obs_length_mins<180)
0070
0071 try
0072
0073 disp(['READING Obs No. ', int2str(i),' of ',int2str(length(start_dates)),' -> ',char(start_dates(i)),' --- ',char(end_dates(i))]);
0074
0075 if strcmp(char(start_dates(i)),'Error')
0076 continue;
0077 end;
0078 d=pipe_read(char(start_dates(i)),char(end_dates(i)));
0079 catch exception
0080 error_string= ['day_reduce: FAILED TO READ ', int2str(i),' of ',int2str(length(start_dates)), ' -> ',char(start_dates(i)),' --- ',char(end_dates(i))];
0081 disp(error_string);
0082
0083
0084
0085 continue;
0086 end;
0087
0088
0089 new_source = length(unique(d.antenna0.tracker.source));
0090 source_names = unique(d.antenna0.tracker.source);
0091 for k = 1:new_source;
0092 sources{n_source+k-1,1} = source_names{k,1};
0093 sources{n_source+k-1,2} = char(start_dates(i));
0094 sources{n_source+k-1,3} = char(end_dates(i));
0095 end
0096 n_source = n_source+new_source;
0097 end;
0098 end;
0099
0100 end;
0101
0102
0103
0104
0105 if(n_source>1)
0106
0107 fid = fopen(([home,'/',installeddir,'/log/calibrator_list.log']),'a+')
0108
0109
0110 for i=1:length(sources);
0111 fprintf(fid,'%12s %20s %20s\n',sources{i,:});
0112 end
0113 fclose(fid);
0114
0115
0116 cd ([home,'/',installeddir,'/log'])
0117 system('grep -v "NCP" calibrator_list.log > c.txt');
0118 system('grep -v "current" c.txt > c.txt2');
0119 system('mv c.txt2 calibrator_list.log');
0120 system('rm c.txt');
0121 cd ([home,'/',installeddir,]);
0122
0123 usn = unique(sources(:,1));
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156 else
0157 disp(' ');
0158 disp('DID NOT FIND ANY CALIBRATORS DURING THIS TIME PERIOD')
0159 sources = 0;
0160 usn = 0;
0161 end
0162
0163 function processed_string = remove_colon_datestring(date_string)
0164 splitline = regexp(char(date_string), ':', 'split');
0165 processed_string=[char(splitline(1)),' ',char(splitline(2)),':',char(splitline(3)),':',char(splitline(4))];
0166
0167 function processed_string = insert_colon_datestring(date_string)
0168 splitline = regexp(char(date_string), ' ', 'split');
0169 processed_string=[char(splitline(1)),':',char(splitline(2))];