I am trying to draw a tidal ellipse in R (using Eastern and Western wind components). I have run my code in R and I don't think it contains any errors. Does anyone have experience with graphing tidal ellipses in R? Any help would be greatly appreciated.
I am using a Mac and R Console (Version 3.4.1 aka Single Candle). The Matlab code that I have currently is:
###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
I suggest if you can follow this link, it will help you: https://www.rdocumentation.org/packages/plotrix/versions/3.6-5/topics/draw.ellipse