我正在尝试在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
我建议如果你能点击这个链接,它会帮助你: https://www.rdocumentation.org/packages/plotrix/versions/3.6-5/topics/draw.ellipse