script saving an image sequence does not work correctly

Errors and unexpected results
User avatar
hproe
Posts: 504
Joined: Sat Nov 27, 2010 3:46 pm

Re: script saving an image sequence does not work correctly

Post by hproe »

Hi Bob -

I have implemented the changes as proposed by you and run a thorough test with a sequence of two 100 big frames (a single-channel and an RGB one). Like you, I get an orderly time series when not touching the layer label (switch=0). However, when I turn off the layer label (switch=1), I am back at getting a repeat of the first image and subsequent images off by one, both with single-channel and RGB. Adding a label (switch=2) and adding a colour bar (switch=3) gives the same bad result. Can you replicate this - not sure how you have been running your test. For me it appears that manipulating the layer label somehow upsets the saving.

HP
User avatar
bobc
Posts: 988
Joined: Mon Nov 15, 2010 5:57 pm

Re: script saving an image sequence does not work correctly

Post by bobc »

Hi HP -

I've tried testing out with a loop of both single-banded images and RGBs. Using switches of 0, 1, 2, and 3 all seem to work fine for me. All of the timesteps are saved in the correct images without any repeats. I'm wondering if you are somehow creating your display differently than I am. Can you please send me one of your scripts that loads in and displays the data? After running the script, do you do anything in the Main Display before running your svImageSeq function?

Thanks -
Bob
User avatar
hproe
Posts: 504
Joined: Sat Nov 27, 2010 3:46 pm

Re: script saving an image sequence does not work correctly

Post by hproe »

Hi Bob -

I have been creating the image series, both in foreground from msg.ssec.wisc.edu/adde.eumetsat.int and in backround with a scripts calling geoarc.ssec.wisc.edu of which I attach a sample (add accounting information!).

cheers, HP
Attachments
singleChannel.txt
(1.79 KiB) Downloaded 337 times
User avatar
bobc
Posts: 988
Joined: Mon Nov 15, 2010 5:57 pm

Re: script saving an image sequence does not work correctly

Post by bobc »

Hi HP -

Thanks for the sequence_FD function. I've run several tests with your function and my own scripts (both from the foreground and background), and I'm not able to reproduce the problems you are seeing with the sleep() lines removed from svImageSeq. I'll keep running some more tests to try replicating the bug. I also made a programmer aware of the issue and I will get back to you with ideas/suggestions.

Thanks -
Bob
User avatar
hproe
Posts: 504
Joined: Sat Nov 27, 2010 3:46 pm

Re: script saving an image sequence does not work correctly

Post by hproe »

Hi Bob -

Up to now I have been run the script only on my Windows 8.1 notebook. Running it now on the Windows 7 I one the problem is perfectly reproduced.

Just to be sure I run the script with both touching the layer label

Code: Select all

  imLayer.setLayerLabel(visible=True)    # on

and pausing/syncing

Code: Select all

 pause()
 imControls[1].notifyViewManagersOfChange()


When commenting out the layer label manipulation, there is no time shift in the saved sequence, but in longer series there may be occasional drop-outs (frame repeats with no time shift - can be easily repaired).

HP
User avatar
bobc
Posts: 988
Joined: Mon Nov 15, 2010 5:57 pm

Re: script saving an image sequence does not work correctly

Post by bobc »

Hi HP -

Sorry that this one is taking a while to figure out. Can you please do the following things?

1. Can you please send us your mcidasv.log file when you run into the problem?

2. Can you let me know exactly what commands you are running in the Jython Shell? For example, after putting the svImageSeq and sequenceFD functions in my local Jython Library, I've run the following commands in the Jython Shell:

Code: Select all

sequence_FD('2005-12-01 00:00UTC',100,2)
svImageSeq(2,'/HP/Dec16/switch2/','postFix','preFix',10,1000,800,'Spain')

I've tested with switches 0 through 3, as well as different numbers of images to load from sequence_FD (ranging from 10 to 100).

3. To see if anything locally might be causing a problem, can you try running your script with a fresh McIDAS-V directory? To do this in the 1.5beta2 nightlies, you can use the -tempuserpath flag. This creates a temporary userpath that McIDAS-V will start up from. For example, in a command prompt, cd to the directory where the 1.5beta2 build is installed and run the following:

Code: Select all

runMcV.bat -tempuserpath

Do you see better results in this case?

4. Have you tried running this from the background? If so, do you see any better results?

Thanks -
Bob
User avatar
hproe
Posts: 504
Joined: Sat Nov 27, 2010 3:46 pm

Re: script saving an image sequence does not work correctly

Post by hproe »

Hi Bob -

The commands used by you under point 2 are corresponding to the ones I am using. So, this is fine.

For the time being I have only checked as per point 4, i.e. I run

Code: Select all

runMcV.bat -tempuserpath

from the shell, create an image sequence from adde.ucar.edu (I don't think the method to create an image sequence matters), set an adequate Viewpoint and put svImageSeq in the local Jython Library. To my surprise this gives strange results.
A. with a layer label:
The layer label is saved correctly, but all frames show the first image of the sequence.
B. no layer label (delete manually)
All frames show the first images with the exception of 1 or 2 frames that remain empty.

I have repeated the same exercise in my operational suite in Windows 8.1.
C. with a layer label
Image sequence is perfectly saved.
D.no layer label (delete manually)
The image sequence is saved correctly, at random 1 or 2 frames are blank.

I have repeated the above procedure several times. Also, I note changes in the saving procedure. Saving of the images takes considerably longer. When an image is saved, first an empty frame appears, then the former frame is displayed immediately followed by the correct frame.

I am running McV1.5beta2 of 29 Dec under Windows 8.1 and 7)

