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/timeseries.ncl

    r526 r532  
    3535
    3636   ;***************************************************
     37   ; Retrieving the NCL version used
     38   ;***************************************************
     39   
     40   ncl_version_ch = systemfunc("ncl -V")
     41   ncl_version    = stringtofloat(ncl_version_ch)
     42
     43   ;***************************************************
    3744   ; Retrieving the double quote character
    3845   ;***************************************************
     
    5360   end if
    5461
    55    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
     62   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
    5663      print(" ")
    5764      print("'format_out = "+format_out+"' is invalid and set to'x11'")
     
    5966      format_out="x11"
    6067   end if 
     68
     69   if (ncl_version .LE. 5.1 .AND. format_out .EQ. "png") then
     70      print(" ")
     71      print("Output of png files not available")
     72      print("png output is avaiable with NCL version 5.2.0 and higher ")
     73      print("NCL version used: " + ncl_version_ch)
     74      print(" ")
     75      exit
     76   end if
    6177
    6278   if (over .NE. 0 .AND. over .NE. 1) then
     
    275291   res@gsnDraw                 = False
    276292   res@gsnFrame                = False
    277    res@gsnPaperOrientation     = "portrait"
    278    res@gsnPaperWidth           = 8.27
    279    res@gsnPaperHeight          = 11.69
    280    res@gsnPaperMargin          = 0.79
    281293   res@tmXBMode                = True
    282294   res@tmYLMode                = True
     
    308320   ; ***************************************************
    309321   
     322   if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then
     323      format_out@wkPaperSize = "A4"
     324   end if
     325   if ( format_out .EQ. "png" ) then
     326      format_out@wkWidth  = 1000
     327      format_out@wkHeight = 1000
     328   end if
     329
    310330   wks_ps = gsn_open_wks(format_out,file_out)           
    311331   gsn_define_colormap(wks_ps,"rainbow+white")
     
    12071227   ; merge plots onto one page
    12081228   ; ***************************************************
     1229
     1230   no_frames = 0
    12091231 
    12101232   if ((format_out .EQ. "eps" .OR. format_out .EQ. "epsi") .AND. n .gt. no_rows*no_columns) then
     
    12171239         if ( np + no_rows*no_columns .gt. n) then   
    12181240            gsn_panel(wks_ps, plot_ps(np:n),(/no_rows,no_columns/),resP)
     1241            no_frames = no_frames + 1           
    12191242         else
    12201243            gsn_panel(wks_ps, plot_ps(np:np+no_rows*no_columns-1),(/no_rows,no_columns/),resP)
     1244            no_frames = no_frames + 1
    12211245         end if
    12221246      end do
    12231247   end if
    12241248
    1225    print(" ")
    1226    print("Output to: " + file_out +"."+ format_out)
    1227    print(" ")
     1249   if (format_out .EQ. "png" ) then
     1250     png_output = new((/no_frames/), string)
     1251     j = 0
     1252     do i=0, no_frames-1
     1253       j = i + 1
     1254       if (j .LE. 9) then
     1255         png_output(i) = file_out+".00000"+j+".png"
     1256       end if
     1257       if (j .GT. 9 .AND. j .LE. 99) then
     1258         png_output(i) = file_out+".0000"+j+".png"
     1259       end if
     1260       if (j .GT. 99 .AND. j .LE. 999) then
     1261         png_output(i) = file_out+".000"+j+".png"
     1262       end if
     1263       if (j .GT. 999) then
     1264         png_output(i) = file_out+".00"+j+".png"
     1265       end if
     1266
     1267       ;using imagemagick's convert for reducing the white
     1268       ;space around the plot
     1269       cmd = "convert -geometry 1000x1000 -density 300 -trim " +  \
     1270              png_output(i) + " " + png_output(i)
     1271       system(cmd)
     1272     end do
     1273
     1274     print(" ")
     1275     print("Output to: "+ png_output)
     1276     print(" ")
     1277   else
     1278     print(" ")
     1279     print("Output to: " + file_out +"."+ format_out)
     1280     print(" ")
     1281   end if
     1282 
    12281283 
    12291284end
Note: See TracChangeset for help on using the changeset viewer.