Error in SNAP - StaMPS processing of RS2 data: "Index in position 1 is invalid"

Hello,

I am trying to apply the PSI method to a test set of RS2 data using SNAP and StaMPS. I have been able to follow all of the steps that are outlined elsewhere in the forum (generating and SLC and interferogram stacks, StaMPS export, running mt_prep_snap) up until running the matlab script stamps.m. It is failing in step 2 in the ‘Calculating patch phases…’ step. The error is:
"
Index in position 1 is invalid. Array indices must be positive integers or logical values.

Error in ps_est_gamma_quick (line 236)
ph_grid(grid_ij(i,1),grid_ij(i,2),:)=ph_grid(grid_ij(i,1),grid_ij(i,2),:)+shiftdim(ph_weight(i,:),-1);

Error in stamps (line 326)
ps_est_gamma_quick(est_gamma_parm);
"
I have looked into the matlab code itself and it looks like the problem is the existence of NaNs in the array grid_ij() in ps_est_gamma_quick.m. I was wondering if anyone has a suggestion as to what the cause of this might be? I have included screen shots of the stacks I am using, in case this is helpful.

Many thanks in advance,

Best,

Thomas

slcs

Well, I see three different things there:

  1. For PSI, you should not apply any filter, as original DInSAR are expected, otherwise you would not get PS points, but more distribute scatterers alike (DS). Still, this cannot be causing the error you have mentioned.
  2. I hope you are not using such few images for PSI analysis, otherwise your results will not be very accurate (normally more than 20 SLCs are recommended to run such kind of processing). But still, this is not causing the error neither.
  3. which is the stamps version are you using? You should use the last developer version (from github) and not the official release, as it solves issues as the one you have pointed out here.

I hope this helps.

Hello and thank you for your quick response.

  1. For PSI, you should not apply any filter, as original DInSAR are expected, otherwise you would not get PS points, but more distribute scatterers alike (DS). Still, this cannot be causing the error you have mentioned.

Thank you for mentioning this, even though it is not the cause of the error. I have changed my processing accordingly.

  1. I hope you are not using such few images for PSI analysis, otherwise your results will not be very accurate (normally more than 20 SLCs are recommended to run such kind of processing). But still, this is not causing the error neither.

I am only running these few images as a test run before scaling up. I ultimately plan to use stacks several times as large, but it is good to know that this is not the issue.

  1. which is the stamps version are you using? You should use the last developer version (from github) and not the official release, as it solves issues as the one you have pointed out here.

I am using the version form github (https://github.com/dbekaert/StaMPS/releases/tag/v4.1-beta). Would there be another cause of the error that you can think of? Just to give a little more information, after running StaMPS export (the image is of size 6k x 9k pixels) the directories dem, diff0, geo and rslc are all created, after which I am running mt_prep_snap as:

mt_prep_snap 20110804 D:/snap/PSI/feb19 0.3 3 3

Thank you,

Thomas

Hi Jose,

I have this error posted in here,

I checked up all your point in this post, and I think nothing from above 1 and 2 has been done, so my process concatenation is true, I’d highly appreciate your opinion.

Thanks,

Falah,

Well,

My suggestion then is to do some debugging investigating within matlab the variables that are involved in the lines in which the error is coming.

Probably they had either NaNs or 0s.

Please check them and let me know

Tremendous thanks Jose,

I added break point as you see in the following and it runs until this point, so what is the error in this line,

also I added break point here,

Perfect!

Once the processing reach this point, you should check the values of the different variables, so you can see where exactly the problem is, for later trying to solve it.

I hope this help

image

Is that mean the error before line 221

Well, within the ps_est_gamma_quick you should put another break point, so you get the actual value of the variables on the moment that they produce the error

I added two break point and this is the result

image

Well,

  1. remove the break point at the moment launching the function ps_est_gamma_quick
  2. run again without any breakpoint
  3. add new breakpoint on the exact line inside ps_est_gamma_quick which gives the error, so you will be able to get the actual value of the variables on the moment that they produce the error
1 Like

I followed exactly your points

image

I am sorry that I cannot express properly. I will try to give you some hints.
If you click on the 115 (in blue) it should bring you to the point where the code stops.
You should then try to figure out which values had the variables there involve, so you can identify which variables have the wrong values assigned, which should help you to identify what is wrong.

I am not sure how else I can help you. Let me know.

Cheers

It is Friday, you are explaining very nicely, this is the whole statement of the line 115, I’m not sure which one is wrong,

image

Hi @falahfakhri, did you find where the error was, and how to fix it? Beacause I am having the same problem in step2!
many thanks in advice

Yes! I have shared the script that solves the problem.
The trick is to find the wrong indexes during step 1, as the same way as Dr. Bekaert did, but also including 0s in addition to the NaNs.

You can find it here.

Let me know if this also solves the problem for you

4 Likes

Hello and thank you for sharing this script. For me, the new script introduces the following error in the same step of the StaMPS processing:
"
Index in position 2 is invalid. Array indices must be positive integers or logical values.

Error in clap_filt (line 71)
ph_bit(1:n_win,1:n_win)=ph(i1:i2,j1:j2);

Error in ps_est_gamma_quick (line 225)
ph_filt(:,:,i)=clap_filt(ph_grid(:,:,i),clap_alpha,clap_beta,n_win0.75,n_win0.25,low_pass);

Error in stamps (line 326)
ps_est_gamma_quick(est_gamma_parm);

"
in place of the one that occurred above for me. Is there anything that you could recommend as a next step to solving this? Please let me know if there is any other information that I can provide.

Thank you,

Thomas

You should re-run step1. Not sure you did it

I reran the processing from the beginning and the error no longer occurs. Thank you.

1 Like

There is on additional issue though. The processing now throws an error in step five:

"
STAMPS: ########################################
STAMPS: ################ Step 5 ################
STAMPS: ########################################
STAMPS: Directory is D:\test\r0\PATCH_1

PS_CORRECT_PHASE: Starting
Correcting phase for look angle error…
GETPARM: small_baseline_flag=‘n’
PS_CORRECT_PHASE: Finished
Error using movefile
The process cannot access the file because it is being used by another process.

Error in stamps (line 462)
movefile(‘patch.list’,‘patch.list_old’);"

Is there a recommended fix for this? I have noticed that this always occurs on the last patch being processed.

Thank you.

1 Like