[ncl-talk] plotting of 1dim var to 2dim

Dennis Shea shea at ucar.edu
Mon Nov 21 16:30:36 MST 2016


I don't think people have time to look at code that has been heavily
commented.
You should send clean minimal scripts that illustrate the problem(s).
*Out time is valuable too!*

I think you asked about TRMM HDF files before.  These A* TRMM files have
issues. For example, no _FillValue or missing_value attribute associated
with the data.  It becomes *your* responsibility to address these
file/variable issues.

My guess is that the A25 file is somewhat analogous to the A12 file at

http://www.ncl.ucar.edu/Applications/HDF.shtml
hdf4sds_6.ncl <http://www.ncl.ucar.edu/Applications/Scripts/hdf4sds_6.ncl>


A quick scan of your code .... ***LOOK*** at the outputs as you go along.


---
[1]  I have no idea why ypu are using so many temporary variables.

   Z_short            =  hdf4_file->correctZFactor
                               printVarSummary(Z_short)
                               printMinMax(Z_short,0)

   Z_short at _FillValue = toshort(-9999)             ; _FillValue must match
the variable type
   Z_short = where(Z_short.lt.0, Z_short at _FillValue, Z_short)
   printMinMax(Z_short,0)

   Z_fnl            =   Z_short/(Z_short at scale_factor)   ; same type as
typeof(Z_short at scale_factor)
   printVarSummary(Z_fnl)
   printMinMax(Z_fnl,0)

    copy_VarCoords(Z_short, Z_fnl)                   ; add meta data
    Z_fnl at long_name = Z_short at hdf_name
    Z_fnl at units     = Z_short at units
    printVarSummary(Z_fnl)                                ; 3D; (:,:,:)
    printMinMax(Z_fnl,0)



[2] Why are you using a double 'do loop' ?

        do NS            =  0, Total_Nscan-1
           do NP       =  0, Total_Npix-1

    Why not the dim_max_n or dim_max_n_Wrap? Faster, cleaner, clearer !
       http://www.ncl.ucar.edu/Document/Functions/Built-in/dim_max_n.shtml

http://www.ncl.ucar.edu/Document/Functions/Contributed/dim_max_n_Wrap.shtml

        max_Z    = dim_max_n_Wrap(Z_fnl,2)  ;  Z_fnl(0,1,2) <== dimension
numbers, 2 is level
        printVarSummary(max_Z)                     ; (:,:)
        printMinMax(max_Z, 0)


[3]
Using your settings

        maz_Z at lat2d = latitude
        maz_Z at lon2d = longitude

; graphics

   WKS_maxZ  =  gsn_open_wks("png","maxZ")

   max_Z at lat2d = latitude
   max_Z at lon2d = longitude

   PLOT_maxZ =  gsn_csm_contour_map(WKS_maxZ,max_Z,False)  ; global

   res       =  True
   res at mpMinLatF   = 5.000
   res at mpMaxLatF   = 20.0
   res at mpMinLonF   = 72.0
   res at mpMaxLonF   = 84.0

   res at gsnDraw     = True               ; default is True
   res at gsnFrame    = True             ; default is True

   res at cnFillOn    = True
   res at cnLevelSelectionMode = "ExplicitLevels"
   res at cnLevels             = (/4,12,20,28,36,44,52/)
   PLOT_maxZ =  gsn_csm_contour_map(WKS_maxZ,max_Z,res)





On Sun, Nov 20, 2016 at 9:30 AM, Geeta Geeta <geetag54 at yahoo.com> wrote:

> Hi all.
> I am using orbital data. One of the variables that I am interested in is
> Reflectivity (Z) which is 3 dim (Nscan,Npix,Nlevel).
> Nscan =0,9247,
> Npix    = 0, 48
> Nlevel  = 0,79.
>
> I have found out the maximum value of Z at each pixel ie. Max Z is the
> maximum value amongst 80 levels.  This variable in my code is named as
> max_Z.
>
> Now this variable is one dimensional, I need a 2 dim plot. I am attaching
> one of the sample plot of Z at level 64.
>
> I got this error.
>             453152 values
> Number of Dimensions: 2
> Dimensions and sizes: [9248] x [49]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue : -9999
>
> Variable: Z_fnl_le170_removd
> Type: double
> Total Size: 3625216 bytes
>             453152 values
> Number of Dimensions: 2
> Dimensions and sizes: [9248] x [49]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue : -9999
> (0)
> (0) min=0   max=52.05
> fatal:Variable (max_Z) has (1) dimensions can not write to dimension (1)
> fatal:["Execute.c":8578]:Execute: Error occurred at or near line 109 in
> file 2a25.080324.proj.v1.ncl
>
>
> aditya at agniilap:~/geeta/ncl/ReadHDF-2A2
>
> How to go about making 2 dim plot.
> (0)     NS  9247   20max_Z is =    0
> (0)     NS  9247   21max_Z is =    0
> (0)     NS  9247   22max_Z is =    0
> (0)     NS  9247   23max_Z is =    0
> (0)     NS  9247   24max_Z is =    0
> (0)     NS  9247   25max_Z is =    0
> (0)     NS  9247   26max_Z is =    0
> (0)     NS  9247   27max_Z is =    0
> (0)     NS  9247   28max_Z is =    0
> (0)     NS  9247   29max_Z is =    0
> (0)     NS  9247   30max_Z is =    0
> (0)     NS  9247   31max_Z is =    0
> (0)     NS  9247   32max_Z is =    0
> (0)     NS  9247   33max_Z is =    0
> (0)     NS  9247   34max_Z is =    0
> (0)     NS  9247   35max_Z is =    0
> (0)     NS  9247   36max_Z is =    0
> (0)     NS  9247   37max_Z is =    0
> (0)     NS  9247   38max_Z is =    0
> (0)     NS  9247   39max_Z is =    0
> (0)     NS  9247   40max_Z is =    0
> (0)     NS  9247   41max_Z is =    0
> (0)     NS  9247   42max_Z is =    0
> (0)     NS  9247   43max_Z is =    0
> (0)     NS  9247   44max_Z is =    0
> (0)     NS  9247   45max_Z is =    0
> (0)     NS  9247   46max_Z is =    0
> (0)     NS  9247   47max_Z is =    0
> (0)     NS  9247   48max_Z is =    0
> (0)     Error: scalar_field: If the input data is 1-dimensional, you must
> set sfXArray and sfYArray to 1-dimensional arrays of the same length.
> warning:create: Bad HLU id passed to create, ignoring it
> ^M
>
> It would be very kind of you to suggest.
> I am attaching the output when I run this code on my system. Kindly suggest
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161121/71f4ae77/attachment.html 


More information about the ncl-talk mailing list