[ncl-talk] high resolution png image
David Brown
dbrown at ucar.edu
Thu Oct 30 14:48:58 MDT 2014
Hi Kyle,
My experience is that drawing a raster fill png plot keeping the cell
size close to the grid cell size is usually (much) faster than drawing
an AreaFill plot. For the example I just used, drawing the MPAS grid,
the raster sample factor does not work well because it is an
unstructured grid, and therefore there is not a clear definition of
the size of a grid cell, which the cnRasterSampleFactorF resource
depends on. With a little work, this could be improved I think.
-dave
On Thu, Oct 30, 2014 at 2:35 PM, Kyle Griffin <ksgriffin2 at wisc.edu> wrote:
> Interesting. I would agree on having a couple of examples. In the meantime,
> a couple of thoughts...
>
> Between the cnRasterCellSizeF and cnRasterSampleFactorF, you can essentially
> set the cell size to be infinitely small (e.g. 1e-30, within the range of
> float still) and keeping the sample factor at 1.0 should keep the cells no
> smaller than the size of the grid itself, correct? If this was done, is
> there any computational efficiency to be gained versus using an AreaFill?
> Might depend on the data itself, I suppose, but it would seem that the
> infinitely-small limit of RasteFill is essentially CellFill mode, but
> perhaps more computations (such as averaging all data points contributing a
> cell - in this case this is 1, but don't know if the average is removed in
> this limiting case) which would make CellFill more example in this limiting
> case, perhaps? Either way, you could avoid wkWidth/Height-dependent
> calculations with the sample factor limit, if I'm reading the documentation
> correctly.
>
> I think the application Micah has in mind would involve transferring the
> image over the web and using a browser-side piece of software to subset the
> image to the desired visible region. Plotting resolution issues were the
> problem when I tried something a while ago, so it would be interesting to
> find the most efficient way of hi-res plotting of an entire global grid and
> getting a subset to a web-based user.
>
>
> Kyle
>
> ----------------------------------------
> Kyle S. Griffin
> Department of Atmospheric and Oceanic Sciences
> University of Wisconsin - Madison
> Room 1421
> 1225 W Dayton St, Madison, WI 53706
> Email: ksgriffin2 at wisc.edu
>
> On Thu, Oct 30, 2014 at 3:19 PM, David Brown <dbrown at ucar.edu> wrote:
>>
>> Compared with high resolution PostScript files, high resolution PNG
>> images do seem to be much more cost effective in terms of file size
>> and quickness to load and manipulate by typical viewing tools like Mac
>> Preview.
>>
>> Ideally you would want a PNG image that is close to the same
>> resolution as your data or higher. In order to get this with an NCL
>> "RasterFill" plot there are two things you need to adjust: the output
>> workstation resolution, controlled by "wkWidth" and "wkHeight", and
>> the resolution that the raster fill method uses when drawing, which is
>> most easily controlled by setting the resource "cnRasterCellSizeF" to
>> a suitable small number. Note that the workstation resources set a
>> resolution for the plot as a whole, including the annotations and any
>> white space that surrounds the plot, while the raster cell size only
>> relates to the area inside the viewport of the actual plot -- just
>> something to keep in mind.
>>
>> For example, to visualize a 65,000,000 cell MPAS grid with maximum
>> possible detail, I set
>> wkWidth and wkHeight to 16384 (a power of 2 but not really necessary
>> -- it could have been 16000).
>> Then I set cnRasterCellSizeF to 1.0/16384.0 Nothing magical about
>> these numbers, and they don't account for the whole plot vs viewport
>> issue mathematically, but they do produce a very detailed image. The
>> output PNG file is about 40 MB -- too big to attach to this message
>> unfortunately.
>>
>> We should probably have an example or two showing how to create
>> high-res graphics.
>> -dave
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Thu, Oct 30, 2014 at 11:30 AM, Micah Sklut <micahs2005 at gmail.com>
>> wrote:
>> > Okay, thanks for explaining how the raster fill works Kyle. That does
>> > help
>> > me understand this limitation. With respect to processing time between
>> > rasterFill and areaFill. It took about 1-2 minutes for rasterFill,
>> > compared
>> > to a ball park of 4 hours for areaFill. Quite a difference!
>> >
>> > On Thu, Oct 30, 2014 at 1:26 PM, Kyle Griffin <ksgriffin2 at wisc.edu>
>> > wrote:
>> >>
>> >> That's part of the definition of Raster fill - it will always create
>> >> the
>> >> same number of boxes regardless of resolution of the data underneath,
>> >> typically based on an average of the data points within that set of
>> >> grid
>> >> points. Although I'm not knowledgeable about the behind-the-scenes
>> >> computations, I know it's common for NCL to mark the whole average as
>> >> missing if any subset of that average is missing. I'm not sure if
>> >> there's a
>> >> way to override this - a developer might need to chime in here - but
>> >> that
>> >> would be your only hope if you want to keep your image production time
>> >> down,
>> >> as the other fill modes will almost certainly be more intensive. You
>> >> can
>> >> scan examples of Raster Fill code here (see link) and in the contour
>> >> resources page as well.
>> >>
>> >> https://www.ncl.ucar.edu/Applications/raster.shtml
>> >>
>> >> If you did AreaFill or CellFill, I don't think you see much difference
>> >> in
>> >> the time to produce a vector file output versus a raster image output.
>> >> But
>> >> yes, what you are seeing is a limitation of using the RasterFill
>> >> setting.
>> >>
>> >>
>> >> Kyle
>> >>
>> >> ----------------------------------------
>> >> Kyle S. Griffin
>> >> Department of Atmospheric and Oceanic Sciences
>> >> University of Wisconsin - Madison
>> >> Room 1421
>> >> 1225 W Dayton St, Madison, WI 53706
>> >> Email: ksgriffin2 at wisc.edu
>> >>
>> >> On Thu, Oct 30, 2014 at 11:55 AM, Micah Sklut <micahs2005 at gmail.com>
>> >> wrote:
>> >>>
>> >>> No, I"m not masking data. Yes, I am using RasterFill, and the
>> >>> resulting
>> >>> image for the Mid Atlantic is great. But, when I expand to global, I
>> >>> lose
>> >>> the high detail, no matter how much I increase the png resolution. So,
>> >>> just
>> >>> wondering why I am losing detail with the global image, and if there
>> >>> is a
>> >>> way around it.
>> >>>
>> >>> On Thu, Oct 30, 2014 at 12:52 PM, Kyle Griffin <ksgriffin2 at wisc.edu>
>> >>> wrote:
>> >>>>
>> >>>> Hi Micah,
>> >>>>
>> >>>> This seems to me the type of result you would expect when using
>> >>>> RasterFill as a cnFillMode - the default should be cnAreaFill, which
>> >>>> increases plot time significantly, but might that be an issue?
>> >>>> Otherwise, I assume you're doing nothing else to mask the data,
>> >>>> correct?
>> >>>> Sometimes masking data with a land mask can create similar
>> >>>> blockiness,
>> >>>> although I am unaware (via inexperience) as to whether there is a
>> >>>> resolution
>> >>>> dependence based on the plot size or native data resolution.
>> >>>>
>> >>>>
>> >>>> Kyle
>> >>>>
>> >>>> ----------------------------------------
>> >>>> Kyle S. Griffin
>> >>>> Department of Atmospheric and Oceanic Sciences
>> >>>> University of Wisconsin - Madison
>> >>>> Room 1421
>> >>>> 1225 W Dayton St, Madison, WI 53706
>> >>>> Email: ksgriffin2 at wisc.edu
>> >>>>
>> >>>> On Thu, Oct 30, 2014 at 11:37 AM, Micah Sklut <micahs2005 at gmail.com>
>> >>>> wrote:
>> >>>>>
>> >>>>> Hi Kyle,
>> >>>>>
>> >>>>> Thanks for the reply.
>> >>>>>
>> >>>>> The dataset is of 0.05 degree resolution, so that certainly isn't
>> >>>>> the
>> >>>>> problem. I have attached an image of the same data, but limiting the
>> >>>>> min/max
>> >>>>> lat/lon to the US Mid Atlantic. In this image you will see much more
>> >>>>> detail.
>> >>>>> This is the type of detail I was hoping to achieve for the entire
>> >>>>> globe. I
>> >>>>> figured if I increased the resolution of the global png, it would
>> >>>>> create the
>> >>>>> desired effect, but as you can see from the global image I attached,
>> >>>>> this
>> >>>>> wasn't the case.
>> >>>>>
>> >>>>> Looking forward to hearing your thoughts.
>> >>>>> Thank you,
>> >>>>>
>> >>>>> Micah
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>> On Thu, Oct 30, 2014 at 12:26 PM, Kyle Griffin <ksgriffin2 at wisc.edu>
>> >>>>> wrote:
>> >>>>>>
>> >>>>>> Micah,
>> >>>>>>
>> >>>>>> This looks more like a limitation of your dataset - SST data is not
>> >>>>>> of
>> >>>>>> infinite resolution, and you're plotting far more pixels than would
>> >>>>>> be data
>> >>>>>> points in even a 0.1˚ dataset! It looks like the internal pixels
>> >>>>>> are the
>> >>>>>> same size as your coastlines, so I don't see an issue with NCL
>> >>>>>> there. More
>> >>>>>> specifically, you are not actually plotting coastlines - they only
>> >>>>>> plot if
>> >>>>>> you tell them to plot with a call to gsn_csm_map or another similar
>> >>>>>> plotting
>> >>>>>> tool. If you're looking for high resolution coastlines, look at the
>> >>>>>> RANGS
>> >>>>>> mapping capabilities in NCL. Beyond that, you can always plot
>> >>>>>> shapefiles as
>> >>>>>> well.
>> >>>>>>
>> >>>>>> Yes, vector images are going to be extremely large and painful for
>> >>>>>> even a moderate resolution file over the full globe. When you say
>> >>>>>> raster,
>> >>>>>> are you talking about it in the image sense (non-vector file) or in
>> >>>>>> the
>> >>>>>> cnFillMode sense (RasterFill, AreaFill, etc.;
>> >>>>>>
>> >>>>>> https://www.ncl.ucar.edu/Document/Graphics/Resources/cn.shtml#cnFillMode)?
>> >>>>>> Raster fill mode will make the data more blocky and reduce
>> >>>>>> interpolation
>> >>>>>> between points, but the trade-off is a much faster plotting of the
>> >>>>>> image and
>> >>>>>> works well for high-resolution datasets being plotted at relatively
>> >>>>>> low
>> >>>>>> resolution/wide zoom.
>> >>>>>>
>> >>>>>>
>> >>>>>> Kyle
>> >>>>>>
>> >>>>>> ----------------------------------------
>> >>>>>> Kyle S. Griffin
>> >>>>>> Department of Atmospheric and Oceanic Sciences
>> >>>>>> University of Wisconsin - Madison
>> >>>>>> Room 1421
>> >>>>>> 1225 W Dayton St, Madison, WI 53706
>> >>>>>> Email: ksgriffin2 at wisc.edu
>> >>>>>>
>> >>>>>> On Thu, Oct 30, 2014 at 9:58 AM, Micah Sklut <micahs2005 at gmail.com>
>> >>>>>> wrote:
>> >>>>>>>
>> >>>>>>> Hi,
>> >>>>>>>
>> >>>>>>> This is a follow up to my previous posts, in reference to
>> >>>>>>> searching
>> >>>>>>> for high resolution images that could be used as
>> >>>>>>> zooming/navigating
>> >>>>>>> (specific interest is with image tile layers).
>> >>>>>>>
>> >>>>>>> I figured if I created a png file with a high resolution, it would
>> >>>>>>> be
>> >>>>>>> able to capture the high detail, like with coastlines and so
>> >>>>>>> forth.
>> >>>>>>> I've attached an image with very high resolution (16384x16384),
>> >>>>>>> but
>> >>>>>>> as you can see, if you zoom the global image into the coastlines
>> >>>>>>> they are
>> >>>>>>> extremely blocky.
>> >>>>>>>
>> >>>>>>> Is is possible to capture high resolution features, such as
>> >>>>>>> coastlines in a global raster image with NCL?
>> >>>>>>>
>> >>>>>>> FYI, I tried the vector image route, but the file size was
>> >>>>>>> gigantic,
>> >>>>>>> so that didn't seem like a proper route.
>> >>>>>>>
>> >>>>>>> Thank you,
>> >>>>>>>
>> >>>>>>> --
>> >>>>>>> Micah Sklut
>> >>>>>>>
>> >>>>>>> _______________________________________________
>> >>>>>>> ncl-talk mailing list
>> >>>>>>> List instructions, subscriber options, unsubscribe:
>> >>>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>> >>>>>>>
>> >>>>>>
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>> --
>> >>>>> Micah Sklut
>> >>>>>
>> >>>>
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Micah Sklut
>> >>>
>> >>
>> >
>> >
>> >
>> > --
>> > Micah Sklut
>> >
>> >
>> > _______________________________________________
>> > ncl-talk mailing list
>> > List instructions, subscriber options, unsubscribe:
>> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>> >
>
>
More information about the ncl-talk
mailing list