2012-02-02 127 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