openradar / PyDDA

Pythonic multiple doppler code based off the 3D variational technique
http://openradarscience.org/PyDDA
Other
91 stars 44 forks source link

TypeError in calculate_background_gradient when given a nonzero Cb value #62

Closed dm0096 closed 3 years ago

dm0096 commented 3 years ago

I've given the PyDDA wind retrieval function a nonzero (1e3) value for Cb to activate the background field constraint. However, PyDDA errors with TypeError: calculate_background_gradient() got an unexpected keyword argument 'upper_bc'. I'll paste the relevant output below.

Could this be a bug in grad_J()? I noticed it's passing upper_bc into calculate_background_gradient() even though the latter doesn't accept that argument.

/nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/pydda/retrieval/angles.py:24: RuntimeWarning: invalid value encountered in arccos elev = np.arccos((Re2 + slantrsq - rh2)/(2 Re slantr)) Calculating weights for radars 0 and 1 /nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/pydda/retrieval/wind_retrieve.py:652: RuntimeWarning: invalid value encountered in true_divide theta_1 = np.arccos(x/a) /nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/pydda/retrieval/wind_retrieve.py:653: RuntimeWarning: invalid value encountered in arccos theta_2 = np.arccos((x-rad2[1])/b) /nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/pydda/retrieval/wind_retrieve.py:654: RuntimeWarning: invalid value encountered in true_divide return np.arccos((aa+bb-cc)/(2ab)) Calculating weights for models... Starting solver rmsVR = 20.396509094257294 Total points: 115926 Traceback (most recent call last): File "/nas/rhome/share/opt/pkgs/anaconda/x64/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/nas/rhome/share/opt/pkgs/anaconda/x64/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/dda/dda.py", line 642, in ans.run_pydda() File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/dda/dda.py", line 200, in inner func(args, kwargs) File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/dda/dda.py", line 544, in run_pydda self.grids, self.u_init, self.v_init, self.w_init, self.analysis_args File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/pydda/retrieval/wind_retrieve.py", line 518, in get_dd_wind_field fprime=grad_J, disp=0, iprint=-1) File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/scipy/optimize/lbfgsb.py", line 198, in fmin_l_bfgs_b *opts) File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/scipy/optimize/lbfgsb.py", line 308, in _minimize_lbfgsb finite_diff_rel_step=finite_diff_rel_step) File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/scipy/optimize/optimize.py", line 262, in _prepare_scalar_function finite_diff_rel_step, bounds, epsilon=epsilon) File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/scipy/optimize/_differentiable_functions.py", line 155, in init self._update_grad() File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/scipy/optimize/_differentiable_functions.py", line 231, in _update_grad self._update_grad_impl() File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/scipy/optimize/_differentiable_functions.py", line 145, in update_grad self.g = grad_wrapped(self.x) File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/scipy/optimize/_differentiable_functions.py", line 142, in grad_wrapped return np.atleast_1d(grad(x, args)) File "/nas/rhome/dmeyer/Work/GRA/pydda-meyer/env/lib/python3.7/site-packages/pydda/cost_functions/cost_functions.py", line 142, in grad_J upper_bc=parameters.upper_bc) TypeError: calculate_background_gradient() got an unexpected keyword argument 'upper_bc'

rcjackson commented 3 years ago

We are going to soon (by October) release a new version of PyDDA with gradients calculated using automatic differentiation. This issue will be fixed in that release.