formula not working, why?
formula not working, why?
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?
Re: formula not working, why?
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?
Joleen
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
Re: formula not working, why?
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.
Re: formula not working, why?
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:
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
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:
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
Re: formula not working, why?
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?