Ignore:
Timestamp:
Apr 21, 2010 1:33:38 PM (14 years ago)
Author:
heinze
Message:

NCL scripts allow the output of png files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/NCL/profiles.ncl

    r526 r532  
    3333   
    3434begin
     35
     36   ;***************************************************
     37   ; Retrieving the NCL version used
     38   ;***************************************************
     39   
     40   ncl_version_ch = systemfunc("ncl -V")
     41   ncl_version    = stringtofloat(ncl_version_ch)
    3542
    3643   ;***************************************************
     
    241248
    242249   
    243    if (format_out .NE. "x11" .AND. format_out .NE. "pdf" .AND. format_out .NE. "eps" .AND. format_out .NE. "ps" .AND. format_out .NE. "epsi" .AND. format_out .NE. "ncgm")then
     250   if (format_out .NE. "x11" .AND. format_out .NE. "pdf" .AND. format_out .NE. "eps" .AND. format_out .NE. "ps" .AND. format_out .NE. "epsi" .AND. format_out .NE. "ncgm" .AND. format_out .NE. "png")then
    244251      print(" ")
    245252      print("'format_out = "+format_out+"' is invalid and set to'x11'")
     
    247254      format_out="x11"
    248255   end if 
     256
     257   if (ncl_version .LE. 5.1 .AND. format_out .EQ. "png") then
     258      print(" ")
     259      print("Output of png files not available")
     260      print("png output is avaiable with NCL version 5.2.0 and higher ")
     261      print("NCL version used: " + ncl_version_ch)
     262      print(" ")
     263      exit
     264   end if
    249265
    250266   if (over .NE. 0 .AND. over .NE. 1) then
     
    10881104   res@gsnDraw                 = False
    10891105   res@gsnFrame                = False
    1090    res@gsnPaperOrientation     = "portrait"
    1091    res@gsnPaperWidth           = 8.27
    1092    res@gsnPaperHeight          = 11.69
    1093    res@gsnPaperMargin          = 0.79
    10941106   res@txFont                  = "helvetica"
    10951107   res@tiMainFont              = "helvetica"
     
    11641176   end if
    11651177 
     1178   if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then
     1179      format_out@wkPaperSize = "A4"
     1180   end if
     1181   if ( format_out .EQ. "png" ) then
     1182      format_out@wkWidth  = 1000
     1183      format_out@wkHeight = 1000
     1184   end if
     1185
    11661186   wks=gsn_open_wks(format_out,file_out)
    11671187   gsn_define_colormap(wks,"rainbow+white")
     
    40924112   end do
    40934113
     4114   no_frames = 0
     4115
    40944116   if ((format_out .EQ. "eps" .OR. format_out .EQ. "epsi") .AND. n .gt. no_rows*no_columns) then
    40954117      gsn_panel(wks,plot_,(/n,1/),resP)
     
    41014123         if( (i+no_rows*no_columns) .gt. (n-1)) then
    41024124            gsn_panel(wks,plot_(i:n-1),(/no_rows,no_columns/),resP)
     4125            no_frames = no_frames + 1 
    41034126         else
    41044127            gsn_panel(wks,plot_(i:i+no_rows*no_columns-1),(/no_rows,no_columns/),resP)
     4128            no_frames = no_frames + 1 
    41054129         end if
    41064130      end do
    41074131   end if
    41084132
    4109    print(" ")
    4110    print("Output to: " + file_out +"."+ format_out)
    4111    print(" ")
     4133    if (format_out .EQ. "png" ) then
     4134     png_output = new((/no_frames/), string)
     4135     j = 0
     4136     do i=0, no_frames-1
     4137       j = i + 1
     4138       if (j .LE. 9) then
     4139         png_output(i) = file_out+".00000"+j+".png"
     4140       end if
     4141       if (j .GT. 9 .AND. j .LE. 99) then
     4142         png_output(i) = file_out+".0000"+j+".png"
     4143       end if
     4144       if (j .GT. 99 .AND. j .LE. 999) then
     4145         png_output(i) = file_out+".000"+j+".png"
     4146       end if
     4147       if (j .GT. 999) then
     4148         png_output(i) = file_out+".00"+j+".png"
     4149       end if
     4150
     4151       ;using imagemagick's convert for reducing the white
     4152       ;space around the plot
     4153       cmd = "convert -geometry 1000x1000 -density 300 -trim " +  \
     4154              png_output(i) + " " + png_output(i)
     4155       system(cmd)
     4156     end do
     4157
     4158     print(" ")
     4159     print("Output to: "+ png_output)
     4160     print(" ")
     4161   else
     4162     print(" ")
     4163     print("Output to: " + file_out +"."+ format_out)
     4164     print(" ")
     4165   end if
    41124166
    41134167end
Note: See TracChangeset for help on using the changeset viewer.