[ncl-talk] Defining bin spacing

Sri nandini bax8609 at uni-hamburg.de
Thu Oct 1 02:45:12 MDT 2020


Hello everyone,

I'm defining my own bin spacing, as well as number of bin calculations 
for the PDF. But when i print out the information, the bin spacing is 
not defined but more approximately the same. What i want to do is to 
define exactly the same bin width e.g. 0.5cm and not only approximately 
the same for each dataset.

An example of my script as well as the print out information is below. I 
would be grateful for any advice.

    opt = True
    opt at bin_spacing=0.9
    max_ws = max(anom1_1d)
    min_ws= min(anom1_1d)
    nbins1 = floattointeger(((max_ws - min_ws)/0.9)+1)
    print(nbins1)

    max_ws1 = max(anom2_1d)
    min_ws1= min(anom2_1d)
    nbins2 = floattointeger(((max_ws1 - min_ws1)/0.9)+1)
    print(nbins2)

    max_ws2 = max(anom3_1d)
    min_ws2= min(anom3_1d)
    nbins3 = floattointeger(((max_ws2 - min_ws2)/0.9)+1)
    print(nbins3)

  ;but this method wont work for plotting all 3 into one plot beause the 
bins are of different lengths.

   pdf1 = pdfx(hist_anom1, nbins1, opt)
   printVarSummary(pdf1)
   pdf2 = pdfx(rcp45_anom1, nbins2, opt)
   printVarSummary(pdf2)
   pdf3 = pdfx(rcp85_anom1,nbins3, opt)
   printVarSummary(pdf3)

Variable: pdf1
Type: double
Total Size: 352 bytes
             44 values
Number of Dimensions: 1
Dimensions and sizes:    [x | 44]
Coordinates:
             x: [-17.11023850874467..21.20948167280718]
Number Of Attributes: 11
   _FillValue :    -9.969209968386869e+36
   bin_center :    <ARRAY of 44 elements>
   bin_bounds :    <ARRAY of 45 elements>
   bin_bound_min :    -17.55581665039062
   bin_bound_max :    21.65505981445312
   bin_spacing :    0.8911562832919034
   nbins :    44
   nMax :    24000
   nUse :    24000
   long_name :    PDF: Sea surface elevation
   units :    %

Variable: pdf2
Type: double
Total Size: 368 bytes
             46 values
Number of Dimensions: 1
Dimensions and sizes:    [x | 46]
Coordinates:
             x: [-18.79115660294243..20.87602598770805]
Number Of Attributes: 11
   _FillValue :    -9.969209968386869e+36
   bin_center :    <ARRAY of 46 elements>
   bin_bounds :    <ARRAY of 47 elements>
   bin_bound_min :    -19.23190307617188
   bin_bound_max :    21.3167724609375
   bin_spacing :    0.8814929464588994
   nbins :    46
   nMax :    24000
   nUse :    24000
   long_name :    PDF: Sea surface elevation
   units :    %

Variable: pdf3
Type: double
Total Size: 360 bytes
             45 values
Number of Dimensions: 1
Dimensions and sizes:    [x | 45]
Coordinates:
             x: [-17.15226711697049..22.11448635525174]
Number Of Attributes: 11
   _FillValue :    -9.969209968386869e+36
   bin_center :    <ARRAY of 45 elements>
   bin_bounds :    <ARRAY of 46 elements>
   bin_bound_min :    -17.59848022460938
   bin_bound_max :    22.56069946289062
   bin_spacing :    0.8924262152777778
   nbins :    45
   nMax :    24000
   nUse :    24000
   long_name :    PDF: Sea surface elevation
   units :    %

Sri



More information about the ncl-talk mailing list