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

    r526 r532  
    3434
    3535   ;***************************************************
     36   ; Retrieving the NCL version used
     37   ;***************************************************
     38   
     39   ncl_version_ch = systemfunc("ncl -V")
     40   ncl_version    = stringtofloat(ncl_version_ch)
     41
     42   ;***************************************************
    3643   ; Retrieving the double quote character
    3744   ;***************************************************
     
    5259   end if
    5360
    54    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
     61   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
    5562      print(" ")
    5663      print("'format_out = "+format_out+"' is invalid and set to'x11'")
     
    5865      format_out="x11"
    5966   end if
     67
     68   if (ncl_version .LE. 5.1 .AND. format_out .EQ. "png") then
     69      print(" ")
     70      print("Output of png files not available")
     71      print("png output is avaiable with NCL version 5.2.0 and higher ")
     72      print("NCL version used: " + ncl_version_ch)
     73      print(" ")
     74      exit
     75   end if
    6076   
    6177   if (log_x .NE. 0 .AND. log_x .NE. 1)then
     
    340356   res@gsnDraw                 = False
    341357   res@gsnFrame                = False
    342    res@gsnPaperOrientation     = "portrait"
    343    res@gsnPaperWidth           = 8.27
    344    res@gsnPaperHeight          = 11.69
    345    res@gsnPaperMargin          = 0.79
    346358   res@txFont                  = "helvetica"
    347359   res@tiMainFont              = "helvetica"
     
    417429   if ( dash .eq. 0 ) then
    418430      res@xyMonoDashPattern = True
     431   end if
     432
     433   if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then
     434      format_out@wkPaperSize = "A4"
     435   end if
     436   if ( format_out .EQ. "png" ) then
     437      format_out@wkWidth  = 1000
     438      format_out@wkHeight = 1000
    419439   end if
    420440
     
    664684   end if
    665685
    666    print(" ")
    667    print("Output to: " + file_out +"."+ format_out)
    668    print(" ")
     686   if (format_out .EQ. "png" ) then
     687     png_output = new((/no_frames/), string)
     688     j = 0
     689     do i=0, no_frames-1
     690       j = i + 1
     691       if (j .LE. 9) then
     692         png_output(i) = file_out+".00000"+j+".png"
     693       end if
     694       if (j .GT. 9 .AND. j .LE. 99) then
     695         png_output(i) = file_out+".0000"+j+".png"
     696       end if
     697       if (j .GT. 99 .AND. j .LE. 999) then
     698         png_output(i) = file_out+".000"+j+".png"
     699       end if
     700       if (j .GT. 999) then
     701         png_output(i) = file_out+".00"+j+".png"
     702       end if
     703
     704       ;using imagemagick's convert for reducing the white
     705       ;space around the plot
     706       cmd = "convert -geometry 1000x1000 -density 300 -trim " +  \
     707              png_output(i) + " " + png_output(i)
     708       system(cmd)
     709     end do
     710
     711     print(" ")
     712     print("Output to: "+ png_output)
     713     print(" ")
     714   else
     715     print(" ")
     716     print("Output to: " + file_out +"."+ format_out)
     717     print(" ")
     718   end if
    669719   
    670720end
Note: See TracChangeset for help on using the changeset viewer.