0001
0002
0003
0004 clear
0005
0006
0007
0008 [r, home] = unix('printenv CBASSHOME');
0009 home= '/home/charles/';
0010 logfile = ([home, '/cbass_analysis/log/obs_log.html']);
0011 pipeline_file = @pipelinedData
0012 start_scan=1;
0013 max_time=4
0014 scanlocation=(['/data/cbassuser/data/scanfits/']);
0015 out_dir = 'CarmaFilter2'
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 t3=extract_obslog(logfile,'cbass_survey_test','19-Jun-2010:00:00:11','13-Sep-2010:15:32:34');
0026
0027 t=t3;
0028
0029 for i=1:length(t)
0030 tstring=strtrim(t{i,1});
0031 tstring2=strtrim(t{i,2});
0032 tt(i,1) = datenum(tstring,'dd-mmm-yyyy:HH:MM:ss');
0033 tt(i,2) = datenum(tstring2,'dd-mmm-yyyy:HH:MM:ss');
0034
0035 end
0036
0037
0038 aa=[];
0039 for i=1:length(t)
0040
0041
0042 startt=tt(i,1);
0043 endt=tt(i,2);
0044 scan_time=endt-startt;
0045 while (scan_time > max_time/24)
0046 aa=[aa;[startt startt+max_time/24]];
0047 startt=startt+(max_time+0.00001)/24;
0048 scan_time=endt-startt;
0049 end
0050 aa=[aa;[startt endt]];
0051
0052 end
0053
0054 for i=1:length(aa)
0055 tsplit{i,1}=datestr(aa(i,1),'dd-mmm-yyyy:HH:MM:ss');
0056 tsplit{i,2}=datestr(aa(i,2),'dd-mmm-yyyy:HH:MM:ss');
0057 end
0058
0059 numscans=length(tsplit);
0060 i=0;
0061 n=0;
0062
0063 [r, home] = unix('printenv HOME');
0064
0065
0066 if ~strcmp(home(1:5),'/home')
0067
0068 startpt=find(home=='/');
0069 home=home(startpt(1):end-1);
0070 clear startpt
0071 else
0072 home=home(1:end-1);
0073 end
0074
0075
0076 i=start_scan
0077 try
0078 unix(['mkdir ',scanlocation,out_dir,'/']);
0079 catch
0080 disp('Error making the scan directory')
0081 end
0082 while i<=numscans
0083 fits{i} = ([scanlocation,out_dir,'/',num2str(i-1),'.fits']);
0084
0085
0086
0087
0088 i=i+1;
0089
0090 end
0091
0092
0093 for i=start_scan:numscans
0094 close all;
0095 try
0096 time1{i}=tsplit{i,1};
0097 time2{i}=tsplit{i,2};
0098 disp(['Recording the fits file: ',fits{i}])
0099 disp(['Time Start: ',time1{i},' Time End: ',time2{i}]);
0100 disp(['Total Reduction Run from ',tsplit{1},' to ',tsplit{length(tsplit),2}]);
0101 d=pipe_read(time1{i},time2{i});
0102 disp(['Total Reduction Run from ',tsplit{1},' to ',tsplit{length(tsplit),2}]);
0103 catch
0104 disp('Failed to Read in Data')
0105 clear d
0106 clear flags
0107 continue
0108 end
0109
0110
0111 try
0112 d = pipeline_file(d)
0113 catch
0114 disp('Failed the pipelining')
0115 clear d
0116 clear flags
0117 continue
0118 end
0119 try
0120 disp('0')
0121 unix(['rm ',fits{i}]);
0122
0123 start_batch_scan = datenum(tsplit{1},'dd-mmm-yyyy:HH:MM:ss');
0124 disp('1')
0125 end_batch_scan = datenum(tsplit{length(tsplit),2},'dd-mmm-yyyy:HH:MM:ss');
0126 disp('2')
0127 [y_start_batch,m_start_batch,d_start_batch,h_start_batch,mi_start_batch,s_start_batch] = datevec(start_batch_scan);
0128 disp('3')
0129 [y_end_batch,m_end_batch,d_end_batch,h_end_batch,mi_end_batch,s_end_batch] = datevec(end_batch_scan);
0130 disp('4')
0131 startBatchMJD = date2mjd(y_start_batch,m_start_batch,d_start_batch,h_start_batch,mi_start_batch,s_start_batch);
0132 disp('5')
0133 endBatchMJD = date2mjd(y_end_batch,m_end_batch,d_end_batch,h_end_batch,mi_end_batch,s_end_batch);
0134 disp('6')
0135 figure
0136 disp('7')
0137
0138 disp('8')
0139 catch
0140 disp('Failed to allocate FITS names');
0141 clear d
0142 clear flags
0143 continue
0144 end
0145 try
0146 flags=zeros(length(d.antenna0.servo.az),1);
0147 writeFitsMap(fits{i},d,startBatchMJD,endBatchMJD,i,numscans,flags);
0148 disp('9')
0149 catch
0150 disp('Failed to write the FITS files')
0151 clear d
0152 clear flags
0153 continue
0154 end
0155 clear d
0156 clear flags
0157
0158
0159 end
0160
0161
0162