This is a static copy of a profile reportHome
reduceData>writeOutFits (1 call, 7.837 sec)
Generated 05-Aug-2011 13:01:02 using cpu time.
subfunction in file /home/LeechJ/cbass_analysis/reduc/reduceData.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
reduceData | function | 1 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
678 | writeFitsMap([root_name,'.fits... | 1 | 7.400 s | 94.4% |  |
762 | unix([png_plot_script,' map.fi... | 1 | 0.131 s | 1.7% |  |
671 | d = getIV(d); | 1 | 0.098 s | 1.3% |  |
757 | unix(['descart_cbass ',locatio... | 1 | 0.077 s | 1.0% |  |
750 | unix(select_command); | 1 | 0.044 s | 0.6% |  |
All other lines | | | 0.087 s | 1.1% |  |
Totals | | | 7.837 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
writeFitsMap | function | 1 | 7.400 s | 94.4% |  |
getIV | function | 1 | 0.098 s | 1.3% |  |
strcat | function | 7 | 0.022 s | 0.3% |  |
pwd | function | 1 | 0 s | 0% |  |
where_am_i | function | 1 | 0 s | 0% |  |
logcal | function | 1 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 0.317 s | 4.0% |  |
Totals | | | 7.837 s | 100% | |
Code Analyzer results
Line number | Message |
688 | IF might not be aligned with its matching END (line 807). |
688 | Use STRCMP instead of == or ~= to compare strings. |
692 | Using ISEMPTY is usually faster than comparing LENGTH to 0. |
699 | Using ISEMPTY is usually faster than comparing LENGTH to 0. |
706 | Use && instead of & as the AND operator in (scalar) conditional statements. |
709 | Use && instead of & as the AND operator in (scalar) conditional statements. |
712 | Use && instead of & as the AND operator in (scalar) conditional statements. |
760 | EXIST with two input arguments is generally faster and clearer than with one input argument. |
764 | Use of brackets [] is unnecessary. Use parentheses to group, if needed. |
781 | Use && instead of & as the AND operator in (scalar) conditional statements. |
795 | Use && instead of & as the AND operator in (scalar) conditional statements. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 162 |
Non-code lines (comments, blank lines) | 58 |
Code lines (lines that can run) | 104 |
Code lines that did run | 76 |
Code lines that did not run | 28 |
Coverage (did run/can run) | 73.08 % |
Function listing
time calls line
650 function olddir = writeOutFits(maindir, d, parm)
651
652 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
653 %
654 % function olddir = writeOutFits(maindir, d, parm)
655 %
656 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
657
0.01 1 658 root_name = strcat(maindir,'/fits/','fitstable');
659 % JL TO DO check if file exists, if so delete.
1 660 flags = d.flags.fast(:,1);
1 661 startTimeMJD = d.antenna0.receiver.utc(1);
1 662 endTimeMJD = d.antenna0.receiver.utc(length(d.antenna0.receiver.utc));
1 663 display('Calling writefits map');
664
665 % recombine 1st and 8th columns.
666 % At this point the 8 columns are
667 % [(I+V)-r1*Tload1 Q1 U1 Q2 U2 Q3 U3 (I-V)-r2*Tload2]
668 % d.antenna0.receiver.data
1 669 [d q] = logcal(d, 'iv');
1 670 if(~q)
0.10 1 671 d = getIV(d);
1 672 end
673 %I=d.antenna0.receiver.data(:,1)+d.antenna0.receiver.data(:,8);
674 %V=d.antenna0.receiver.data(:,1)-d.antenna0.receiver.data(:,8);
675 %d.antenna0.receiver.data(:,1)=I;
676 %d.antenna0.receiver.data(:,8)=V;
677
7.40 1 678 writeFitsMap([root_name,'.fits'],d,startTimeMJD,endTimeMJD,1,1,flags);
679
680
681
682 % this -- exist('parm.fits.domapflag') returns zero for some reason
683 % despite the fact that it exists!!!
684
1 685 [home,installeddir]=where_am_i();
1 686 location = [home,'/',installeddir];
687
1 688 if (parm.fits.domapflag=='yes')
689
1 690 disp('Attempting to make a map from the fits file...');
691
1 692 if(length(parm.fits.frame) ~= 0)
1 693 frame = parm.fits.frame;
694 else
695 frame = 'heal';
696 end
1 697 disp('Got frame');
698
1 699 if(length(parm.fits.projection) ~= 0)
1 700 projection = parm.fits.projection;
701 else
702 projection = 'moll';
703 end
1 704 disp('Got projection');
705
1 706 if (strcmp(frame,'heal') & strcmp(projection,'moll'))
1 707 descart_ini_file = 'mapping_params_heal_moll.ini';
1 708 png_plot_script = 'plot_healpix_map.py';
709 elseif (strcmp(frame,'radec') & strcmp(projection,'tan'))
710 descart_ini_file = 'mapping_params_radec_tan.ini';
711 png_plot_script = 'plot_radec_map.py';
712 elseif (strcmp(frame,'azel') & strcmp(projection,'plate'))
713 descart_ini_file = 'mapping_params_azel_plate.ini';
714 png_plot_script = 'plot_cart_map.py';
715 else
716 disp(' Could not parse frame and projection, defaulting to heal / moll');
717 descart_ini_file = 'mapping_params_heal_moll.ini';
718 png_plot_script = 'plot_healpix_map.py';
719 end
720
1 721 disp(['Will use ini file ',descart_ini_file,' -- plot script ',png_plot_script]);
722
1 723 disp('Setting Paths and Pythonpath...');
724 % The following assumes that you have descart_cbass
725 % and plot_healpix_map.py installed in the appropriate locations.
1 726 olddir=pwd;
1 727 fitsdir=[maindir,'/fits/'];
1 728 cd(fitsdir);
1 729 current_pythonpath = getenv('PYTHONPATH');
1 730 new_pythonpath =[location,'/descart/data_selection/:',current_pythonpath];
1 731 setenv('PYTHONPATH',new_pythonpath);
1 732 current_path = getenv('PATH');
1 733 new_path=[location,'/webpage_logging/:',location,'/descart/map_making/:',current_path];
0.01 1 734 setenv('PATH',new_path);
1 735 disp('...done');
736
737 % delete the chunks
1 738 disp('Deleting chunks ...');
1 739 delete_chunks_command=['python -m cbass.delete_chunks ',root_name,'.fits'];
1 740 disp(['Deleting chunks: ',delete_chunks_command]);
0.01 1 741 unix(delete_chunks_command);
1 742 disp('...done');
743
744 % data selection stage
1 745 do_select=1;
746
0.01 1 747 if(do_select==1)
1 748 select_command=['python -m cbass.split_data -zkg -N BASIC ',root_name,'.fits'];
1 749 disp(['Selecting the data with: ',select_command]);
0.04 1 750 unix(select_command);
1 751 disp('...done');
1 752 end
753
754 % prepare file list then called descart mapper.
1 755 unix('echo fitstable.fits > files.txt');
1 756 disp(['Calling descart_cbass to make map using ',descart_ini_file]);
0.08 1 757 unix(['descart_cbass ',location,'/webpage_logging/',descart_ini_file]);
758
759 % Make the .png previews from the map fits file
1 760 if (exist('map.fits')==2)
1 761 disp(['Making png previews using ',png_plot_script]);
0.13 1 762 unix([png_plot_script,' map.fits']);
763 else
764 disp(['map.fits does not exist will not make preview']);
765 end;
766
767 % Now rename relevant files
1 768 disp('Renaming files...');
1 769 s2 = regexp(maindir, '/', 'split');
1 770 thedate=char(s2(end));
1 771 fitsfile = strcat(thedate,'.fits');
1 772 fitsmapfile= strcat(thedate,'_map.fits');
1 773 hitsfile= strcat(thedate,'.hits');
774
0.01 1 775 movefile('fitstable.fits',fitsfile);
1 776 movefile('map.fits',fitsmapfile);
1 777 movefile('map.hits',hitsfile);
778
779
780
1 781 if (strcmp(frame,'heal') & strcmp(projection,'moll'))
782
1 783 tmap= strcat(thedate,'_T.png');
1 784 qmap= strcat(thedate,'_Q.png');
0.01 1 785 umap= strcat(thedate,'_U.png');
786
1 787 movefile('map_T.png',tmap);
1 788 movefile('map_Q.png',qmap);
1 789 movefile('map_U.png',umap);
790 % Make Figs for the web page.
1 791 copyfile(tmap,'fig1.png');
1 792 copyfile(qmap,'fig2.png');
0.01 1 793 copyfile(umap,'fig3.png');
794
795 elseif (strcmp(frame,'azel') & strcmp(projection,'plate'))
796
797 tmap= strcat(thedate,'_azel_T.png');
798 movefile('map_T.png',tmap);
799 copyfile(tmap,'fig1.png');
800
801 end
802
1 803 delete('files.txt');
1 804 disp('...map making completed');
805 else
806 disp('Will not attempt to make a map...');
807 end
808
809 %disp(['Returning to directory ',olddir]);
1 810 cd(olddir);
1 811 return;
Other subfunctions in this file are not included in this listing.