Home > example_scripts > writeFitsMapOvro_test.m

writeFitsMapOvro_test

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 %This script (23 August 2010) is a brief introduction to the FITS map
0002 %writing in matlab
0003 
0004 clear
0005 %nside = 128
0006 %h = gov.fnal.eag.healpix.PixTools;
0007 %npix= h.Nside2Npix(nside);
0008 start_scan=1; %which scan to start from
0009 directory = '/data/cbassuser/data/scanfits/skymaptestnew/'
0010 max_time=4%maximum length of each data section in hours
0011 %list of scans to use- check obslog to get appropriate scan
0012 
0013 %Get the appropriate times using the extract_obslog script
0014 %t1=extract_obslog('obs_log.html','cbass_survey_test','4-Jun-2010:22:42:13','8-Jun-2010:20:49:53')
0015 %t2=extract_obslog('obs_log.html','cbass_survey_test','9-Jun-2010:00:25:28','9-Jun-2010:15:52:00')
0016 t3=extract_obslog('../obs_log.html','cbass_survey_test','21-Aug-2010:00:00:11','26-Aug-2010:15:32:34')
0017 
0018 t=t3;%[t1;t2;t3];
0019 %t=[t1;t2;t3];
0020 for i=1:length(t)
0021     tstring=strtrim(t{i,1});
0022     tstring2=strtrim(t{i,2});
0023     tt(i,1) = datenum(tstring,'dd-mmm-yyyy:HH:MM:ss');
0024     tt(i,2) = datenum(tstring2,'dd-mmm-yyyy:HH:MM:ss');
0025     
0026 end
0027 %scan_times=tt(:,2)-tt(:,1);
0028 %split_times=find(scan_times > 3/24)   ;
0029 aa=[];
0030 for i=1:length(t)
0031     %aa=[aa;tt(i,:)]
0032     
0033     startt=tt(i,1);
0034     endt=tt(i,2);
0035     scan_time=endt-startt;
0036     while (scan_time > max_time/24)
0037       aa=[aa;[startt startt+max_time/24]];
0038       startt=startt+(max_time+0.00001)/24;
0039       scan_time=endt-startt;
0040     end
0041     aa=[aa;[startt endt]];
0042           
0043 end
0044 %make new time data section to avoid huge data sections
0045 for i=1:length(aa)
0046     tsplit{i,1}=datestr(aa(i,1),'dd-mmm-yyyy:HH:MM:ss');
0047     tsplit{i,2}=datestr(aa(i,2),'dd-mmm-yyyy:HH:MM:ss');
0048 end
0049 
0050 numscans=length(tsplit);
0051 i=0;
0052 n=0;
0053 
0054 [r, home] = unix('printenv HOME');
0055 
0056 
0057 if ~strcmp(home(1:5),'/home')
0058   %case where you get tcsh shell error
0059    startpt=find(home=='/');
0060    home=home(startpt(1):end-1);
0061    clear startpt
0062 else
0063    home=home(1:end-1);
0064 end
0065 
0066 
0067 i=start_scan
0068 unix(['mkdir ',directory]);
0069 while i<=numscans
0070     fits{i} = ([directory,'skymap',num2str(i-1),'.fits']);
0071    % fits2{i} = ([home,'/cbass_analysis/fits_files/atestcumulative',num2str(80+i-1),'.fits']);
0072     %unix(['rm ',fits{i}]);
0073   %  unix(['rm ',fits2{i}]);
0074     
0075     i=i+1;
0076     
0077 end
0078 
0079 
0080 for i=start_scan:numscans
0081     
0082     try
0083         time1{i}=tsplit{i,1};
0084         time2{i}=tsplit{i,2};
0085         disp(['Recording the fits file: ',fits{i}])
0086         disp(['Time Start: ',time1{i},' Time End: ',time2{i}]);
0087         disp(['Total Reduction Run from ',tsplit{1},' to ',tsplit{length(tsplit),2}]);
0088         d=pipe_read(time1{i},time2{i});
0089         disp(['Total Reduction Run from ',tsplit{1},' to ',tsplit{length(tsplit),2}]);
0090         d=pipelinedData(d)
0091         unix(['rm ',fits{i}]);
0092         %Calcuimes to write to the
0093         start_batch_scan = datenum(tsplit{1},'dd-mmm-yyyy:HH:MM:ss');
0094         end_batch_scan = datenum(tsplit{length(tsplit),2},'dd-mmm-yyyy:HH:MM:ss');
0095         [y_start_batch,m_start_batch,d_start_batch,h_start_batch,mi_start_batch,s_start_batch] = datevec(start_batch_scan);
0096         [y_end_batch,m_end_batch,d_end_batch,h_end_batch,mi_end_batch,s_end_batch] = datevec(end_batch_scan);
0097         startBatchMJD = date2mjd(y_start_batch,m_start_batch,d_start_batch,h_start_batch,mi_start_batch,s_start_batch);
0098         endBatchMJD = date2mjd(y_end_batch,m_end_batch,d_end_batch,h_end_batch,mi_end_batch,s_end_batch);
0099               
0100         writeFitsMap(fits{i},d,startBatchMJD,endBatchMJD,i,numscans)
0101         clear d
0102         clear flags
0103         %cbass_write_image(fits{i},d.antenna0.writeHealpixDat,nside,npix,time1{1},time2{length(time2)});
0104     catch
0105         disp('Error in data')
0106     end
0107     
0108 end
0109     
0110 
0111

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