McIDAS-V Support Forums

Support and discussion of the McIDAS-V software package
Forum HomeMcIDAS-V Home
It is currently 22 Jul 2019, 09:36

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Grid display parameters in Jhyton
PostPosted: 14 Jun 2019, 11:25 
User avatar

Joined: 01 May 2019, 12:40
Posts: 14
Hello:

How can I select in a Jhyton script parameters to display grids such as:
- Contour interval
- Clip Display Range
- Smoothing
- Shade Colours
- Color Table

etc.

Thank you very much


Top
 Profile  
 
 Post subject: Re: Grid display parameters in Jhyton
PostPosted: 14 Jun 2019, 17:40 
User avatar

Joined: 15 Nov 2010, 17:57
Posts: 876
Hello,

There are inquiries written up to develop functions to make some of the items in your list easier to do through scripting. Currently, none of them have a single function that allow you to do them. However, they can all be done through a series of functions. Note that while these functions update the displayed layer, you'll likely see that the actual Layer Controls panel of the Data Explorer doesn't update to reflect the changes. All of these commands below assume that the layer object you want to operate on in the display is called: layer

Contour Interval:
Code:
# set a variable to define the new contour values
# in the format  (interval;base;min;max)
newContours = layer.setContourInfoParams('10;952;952;1052')

# change the display to use the new contour values
layer.setContourInfo(newContours)
layer.applyContourInfo()

Clip Display Range:
Code:
# Return if layer has clipping enabled:
layer.selectRangeEnabled
# If this is False and you want to use clipping, set this to True:
layer.setSelectRangeEnabled(True)

# You must import Range:
from ucar.unidata.util import Range
#Define the range you want to clip, for example 1000 to 1010:
clipRange = Range(1000,1010)

# Apply the clipped range to your displayed layer:
aLayer.setSelectRange(clipRange)

Smoothing:
Code:
# Valid options for setSmoothingType():
# 5 point: SM5S
# 9 point: SM9S
# Gaussian Weighted: GWFS
# Cressman Weighted: CRES
# Circular Aperture: CIRC
# Rectangular Aperture: RECT

layer.getSmoothingType()
# Returns current smoothing type

layer.setSmoothingType('CIRC')
# Changes display to use Circular Aperture

# Change the smoothing factor:
layer.getSmoothingFactor()
# Returns the current smoothing factor value
layer.setSmoothingFactor(10)
# Changes the smoothing factor to 10.  Note that None, 5 point, and 9 point smoothing
# types don't allow for smoothing factors through the user interface or scripting

Shade Colors:
Code:
# Enable "Shade Colors"
layer.getGridDisplay().setTextureEnable(0)
# Disable "Shade Colors"
layer.getGridDisplay().setTextureEnable(1)

Color Table:
Code:
# I'm unsure if you're looking to set the enhancement
# or add a color scale to the display, so I'll describe both:

# Change enhancement of layer with:
layer.setEnhancement('Gray Scale')

# Add color scale to the display with:
layer.setColorScaleVisible()
# Move color scale in display with:
layer.setColorScalePlacement('Right')
layer.setColorScalePlacement('Bottom')
# Set color of color scale labels
layer.setColorScaleFontColor('Red')

Please let me know if any of this doesn't work for you or if you have any other questions.

Thanks,
Bob Carp
McIDAS Help Desk


Top
 Profile  
 
 Post subject: Re: Grid display parameters in Jhyton
PostPosted: 15 Jun 2019, 07:08 
User avatar

Joined: 01 May 2019, 12:40
Posts: 14
Thank you very much Bop, I will try the functions.

Ricardo Riosalido


Top
 Profile  
 
 Post subject: Re: Grid display parameters in Jhyton
PostPosted: 16 Jun 2019, 10:30 
User avatar

Joined: 01 May 2019, 12:40
Posts: 14
Hi Bob:

I've tested the functions and they work perfectly but I haven't been able to find documentation on them. Where can I see a list of available functions?

Thanks

Ricardo


Top
 Profile  
 
 Post subject: Re: Grid display parameters in Jhyton
PostPosted: 17 Jun 2019, 14:06 
User avatar

Joined: 15 Nov 2010, 17:57
Posts: 876
Hello,

Since the majority of these functions take at least two commands to apply to the display (the setter and the applier), they aren't documented in the User's Guide. We do have inquiries written up for all of your requests to come up with a single function to set and apply the changes to the display. Until then, your best bet may be looking through the java docs. If you go to the Scripting page of the User's Guide you'll see links at the bottom for the java docs. Specifically, you'll want to look at:

McIDAS-V https://www.ssec.wisc.edu/mcidas/software/v/javadoc/current/
IDV (the software that McIDAS-V is built on top of) https://www.unidata.ucar.edu/software/idv/docs/javadoc/index.html

setContourInfoParams
applyContourInfo

setSelectRangeEnabled
setSelectRange
for the part with importing Range, I looked at the Jython Library (Tools > Formulas > Jython Library) to see how "range" was set in setEnhancement() and I used that method

getSmoothingType
setSmoothingType
setSmoothingFactor

For shading colors, from the Jython Shell you can run:
Code:
print see(layer.getGridDisplay())

and you'll see a variety of functions that can be run on the layer. This includes setTextureEnable(). You'll see various other functions listed as well. see() is a pretty powerful function you can run from the Jython Shell to get a list of functions that you can run to operate on the layer or data. You can find documentation for see() on the Environment page of the McIDAS-V User's Guide.

setColorScale is actually included in the McIDAS-V documentation on the Modify the Layer Object page. There's one command that has keywords to say where to place the color scale, the font/style, size, and color to use for the labeling. setEnhancement is also on this page.

Generally, when I want to figure how to how to replicate UI functionality through scripting I grep through the source code. You can download the source code from the McIDAS-V Download page (in the Developer block). To find out how to shade colors in the source code, I cd'd to the directory I downloaded the data to and ran:
Code:
grep -irn "Shade Colors:"

I included the colon there since I wanted to make sure my search matched on the exact shading being used in the UI, which includes a colon. This search returned four code matches:
IDV/src/ucar/unidata/idv/control/ColorCrossSectionControl.java:120:
IDV/src/ucar/unidata/idv/control/ColorPlanViewControl.java:155:
IDV/src/ucar/unidata/idv/control/ColorPlanViewControl.java:161:
IDV/src/ucar/unidata/idv/control/TopographyControl.java:158:

I then used vi to see how the color shading was done in the code.

As always, please feel free to ask any questions you have. It's good to see how users in the field are using McIDAS-V.

Thanks again,
Bob


Top
 Profile  
 
 Post subject: Re: Grid display parameters in Jhyton
PostPosted: 17 Jun 2019, 19:09 
User avatar

Joined: 01 May 2019, 12:40
Posts: 14
Thank you so much again, Bob.

Ricardo


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group