2012-02-02 139 views
2

多個附圖我正在與處理數據(在卡爾曼濾波器)的一些MATLAB代碼工作和創建一系列等高線圖的。它已經在matlab 2006a的RHEL 4服務器上運行了幾年,但是我的老闆最近要求所有的服務器都更新到RHEL 6 ...至少matlab 2007a。我已經計算出這些版本之間的所有折舊,但我仍然遇到一個主要問題。繪製在Matlab

創建和打印不同的等高線圖的代碼是三個地塊以先到爲準創建工作。它看起來像這樣: enter image description here

遺憾的是,接下來的兩個地塊是這樣的:

enter image description here

這三個數字在單獨的功能獨立策劃和我之前和創建每個數字後使用clf("reset");。每個功能本身都起作用,但是當所有三個功能都被繪製出來時,第二個和第三個功能都搞砸了。有沒有其他人有這個問題?這是創建其中一個數字的代碼。

function Crd = TEC_plot(ITEC,RT,Param,Input,t,OutPath,RxExtAll,Time) 
% Generate TEC plot 
    Function_for_Spline_Smoothing = [.05 .1 .05; .1 .4 .1; .05 .1 .05]; 
    ITEC = conv2(ITEC,Function_for_Spline_Smoothing,'same'); % add more of these lines to make contours smoother 
    ITEC = conv2(ITEC,Function_for_Spline_Smoothing,'same'); % add more of these lines to make contours smoother 
% ITEC = conv2(ITEC,Function_for_Spline_Smoothing,'same'); % add more of these lines to make contours smoother 
% ITEC = conv2(ITEC,Function_for_Spline_Smoothing,'same'); % add more of these lines to make contours smoother 

    earth('CAMERA',RT.Camera,'FIG',1); 
    figure; 
    warning off; hold on; 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% Changed 13 February 2007 to make plots prettier 
    thinning_scale=2; % (1 to 10) increase this value to thin the density of the contour number labels 
    [cscale,hgt]=m_contour(Param.Grid.LonAxis,Param.Grid.LatAxis,ITEC, ... 
     round(RT.Levels(1:thinning_scale:end)/5)*5); 
    hold on 
    m_contourf(Param.Grid.LonAxis,Param.Grid.LatAxis,ITEC,RT.Levels); 
    shading flat 

    m_coast('line','color','y','LineWidth',1); 

    clabel(cscale,hgt,'labelspacing',72,'rotation',0,'fontsize',10 ... 
         ,'FontAngle','italic','color','w'); 
    axis([-.65 .6 .25 1.32]) % hardwiring axis length since the coastline runs off of the plot 
% Changed 13 February 2007 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 


% %-------------------- to include different station markers for different sources ------------------- 
    if ~isempty(Input.Data) % Plot receivers used in this inversion 

     Crd=uniquerows(double(cat(1,RxExtAll))); 
     RxType=round(Crd(:,4)); 
     Crd=cartsph(Crd)*180/pi; 

     i1 = find((Crd(:,3) > RT.Camera(3)).*(Crd(:,3) < RT.Camera(4)).*... 
        (Crd(:,2) > RT.Camera(1)).*(Crd(:,2) < RT.Camera(2)).*... 
        (RxType==1)); 

     i2 = find((Crd(:,3) > RT.Camera(3)).*(Crd(:,3) < RT.Camera(4)).*... 
        (Crd(:,2) > RT.Camera(1)).*(Crd(:,2) < RT.Camera(2)).*... 
        (RxType==2)); 

     i3 = find((Crd(:,3) > RT.Camera(3)).*(Crd(:,3) < RT.Camera(4)).*... 
        (Crd(:,2) > RT.Camera(1)).*(Crd(:,2) < RT.Camera(2)).*... 
        (RxType==3)); 

     m_plot(Crd(i1,3),Crd(i1,2),'ro','markersize',5,'LineWidth',2); 
%  m_plot(Crd(i1,3),Crd(i1,2),'r.','markersize',6,'LineWidth',2); 
     m_plot(Crd(i2,3),Crd(i2,2),'r^','markersize',5,'LineWidth',2); 
%  m_plot(Crd(i2,3),Crd(i2,2),'r.','markersize',6,'LineWidth',2); 
     m_plot(Crd(i3,3),Crd(i3,2),'rp','markersize',5,'LineWidth',2); 

     plot(-.6,.45,'ro','markersize',5,'LineWidth',2);text(-.55,.45,'CORS','Color','k') 
     plot(-.6,.39,'r^','markersize',5,'LineWidth',2);text(-.55,.39,'GPS/Met','Color','k') 
     plot(-.6,.33,'rp','markersize',5,'LineWidth',2);text(-.55,.33,'RTIGS','Color','k') 

    end 
% % ------------------------------------------------------------------------------- 

    hold off; warning on;axis off; 

