Error in Jython Shell

Errors and unexpected results
Post Reply
User avatar
joleenf
Posts: 1120
Joined: Mon Jan 19, 2009 7:16 pm

Error in Jython Shell

Post by joleenf »

Hi,

I am using old code with a tempuserpath for runMcV:

Code: Select all

panel=buildWindow()
theFile = "/Users/joleenf/data/CG_ABI-L2-CMIPM1-M6C01_G16_s20191060040287_e20191060040344_c20191060040542.nc"

d = loadGrid(filename=theFile, field='CMI')

panel[0].createLayer(‘Image Display’, d)


Fails for both a Full Disk and the meso referenced above which I just downloaded to my computer with java.lang.IllegalArgumentException: Cannot create PyString with non-byte value.
The failure occurs at the createLayer line.

Version: 1.9beta1 Build-date: 2019-04-15 09:30

This error is happening on my mac. I don't see the same problem on the lunix box that I am using.


Thanks,
Joleen
User avatar
joleenf
Posts: 1120
Joined: Mon Jan 19, 2009 7:16 pm

Re: Error in Jython Shell

Post by joleenf »

This seems to be due to a xRange value I used in an earlier statement. For some reason, that hung around to mess up the loadGrid which was run after.

Joleen
User avatar
bobc
Posts: 933
Joined: Mon Nov 15, 2010 5:57 pm

Re: Error in Jython Shell

Post by bobc »

Hi Joleen,

I'm glad that you were able to figure out how to get your script working.

I've been trying to simulate a case where I could replicate this problem, but I haven't been able to do so yet. If things with loadGrid are working correctly, xRange shouldn't have any default setting at all, so no xRange should be used by loadGrid unless it was passed directly through the function.

You mentioned that the xRange value was used in an earlier statement. Was this run in the same script, or was it run previously? If this is something you are still concerned about, could you please send me the part of your script where xRange was specified so I can check and see how this could've been passed to loadGrid?

Thanks,
Bob
User avatar
joleenf
Posts: 1120
Joined: Mon Jan 19, 2009 7:16 pm

Re: Error in Jython Shell

Post by joleenf »

Hi Bob,

This is a silly script, I am not sure it is working in the way I had hoped, I was working on finding xrange and yrange endpoints associated with lat/lon values. I needed to use these xRange and yRange values rather than the latLonBounds box because I wanted to keep the data in the fixed grid format.

Code: Select all

lalo1 = [[14.4],[-84.0]]
lalo2 = [[-35], [-39]]

theFile = "/Users/joleenf/data/goes16/sand/CG_ABI-L2-CMIPF-M3C02_G16_s20190241700340_e20190241711110_c20190241711456.nc"

a=loadGrid(filename=theFile, field='CMI', stride=2)
targetSet = getDomainSet(a)
cs = targetSet.getCoordinateSystem()

ref1 =  cs.fromReference(lalo1)
gval1 = targetSet.valueToGrid([[ref1[0][0]], [ref1[1][0]]])

ref2 = cs.fromReference(lalo2)

gval2 = targetSet.valueToGrid([[ref2[0][0]], [ref2[1][0]]])


xval = (int(gval1[0][0]), int(gval2[0][0]))
yval = (int(gval1[1][0]), int(gval2[1][0]))

print xval, yval

d = loadGrid(filename=theFile, field='CMI', xRange = xval, yRange = yval)


Perhaps this replicates the error? I thought this problem was solved, but apparently I found the code where it was not solved.

Joleen
User avatar
bobc
Posts: 933
Joined: Mon Nov 15, 2010 5:57 pm

Re: Error in Jython Shell

Post by bobc »

Hi Joleen,

Thanks for the script. I've run it several times with different lat/lon values and I'm not getting the error to appear on my Windows 7 machine using today's nightly. I'll give this a try on a macOS machine shortly. One thing I noticed is that after I displayed the data the from the second loadGrid (data object "d") the corner points of the display didn't match the list values (lalo1 and lalo2) specified at the beginning of the script. In order to get the correct lat/lon corner points, I had to remove the stride=2 from your first loadGrid command. If you want to display the data with a stride of 2, you can add stride=2 to your second loadGrid command. This would make your script:

Code: Select all

lalo1 = [[14.4],[-84.0]]
lalo2 = [[-35], [-39]]

theFile = "/Users/joleenf/data/goes16/sand/CG_ABI-L2-CMIPF-M3C02_G16_s20190241700340_e20190241711110_c20190241711456.nc"

a=loadGrid(filename=theFile, field='CMI')
targetSet = getDomainSet(a)
cs = targetSet.getCoordinateSystem()

ref1 =  cs.fromReference(lalo1)
gval1 = targetSet.valueToGrid([[ref1[0][0]], [ref1[1][0]]])

ref2 = cs.fromReference(lalo2)

gval2 = targetSet.valueToGrid([[ref2[0][0]], [ref2[1][0]]])


xval = (int(gval1[0][0]), int(gval2[0][0]))
yval = (int(gval1[1][0]), int(gval2[1][0]))

print xval, yval

d = loadGrid(filename=theFile, field='CMI', xRange = xval, yRange = yval, stride=2)

Bob
User avatar
joleenf
Posts: 1120
Joined: Mon Jan 19, 2009 7:16 pm

Re: Error in Jython Shell

Post by joleenf »

Hi Bob,

I can't reproduce this error today either.

Joleen
Post Reply