Home > example_scripts > startTemplate.m

startTemplate

PURPOSE ^

This script (23 August 2010) is a brief introduction to the FITS map

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

This script (23 August 2010) is a brief introduction to the FITS map
writing in matlab

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 %This script (23 August 2010) is a brief introduction to the FITS map
0003 %writing in matlab
0004 clear
0005 
0006 
0007 %%%YOU SHOULD AMEND THE FOLLOWING TO YOUR LOCAL INSTALLATION
0008 [r, home] = unix('printenv CBASSHOME');
0009 home= '/home/charles/';
0010 logfile = ([home, '/cbass_analysis/log/obs_log.html']);
0011 pipeline_file = @pipelinedData %Pick your pipeline file to use
0012 start_scan=1; %which scan to start from in case it stops half way through
0013 max_time=4%maximum length of each data section in hours
0014 scanlocation=(['/data/cbassuser/data/scanfits/']);
0015 out_dir = 'CarmaFilter2'    % Puts fits files in /Volumes/Data/CBASS/cbass_analysis/mapdata/OUT_DIR
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
0017 
0018 
0019 %list of scans to use- check obslog to get appropriate scan
0020 
0021 %Get the appropriate times using the extract_obslog script
0022 %t1=extract_obslog('obs_log.html','cbass_survey_test','4-Jun-2010:22:42:13','8-Jun-2010:20:49:53')
0023 %t2=extract_obslog('obs_log.html','cbass_survey_test','9-Jun-2010:00:25:28','9-Jun-2010:15:52:00')
0024 %t3=extract_obslog('/Volumes/Data/CBASS/cbass_analysis/log/obs_log.html','cbass_survey_test','1-Sep-2010:00:00:00','1-Sep-2010:10:00:00');
0025 t3=extract_obslog(logfile,'cbass_survey_test','19-Jun-2010:00:00:11','13-Sep-2010:15:32:34');
0026 
0027 t=t3;%[t1;t2;t3];
0028 %t=[t1;t2;t3];
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 %scan_times=tt(:,2)-tt(:,1);
0037 %split_times=find(scan_times > 3/24)   ;
0038 aa=[];
0039 for i=1:length(t)
0040     %aa=[aa;tt(i,:)]
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 %make new time data section to avoid huge data sections
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   %case where you get tcsh shell error
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    % fits2{i} = ([home,'/cbass_analysis/fits_files/atestcumulative',num2str(80+i-1),'.fits']);
0085     %unix(['rm ',fits{i}]);
0086   %  unix(['rm ',fits2{i}]);
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         %d=pipeline_basic(d)
0110         %disp('Using pipeline reduction file: ',
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         %Calcuimes to write to the
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         %plot(d.antenna.receiver.dataTcorr)
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

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