formula not working, why?

How do I...?
Post Reply
User avatar
kbedka
Posts: 46
Joined: Fri Jan 04, 2013 8:53 pm

formula not working, why?

Post by kbedka »

I am trying to create a formula to mask one parameter by the value of another, but am getting an error that I don't understand. See attached screenshots of formula and jython library function. I only want to display a product if the value of the phase product is 1 or 6. I've modeled my jython library function after others that have worked, but in this case, I am getting the attached error. Are there any suggested modifications to my library or formula that will allow me to get my desired result?
Attachments
Screen Shot 2016-10-13 at 11.11.52 AM.png
Screen Shot 2016-10-13 at 11.04.32 AM.png
Screen Shot 2016-10-13 at 11.04.32 AM.png (11.61 KiB) Viewed 3577 times
Screen Shot 2016-10-13 at 11.04.09 AM.png
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: formula not working, why?

Post by joleenf »

Hi Kris,

I think you might have to iterate when you run the max command. Let me know if the code below produces the result you expect when you run in the jython shell. Are both your inputs FlatFields?

Code: Select all

import jarray
phase=field([1,3,4,5,6,1,1,1,6,6,6])
product= jarray.array(range(0,10),'i')

def DISPLAYLIQUID(product,phase):
    c=mask(phase,'eq',1,1)
    d=mask(phase,'eq',6,1)

    newC=[max(c.getSample(i),d.getSample(i)) for i in range(len(c))]

    print (newC)


DISPLAYLIQUID(product,phase)



Joleen
User avatar
kbedka
Posts: 46
Joined: Fri Jan 04, 2013 8:53 pm

Re: formula not working, why?

Post by kbedka »

No idea if they're "flat fields", they are 2-D arrays (well actually 3-D as they are also dimensioned by time but there's only 1 time) read from a NetCDF file. I tried replacing my max command with your newC= line but I got the same error. If I enter what you have below directly into the jython shell, I get syntax error at the line def DISPLAYLIQUID. A sample file is at pub/incoming/G14V04.0.CONUS.2015147.2147.PX.04K.nc Specifically I'm trying to filter effective particle radius.
User avatar
jayh
Posts: 424
Joined: Thu Jan 15, 2009 10:34 pm

Re: formula not working, why?

Post by jayh »

Hi Kris-

I followed your instructions...

1. Added the def DISPLAYLIQUID(product,phase) to my Jython Library.
2. I created the formula as you displayed.
3. I loaded your netCDF file through the General Files chooser.
4. In the Field Selector I chose the Display Only Liquid Cloud Properties formula
5. In the new input box I chose "effective particle radius or diameter" for the product, and then I chose "cloud phase" for the phase. Once I hit ok, I received this display:

formula_result.png


Is this what you are expecting? I'm using a mac laptop running 10.9 with the latest nightly version. I can try other platforms or McV versions if necessary to try to replicate the error.

Thanks, Jay
User avatar
kbedka
Posts: 46
Joined: Fri Jan 04, 2013 8:53 pm

Re: formula not working, why?

Post by kbedka »

Perhaps I was a little early with my nightly, I got today's nightly and now this worked as I originally typed. Any idea why I can't probe pixel values with the cursor?
User avatar
jayh
Posts: 424
Joined: Thu Jan 15, 2009 10:34 pm

Re: formula not working, why?

Post by jayh »

Hi Kris-

The probe issues are written up in this inquiry from the other forum thread, inq. 2437. Most likely it's the same problem as you have had in the past with other netCDF files that is written up in inq. 1941. I cross-referenced 1941 and 2437 in each inquiry.

Thanks, Jay
Post Reply