[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IDV #CTK-522001]: Re: Jython Script for 2D plot



Hi Roman.

Try dc.setDisplayUnitName("K") although I have a feeling this will not do 
exactly what you want.

dc.setDisplayUnit is actually protected

I would suggest learning some Jython and figuring out how to call into Java. 
That would be a good exercise.

Next, I would start looking at the IDV source and looking at classes like 
DisplayControlImpl.

As we move forward, specific questions are best, rather than a list of general 
questions.

-Julien


> Hi,
> I have posted my IDV support issue below.
> 
> -Roman
> 
> 
> 
> > On 11/18/10 12:19 PM, Roman Kowch wrote:
> >>
> >> Julien &ÂYuan,
> >>
> >> I'm still having problems with writing a jython script to create an
> >> image from the file IDVmitmodel2.nc. I keep getting an attribute error
> >> when I type in dc.setDisplayUnit("K"). Also, I'm not familiar with
> >> jython and I can't create the objects you noted in the previous reply.
> >> I still need more guidance on this issue. Is there anyway I can get a
> >> helpful script that tries to generate the image I noted in the
> >> "original message" below?
> >>
> >> Can I also get your phone hours? I may want to call one of you to fix
> >> this scripting problem.
> >>
> >> Regards,
> >> Roman
> >>
> >>
> >> ----------------------------------------------
> >>
> >> Hi Roman.
> >>
> >> Sorry this took so long. We have been somewhat understaffed Âthis week
> >> and last. Things should be returning to normal shortly. I was able to
> >> get the ncfile in question.
> >>
> >> Since this is Jython you may have to get your hands dirty by looking
> >> at the actual IDV source. I try to answer some of your questions here:
> >>
> >> Display unit: dc.setDisplayUnit("K")
> >>
> >> Color range on the color table: Do you want to create your own, or use
> >> a prebuilt color table? You could do something like
> >> dc.setColorTableName("Temperature"). ÂOtherwise, I suppose you could
> >> create your own color via Jython.
> >>
> >> In your script, it looks like you are already modifying the contour
> >> parameters. Is there something wrong with that?
> >>
> >> Setting the level ought to be possible, but I have not figured out how
> >> to do it since the PlanViewControl.setLevel method takes an Java
> >> Object type. I do not know how that Object is instantiated. I am still
> >> looking into that.
> >>
> >> For the time range, there is a dc.setDataTimeRange. You will have to
> >> figure out how to properly construct a DataTimeRange object to supply
> >> to that function call.
> >>
> >> About the order, Python is an imperative / functional as opposed to a
> >> declarative language so yes order is important.
> >>
> >> This is probably enough to get you started. Let us know if you have
> >> more questions.
> >>
> >> -Julien
> >>
> >>
> >>
> >>
> >> ***ORIGINAL MESSAGE***
> >>
> >> Â Â Â Â Â Â Â Â ÂName: Roman Kowch
> >> Â Â Â Â Â Â Â Â E-mail: address@hidden
> >> Â Â Â ÂOrganization: MIT PAOC
> >> Software Package: IDV 2.7u2
> >> Operating System: Linux Ubuntu
> >> Â Â Â Â Â Â Â Subject: Jython script for 2D plot movie
> >>
> >>
> >>
> >> Hi,
> >>
> >> I am trying to write a simple script in Jython that commands
> >> IDV to make a 2D display of potential temperature from a Netcdf
> >> file and write a movie file. So far, the following code below only seems
> >> to make the display as if I just selected the potential temperature
> >> field and hit "Create Display" in the interactive mode:
> >>
> >>
> >> setOffScreen(1)
> >> idv.getStateManager().setViewSize(java.awt.Dimension(400,400))
> >> ds =
> >> makeDataSource("/disk7/rkowch/IDV/mitfluids/netcdf/IDVmitmodel2.nc","netcdf.grid")
> >> a = getData(ds.getName(),"Temp")
> >> dc = createDisplay('planviewcontourfilled',a)
> >> pause()
> >>
> >> dc.setDisplayListTemplate("Potential Temperature 2D plot");
> >> dc.setColorTableName("default")
> >> dc.range.set(-50.0,25.0)
> >> dc.setContourInfoParams("interval=2.0;min=-90.0;max=45.0;base=-230.0")
> >> dc.applyPreferences();
> >> writeMovie("2DThetaLoop.mov")
> >>
> >>
> >> How could this script be modified to correctly set the display unit
> >> (e.g. degC, K), color range on the color table, contouring parameters,
> >> height level, and what times to use (which is specified before you hit
> >> "Create Display")?
> >>
> >> Could you modify the script above to give an example of how this could
> >> be done? What commands are commonly used in scripts like this? Also,
> >> is there a certain order that must be followed when writing the
> >> commands in the text file?
> >>
> >> I've been looking at the IDV documentation at this website, but
> >> there's quite a bit
> >> of info to sort through:
> >>
> >> http://www.unidata.ucar.edu/software/idv/docs/javadoc/
> >>
> >>
> >>
> >> Thanks for your help,
> >> Roman
> >
> >
> 
> 


Ticket Details
===================
Ticket ID: CTK-522001
Department: Support IDV
Priority: Normal
Status: Closed


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.