Home > matutils > mosaic > write_sched.m

write_sched

PURPOSE ^

function write_sched(t,c,fn,src,cal,bp,start,noise,load)

SYNOPSIS ^

function write_sched(t,c,fn,src,cal,bp,start,noise,load)

DESCRIPTION ^

 function write_sched(t,c,fn,src,cal,bp,start,noise,load)

 write schedule.  Will only work for 2 pair observations

 t  - output of timesync2pr 
 c  - output of timesync2pr
 fn - file name
 src - source names, as cell array of strings
       src{1:2} == pair 1, ie (1,9)
       src{3:4} == pair 2, ie (2,10)
 cal - cal name
 bp  - bandpass name
 start - start time in lst

 noise - 2: bracketing each observation with noise
         1: only one noise during integration
         0: no noise at all

 load  - 8: load cal on all targ fields
         4: L-1-9-L-L-2-10-L
         2: load at begining of one and end of 10
         0: no load cal on all, including calibrator

 Michael Loh

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function write_sched(t,c,fn,src,cal,bp,start,noise,load)
0002 
0003 % function write_sched(t,c,fn,src,cal,bp,start,noise,load)
0004 %
0005 % write schedule.  Will only work for 2 pair observations
0006 %
0007 % t  - output of timesync2pr
0008 % c  - output of timesync2pr
0009 % fn - file name
0010 % src - source names, as cell array of strings
0011 %       src{1:2} == pair 1, ie (1,9)
0012 %       src{3:4} == pair 2, ie (2,10)
0013 % cal - cal name
0014 % bp  - bandpass name
0015 % start - start time in lst
0016 %
0017 % noise - 2: bracketing each observation with noise
0018 %         1: only one noise during integration
0019 %         0: no noise at all
0020 %
0021 % load  - 8: load cal on all targ fields
0022 %         4: L-1-9-L-L-2-10-L
0023 %         2: load at begining of one and end of 10
0024 %         0: no load cal on all, including calibrator
0025 %
0026 % Michael Loh
0027 
0028 fid=fopen(fn,'w');
0029 
0030 % impossible to have scanned second pair more than first
0031 if (length(t(1).start)>length(t(3).start))
0032   tlf=1;
0033 else
0034   tlf=0;
0035 end
0036 
0037 ln=length(t(1).start);
0038 
0039 ldcal='true, true';
0040 switch load
0041   case 8
0042     ld1='true, true';
0043     ld2=ld1;
0044     ld3=ld1;
0045     ld4=ld1;
0046     
0047   case 4
0048     ld1='true, false';
0049     ld2='false, true';
0050     ld3=ld1;
0051     ld4=ld2;
0052     
0053   case 2
0054     ld1='true, false';
0055     ld2='false, false';
0056     ld3=ld2;
0057     ld4='false, true';
0058     
0059   case 0
0060     ld1='false, false';
0061     ld2=ld1;
0062     ld3=ld1;
0063     ld4=ld1;
0064     dlcal='false, false';
0065 end
0066     
0067 switch noise
0068   case 2
0069     nstr='true, true';
0070     
0071   case 1
0072     nstr='true, false';
0073     
0074   case 0
0075     nstr='false, false';
0076 end
0077 
0078 bra='{';
0079 ket='}';
0080 
0081 fprintf(fid,'import ~szadaq/sza/array/sch/schedlib.sch\n\n'); 
0082 fprintf(fid,'group Cal %s\n',bra);
0083 fprintf(fid,'   Source name # source name\n');
0084 fprintf(fid,'%s\n\n',ket);
0085 fprintf(fid,'group Source %s\n',bra);
0086 fprintf(fid,'   Source name,\n');
0087 fprintf(fid,'   Features feat,\n');
0088 fprintf(fid,'   Count nrep,\n');
0089 fprintf(fid,'   Boolean load1,\n');
0090 fprintf(fid,'   Boolean load2,\n');
0091 fprintf(fid,'   Boolean n1,\n');
0092 fprintf(fid,'   Boolean n2,\n');
0093 fprintf(fid,'   Time start,\n');
0094 fprintf(fid,'   Time stop\n');
0095 fprintf(fid,'%s\n\n',ket);
0096 fprintf(fid,'listof Source sources = %s\n',bra);
0097 fprintf(fid,'   {%s, f1+f2, 1, %s, %s, %s, %s},\n',cal,ldcal,nstr,c.start{1},c.stop{1});
0098 
0099 
0100 switch tlf
0101   case 1
0102     for i=1:ln
0103       fprintf(fid,'   {%s, f0, 1, %s, %s, %s, %s},\n',...
0104       src{1},ld1,nstr,t(1).start{i},t(1).stop{i});
0105       fprintf(fid,'   {%s, f0, 1, %s, %s, %s, %s},\n',...
0106       src{2},ld2,nstr,t(2).start{i},t(2).stop{i});
0107       if (i==ln)
0108     fprintf(fid,'   {%s, f1+f2, 1, %s, %s, %s, %s}\n',...
0109         cal,ldcal,nstr,c.start{i+1},c.stop{i+1});
0110     break;
0111       else
0112     fprintf(fid,'   {%s, f0, 1, %s, %s, %s, %s},\n',...
0113         src{3},ld3,nstr,t(3).start{i},t(3).stop{i});
0114     fprintf(fid,'   {%s, f0, 1, %s, %s, %s, %s},\n',...
0115         src{4},ld4,nstr,t(4).start{i},t(4).stop{i});
0116     fprintf(fid,'   {%s, f1+f2, 1, %s, %s, %s, %s},\n',...
0117         cal,ldcal,nstr,c.start{i+1},c.stop{i+1});
0118       end
0119     end
0120     
0121   case 0
0122     for i=1:ln
0123       fprintf(fid,'   {%s, f0, 1, %s, %s, %s, %s},\n',...
0124       src{1},ld1,nstr,t(1).start{i},t(1).stop{i});
0125       fprintf(fid,'   {%s, f0, 1, %s, %s, %s, %s},\n',...
0126       src{2},ld2,nstr,t(2).start{i},t(2).stop{i});
0127       fprintf(fid,'   {%s, f0, 1, %s, %s, %s, %s},\n',...
0128       src{3},ld3,nstr,t(3).start{i},t(3).stop{i});
0129       fprintf(fid,'   {%s, f0, 1, %s, %s, %s, %s},\n',...
0130       src{4},ld4,nstr,t(4).start{i},t(4).stop{i});
0131       if (i==ln)
0132     fprintf(fid,'   {%s, f1+f2, 1, %s, %s, %s, %s}\n',...
0133         cal,ldcal,nstr,c.start{i+1},c.stop{i+1});
0134       else
0135     fprintf(fid,'   {%s, f1+f2, 1, %s, %s, %s, %s},\n',...
0136         cal,ldcal,nstr,c.start{i+1},c.stop{i+1});
0137       end
0138     end
0139 end
0140 
0141 fprintf(fid,'%s\n\n',ket);
0142 
0143 fprintf(fid,'resetSystemState "Starting schedule %s"\n\n',fn);
0144 fprintf(fid,'setDownconAGC\n\n');
0145 fprintf(fid,'until $after(%s,lst)\n\n',start);
0146 fprintf(fid,'log "%s: Beginning calibration observations."\n',fn);
0147 fprintf(fid,'doBPCalObs(%s)\n',bp);
0148 fprintf(fid,'doPointCross %s\n',bp);
0149 fprintf(fid,'foreach(Source source) $sources %s\n',bra);
0150 fprintf(fid,'  log "%s: Observing field: ", $source.name\n',fn);
0151 fprintf(fid,['  observeTimeSyncAllManual $source.name, $source.feat,', ...
0152     '$source.nrep, $source.load1, $source.load2,', ...
0153     '$source.n1, $source.n2, $source.start, $source.stop\n']);
0154 fprintf(fid,'%s\n\n',ket);
0155 
0156 fclose(fid);

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