Loop through grid cells

From: Modise Wiston <modise.wiston_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 09 2014 - 05:59:53 MDT

Hi 'NCl-talkers'

I want to determine the maximum (&/or min'm) cloud droplet (Qndrop) number =
from the cloud layers. How can I write (use a code) to loop through all the=
 x- and y-directions and get/calculate the maximum droplet number along the=
 z-plane. The idea is to find the maximum Qndrop so as to determine the cor=
responding CCN number (supersaturation level). i.e. going through cloud lay=
ers/height levels from the cloud base.

Below is [part of] my script code I have. Currently this plots droplet numb=
er in horizontal cross section (map overlaid) for the first 5 levels (from =
the ground surface), but I want to get Qndrop at specific points (x,y,z coo=
rdinates); only at points where I have clouds. While I want to loop through=
 cloud height/layers -say height z0 [cloud base] to zn [cloud top]. I only =
need to go up to point where I 'hit' the first cloud base and its top (not =
necessarily going through all clouds above). Is there a way that I can writ=
e this to get Qndrop at a given height and location?

---------------------------------------------------------------------------=
----------------------------------------
 do ispec = 0, nspecies-1 ; spec
    species = speclist(ispec)

    dt = 6

    do ifil = 0, numFILES-1, dt ; fi=
le loop

        print("Opening file "+FILES(ifil))
        a = addfile(FILES(ifil)+".nc","r")

        ;Define the time step to output data
        times = wrf_user_list_times(a)
        ntimes = dimsizes(times)

        do it = 0,ntimes-1,2 ; time =
loop
            map = wrf_map(wks,a,mpres)

            ;Obtain the variables from the file
            if(isfilevar(a,"QNDROP"))
            Nd = wrf_user_getvar(a,"QNDROP",it)
            conv = Nd*1.2923/1e6 ; convert from=
 /kg to /sm^3 then to /scm^3
            Nd@units = "/cm^3" ; converted u=
nits
            end if

            do level = 0,5,1 ;model l=
evel loop
                 Lvl = level + 1
                 opts@cnFillOn = True
                 opts@gsnSpreadColors = False
                 opts@PlotLevelID = "Level " + Lvl

          ;define an array to hold data
        ; Nd = (/i,j,k/)

           min_Nd = new(2,float)
           max_Nd = new(2,float)

       ; do k = 0, k-1
            do j = 0, j-1
             do i = 0, i-1

        ; min_Nd(i) = min(Nd(:,i)) ;goes through x-direction and finds m=
in along y-direction
        ; max_Nd(i) = max(Nd(:,i)) ;finds max along y-direction
        ; min_Nd(j) = min(Nd(:,j)) ;goes through y-direction and finds m=
in along x-direction
        ; max_Nd(j) = max(Nd(:,j)) ;finds max along x-direction

            min_Nd(k) = min(Nd(:,j,i)) ;goes through x-y direction and f=
inds min along k-direction
            max_Nd(k) = max(Nd(:,j,i)) ;finds max along k-direction

            end do
          end do
     ; end do

     if (isvar("Nd"))
        print(min(Nd))
        print(max(Nd))
        opts@FieldTitle = Nd@description +" at: " +times(it) +" Nmbr /cm=
^3"
        contour = wrf_contour(a,wks,conv(level,:,:),opts)
        plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)
        delete(contour)
     end if

                end do ; spec
            end do ;file
    end do ; time

  end do ;level
---------------------------------------------------------------------------=
---------------------------------

Any help would be appreciated please

Thank you in advance
M. Wiston
(The University of Manchester)


_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk


Received on Wed Jul 09 12:00:03 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT