Re: do loop + if statement problems with CALIPSO data

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Feb 23 2010 - 22:21:41 MST

Mike,

I think you need to put in some debug writes to determine where the
problem is.

For one, do you know if the code is ever making it inside the "if
(.not.ismissing(latN_lgth(k)) .and. latN_lgth(k) .eq. 134) then"
statement? If not, then layer_top will always be set to -9999.

First, though, I think we can clean up this code so there aren't as
many nested "do" loops. Do loops run slow in NCL (as well as other
interpreted languages).

For example, instead of:

> do l = 0,3
> do m=0,134
> if (ftr_chk(k,m,l) .eq. 6) then
> layer_top_(k,m,l) = layer_top(k,m,l)
> else
> layer_top_(k,m,l) = -9999
> end if
> end do
> end do
>

you can use the "where" statement:

layer_top_ = where(ftr_chk(k,:,:).eq.6,layer_top(k,:,:),-9999)

To make sure that ftr_chk(k,:,:) actually contains some values that
equal 6, you can print this:

    print("# of values where ftr_chk is 6 = " + num(ftr_chk(k,:,:).eq.
6))

to get the count of how many values are equal to 6.

Please put some debug statements like this in your code to see if you
can narrow down the problem.

--Mary

On Feb 23, 2010, at 3:02 PM, Mike wrote:

> I am using 5km CALIPSO aerosol layer data and the aerosol
> classification and layer top variables. What I want to do is assign
> a value in the array called "layer_top_" from the array "layer_top"
> which I read from the file. However, I only want this value to be
> assigned to "layer_top_" if the aerosol is classified as "smoke",
> that is when ftr_chk (the feature classification, unpacked integer
> value) = 6. The code runs fine, but when I go back and check to see
> if everywhere the aerosol was classified as smoke, the corresponding
> "layer top" value has been put into the array "layer_top_" I notice
> that it didn't work correctly. Namely, ftr_chk(k,m,l) = 6, but
> layer_top_(k,m,l) = -9999 even though layer_top(k,m,l) = *value* (as
> reported in the original dataset). I've attached the code below (the
> latN_top and latN_btm are just there so I can just remove values for
> the latitude range I'm interested in):
>
> do k = 0,37
> if (.not.ismissing(latN_lgth(k)) .and. latN_lgth(k) .eq. 134) then
> ftr_flg(k,:,:) = ftr_flg_tst(k,latN_top(k):latN_btm(k),:)
> ftr_chk(k,:,:) = dim_gbits(ftr_flg(k,:,:),4,3,13,8)
> layer_top(k,:,:) = layer_top_tst(k, latN_top(k):latN_btm(k),:)
> lon1(k,:) = lonN(k, latN_top(k):latN_btm(k))
> do l = 0,3
> do m=0,134
> if (ftr_chk(k,m,l) .eq. 6) then
> layer_top_(k,m,l) = layer_top(k,m,l)
> else
> layer_top_(k,m,l) = -9999
> end if
> end do
> end do
> else
> ftr_flg(k,:,:) = -999
> layer_top(k,:,:) = -9999
> end if
> end do
>
> Thanks for your help!
>
> -Mike
>
> Michael Tosca
> Ph.D. Candidate
> Dept. Earth System Science
> University of California, Irvine
> Irvine, CA 92697
> http://dust.ess.uci.edu/mtosca/web
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Feb 23 22:21:48 2010

This archive was generated by hypermail 2.1.8 : Thu Feb 25 2010 - 09:38:32 MST