0001 function fullSpectrumAnalysis(first_day,ndays,channel,outfile)
0002
0003 first_day_start_date=strcat(first_day,':00:00:00');
0004 first_day_start_mjd=tstr2mjd(first_day_start_date);
0005
0006 for day=1:ndays,
0007 start_mjd=first_day_start_mjd+day-1;
0008 end_mjd=start_mjd+1;
0009
0010
0011 sampling_freq = 100;
0012 total_hours = (end_mjd-start_mjd)*24;
0013 total_samples = total_hours*60*60*sampling_freq ;
0014
0015 chunk_hours=3;
0016 chunk_size = chunk_hours/24;
0017 nChunk = ceil(total_hours/chunk_hours);
0018 windowLength=1024;
0019 spec_length=windowLength/2+1;
0020
0021 current_start=start_mjd;
0022 start_index=1;
0023 total_windows = ceil(total_samples/windowLength);
0024 full_spec=zeros([spec_length total_windows]);
0025
0026 for i=1:nChunk,
0027 chunk_start = mjd2string(current_start);
0028 chunk_end = mjd2string(min(current_start+chunk_size,end_mjd));
0029 display([chunk_start ' to ' chunk_end]);
0030 try
0031
0032 d=pipe_read(chunk_start,chunk_end);
0033 d=pipelinedData(d);
0034 current_start = current_start + chunk_size;
0035
0036 spec = spectrogram(d.antenna0.receiver.data(:,channel),windowLength,0,windowLength,sampling_freq);
0037 nWindow=size(spec,2);
0038 full_spec(:,start_index:start_index+nWindow-1)=spec;
0039 start_index = start_index+nWindow;
0040 catch exception
0041 print_error('Error:\n');
0042 print_error(strcat('at date ',chunk_start,'\n'));
0043 print_error(strcat(exception.identifier,'\n'));
0044 current_start = current_start + chunk_size;
0045 nWindow=floor((chunk_end-chunk_start)*24.*60.*60*sampling_freq/windowLength);
0046 full_spec(:,start_index:start_index+nWindow-1)=nan;
0047 start_index = start_index+nWindow;
0048 end
0049
0050 end
0051
0052 filename=sprintf(outfile,day,channel);
0053 save(filename,'full_spec','first_day','day','channel','chunk_start','chunk_end');
0054
0055 end
0056 end