map layer visibility affects other layers/vnc server

Post any questions, ideas, or topics related to Jython and Python scripting.
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

map layer visibility affects other layers/vnc server

Post by joleenf »

Hi,

I know this is not officially supported...but it would be really nice to understand/fix this problem.

I am trying to generate kmz files which will be converted to geoTiff for display in RealEarth: http://realearth.ssec.wisc.edu/
Ideally, direct to geoTiff would be really nice, but there is a way to convert kmz to geoTiff.

I wrote a script to create an airmass RGB for H8 data. When I run a McIDAS-V interactive session on a Virtual Machine (using a vncserver), open a jython shell, I can toggle the visibility of the map layer without affecting the visibility of the rgb layer. When I run that same script from a command line (connected to a vnc server), the map layer affects the visibility of the rgb layer. I have tried the following:
    Toggle map layer off after rgbLayer is displayed. Result: No layers displayed
    Toggle map layer off after the buildWindow is executed. Result: No layers displayed
    Use only US County outlines (the view is over Asia, in this way, no map would appear) in default map set Result: No Layers Displayed in view region
    Remove the map layer after the buildWindow is executed. Result: No Layers displayed
    Give Up, display the map layer. Result: Both Layers Displayed
    Try to move map layer to -1 Result: Still see map
    Try to use the dots for the map outline Result: ugly, looks like a problem with the image
    Try to make the map layer transparent. Result: Apparently transparency never gets applied to the image or it does not work in kmz files.


Otherwise, the RGB ran from a cron well. This is soooo close. Why does the map layer seem to be tied to the rgb layer? Is there a way to make the map transparent (and actually make it transparent, not just set it that way in the GUI without seeing any evidence that it is working?).

ftp://ftp.ssec.wisc.edu/ABI/joleenf/H8/ ... 000UTC.kmz

Thanks,
Joleen
User avatar
jayh
Posts: 424
Joined: Thu Jan 15, 2009 10:34 pm

Re: map layer visibility affects other layers/vnc server

Post by jayh »

Hi Joleen-

I have a couple of questions.

1. Have you tried running your script directly on a -V workstation? (To take the vnc server out of the equation.)
2. If you could post your script, we can try some exercises out here.

Thanks, Jay
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: map layer visibility affects other layers/vnc server

Post by joleenf »

Hi Jay,

Taking the vnc server out, I still see the same behavoir:
- within McIDAS-V from Jython Shell, I can turn map off with no negative affect on the other layer

- from the command line, turning the map off simultaneously turns off the other layer or some other problem and I see nothing in my output file.

Example command line:
${HOME}/Applications/McIDAS-V-System/runMcV -script ${HOME}/mcidas/scripts/h8rgbAirMass.py -scriptargs --lat 21 --lon 136

h8rgbAirMass.py
(3.17 KiB) Downloaded 374 times


Other code in my jython shell...this could be removed from above script. The only thing it does is create a temporary directory which prevents the script from processing the same date/time/tile twice.

Code: Select all

def makeDirectory(parentDataDir,date,time):
   created = False
   #datedDirLock = ''.join([parentDataDir,date,'/',time])
   datedDirLock = os.path.join(parentDataDir,date,time)

   if not os.path.exists(datedDirLock):
      os.makedirs(datedDirLock)
      print 'made directory: %s' % (datedDirLock)
      created = True

   return created

def toDoList(parentDataDir, day, time):

      # check if directory exists If not, create a directory lock, process data. 
      processThisTime = makeDirectory(parentDataDir, day, time)

      return processThisTime

def removeDirectory(parentDataDir,date,time):
   datedDirLock = os.path.join(parentDataDir,date,time)
   if os.path.exists(datedDirLock):
       os.removedirs(datedDirLock)


Joleen
Last edited by joleenf on Thu Jul 16, 2015 2:45 pm, edited 1 time in total.
User avatar
jayh
Posts: 424
Joined: Thu Jan 15, 2009 10:34 pm

Re: map layer visibility affects other layers/vnc server

Post by jayh »

Hi Joleen-

I simplified your script a bit to work in my environment and I'm seeing the same behavior you are.

-Running the script through the jython shell works as expected when setting the map layer to 'false'
-Running the script outside the environment will only work if I comment out the mapLayer.setLayerVisible(False) line. Then you get conflicting map lines in the kmz file.

I did add a captureImage line that also created a jpeg image. I see the same issues with that. I get a black image with no contents when I set the map layer to false. I get a nice image when I leave the maps on.

