This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>From: "John C Cartwright" <address@hidden> >Organization: NOAA >Keywords: 200411031837.iA3Ib2vV019921 IDV jython Hi John- >thanks again for your prompt response. No problem. >Unidata Support wrote: >> I've never had this problem but others have. In some cases, >> "from visad import *" does not seem to get picked up. Try >> adding the following (in the body of the procedure): >> >> from visad import RealTupleType >> from visad import FunctionType >> from visad import Gridded2DSet >> from visad import FlatField >> >> (those seem to be the ones that are needed, add others as necessary). > >I'm surprised that the explicit imports are required, but that does seem >to work. It surprises me and there seems to be no rhyme nor reason to when the global one works or not. Most times for me it works, but for others, it doesn't seem to. >> 3) To display this in the IDV, I changed: >> >> row = getRealType("Longitude") >> col = getRealType("Latitude") > >I just swapped the order of the RealTypes in the RealTupleType to: >domain_tuple. Seemed to have the same effect. 6 of one, 1/2 dozen of the other. ;-) >> Let me know if you have problems with what I sent. > >seems to work fine now. Great. >Can you provide some guidance on when you >choose the visad.python.JPython methods instead of direct use of the >VisAD classes? For example: >row = getRealType("ROW") >vs. >row = RealType("ROW") If you can use the JPythonMethod routines, that is the way I would go. They are usually easier to deal with, but sometimes are not complete enough for some things. I know the real VisAD classes/methods inside and out (and don't know the JPythonMethods), so I usually use those but I would recommend using the JPythonMethods if you can. It's less tax on your brain when dealing with VisAD. ;-) Also, you don't need to do the explicit "from visad.python.JPythonMethods import *" in your editor since this line is actually already in the editor (but hidden). Since these methods are automatically imported, you save yourself the pain of having to worry about the issue of global imports not working. As far as your specific example above, the RealType("ROW") is actually (in Java) the "new RealType("ROW")" constructor which is deprecated. So in this case, using the JPythonMethods call saves you from using a deprecated ctor, and you don't have to do any explicit imports. Don Murray NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.