0001 function J =jacobian_apparent_resistivity(fwd_model, img)
0002
0003
0004
0005
0006
0007
0008
0009
0010 if ischar(fwd_model) && strcmp(fwd_model,'UNIT_TEST'); do_unit_test; return; end
0011
0012 if nargin == 1
0013 img= fwd_model;
0014 elseif strcmp(getfield(warning('query','EIDORS:DeprecatedInterface'),'state'),'on')
0015 warning('EIDORS:DeprecatedInterface', ...
0016 ['Calling JACOBIAN_APPARENT_RESISTIVITY with two arguments is deprecated and will cause' ...
0017 ' an error in a future version. First argument ignored.']);
0018 end
0019 fwd_model= img.fwd_model;
0020
0021 if mdl_normalize(fwd_model)
0022 error('Cannot calculate apparent resistivity for normalized difference data');
0023 end
0024
0025
0026 solver = @eidors_default;
0027 try
0028 solver = fwd_model.jacobian_apparent_resistivity.jacobian;
0029 end
0030
0031 img.fwd_model.jacobian = solver;
0032
0033 J = calc_jacobian(img);
0034
0035 fctr = get_factor(img);
0036
0037 J = fctr * J;
0038
0039 function fctr = get_factor(img)
0040 fctr = NaN;
0041 try
0042 fctr = img.fwd_model.apparent_resistivity_factor;
0043 end
0044
0045 if ischar(fctr), fctr = str2func(fcstr); end;
0046
0047 if isa(fctr, 'function_handle')
0048 fctr = feval(fctr, img);
0049 end
0050
0051 if isnan(fctr)
0052 vh = fwd_solve(mk_image(img.fwd_model,1));
0053 n = length(vh.meas);
0054 fctr = spdiags(1./vh.meas,0,n,n);
0055 end
0056
0057
0058 function do_unit_test
0059 disp('TODO: NEED TO WRITE TESTS');