Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.

Re: problem with writing netcdf file

Hi tom:

nectdf-3 file format doesnt support "long" type, so NetcdfFileWriteable wont accept it.
sorry the error message wasnt more useful.


Tom Whittaker wrote:

I tried joining the netcdf-java mailing list using the on-line form, but got no results emailed back to me...so I'm writing directly (sorry).

I'm trying to write my very first netcdf file from scratch using netcdf-2.2.jar. Just as I'm starting, I'm testing and it's throwing an interesting exception. I'm sure it's "Pilot Error", but I have no clue at this point.

I'm using the current netcdf-2.2.jar file from the web site.

Here's the code (sorry it's in Jython, but that's what we're using these days -- if it turns out to be some data type conversion problems, then I'll have to find a way around that, but when I look at "DataType.LONG" it prints a "long" and is a class ucar.nc2.DataType):

from ucar.nc2 import NetcdfFileWriteable
from ucar.nc2 import DataType

def makeNetCDFtest():

  ncfile = NetcdfFileWriteable()
  ncfile.setName("mydata.nc")
  oneDim = ncfile.addDimension("one",1)

  ncfile.addVariable("date", DataType.LONG, [oneDim,])
ncfile.addVariableAttribute("date","long_name","Date, in YYYYMMDD format")

  ncfile.create()
  ncfile.close()

if __name__ == "__main__":
  makeNetCDFtest()
  print "done..."


Here's the exception:

raceback (innermost last):

  File "<string>", line 19, in ?
  File "<string>", line 15, in makeNetCDFtest

java.lang.IllegalStateException: unknown DataType == long
    at ucar.nc2.N3header.getType(N3header.java:405)
    at ucar.nc2.N3header.writeVars(N3header.java:586)
    at ucar.nc2.N3header.create(N3header.java:458)
    at ucar.nc2.N3iosp.create(N3iosp.java:255)
    at ucar.nc2.NetcdfFileWriteable.create(NetcdfFileWriteable.java:299)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
    at org.python.core.PyMethod.__call__(PyMethod.java)
    at org.python.core.PyObject.__call__(PyObject.java)
    at org.python.core.PyInstance.invoke(PyInstance.java)
    at org.python.pycode._pyx79.makeNetCDFtest$1(<string>:15)
    at org.python.pycode._pyx79.call_function(<string>)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyFunction.__call__(PyFunction.java)
    at org.python.pycode._pyx79.f$0(<string>:19)
    at org.python.pycode._pyx79.call_function(<string>)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyCode.call(PyCode.java)
    at org.python.core.Py.runCode(Py.java)
    at org.python.core.Py.exec(Py.java)
    at org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
    at org.jext.scripting.python.Run.execute(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java) at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
    at org.python.core.PyObject.__call__(PyObject.java)
    at org.python.core.PyObject.invoke(PyObject.java)
    at org.python.pycode._pyx78.f$0(<string>:3)
    at org.python.pycode._pyx78.call_function(<string>)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyCode.call(PyCode.java)
    at org.python.core.Py.runCode(Py.java)
    at org.python.core.Py.exec(Py.java)
    at org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
    at org.jext.PythonAction.actionPerformed(Unknown Source)
at org.gjt.sp.jedit.textarea.InputHandler.executeAction(Unknown Source) at org.gjt.sp.jedit.textarea.DefaultInputHandler.keyPressed(DefaultInputHandler.java:259) at org.gjt.sp.jedit.textarea.JEditTextArea.processKeyEvent(Unknown Source)
    at java.awt.Component.processEvent(Component.java:4909)
    at java.awt.Container.processEvent(Container.java:1569)
    at java.awt.Component.dispatchEventImpl(Component.java:3615)
    at java.awt.Container.dispatchEventImpl(Container.java:1627)
    at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1713) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:627) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:831) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:741) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:592)
    at java.awt.Component.dispatchEventImpl(Component.java:3506)
    at java.awt.Container.dispatchEventImpl(Container.java:1627)
    at java.awt.Window.dispatchEventImpl(Window.java:1606)
    at java.awt.Component.dispatchEvent(Component.java:3477)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

java.lang.IllegalStateException: java.lang.IllegalStateException: unknown DataType == long






  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: