Home > example_scripts > Charles_fitsmaps.m

Charles_fitsmaps

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 = 'NewAlpha2'    % 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(['\n\n\n Starting New Scan'])
0099     disp(['Recording the fits file: ',fits{i}])
0100         disp(['Time Start: ',time1{i},' Time End: ',time2{i}]);
0101         disp(['Total Reduction Run from ',tsplit{1},' to ',tsplit{length(tsplit),2}]);
0102         d=pipe_read(time1{i},time2{i});
0103         disp(['Total Reduction Run from ',tsplit{1},' to ',tsplit{length(tsplit),2}]);
0104     catch
0105         disp('Failed to Read in Data')
0106         clear d
0107         clear flags
0108         continue
0109     end
0110         %d=pipeline_basic(d)
0111         %disp('Using pipeline reduction file: ',
0112     try   
0113         d = pipeline_file(d)
0114     pause(3)
0115     catch
0116         disp('Failed the pipelining')
0117         clear d
0118         clear flags
0119         continue
0120     end
0121     try
0122         disp('0')
0123         unix(['rm ',fits{i}]);
0124         %Calcuimes to write to the
0125         start_batch_scan = datenum(tsplit{1},'dd-mmm-yyyy:HH:MM:ss');
0126         disp('1')
0127         end_batch_scan = datenum(tsplit{length(tsplit),2},'dd-mmm-yyyy:HH:MM:ss');
0128         disp('2')
0129         [y_start_batch,m_start_batch,d_start_batch,h_start_batch,mi_start_batch,s_start_batch] = datevec(start_batch_scan);
0130         disp('3')
0131         [y_end_batch,m_end_batch,d_end_batch,h_end_batch,mi_end_batch,s_end_batch] = datevec(end_batch_scan);
0132         disp('4')
0133         startBatchMJD = date2mjd(y_start_batch,m_start_batch,d_start_batch,h_start_batch,mi_start_batch,s_start_batch);
0134         disp('5')
0135         endBatchMJD = date2mjd(y_end_batch,m_end_batch,d_end_batch,h_end_batch,mi_end_batch,s_end_batch);
0136         disp('6')   
0137         %figure
0138         disp('7')   
0139         %plot(d.antenna.receiver.dataTcorr)
0140         disp('8')
0141     pause(3)   
0142     catch
0143         disp('Failed to allocate FITS names');
0144         clear d
0145         clear flags
0146         continue
0147     end
0148     try
0149     disp('Trying to write the Data to FITS')
0150     pause(3)
0151         flags=zeros(length(d.antenna0.servo.az),1);
0152         %feat=interp1(d.array.frame.utc,double(d.array.frame.features),d.antenna0.receiver.utc,'nearest');
0153 %    flags=(feat~=2^16);
0154     writeFitsMap(fits{i},d,startBatchMJD,endBatchMJD,i,numscans,flags);
0155     disp('9')   
0156     catch
0157         disp('Failed to write the FITS files')
0158         clear d
0159         clear flags
0160         continue
0161     end
0162     clear d
0163     clear flags
0164          
0165     
0166 end
0167     
0168 
0169

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