Re: how to automate contour levels when paneling multiple frames

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 23 2013 - 12:19:59 MDT

It's certainly possible to get the level settings from one plot and then set them for the next plot using the getvalues "visualization block". This is not well documented currently, because getvalues
is not a function or a procedure and has an unusual syntax. It is documented in the reference manual:
Expanding your code snippet:

do z = 0, nlev -1
     resT@cnLevelSelectionMode = "AutomaticLevels"
     plot(0) = gsn_csm_contour_map(wks, T_avg(0,z,:,:), resT)

     getvalues plot(0)
          "cnMinLevelValF" : minlev
          "cnMaxLevelValF" : maxlev
                "cnLevelSpacingF" : level_spacing
     end getvalues

     resT@cnLevelSelectionMode = "ManualLevels"
     resT@cnMinLevelValF = minlev
     resT@cnMaxLevelValF = maxlev
     resT@cnLevelSpacingF = level_spacing
     plot(1) = gsn_csm_contour_map(wks, T_avg(1,z,:,:), resT)
end do

As long as the two data sets have reasonably similar max and min values at each level, this approach could work pretty well. But if one has a significant difference in the max and min it might be obscured by this technique.
It might be better to use dim_max_n and dim_min_n to get the overall max and min first. You would need to apply it twice to the variable T_avg as you have defined it to get the overall max, min for each level:
  dataset_min = dim_min_n(T_avg,(/2,3/)) ; returns a 2d variable (dataset, level)
  minval1d = dim_min_n(dataset_min, 0) ; returns a 1d variable with the overall min at each level.

Not tested. Hope this helps.

On Oct 23, 2013, at 10:22 AM, jonathan meyer <> wrote:

> Hi,
> I am plotting multiple frames that compare two datasets on pressure levels.
> I am looking for a way to automate the code to ensure the contours are the same between both datasets and their panels.
> For example:
> I have temperature that needs comparing at 40 pressure levels between two reanalysis datasets.
> Obviously I could create an array of the max/min/spacing values that should be used on each pressure level, but with 40 levels, this can get extensive, and require the panels to be visually inspected first.
> Is there a way to have panel 1 created, while assigning panel 2's contour resources to what panel 1 was set to?
> -----------
> Here is the paraphrased hardcoded (inefficient) code snippet for the plotting I am currently doing.
> ;Tavg(n_datasets, n_lev, n_lat, n_lon)
> ;mn = (/n_lev/)
> ;mx = (/n_lev/)
> ;sp = (/n_lev/)
> do z = 0, n_lev-1
> resT@cnMinLevelValF = mn(z)
> resT@cnMaxLevelValF = mx(z)
> resT@cnLevelSpacingF = sp(z)
> plot(0) = gsn_csm_contour_map(wks, T_avg(0,z,:,:), resT)
> plot(1) = gsn_csm_contour_map(wks, T_avg(1,z,:,:), resT)
> end do
> Thanks in advance for all your time/efforts!
> Jon
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:

ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Wed Oct 23 12:20:06 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 01 2013 - 08:58:14 MDT