在R中绘制潮汐椭圆

时间:2017-08-01 14:22:49

标签: r ellipse drawellipse

我试图在R中绘制一个潮汐椭圆(使用东西风组件)。我在R中运行了我的代码,我认为它不包含任何错误。有没有人有经验在R中绘制潮汐椭圆?任何帮助将不胜感激。

我使用的是Mac和R控制台(版本3.4.1又称单烛)。我目前使用的Matlab代码是:



###East Components!!!!!!
library(TideHarmonics)
F<-file.choose()  
data<-read.csv(F) ###read tidal data
C<-coef(Out4,hc=TRUE,mat=TRUE) 
C
#####Assume input phase lags are in degrees and convert them to radians<-####PHIu=PHIu/180*pi 
####PHIv= PHIv/180*pi
PHIu<-C[5]####PHI is phase
Au<-C[1]###Amplitude
Av<-C[1] ####Amplitude
###Make complex amplitudes for u 
i<-sqrt(-1+0i) ####also sqrt(as.complex(-1))
u<-Au*exp(-i*PHIu) ####assign U


####North components!!!!
library(TideHarmonics)
FA<-file.choose()  
data<-read.csv(FA) 
CB<-coef(Out4,hc=TRUE,mat=TRUE) ####Shows available values 
CB
PHIv<-CB[5] ###Phase
Av<-CB[1] ####Amplitude
###Make complex amplitudes for u 
i<-sqrt(-1+0i) ####also sqrt(as.complex(-1)) 
v<-Av*exp(-i*PHIv) ###Assign V


wp<-(u+i*v)/2 ####Calculate complex radius of anti-clockwise
wm<-Conj(u-i*v)/2 ####Calculate complex radius of clockwise
####Anti-clockwise Circle amplitudes and angles
Wp<-abs(wp)
THETAp<-atan2(Im(wp), Re(wp)) ###corresponds to Matlab's angle function
Wp1<-Wp*exp(i*THETAp)

####Clockwise Circle amplitudes and angles
Wm<-abs(wm)
THETAm<-atan2(Im(wm), Re(wm)) ###corresponds to Matlab's angle function
Wm1<-Wm*exp(i*THETAm)

####calculate ep-parameters (ellipse parameters, in degrees)
SEMA<-Wp1+Wm1   ###Semi-Major Axis
SEMI<-Wp1-Wm1  ###Semi-Minor Axis
ECC<-SEMI/SEMA ####Eccentricity
PHA<-(THETAm-THETAp)/2 ####Phase Angle 
INC<-(THETAm+THETAp)/2  ###INclination 

###convert to degrees for output
PHAd<-PHA/pi*180 
INCd<-INC/pi*180
Thetapd<-THETAp/180*pi 
THETAmd<-THETAm/180*pi 

####Map resultant angles to range of [0,360]
PHAr<-mod(PHA+360, 360) ###PHAr<-PHA+360%%360
INCr<-INC+360%%360 ###INCr<-mod(INC+360,360) in Matlab
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

我建议您是否可以点击此链接,它会对您有所帮助: https://www.rdocumentation.org/packages/plotrix/versions/3.6-5/topics/draw.ellipse