Home > example_scripts > getDatpipelineDataExtract.m

getDatpipelineDataExtract

PURPOSE ^

This script reads in scan data and then p writes the data to fits file for the map maker using cbass_write_data.c routine

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

This script reads in scan data and then p writes the data to fits file for the map maker using cbass_write_data.c routine
Need to adjust the start position of the scan

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %This script reads in scan data and then p writes the data to fits file for the map maker using cbass_write_data.c routine
0002 %Need to adjust the start position of the scan
0003 
0004 clear
0005 %nside = 128
0006 %h = gov.fnal.eag.healpix.PixTools;
0007 %npix= h.Nside2Npix(nside);
0008 start_scan=140; %which scan to start from
0009 max_time=4%maximum length of each data section in hours
0010 %list of scans to use- check obslog to get appropriate scan
0011 
0012 %Get the appropriate times using the extract_obslog script
0013 %t1=extract_obslog('obs_log.html','cbass_survey_test','4-Jun-2010:22:42:13','8-Jun-2010:20:49:53')
0014 %t2=extract_obslog('obs_log.html','cbass_survey_test','9-Jun-2010:00:25:28','9-Jun-2010:15:52:00')
0015 %t3=extract_obslog('obs_log.html','cbass_survey_test','19-Jun-2010:00:00:11','17-Aug-2010:15:32:34')
0016 t3=extract_obslog('obs_log.html','cbass_survey_test','01-Sep-2010:06:13:05','     01-Sep-2010:08:24:41');
0017 t=t3;%[t1;t2;t3];
0018 %t=[t1;t2;t3];
0019 for i=1:length(t)
0020     tstring=strtrim(t{i,1});
0021     tstring2=strtrim(t{i,2});
0022     tt(i,1) = datenum(tstring,'dd-mmm-yyyy:HH:MM:ss');
0023     tt(i,2) = datenum(tstring2,'dd-mmm-yyyy:HH:MM:ss');
0024     
0025 end
0026 %scan_times=tt(:,2)-tt(:,1);
0027 %split_times=find(scan_times > 3/24)   ;
0028 aa=[];
0029 for i=1:length(t)
0030     %aa=[aa;tt(i,:)]
0031     
0032     startt=tt(i,1);
0033     endt=tt(i,2);
0034     scan_time=endt-startt;
0035     while (scan_time > max_time/24)
0036       aa=[aa;[startt startt+max_time/24]];
0037       startt=startt+(max_time+0.00001)/24;
0038       scan_time=endt-startt;
0039     end
0040     aa=[aa;[startt endt]];
0041           
0042 end
0043 %make new time data section to avoid huge data sections
0044 for i=1:length(aa)
0045     tsplit{i,1}=datestr(aa(i,1),'dd-mmm-yyyy:HH:MM:ss');
0046     tsplit{i,2}=datestr(aa(i,2),'dd-mmm-yyyy:HH:MM:ss');
0047 end
0048 
0049 numscans=length(tsplit);
0050 i=0;
0051 n=0;
0052 
0053 [r, home] = unix('printenv HOME');
0054 
0055 
0056 if ~strcmp(home(1:5),'/home')
0057   %case where you get tcsh shell error
0058    startpt=find(home=='/');
0059    home=home(startpt(1):end-1);
0060    clear startpt
0061 else
0062    home=home(1:end-1);
0063 end
0064 
0065 
0066 i=start_scan
0067 unix(['mkdir ','./data/scanfits/skymaptest/']);
0068 while i<=numscans
0069     fits{i} = (['./scanfits/skymaptest/skymap',num2str(i-1),'.fits']);
0070    % fits2{i} = ([home,'/cbass_analysis/fits_files/atestcumulative',num2str(80+i-1),'.fits']);
0071     %unix(['rm ',fits{i}]);
0072   %  unix(['rm ',fits2{i}]);
0073     
0074     i=i+1;
0075     
0076 end
0077 
0078 
0079 for i=start_scan:numscans
0080     
0081     try
0082         time1{i}=tsplit{i,1};
0083         time2{i}=tsplit{i,2};
0084     disp(['Recording the fits file: ',fits{i}])
0085         disp(['Time Start: ',time1{i},' Time End: ',time2{i}]);
0086         disp(['Total Reduction Run from ',tsplit{1},' to ',tsplit{length(tsplit),2}]);
0087         d=pipe_read(time1{i},time2{i});
0088         disp(['Total Reduction Run from ',tsplit{1},' to ',tsplit{length(tsplit),2}]);
0089     d=pipelinedData(d)
0090         unix(['rm ',fits{i}]);
0091         %Calcuimes to write to the
0092         start_time = datenum(time1{i},'dd-mmm-yyyy:HH:MM:ss');
0093         end_time = datenum(time2{i},'dd-mmm-yyyy:HH:MM:ss');
0094         start_batch_scan = datenum(tsplit{1},'dd-mmm-yyyy:HH:MM:ss');
0095         end_batch_scan = datenum(tsplit{length(tsplit),2},'dd-mmm-yyyy:HH:MM:ss');
0096         [y_start,m_start,d_start,h_start,mi_start,s_start] = datevec(start_time);
0097         [y_end,m_end,d_end,h_end,mi_end,s_end] = datevec(end_time);
0098         [y_start_batch,m_start_batch,d_start_batch,h_start_batch,mi_start_batch,s_start_batch] = datevec(start_batch_scan);
0099         [y_end_batch,m_end_batch,d_end_batch,h_end_batch,mi_end_batch,s_end_batch] = datevec(end_batch_scan);
0100         start_time_mjd = date2mjd(y_start,m_start,d_start,h_start,mi_start,s_start);
0101         end_time_mjd = date2mjd(y_end,m_end,d_end,h_end,mi_end,s_end);
0102         start_time_batch_mjd = date2mjd(y_start_batch,m_start_batch,d_start_batch,h_start_batch,mi_start_batch,s_start_batch);
0103         end_time_batch_mjd = date2mjd(y_end_batch,m_end_batch,d_end_batch,h_end_batch,mi_end_batch,s_end_batch);
0104         %Flag the data that we don't want to use
0105         flags=logical(d.index.skydip.fast)|logical(d.index.noise.fast);
0106         
0107         cbass_write_data(fits{i},[d.antenna0.receiver.utc-start_time_mjd d.antenna0.servo.equa(:,1:2) d.antenna0.servo.apparent(:,1:2) d.antenna0.receiver.dataTcorr flags],0,0,start_time_mjd,end_time_mjd,i,numscans,start_time_batch_mjd,end_time_batch_mjd )
0108         clear d
0109         clear flags
0110         %cbass_write_image(fits{i},d.antenna0.writeHealpixDat,nside,npix,time1{1},time2{length(time2)});
0111     catch
0112         disp('Error in data')
0113     end
0114     
0115 end
0116     
0117 
0118

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