FUNCTION smei_theta2radial, thetay, thetax

    @compile_opt.pro        ; On error, return to caller

ty = thetay
rr = where( abs(thetay) GT 30.0 )
IF rr[0] NE -1 THEN ty[rr] = 0.0

CASE IsType(thetax, /defined) OF

0: rr = thetay*(-18.0226 + thetay*(0.1664 + thetay*(-0.00744 + ty*(-0.00015))))

1: BEGIN

    dr_present = n_elements(thetax) EQ 2*n_elements(thetay) 

    CASE dr_present OF
    0: tx = thetax
    1: BEGIN
        tx = SubArray(thetax, element=0)
        dr = SubArray(thetax, element=1)
    END
    ENDCASE

    tx = tx*tx
    rr = 0.000936*tx - 1.044E-7*tx*tx + thetay*(-18.0226 + 3.6E-5*tx + thetay*(0.1664 - 1.0E-5*tx+thetay*(-0.00744 +ty*(-0.00015))))

    IF dr_present THEN rr = rr-dr

END

ENDCASE

RETURN, rr  &  END