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
Grid display parameters in Jhyton
Re: Grid display parameters in Jhyton
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:
Clip Display Range:
Smoothing:
Shade Colors:
Color Table:
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
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: Select all
# 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: Select all
# 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: Select all
# 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: Select all
# Enable "Shade Colors"
layer.getGridDisplay().setTextureEnable(0)
# Disable "Shade Colors"
layer.getGridDisplay().setTextureEnable(1)
Color Table:
Code: Select all
# 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
- rriosalido
- Posts: 28
- Joined: Wed May 01, 2019 12:40 pm
Re: Grid display parameters in Jhyton
Thank you very much Bop, I will try the functions.
Ricardo Riosalido
Ricardo Riosalido
- rriosalido
- Posts: 28
- Joined: Wed May 01, 2019 12:40 pm
Re: Grid display parameters in Jhyton
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
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
Re: Grid display parameters in Jhyton
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:
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:
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
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: Select all
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: Select all
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
- rriosalido
- Posts: 28
- Joined: Wed May 01, 2019 12:40 pm
Re: Grid display parameters in Jhyton
Thank you so much again, Bob.
Ricardo
Ricardo