Re: do loop + if statement problems with CALIPSO data

From: Mike <mtosca_at_nyahnyahspammersnyahnyah>
Date: Thu Feb 25 2010 - 12:48:10 MST

Mary

What appears to be happening is this:

I put in two print commands. One prints out all the places where
ftr_chk = 6. For example, for one files, this number = 36
However, a second command prints out all the places where layer_top_
> 0, after the "where" statement. This number = 17. This seems to be
a discrepancy, because I went and looked at the actual places where
ftr_chk = 6, and they have a corresponding value in layer_top, but
not in layer_top_. For some reason, all values are not being read
into layer_top_. Any idea why this might be?

Mike

On Feb 23, 2010, at 9:21 PM, Mary Haley wrote:

> 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
>

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
Received on Thu Feb 25 12:48:13 2010

This archive was generated by hypermail 2.1.8 : Mon Mar 01 2010 - 08:49:37 MST