0
我試圖在R中繪製潮汐橢圓(使用東風和西風分量)。我已經在R中運行我的代碼,我不認爲它包含任何錯誤。有沒有人在R中繪製潮汐橢圓的經驗?任何幫助將不勝感激。在R中繪製潮汐橢圓
我使用Mac和R控制檯(版本3.4.1 aka單蠟燭)。 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
包括你已經嘗試了什麼,使代碼我們可以告訴你如何解決或改進它。 – yanman1234
@ yanman1234 Woops,我現在已將代碼添加到我的帖子中。 :) –