Home > loadamplitude > runLoadAmplitudes.m

runLoadAmplitudes

PURPOSE ^

automate the get1fMagCal prog

SYNOPSIS ^

function [done] = runLoadAmplitudes(start,enddate,filename,debug,cal)

DESCRIPTION ^

 automate the get1fMagCal prog

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [done] = runLoadAmplitudes(start,enddate,filename,debug,cal)
0002 % automate the get1fMagCal prog
0003 
0004 home = '~/sparrow3/cbass/stable';
0005 addpath([home, '/cbass_analysis'])
0006 logfile = ([home, '/cbass_analysis/log/obs_log.html']);
0007 start_scan= 1; %which scan to start from in case it stops half way through
0008 max_time= 1;%maximum length of each data section in hours
0009 location =(['~/sparrow3/cbass/stable/cbass_analysis/loadamplitude']);
0010 
0011 disp(logfile)
0012 disp(start)
0013 disp(enddate)
0014 
0015 t0=extract_obslog(logfile,'cbass_survey_test2.sch',start,enddate)
0016 t1=extract_obslog(logfile,'cbass_survey_sjcm.sch',start,enddate)
0017 t2=extract_obslog(logfile,'cbass_survey_0.2.sch',start,enddate);
0018 t3=extract_obslog(logfile,'cbass_survey_0.3.sch',start,enddate);
0019 t4=extract_obslog(logfile,'cbass_survey_0.4.sch',start,enddate);
0020 t5=extract_obslog(logfile,'cbass_survey_5speed.sch',start,enddate);
0021 
0022 t=cat(1,t0,t1,t2,t3,t4,t5);
0023 if (length(t) > 1)
0024 
0025     for Z=1:length(t)
0026         tstring=strtrim(t{Z,1});
0027         tstring2=strtrim(t{Z,2});
0028         tt(Z,1) = datenum(tstring,'dd-mmm-yyyy:HH:MM:ss');
0029         tt(Z,2) = datenum(tstring2,'dd-mmm-yyyy:HH:MM:ss');
0030         
0031     end
0032 
0033     aa=[];
0034     for Z=1:length(t)  
0035         startt=tt(Z,1);
0036         endt=tt(Z,2);
0037         scan_time=endt-startt;
0038         while (scan_time > max_time/24)
0039           aa=[aa;[startt startt+max_time/24]];
0040           startt=startt+(max_time+0.00001)/24;
0041           scan_time=endt-startt;
0042         end
0043         aa=[aa;[startt endt]];
0044               
0045     end
0046     %make new time data section to avoid huge data sections
0047     for Z=1:length(aa)
0048         tsplit{Z,1}=datestr(aa(Z,1),'dd-mmm-yyyy:HH:MM:ss');
0049         tsplit{Z,2}=datestr(aa(Z,2),'dd-mmm-yyyy:HH:MM:ss');
0050     end
0051 
0052     numscans=length(tsplit);
0053     n=0;
0054 
0055     [r, home] = unix('printenv HOME');
0056 
0057 
0058     if ~strcmp(home(1:5),'/home')
0059       %case where you get tcsh shell error
0060        startpt=find(home=='/');
0061        home=home(startpt(1):end-1);
0062        clear startpt
0063     else
0064        home=home(1:end-1);
0065     end
0066 
0067     Z=start_scan;
0068 
0069     numscans
0070     file = ([location, '/', filename])
0071     fid = fopen(file,'a');
0072 
0073     if (debug==1)
0074     numscans = 1
0075     end
0076 
0077     for Z=start_scan:numscans
0078         close all;
0079         try
0080             time1{Z}=tsplit{Z,1};
0081             time2{Z}=tsplit{Z,2};
0082             disp(['Time Start: ',time1{Z},' Time End: ',time2{Z}]);
0083             disp(['Total Reduction Run from ',tsplit{1},' to ',tsplit{length(tsplit),2}]);
0084             d = read_arc(time1{Z},time2{Z});
0085             disp(['Total Reduction Run from ',tsplit{1},' to ',tsplit{length(tsplit),2}]);
0086         catch
0087             disp('Failed to Read in Data')
0088            clear flags
0089             continue
0090         end 
0091         
0092           try 
0093             disp('Running set without load correction')
0094             if (cal == 1)
0095                 [mjd, ch1mag, ch2mag, ch3mag, ch4mag, ch5mag, ch6mag, ch7mag, ch8mag] = getLoadAmplitudePipeline(d,0,debug,location);
0096             else
0097                 [mjd, ch1mag, ch2mag, ch3mag, ch4mag, ch5mag, ch6mag, ch7mag, ch8mag] = getLoadAmplitude(d,0,debug);
0098             end
0099             % ch1mag, ch2mag, ch3mag, ch4mag, ch5mag, ch6mag, ch7mag, ch8mag
0100             utc(Z) = mjd;
0101             c1pre(Z) = ch1mag(1);
0102             c2pre(Z) = ch2mag(1);
0103             c3pre(Z) = ch3mag(1);
0104             c4pre(Z) = ch4mag(1);
0105             c5pre(Z) = ch5mag(1);
0106             c6pre(Z) = ch6mag(1);
0107             c7pre(Z) = ch7mag(1);
0108             c8pre(Z) = ch8mag(1);
0109 
0110             c1pre_bg(Z) = ch1mag(4);
0111             c2pre_bg(Z) = ch2mag(4);
0112             c3pre_bg(Z) = ch3mag(4);
0113             c4pre_bg(Z) = ch4mag(4);
0114             c5pre_bg(Z) = ch5mag(4);
0115             c6pre_bg(Z) = ch6mag(4);
0116             c7pre_bg(Z) = ch7mag(4);
0117             c8pre_bg(Z) = ch8mag(4);
0118 
0119             c1pre_noise(Z) = ch1mag(5);
0120             c2pre_noise(Z) = ch2mag(5);
0121             c3pre_noise(Z) = ch3mag(5);
0122             c4pre_noise(Z) = ch4mag(5);
0123             c5pre_noise(Z) = ch5mag(5);
0124             c6pre_noise(Z) = ch6mag(5);
0125             c7pre_noise(Z) = ch7mag(5);
0126             c8pre_noise(Z) = ch8mag(5);
0127 
0128             disp('Running set with load correction')
0129             if (cal == 1)
0130                 [mjd, ch1mag_post, ch2mag_post, ch3mag_post, ch4mag_post, ch5mag_post, ch6mag_post, ch7mag_post, ch8mag_post] = getLoadAmplitudePipeline(d,1,debug, location);
0131             else
0132                 [mjd, ch1mag_post, ch2mag_post, ch3mag_post, ch4mag_post, ch5mag_post, ch6mag_post, ch7mag_post, ch8mag_post] = getLoadAmplitude(d,1,debug);
0133             end
0134 
0135             % ch1mag_post, ch2mag_post, ch3mag_post, ch4mag_post, ch5mag_post, ch6mag_post, ch7mag_post, ch8mag_post
0136 
0137             c1post(Z) = ch1mag_post(1);
0138             c2post(Z) = ch2mag_post(1);
0139             c3post(Z) = ch3mag_post(1);
0140             c4post(Z) = ch4mag_post(1);
0141             c5post(Z) = ch5mag_post(1);
0142             c6post(Z) = ch6mag_post(1);
0143             c7post(Z) = ch7mag_post(1);
0144             c8post(Z) = ch8mag_post(1);
0145 
0146             c1post_bg(Z) = ch1mag_post(4);
0147             c2post_bg(Z) = ch2mag_post(4);
0148             c3post_bg(Z) = ch3mag_post(4);
0149             c4post_bg(Z) = ch4mag_post(4);
0150             c5post_bg(Z) = ch5mag_post(4);
0151             c6post_bg(Z) = ch6mag_post(4);
0152             c7post_bg(Z) = ch7mag_post(4);
0153             c8post_bg(Z) = ch8mag_post(4);
0154 
0155             %disp('Running set with loadcor correction')
0156             %if (cal == 1)
0157             %    [mjd, ch1mag_postcor, ch2mag_postcor, ch3mag_postcor, ch4mag_postcor, ch5mag_postcor, ch6mag_postcor, ch7mag_postcor, ch8mag_postcor] = getLoadAmplitudePipeline(d,2,debug, location);
0158             %else
0159             %    [mjd, ch1mag_postcor, ch2mag_postcor, ch3mag_postcor, ch4mag_postcor, ch5mag_postcor, ch6mag_postcor, ch7mag_postcor, ch8mag_postcor] = getLoadAmplitude(d,2,debug);
0160             %end
0161             % ch1mag_postcor, ch2mag_postcor, ch3mag_postcor, ch4mag_postcor, ch5mag_postcor, ch6mag_postcor, ch7mag_postcor, ch8mag_postcor
0162 
0163             %c1postcor(Z) = ch1mag_postcor(1);
0164             %c2postcor(Z) = ch2mag_postcor(1);
0165             %c3postcor(Z) = ch3mag_postcor(1);
0166             %c4postcor(Z) = ch4mag_postcor(1);
0167             %c5postcor(Z) = ch5mag_postcor(1);
0168             %c6postcor(Z) = ch6mag_postcor(1);
0169             %c7postcor(Z) = ch7mag_postcor(1);
0170             %c8postcor(Z) = ch8mag_postcor(1);
0171 
0172             %c1postcor_bg(Z) = ch1mag_postcor(4);
0173             %c2postcor_bg(Z) = ch2mag_postcor(4);
0174             %c3postcor_bg(Z) = ch3mag_postcor(4);
0175             %c4postcor_bg(Z) = ch4mag_postcor(4);
0176             %c5postcor_bg(Z) = ch5mag_postcor(4);
0177             %c6postcor_bg(Z) = ch6mag_postcor(4);
0178             %c7postcor_bg(Z) = ch7mag_postcor(4);
0179             %c8postcor_bg(Z) = ch8mag_postcor(4);
0180 
0181 
0182     s = Z
0183 
0184     %fprintf(fid, '%10.4f %e %e %e %e %e %e %e %e  %e %e %e %e %e %e %e %e  %e %e %e %e %e %e %e %e  %e %e %e %e %e %e %e %e  %e %e %e %e %e %e %e %e  %e %e %e %e %e %e %e %e \n', utc(s), c1pre(s), c2pre(s), c3pre(s), c4pre(s), c5pre(s), c6pre(s), c7pre(s), c8pre(s), c1pre_bg(s), c2pre_bg(s), c3pre_bg(s), c4pre_bg(s), c5pre_bg(s), c6pre_bg(s), c7pre_bg(s), c8pre_bg(s), c1post(s), c2post(s), c3post(s), c4post(s), c5post(s), c6post(s), c7post(s), c8post(s), c1post_bg(s), c2post_bg(s), c3post_bg(s), c4post_bg(s), c5post_bg(s), c6post_bg(s), c7post_bg(s), c8post_bg(s), c1postcor(s), c2postcor(s), c3postcor(s), c4postcor(s), c5postcor(s), c6postcor(s), c7postcor(s), c8postcor(s), c1postcor_bg(s), c2postcor_bg(s), c3postcor_bg(s), c4postcor_bg(s), c5postcor_bg(s), c6postcor_bg(s), c7postcor_bg(s), c8postcor_bg(s));
0185 
0186     fprintf(fid, '%10.4f %e %e %e %e %e %e %e %e  %e %e %e %e %e %e %e %e  %e %e %e %e %e %e %e %e  %e %e %e %e %e %e %e %e \n', utc(s), c1pre(s), c2pre(s), c3pre(s), c4pre(s), c5pre(s), c6pre(s), c7pre(s), c8pre(s), c1pre_bg(s), c2pre_bg(s), c3pre_bg(s), c4pre_bg(s), c5pre_bg(s), c6pre_bg(s), c7pre_bg(s), c8pre_bg(s), c1post(s), c2post(s), c3post(s), c4post(s), c5post(s), c6post(s), c7post(s), c8post(s), c1post_bg(s), c2post_bg(s), c3post_bg(s), c4post_bg(s), c5post_bg(s), c6post_bg(s), c7post_bg(s), c8post_bg(s));
0187 
0188          catch
0189            
0190           disp('Something went wrong')
0191           clear flags
0192              continue
0193         
0194              end 
0195          clear d
0196          clear flags
0197      end
0198 
0199     fclose(fid);
0200 
0201 end
0202 done = 1
0203 exit
0204 
0205 end

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