[ncl-talk] Fill entire plot area

Rabah Hachelaf hachelaf at sca.uqam.ca
Wed Jul 30 23:04:28 MDT 2014


Hi Mary,

Thanks for this working suggestion, but when trimming the image the pixel
size change, i must keep the same pixel size in each image side because
those images will feed a viewing software like.

Is there another trick to fill the plot area and keep same pixel size.

Thanks again

Rabah


2014-07-30 10:39 GMT-04:00 Mary Haley <haley at ucar.edu>:

> Hi Rabah,
>
> One of NCL's quirks is that it always wants to draw things to a square, so
> even when you have a non-square plot, like with a lat/lon projection that
> may be wider than it is high, there is still an invisible square area that
> NCL is plotting to. You will see this especially when you are plotting
> graphics to an X11 window or a PNG image.
>
> There's not much you can do about the X11 window being square, but you can
> trim the PNG image.
>
> The way I trim the PNG image is to use a tool called "convert" which is
> part of the free ImageMagick package.   "convert" is a handy tool that
> allows you to convert from one format to another (like PS to PNG, GIF to
> JPEG, and PNG to PNG), while at the same time trimming additional white
> space, resizing the image, cropping an image, etc.
>
> Once you have "convert" you can use it directly in your NCL script via a
> system call, to trim the white space.
>
> So, for example, with the script you included, I would do something like
> this when calling "gsn_open_wks":
>
>   wks_type          = "png"
>   wks_type at wkWidth  = pixel
>   wks_type at wkHeight = pixel
>   wks_type at wkBackgroundOpacityF = 0.0
>   wks_filename = "wx_map_" + "zoom" + zoom + "_" + "DOM" + \
>                   sprinti("%0.1i",idom+1) +  "_" + \
>                   lev_str(ilev) + "_" + sprinti("%0.2i", i)
>   wks = gsn_open_wks(wks_type,wks_filename)
>
> Then, after you call "draw" and "frame" on the workstation, you need to
> "delete" the workstation, which merely ensures that the PNG image is
> properly closed. This allows you to then call "convert" to trim the image:
>
>   draw(wks)      ;; Now draw map with text strings and               frame(wks)
>     ; advance the frame
>   delete(wks)    ; Close the PNG image
>
> ;---Trim the PNG image
>   png_filename = wks_filename + ".png"
>   cmd = "convert -trim " + png_filename + " " + png_filename
>   system(cmd)
>
> You can get the ImageMagick suite of tools from:
>
> http://www.imagemagick.org
>
> --Mary
>
>
> On Tue, Jul 29, 2014 at 7:59 AM, Rabah Hachelaf <hachelaf at sca.uqam.ca>
> wrote:
>
>> Hi all,
>>
>> I am using the script attached to plot sub-domains from GFS data.
>> When i plot the whole domain or a 1/4 domain area the plot fit correctly
>> with the entire plot area.
>> But when i want plot 1/16 the plotted map does't fit and there is a white
>> bands appear some time on top and bottom and some times on right and
>> left.(like attached images).
>>
>> I tried mpShapeMode  = "FreeAspect", this make my maps fit with the
>> entire plot area but this not preserve the map projection aspect ratio
>>
>> Thank you for any suggestions.
>>
>> --
>> ------------------------------
>> Cordialement,
>> Best regards,
>> Rabah Hachelaf
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>


-- 
------------------------------
Cordialement,
Best regards,
Rabah Hachelaf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140731/7aead4b4/attachment.html 


More information about the ncl-talk mailing list