can't use captureImage

Errors and unexpected results
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: can't use captureImage

Post by joleenf »

Hi HP,

I have looked at my commit notes and I never actually used writeImageAtIndex as a function. I wanted to add some of the captureImage formatting that was borrowed/brought over from the ISL, so I copied the writeImageAtIndex function and added the extra details of colorbar, labeling, etc. In my first commit, I have a comment about how nextStep is failing randomly. In creating the animation for the GOES-16 sectors (https://www.youtube.com/watch?v=m1_XfLFeY840), I never tried to use a time driver via a script. This may have helped.

My commit message (perhaps a bit muddled and not super helpful for the MUG programmers) is

Version which does most of the work to display a fd, conus and meso together, with M1 and M2 sectors. (Known BUGS) - FD is not looping, even though there are three different images in FD data object and array - animation next step fails, nearly randomly. While the time moves ahead, the image sometimes doesn't and vice versa perhaps this can be fixed by using a index in steps and making sure that we begin at index one.


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

Re: can't use captureImage

Post by bobc »

Hi Joleen -

Thanks for your script with takeStepForward(). I'm replicating what you are seeing, but only if I include captureImage in the loop. I cut things down a bit, and if I run the loop with takeStepForward without captureImage, then things work fine:

Code: Select all

for x in range(steps):
    idx = anim.getCurrent()
    time.sleep(4)
    anim.takeStepForward()

This steps through the animation, and I can go back to the Main Display and get the animation to play through the time animation widget. If I add a captureImage command before time.sleep(4), then things break where the image no longer updates through the time animation widget.

From my tests thus far, I'm thinking that this is related to the other captureImage issues going on, rather than being an issue with takeStepForward(). Do you agree with this, or have you seen issues without using captureImage in your scripts?

I'll respond to this forum when there are any updates on the status of captureImage.

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

Re: can't use captureImage

Post by joleenf »

Hi Bob,

I can't say that I have tried to use takeStepForward without capturing and image. Thank-you for digging deeper on this. Your finding is very interesting. If you use writeImage, do you have a problem with takeStepForward?

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

Re: can't use captureImage

Post by bobc »

Hi Joleen -

writeImage looks to be working fine. For example, in yesterday's nightly, I ran:

Code: Select all

imageDir = 'C:/Users/rcarp/anim/'
for x in range(steps):
    idx = anim.getCurrent()
    activeDisplay().writeImage(imageDir+'writeImage_frame_'+str(x)+'.gif')
    time.sleep(4)
    anim.takeStepForward()

All of the images were captured correctly (image and layer labels) and the time animation widget works to play the loop in the Main Display after running the script. If I substitute writeImage with captureImage then the problem appears.

I'll add this information to the inquiry.

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

Re: can't use captureImage

Post by joleenf »

Just a request, could you make index=0 the default so that it is backwards compatible with old scripts?

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

Re: can't use captureImage

Post by bobc »

Thanks for the request, Joleen. I added it to the inquiry. We will discuss this and I'll let you know the final verdict.

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

Re: can't use captureImage

Post by joleenf »

Hi,

February 25, 2019 build version 1.9 beta1, it seems the index=0 is no longer the default, instead it is index=''. My scripts are failing. Was this an intentional change? Or, is it possible something got mixed up in one of my xml files? When I tried using tempuserpath, a strange thing happened as well, McV started interactively rather than running the script.

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

Re: can't use captureImage

Post by joleenf »

Hi Jay,

I reverted back to a February 11, 2019 build and my scripts work, but -tempuserpath does not work as expected.


This is the more complicated script that I am testing (I am pretty sure it is Bob's test script)

rgb_and_locs.py
(772 Bytes) Downloaded 269 times


Code: Select all

import os
# save an image to $HOME/check
home_directory = os.path.expanduser('~')
image_path = os.path.join(home_directory,'check')

# max the size of the image
panel=buildWindow(height=2160,width=3840)

m1Parms = dict(
    server = 'lead.unidata.ucar.edu',
    dataset = 'RTGOESR',
    descriptor = 'M1',
    size = (500,500),
    position = -1,
    )

# get data with params defined above
vis = loadADDEImage(band=2, mag=(-4,-4), unit='ALB', **m1Parms)
ir = loadADDEImage(band=13, mag=(1,1), unit='TEMP', **m1Parms)

sandData = sandwich(ir,vis)

visLayer = panel[0].createLayer('Image Display', vis)
sandLayer = panel[0].createLayer('RGB Composite', sandData)

final_image_name = os.path.join(image_path, "test_McV_Meso1.png")
panel[0].captureImage(final_image_name)



and this is the simple script (really silly), called hw.py

Code: Select all

print ("Hello World!")
User avatar
jayh
Posts: 424
Joined: Thu Jan 15, 2009 10:34 pm

Re: can't use captureImage

Post by jayh »

Hi Joleen- I checked 1.8 and today's nightly (March 1) and was seeing the same behavior with your rgb_and_locs.py script in both versions. Here is what I'm seeing when running 3 different commands to run the script in the background:

1. ./runMcV -script /Users/jayh/rgb_and_locs.py -> Works correctly

2. ./runMcV -userpath /Users/jayh/aaaaaa -script /Users/jayh/rgb_and_locs.py -> This creates and uses the new directory for the user path, however, the script is NOT executed and there is a error in the log file:
Error running jython script:/Users/jayh/rgb_and_locs.py
java.lang.NullPointerException

3. ./runMcV -tempuserpath -script /Users/jayh/rgb_and_locs.py -> This starts a foreground session and doesn't run the script at all

Bob checked Windows as well, and was seeing different issues with -tempuserpath and these will all be documented for evaluation in inquiry 2778.

Let me know if installing today's nightly fixes the issues you had with the Feb 25th install and executing rgb_and_locs.py script.

Thanks, Jay
Last edited by jayh on Mon Mar 04, 2019 11:08 pm, edited 1 time in total.
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: can't use captureImage

Post by joleenf »

Hi Jay,

I downloaded Build-date: 2019-03-04 10:30 Version 1.9 beta 1 nightly for mac osx.

1.) ~/runMcV -script /Users/joleenf/rgb_and_locs.py -> fails with a null pointer exception

2.) ~/runMcV -tempuserpath -script /Users/joleenf/rgb_and_locs.py --> starts a foreground session and does try to run the script, but that fails with a null pointer exception found within the mcidasv.log of the temporary log directory created by tempuserpath.

3.) Running rgb_and_locs.py in jython shell works both with and without index=0

Joleen
Post Reply