Plot western hemisphere cities

Post any questions, ideas, or topics related to Jython and Python scripting.
User avatar
bobc
Posts: 933
Joined: Mon Nov 15, 2010 5:57 pm

Re: Plot western hemisphere cities

Post by bobc »

Hi Joleen,

I was able to run this from the foreground and background on OS X (10.9.5) as well as Windows 7 and the image and location labels were visible in all captured images.

One thing that could be worth checking is if you have your own userstations.xml in your McIDAS-V directory. I had one of these for the Great Lakes on my Windows 7 machine and the "loc = gs.locationList.get(0)" grabbed the stations from this file. This made it so I only saw a couple location labels on my image. I changed the 0 in the loc= to 1 and then I saw more labels. Could you check and make sure that you don't have one of these userstations.xml files?

Bob
User avatar
joleenf
Posts: 1120
Joined: Mon Jan 19, 2009 7:16 pm

Re: Plot western hemisphere cities

Post by joleenf »

Hi Bob, Jay,

The location labels are plotting, but it seems that I can't get a handle to the layer. However, Bob looked at this with me and it seems that adding a time.sleep(5) will work around the problem. In addition, I can test whether or not the layer handle is available by using

display_layers = list("{}".format(x) for x in a.getLayers())
if 'Locations' in display_layers:
pass
else:
time.sleep(5)

Joleen
User avatar
bobc
Posts: 933
Joined: Mon Nov 15, 2010 5:57 pm

Re: Plot western hemisphere cities

Post by bobc »

Hi Joleen,

Thanks for taking the time to walk through this with me. I'm glad that adding a sleep seems to work for now. I wrote up Inquiry 2759 to look into this problem. I'm replicating this on my Windows and OS X machines.

I'll follow up with you on any updates about this.

Thanks again,
Bob
User avatar
joleenf
Posts: 1120
Joined: Mon Jan 19, 2009 7:16 pm

Re: Plot western hemisphere cities

Post by joleenf »

Hi Bob,

This seems to be working now, using the time.sleep(10) to pause. Is there a way to change the Layout Model? After I found the layer handle, I tried setLayoutModel('Location'), but that does not actually apply the new location model to the point data.

Joleen
User avatar
bobc
Posts: 933
Joined: Mon Nov 15, 2010 5:57 pm

Re: Plot western hemisphere cities

Post by bobc »

Hi Joleen,

Running setLayoutModel is the correct command. If you look in the Layer Controls, you'll see under the "Layout Model" bubble that the layout model you tried changing to is listed there, but it isn't applied to the display. Looking at the source code, there's a function/method called "buttonPressed" to toggle between the "Predefined" and "Layout Model" display options. I found that if you run do things like this:

Code: Select all

gs = getStaticMcv()
loc = gs.locationList.get(0)
controlDesc = gs.getControlDescriptor('locationcontrol')
gs.uiManager.addStationDisplay(loc, controlDesc)
labels = activeDisplay().getLayer(1)
# new part.  sleep isn't needed to make it work, but just
# there so you can see how the display changes.  note that
# the Layer Controls don't update to show that the "Layout
# Model button has been activated
time.sleep(5)
labels.buttonPressed(1)
labels.setLayoutModel('Bob Locations')

If you try this and run into any problems, let me know.

Thanks,
Bob
User avatar
joleenf
Posts: 1120
Joined: Mon Jan 19, 2009 7:16 pm

Re: Plot western hemisphere cities

Post by joleenf »

Hi Bob,

I had to add to add a few commands to make this work on my mac and linux machine:

Code: Select all

gs = getStaticMcv()
loc = gs.locationList.get(0)
controlDesc = gs.getControlDescriptor('locationcontrol')
gs.uiManager.addStationDisplay(loc, controlDesc)
time.sleep(10)
labels = activeDisplay().getLayer(1)
labels.buttonPressed(1)
getStationModel = labels.setLayoutModel('Label')
labels.setTheStationModel(getStationModel)
time.sleep(5)


Joleen
User avatar
bobc
Posts: 933
Joined: Mon Nov 15, 2010 5:57 pm

Re: Plot western hemisphere cities

Post by bobc »

Hi Joleen,

I'm glad you were able to get your script working. I wrote up Inquiry 2762 to come up with a single command that would let users set the layout model and apply it in the display when working with Location Models. Please let me know if you need any other help with this.

Thanks,
Bob
Post Reply