Happy New Year, HP
User avatar
bobc
Posts: 988
Joined: Mon Nov 15, 2010 5:57 pm

Re: script saving an image sequence does not work correctly

Post by bobc »

Hi HP -

Using today's nightly, I'm running into problems with your svImageSeq function as well. Not exactly what you're seeing, but a lot of cases with black images sporadically saving in the loop, both when I don't touch the layer label (switch = 0) and when I do touch the layer label (switch = 1), switch=2 seems to be working fine for me. I spoke with a programmer and we are thinking that there is some type of a threading problem going on, where multiple threads are colliding and producing unpredictable results. The programmer wants to take a look at a couple of different things to see if there is anything that we can do to get this working. We will get back to you about this.

As an alternative to your script, would you be able to capture your images through the GUI (without a script)? This can be done through View>Capture>Movie in the Main Display window. Near the bottom of the Movie Capture window, there is an Image Files section, where you can select a destination directory as well as a filename template that can include information like position in the loop and date/time. When the movie is captured, individual images of each timestep will be saved off to your specified directory.

Thanks, and Happy New Year -
Bob
User avatar
hproe
Posts: 504
Joined: Sat Nov 27, 2010 3:46 pm

Re: script saving an image sequence does not work correctly

Post by hproe »

Hi Bob -

I agree. It's a wild world, my script is moving in!

I know about saving individual frames through Capture/Movie. Actually, this procedure has never had any kind of the glitches as encountered by my script these times and it is fine by me for saving clean frames. However, when it comes to annotations, I do not like to have layer labels and colour bars inside the image. External information mattes, beyond not disturbing the image content, can also be torn off easily later on, if wished so. BTW wouldn't these be nice-to-have options for the McV capturing procedure?

cheers, HP
User avatar
bobc
Posts: 988
Joined: Mon Nov 15, 2010 5:57 pm

Re: script saving an image sequence does not work correctly

Post by bobc »

Hi HP -

As far as adding the writeImage functionalities (e.g. matte, colorbar, text, ...), this is something that we are actively working on. We are adding a new optional 'formatting' keyword to captureImage. Here is a script that goes over some of the options for 'matte', 'colorbar' and 'overlayText' that I ran in today's nightly on my machine. You should just have to change the 'outDir' variable to point to a destination directory for the image on your machine:

Code: Select all

# Image destination directory
outDir = 'C:/Users/myUser/myDirectory/'

# Pulling in satellite data from server
addeParms = dict(
    server = 'adde.ucar.edu',
    dataset = 'RTIMAGES',
    descriptor = 'GE-IR',
    coordinateSystem = LATLON,
    location = (40,-80),
    size = (500,500),
    unit = 'TEMP',
    )
data = loadADDEImage(**addeParms)

# Build window, display data, turn off layer label and wireframe
panel = buildWindow()
layer = panel[0].createLayer('Image Display', data)
panel[0].setWireframe(False)
layer.setLayerLabelVisible(False)

# Formatting options for captureImage
myFormat = [
    # Adds a matte around image
    Matte(
        space = "80", #80 pixel width in all directions
        background = "blue",
        ),
    # Adds a colorbar to image
    Colorbar(
        display = layer, #layer for colorbar
        place = "LM, 0, -30", #Lower Middle pos, xOffset, yOffset
        anchor = "LM", #Anchor lower middle of colorbar at 'place'
        orientation = "top", #Labels on top of colorbar
        tickMarks = "10", #Number of tickmarks to split colorbar into
        showLines = True, #Show lines on colorbar at tickmark locations
        width = "600", #Width of colorbar in pixels
        height = "25", #Height of colorbar in pixels
        showUnit = True, #Show unit with labels
        suffixFrequency = "all", #Show unit at all labels
        color = "white", #Label color
        ),
    # Adds text to the image
    TextOverlay(
        text = "GOES-13 IR Image", #Actual text to display
        place = "UM,0,30", #Place txt in upper middle, xOffset, yOffset
        anchor = "MM", #Anchor middle of colorbar at 'place'
        fontSize = "20", #Size of text
        ),
    ]

panel[0].captureImage(outDir+'myImage.gif', formatting=myFormat)
#formatting keyword is new
print 'Image Capture Complete ...'


I included some in-line documentation on the different keywords, but complete documentation is not yet done. This is also a sample of only some of the formatting options that will be available. Others that we are working on include:

clip - Allows for clipping image at specific lat/lon locations, as well as specific pixel counts in any direction.
ImageOverlay - Allows for doing things like adding logos to the output image.
Resize - Allows for resizing the output image.
TransparentBackground - Allows for setting a transparent background in the image.
TransparentColor - Allows for setting a specific color in the image to be transparent in the output image.

Hopefully you will find these formatting options for captureImage to be useful!

Thanks -
Bob
Post Reply