We are using the following command sequence in an effort to load a NetCDF parameter into a variable for display. We have focused on simply accessing the NetCDF data first and then we will work on display stuff later.
setOffScreen(1)
idv.getStateManager().setViewSize(java.awt.Dimension(400,400))
ds=makeDataSource("/Users/kbedka/TEST.NC","netcdf.grid")
a=getData(ds.getName(),"solar_zenith_angle")
I tried this today on a 1.02 beta 1 nightly build (Mac OSX) in the Mc-V jython shell, and the makeDataSource command failed with the following error:
Error: Traceback (most recent call last): File " ", line 1, in File "/Applications/McIDAS-V-System/idv.jar/ucar/unidata/idv/resources/python/shell.py", line 101, in makeDataSource NameError: global name 'idv' is not defined
My colleague, Baojuan Shan said that she tried this on 1.01 on Mac and Linux and the MakeDataSource command worked, but the getData failed.
What are we doing wrong? For reference, you can find the TEST.NC file at: ftp://ftp.ssec.wisc.edu/pub/incoming/TEST.NC
error loading NetCDF dataset
Re: error loading NetCDF dataset
Here is the getData error Bao received:
Error: Traceback .....
In getDataChoice java.lang.NullPointerException at
ucar.unidata.data.DataSourceImp1.equals(DataSourceImp1.java:1500) at
ucar.unidata.data.FileDataSource.equals(DataSorceImp1.java:546) at ......
Error: Traceback .....
In getDataChoice java.lang.NullPointerException at
ucar.unidata.data.DataSourceImp1.equals(DataSourceImp1.java:1500) at
ucar.unidata.data.FileDataSource.equals(DataSorceImp1.java:546) at ......
Re: error loading NetCDF dataset
Kris,
I have also seen this same behavoir.
Joleen
I have also seen this same behavoir.
Joleen
Re: error loading NetCDF dataset
Hi Kris and Joleen,
For a temporary solution, please add the following lines to the top of the script:
import shell
shell.idv = idv
Let us know how it goes.
Rick
For a temporary solution, please add the following lines to the top of the script:
import shell
shell.idv = idv
Let us know how it goes.
Rick
Re: error loading NetCDF dataset
Rick,
This would only work for the unstable build, correct?
Joleen
This would only work for the unstable build, correct?
Joleen
Re: error loading NetCDF dataset
Hi,
I have tested adding the
import shell
shell.idv = idv
fix to my script and running it with Version: 1.02beta1 Build-date: 2011-06-22 09:30.
I now get this error:
<type 'ucar.visad.data.GeoGridFlatField'>
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "<string>", line 72, in createDisplay
AttributeError: 'module' object has no attribute 'toFront'
Error running jython script:/Users/joleenf/mcidas/scripts/netcdfload.py
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "<string>", line 72, in createDisplay
AttributeError: 'module' object has no attribute 'toFront'
without the fix, the error is
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/Users/joleenf/Applications/McIDAS-V-System/idv.jar/ucar/unidata/idv/resources/python/shell.py", line 101, in makeDataSource
NameError: global name 'idv' is not defined
Error running jython script:/Users/joleenf/mcidas/scripts/netcdfload.py
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/Users/joleenf/Applications/McIDAS-V-System/idv.jar/ucar/unidata/idv/resources/python/shell.py", line 101, in makeDataSource
NameError: global name 'idv' is not defined
in the stable version (McIDAS V1.01)
java.lang.NullPointerException: java.lang.NullPointerException
Error running jython script:/Users/joleenf/mcidas/scripts/netcdfload.py
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "<string>", line 130, in getData
File "<string>", line 119, in getDataChoice
This is the error for the stable version with or without the fix. The error from version 1.01 was what Tom Rink addressed for the nightly fix, which then uncovered the other NPE error. The "import shell" fix was to get around the NPE error but then the toFront error appears?
Joleen
I have tested adding the
import shell
shell.idv = idv
fix to my script and running it with Version: 1.02beta1 Build-date: 2011-06-22 09:30.
I now get this error:
<type 'ucar.visad.data.GeoGridFlatField'>
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "<string>", line 72, in createDisplay
AttributeError: 'module' object has no attribute 'toFront'
Error running jython script:/Users/joleenf/mcidas/scripts/netcdfload.py
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "<string>", line 72, in createDisplay
AttributeError: 'module' object has no attribute 'toFront'
without the fix, the error is
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/Users/joleenf/Applications/McIDAS-V-System/idv.jar/ucar/unidata/idv/resources/python/shell.py", line 101, in makeDataSource
NameError: global name 'idv' is not defined
Error running jython script:/Users/joleenf/mcidas/scripts/netcdfload.py
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/Users/joleenf/Applications/McIDAS-V-System/idv.jar/ucar/unidata/idv/resources/python/shell.py", line 101, in makeDataSource
NameError: global name 'idv' is not defined
in the stable version (McIDAS V1.01)
java.lang.NullPointerException: java.lang.NullPointerException
Error running jython script:/Users/joleenf/mcidas/scripts/netcdfload.py
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "<string>", line 130, in getData
File "<string>", line 119, in getDataChoice
This is the error for the stable version with or without the fix. The error from version 1.01 was what Tom Rink addressed for the nightly fix, which then uncovered the other NPE error. The "import shell" fix was to get around the NPE error but then the toFront error appears?
Joleen
Re: error loading NetCDF dataset
Hmm. It looks as though there's a naming conflict within shell.py from Unidata:
Note that the filename is "shell.py" (and imported like so "import shell"). Apparently the import overwrites the "shell" global variable at the beginning of shell.py…
I'll see what I can do!
Code: Select all
def createDisplay(displayType, data, dataName='Data'):
import ucar.unidata.data.DataDataChoice as DataDataChoice
import ucar.unidata.data.DataChoice as DataChoice
if(isinstance(data, java.util.List)==0):
tmp = java.util.ArrayList();
tmp.add(data);
data = tmp;
dataList = java.util.ArrayList();
for i in range(data.size()):
obj = data.get(i)
if(isinstance(obj, DataChoice)==0):
label = dataName
if(data.size()>1):
label = label +str(i)
obj = DataDataChoice(label,obj);
dataList.add(obj);
control = idv.doMakeControl(displayType, dataList);
if (shell != None):
shell.toFront();
return control
Note that the filename is "shell.py" (and imported like so "import shell"). Apparently the import overwrites the "shell" global variable at the beginning of shell.py…
I'll see what I can do!
Re: error loading NetCDF dataset
import shell as myShell
myShell.idv = idv
seems to do the trick. However, I had to add a whole bunch of pause() lines to make the script work as it does in the interactive jython shell. I have not had to worry about adding pause() lines in the past, though I did because someone told me to. That could be my computer suddenly deciding to be fussy.
import shell as myShell
myShell.idv = idv
setOffScreen(1)
idv.getStateManager().setViewSize(java.awt.Dimension(400,400))
ds = makeDataSource("/Users/joleenf/mcidas/data/netcdf/Simple_AVG_reprojected_Validation_1km_sim_abi_band01_2006_0719_1200utc.nc","netcdf.grid")
a = getData(ds.getName(),'ABI_Refl_b01')
print a.__class__
dc = createDisplay('planviewcolor',a)
pause()
dc.setDisplayListTemplate("This is My Stuff!");
pause()
dc.applyPreferences();
pause()
writeImage("/Users/joleenf/mcidas/images/kbah_image.png")
Joleen
myShell.idv = idv
seems to do the trick. However, I had to add a whole bunch of pause() lines to make the script work as it does in the interactive jython shell. I have not had to worry about adding pause() lines in the past, though I did because someone told me to. That could be my computer suddenly deciding to be fussy.
import shell as myShell
myShell.idv = idv
setOffScreen(1)
idv.getStateManager().setViewSize(java.awt.Dimension(400,400))
ds = makeDataSource("/Users/joleenf/mcidas/data/netcdf/Simple_AVG_reprojected_Validation_1km_sim_abi_band01_2006_0719_1200utc.nc","netcdf.grid")
a = getData(ds.getName(),'ABI_Refl_b01')
print a.__class__
dc = createDisplay('planviewcolor',a)
pause()
dc.setDisplayListTemplate("This is My Stuff!");
pause()
dc.applyPreferences();
pause()
writeImage("/Users/joleenf/mcidas/images/kbah_image.png")
Joleen
Re: error loading NetCDF dataset
Good (temporary) solution, Joleen!!
Re: error loading NetCDF dataset
Thanks, everyone, for the comments and suggestions. We created an inquiry to resolve the problem:
http://mcidas.ssec.wisc.edu/inquiry-v/?inquiry=1073
http://mcidas.ssec.wisc.edu/inquiry-v/?inquiry=1073