I created Inquiry 2106 for this problem. I'll look at it some more and ping the programmers to see if there is a work around.

Thanks, Jay
User avatar
jayh
Posts: 424
Joined: Thu Jan 15, 2009 10:34 pm

Re: map layer visibility affects other layers/vnc server

Post by jayh »

Hi Joleen-

Bob and I did some more playing. He found that if you change your scale to 4, instead of 8, then the background script works and produces the files without the map layer. Scale sizes greater than 5 failed, 2, 3, and 4 worked.

Bob also discovered a way to turn the Auto Set Projection off in a script (which might be useful in future scripting, but didn't fix the problem with scales greater than 5):
panel[0].setProjectionFromData(0)

If you use setProjectionFromData(1), that turns it on.

If the programmers have any more information on workarounds, we'll let you know.

Thanks, Jay
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: map layer visibility affects other layers/vnc server

Post by joleenf »

I was only able to see an image on the first try after adjusting to a lower magnification. After that point, I adjusted the buildWindow size so that the image would fill the screen, and then I ended up with no image. After that, I could not get back to a point where any mag will display an image layer without the map layer.

Thanks,
Joleen
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: map layer visibility affects other layers/vnc server

Post by joleenf »

Is there a way to make a pretend map for that region? Maybe the map could be a very small bit of coastline somewhere in the view? Would that trick the software?

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

Re: map layer visibility affects other layers/vnc server

Post by bobc »

Hi Joleen -

I just wanted to let you know that I'm still looking into this. I've tried a variety of things with maps... turning them all off at once and turning off individual maps using setMapVisibilityByDescription() and they are all giving the same results; scale=4 and lower works, scale=5 and higher gives the black images.

Another idea of a workaround would be setVerticalPosition() to put the RGB display above the map. However, the 'RGB Composite' display type doesn't currently support changing the vertical positioning of the layer in the Main Display, so there's no slider and setVerticalPosition doesn't do anything to the layer. I've written this up adding this functionality as Inquiry 2110. The '3 Color (RGB) Image' display type does allow for changing of the vertical positioning of the layer.

Code: Select all

# set the projection, center, and turn off auto-set projection
# to retain a lat/lon projection after the display of the data
# lat/lon projection is needed for kmz output
panel[0].setProjection('World')
panel[0].setCenter(0, 140, scale=8)
panel[0].setProjectionFromData(0)
# ...
# rest of the script where the data is loaded in
# ...
rgbLayer=panel[0].createLayer('3 Color (RGB) Image', rgb)
rgbLayer.setLayerLabel(visible=False)
rgbLayer.setVerticalPosition(-0.9)
# ... capture the image

One thing to note is that the display looks slightly different using the 'RGB Composite' and '3 Color (RGB) Image' display types. I have asked a programmer how much of an effort it would be to add the vertical positioning functionality to the 'RGB Composite' control.

I'll keep trying to think of alternate workarounds.

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

Re: map layer visibility affects other layers/vnc server

Post by joleenf »

I don't think I want to raise the level of the RGB because that would create a slight navigation shift which would put it in the wrong place in RealEarth. In this case, since I am using the EUMETSAT RGB formula, I won't need to use RGB Composite, I can as easily use 3 Color (RGB) Image. Habits are hard to break, I normally use RGB Composite.

Thanks,
Joleen
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: map layer visibility affects other layers/vnc server

Post by joleenf »

Hi,

I am currently running on my OSX box. It seems that the same code can run correctly for most cases, but seems to consistently turn off the image for a few bands when the map layer is turned off:

ftp://ftp.ssec.wisc.edu/pub/ssec/joleen ... abeled.png

I began running for 1 band (band 4) and got the following results for

1. Map on no reprojection: ftp://ftp.ssec.wisc.edu/pub/ssec/joleen ... apture.png
2. Remove Layer Label: ftp://ftp.ssec.wisc.edu/pub/ssec/joleen ... apture.png
3. Reproject to layer projection: ftp://ftp.ssec.wisc.edu/pub/ssec/joleen ... apture.png
4. Turn off Map: ftp://ftp.ssec.wisc.edu/pub/ssec/joleen ... apture.png
5. Turn On Map: ftp://ftp.ssec.wisc.edu/pub/ssec/joleen ... apture.png

When I was not using the projection of the layer, the module which turns the map off was before the data display. Then, all 16 bands displayed well. It looks like for now, I will have to break out the map setting from the current location and place it earlier in the code. However, I thought that I should note this problem as a follow up to the previous post. In this case, my scale=1.08.

Joleen
Post Reply