error in step 6 (Invalid file identifier)

558 views
Skip to first unread message

zahra hajeb

unread,
Jun 18, 2017, 4:10:50 AM6/18/17
to MAINSAR
########################################
############ StaMPS Step 6 #############
########################################

PS_UNWRAP: Starting
Phase-unwrapping...
GETPARM: small_baseline_flag='n'
GETPARM: unwrap_patch_phase='n'
GETPARM: scla_deramp='n'
GETPARM: drop_ifg_index=
GETPARM: unwrap_time_win=730
GETPARM: unwrap_method='3D'
GETPARM: unwrap_grid_size=200
GETPARM: unwrap_gold_n_win=32
GETPARM: unwrap_prefilter_flag='y'
GETPARM: unwrap_gold_alpha=0.8
GETPARM: unwrap_la_error_flag='y'
GETPARM: unwrap_spatial_cost_func_flag='n'
GETPARM: max_topo_err=5
GETPARM: lambda=0.0562356
PS_UNWRAP: n_trial_wraps=0.835593
Resampling phase to grid...
   Number of interferograms  : 17
   Number of points per ifg  : 95200
   Number of resampled points: 21736
Interpolating grid...
   Number of unique edges in grid: 53485
Unwrapping in time-space...
   Estimating look angle error (elapsed time=13s)
   Using sequential daisy chain of interferograms
   Smoothing in time (elapsed time=24s)
Unwrapping in space...
   Processing IFG 1 of 17
Error using fread
Invalid file identifier.  Use fopen to generate a valid file identifier.

Error in uw_stat_costs (line 145)
    ifguw=fread(fid,[ncol,inf],'float');

Error in uw_3d (line 153)
uw_stat_costs(options.unwrap_method,options.variance);

Error in ps_unwrap (line 177)
[ph_uw_some,msd_some]=uw_3d(ph_w(:,unwrap_ifg_index),ps.xy,day,ifgday_ix(unwrap_ifg_index,:),ps.bperp(unwrap_ifg_index),options);

Error in stamps (line 204)
    ps_unwrap
 
>>

Seyed Mohammad Javad Mirzadeh

unread,
Nov 30, 2017, 11:50:13 AM11/30/17
to MAINSAR
Dear Ms. Hajeb,

Unfortunately, I have an error same to your post. Could you please tell me how you can solve it?

Best regards
Mirzadeh

Parviz

unread,
Dec 21, 2017, 9:22:22 AM12/21/17
to MAINSAR
Hi

I had this problem and after checking the related code i figured out that the snaphu didnt work correctly
You can check it in the snaphu.log to make sure
I ran all steps in matlab software but in this step the script need snaphu so you should run this step in terminal
First in your process directory type :
Matlab -nojvm
After a sec type stamps(6)
Hope it works

Dimitris

unread,
Dec 29, 2017, 3:32:47 AM12/29/17
to MAINSAR
Dear Parviz and dear everyone,

Could you please elaborate a bit more on how can this issue be solved?

As far as I understood the root cause of the error lies in the fact that file "snaphu.out" is missing - failed to be produced. 

In other words, the fread identifier error while opening fid is due to the fopen error opening "snaphu.out". In addition, "snaphu.log" file is also missing. Please refer to the attached part below extracted from um_stat_costs.m :

    offset_cycle=(angle(exp(1i*ut.dph_space_uw(:,i1)))-dph_smooth(:,i1))/2/pi;
    offgrid=zeros(size(rowix),'int16');
    offgrid(nzrowix)=round(offset_cycle(abs(rowix(nzrowix))).*sign(rowix(nzrowix))*nshortcycle);
    rowcost(:,1:4:end)= -offgrid; % offset
    offgrid=zeros(size(colix),'int16');
    offgrid(nzcolix)=round(offset_cycle(abs(colix(nzcolix))).*sign(colix(nzcolix))*nshortcycle);
    colcost(:,1:4:end)= offgrid; % offset
    fid=fopen('snaphu.costinfile','w');
    fwrite(fid,rowcost','int16');
    fwrite(fid,colcost','int16');
    fclose(fid);
    ifgw=reshape(uw.ph(Z,i1),nrow,ncol);
    writecpx('snaphu.in',ifgw)
    cmdstr=['!snaphu -d -f snaphu.conf ',num2str(ncol),' >& snaphu.log'];
    eval(cmdstr)
    fid=fopen('snaphu.out');
    ifguw=fread(fid,[ncol,inf],'float');
    fclose(fid);
    ifguw=ifguw';
    ifg_diff1=ifguw(1:end-1,:)-ifguw(2:end,:);
    ifg_diff1=ifg_diff1(ifg_diff1~=0);
    ifg_diff2=ifguw(:,1:end-1)-ifguw(:,2:end);
    ifg_diff2=ifg_diff2(ifg_diff2~=0);
    msd(i1)=(sum(ifg_diff1.^2)+sum(ifg_diff2.^2))/(length(ifg_diff1)+length(ifg_diff2));
    ph_uw(:,i1)=ifguw(uw.nzix);

It is also worth mentioning that snaphu.exe runs successfully through the dos command line and all systems variables are set as well as in the StaMPS config files.

I would appreciate any help on this.

Thank you.

Dimitris

unread,
Dec 29, 2017, 5:44:29 AM12/29/17
to MAINSAR
Dear all,

As an update to my previous post I have found the source of the error and so I am posting here the solution:

The reason the code fails is the '>&' that orders output to the file snaphu.log in line 145 of the un_stat_costs.m as follows:

cmdstr=['!snaphu -d -f snaphu.conf ',num2str(ncol) '>& snaphu.log'];

Commenting out the '>&' along with the snaphu.log fixes the error as follows:

cmdstr=['!snaphu -d -f snaphu.conf ',num2str(ncol)] % '>& snaphu.log'];

The only disadvantage of this is that no log file is created. However, I can confirm that the code runs successfully to the end of Step 8.
Message has been deleted

Zeyu Jin

unread,
May 31, 2018, 9:44:05 PM5/31/18
to MAINSAR
Dear all:

I tried Dimitris' solution but it did not work for me unfortunately. I think it is not the problem of '>&' redirecting to the log file, it is due to the snaphu.costinfile with the wrong size.
My detail error information as follows:

Thanks,

snaphu v1.4.2

6 parameters input from file snaphu.conf (6 lines total)

File snaphu.costinfile wrong size (243670 elements expected)

Abort

Reading wrapped phase from file snaphu.in

No weight file specified.  Assuming uniform weights

Reading cost information from file snaphu.costinfile

Reply all
Reply to author
Forward
0 new messages