pyNastran  0.5.0
pyNastran BDF Reader/Writer, OP2 Parser, and GUI
op2_helper.py
Go to the documentation of this file.
00001 ## GNU Lesser General Public License
00002 ## 
00003 ## Program pyNastran - a python interface to NASTRAN files
00004 ## Copyright (C) 2011-2012  Steven Doyle, Al Danial
00005 ## 
00006 ## Authors and copyright holders of pyNastran
00007 ## Steven Doyle <mesheb82@gmail.com>
00008 ## Al Danial    <al.danial@gmail.com>
00009 ## 
00010 ## This file is part of pyNastran.
00011 ## 
00012 ## pyNastran is free software: you can redistribute it and/or modify
00013 ## it under the terms of the GNU Lesser General Public License as published by
00014 ## the Free Software Foundation, either version 3 of the License, or
00015 ## (at your option) any later version.
00016 ## 
00017 ## pyNastran is distributed in the hope that it will be useful,
00018 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 ## GNU General Public License for more details.
00021 ## 
00022 ## You should have received a copy of the GNU Lesser General Public License
00023 ## along with pyNastran.  If not, see <http://www.gnu.org/licenses/>.
00024 ## 
00025 
00026 from __future__ import division, print_function
00027 
00028 from numpy import radians, abs, angle #,sin, cos
00029 #from math import radians
00030 from cmath import rect #polar
00031 
00032 def polarToRealImag(mag, phase):
00033     """
00034     Converts magnitude-phase to real-imaginary
00035     so all complex results are consistent
00036     @param mag magnitude c^2
00037     @param phase phase angle phi (degrees; theta)
00038     @retval realValue the real component a of a+bi
00039     @retval imagValue the imaginary component b of a+bi
00040     """
00041     return rect(mag,radians(phase))
00042     #realValue = mag*cos(radians(phase)) # phase in degrees
00043     #imagValue = mag*sin(radians(phase))
00044     #return complex(realValue, imagValue)
00045 
00046 def realImagToMagPhase(realImag):
00047     """returns the magnitude and phase (degrees) of a complex number"""
00048     return abs(realImag), angle(realImag, deg=True)
 All Classes Namespaces Files Functions Variables