Skip to content

Commit

Permalink
#30 small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
korvinos committed Feb 7, 2018
1 parent 771e7f9 commit c0a8357
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions openwind/cdop.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# coding=utf-8
#-------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
# Name: cdop.py
# Purpose: CDOP gmf to estimate the Doppler shift at C-band
#
Expand All @@ -12,23 +12,16 @@
# Copyright: (c) Ifremer
# License: GNU General Public License, v.3
# http://www.gnu.org/licenses/gpl-3.0.html
#-------------------------------------------------------------------------------

'''
This code contains the empirical CDOP geophysical model function, and is
based on the following paper:
Mouche A.A., Collard F., Chapron B., Dagestad K.-F., Guitton G.,
Johannessen J.A., Kerbaol V., Hansen M.W. (2012). On the use of Doppler
shift for sea surface wind retrieval from SAR. IEEE Transactions on
Geoscience and Remote Sensing, Vol. 50, No. 7, pp 2901-2909,
DOI:10.1109/TGRS.2011.2174998.
CDOP estimates the Doppler shift at C-band given a wind field, the radar
incidence angle and the radar transmit and receive polarizations (VV or
HH).
'''
#
# This code contains the empirical CDOP geophysical model function, and is
# based on the following paper:
# Mouche A.A., Collard F., Chapron B., Dagestad K.-F., Guitton G.,
# Johannessen J.A., Kerbaol V., Hansen M.W. (2012). On the use of Doppler
# shift for sea surface wind retrieval from SAR. IEEE Transactions on
# Geoscience and Remote Sensing, Vol. 50, No. 7, pp 2901-2909, DOI:10.1109/TGRS.2011.2174998.
# CDOP estimates the Doppler shift at C-band given a wind field, the radar
# incidence angle and the radar transmit and receive polarizations (VV or HH).
# -------------------------------------------------------------------------------
import numpy as np


Expand All @@ -39,9 +32,9 @@ def cdop_func(x):


def cdop(u10, phi, inc, pol):
'''
Input
-----------
"""CDOP
Parameters
----------
u10 : float, numpy.array
wind speed in m/s
phi : float, numpy.array
Expand All @@ -51,11 +44,11 @@ def cdop(u10, phi, inc, pol):
pol : string
SAR polarization (VV or HH)
Return
-----------
Returns
-------
dop : numpy.array
Estimated Doppler shift [Hz]
'''
"""
# Check inputs
sizes = np.array([np.size(inc), np.size(u10), np.size(phi)])
size = sizes.max()
Expand Down Expand Up @@ -154,13 +147,13 @@ def cdop(u10, phi, inc, pol):
inputs[ivar, :] += B1[ivar]
# Compute CDOP
B2 = np.tile(B2.reshape((11, 1)), (1, size))
dop = W4*cdop_func(np.dot(W3, cdop_func(np.dot(W2, inputs) + B2)) + B3) + B4
dop = W4 * cdop_func(np.dot(W3, cdop_func(np.dot(W2, inputs) + B2)) + B3) + B4
# Reshape output
# (using the shape of input which have the maximum ndim)
ndims = np.array([np.ndim(inc), np.ndim(u10), np.ndim(phi)])
tmp = np.where(sizes == size)[0]
ivar = tmp[ndims[tmp].argmax()]
shp = np.shape((inc, u10, phi)[ivar])
dop = dop.reshape(shp)
return dop

return dop

0 comments on commit c0a8357

Please sign in to comment.