% caxis([RT.Levels(1),(RT.Levels(length(RT.Levels)))/2]); colorbar('vert'); %Color bar from 0 to 50 --- for Low Solar Activity 
    caxis([RT.Levels(1),(RT.Levels(length(RT.Levels)))]); colorbar('vert'); %Color bar from 0 to 100 --- for High Solar Activity 

    title(sprintf('Total Electron Content Units x 10^1^6 m^-^2'),'Fontsize',11) 
    if size(Crd,1)==0, 
     title(sprintf('Total Electron Content Units x 10^1^6 m^-^2 Caution: No Data Available, IRI95 Only'),'Fontsize',10) 
    end 
    whitebg('w') 
    text(-0.6,0.22,sprintf('%s from %s to %s UT   NOAA/SWPC Boulder, CO USA (op.ver. 1.0)',datestr(Time(t)+1E-8,1),datestr(Time(t)+1E-8,15),datestr(Time(t)+1E-7+15/1440,15)),'Fontsize',11) 
    whitebg('w') 

% This option print to a file 
%  set(gcf, 'Position', [0,0,1950,1467]); 
%  print('-f1','-dpng','-painters',filename([OutPath,'{YYYY}{MM}{DD}{HRMN}_TEC'],Time(t))); 
%  system(['convert ', filename([OutPath,'{YYYY}{MM}{DD}{HRMN}_TEC.png'],Time(t)),' -scale 650x489 ',' -colors 256 ', filename([OutPath,'{YYYY}{MM}{DD}{HRMN}_TEC.png'],Time(t))]); 


% Printing a postscript file because requirements for the automatic reboot 
    print('-f1','-dpsc','-r1000','-painters', filename([OutPath,'{YYYY}{MM}{DD}{HRMN}_TEC'],Time(t))); 

% Convert the postscript file to jpg using ghostscripts 
    system(['gs -q -dBATCH -dNOPAUSE -r300 -sDEVICE=jpeg -sOutputFile=',filename([OutPath,'{YYYY}{MM}{DD}{HRMN}_TEC.jpg'],Time(t)),' ', filename([OutPath,'{YYYY}{MM}{DD}{HRMN}_TEC.ps'],Time(t))]); 
% Converting from jpg to png and reducing the size of the figure. 
    system(['convert ',filename([OutPath,'{YYYY}{MM}{DD}{HRMN}_TEC.jpg'],Time(t)),' -crop 2050x1675+325+775 ',' -scale 650x489 ',' -colors 256 ', filename([OutPath,'{YYYY}{MM}{DD}{HRMN}_TEC.png'],Time(t))]); 
% Removing the jpg and ps files (ask Cliff how can we put both files in just one command) 
    %system(['rm ',filename([OutPath,'*.jpg'],Time(t))]); 
    %system(['rm ',filename([OutPath,'*.ps'],Time(t))]); 
end 
+2

當然,我們希望看到一些代碼吳 – tim 2012-02-02 19:32:25

+0

爲什麼代碼看起來象是什麼?我剛剛添加了代碼部分並粘貼了代碼... – GPSmaster 2012-02-02 19:48:41

+0

我更改了代碼:) – tim 2012-02-02 20:07:36

回答

2

儘量不要使用clf這將清除您的整個數字,但使用的figure開三個獨立的數字。看到它,它會工作:)

編輯:這只是猜測沒有真正看到你的代碼

+0

我正在嘗試。看到這是在命令行上運行的只有沒有UI的接口,'figure'會嘗試創建一個新窗口並返回一個錯誤? – GPSmaster 2012-02-02 19:41:05

+0

'figure'只是打開另一個圖形窗口,所有繪圖命令將被繪製在新圖形內。所以你之後會有3個不同的窗口,而不是總是清除相同的數字,並將數據重新輸入到它 – tim 2012-02-02 20:06:17

+0

不幸的是,這並沒有奏效。第一個數字只顯示海岸線,第二個數字完全空白:/ Hmmmm。另外,如何在保存圖像後清除數字窗口? – GPSmaster 2012-02-02 20:12:37

1

一個猜測可能與產生最終的PNG文件的代碼。從JPG轉換爲PNG時,您的第二張圖似乎被錯誤裁剪。

首先將print命令固定爲使用圖1中的任何內容。因此,要確保您使用圖1進行繪圖,請使用命令figure(1)來指定該命令。或者,將打印命令更改爲print(gcf ...以打印當前圖形。

此外,請注意您可以產生直接與print PNG文件作爲

print(gcf,'-dpng','-r1000',filename(...)) 

而跳過從PS到JPG至PNG步轉換。

硬編碼在print圖窗口或許可以解釋爲什麼事情,如果你有多個人物的窗戶可獨立但不能一起工作。只是一個猜測。

+0

非常感謝您的建議!我沒有完全按照你所說的去做,但你確實把我推向了正確的方向。我最終手動定義了每個圖的數字,並通過這樣做,我發現'earth()'函數指定了一個圖號......改變了,現在的東西運行得更加平滑。謝謝!哦,從ps-> jpg-> png的轉換很煩人,但其他原因是必要的。我仍然遇到這些情節的一些其他問題,但我會開始一個新的線程,並在這裏發佈鏈接。再次感謝。 – GPSmaster 2012-02-06 19:33:04