Hello I am trying to convert the coordinates of Telemac2D results files but I am experiencing some difficulties. My model mesh is built in WGS84 coordinates, which is converted to Telemac mercator corrdinates in the CORRXY subroutine using the following code
DO I = 1 , N
X(I) = RADIUS*(X(I)-LON0)*DTR
Y(I) = RADIUS*( LOG(TAN(Y(I)*0.5D0*DTR+PI*0.25D0))
& -LOG(TAN(LAT0 *0.5D0*DTR+PI*0.25D0)))
ENDDO
I am then post processing the reults files to convert the Telemac mercator coordinates back to WGS84 using the following code which should just be the inverse of what was done previously
R=6371000
pi=3.14259
DTR=pi/180
RTD=180/pi
lon0=0
lat0=50
term2=R*log(tan(radians(lat0/2)+(pi/4)))
def x2lon(x):
lamda=lon0+degrees(x/R)
return lamda
def y2lat(y):
phi=(2*(arctan(exp((y+term2)/R))))-(pi/2)
phi=degrees(phi)
return phi
lono=x2lon(x)
lato=y2lat(y)
However this does not give a good coordinate conversion. I have tried changing the offset values (lon0 and lat0) and this does improve results however there is still a significant error. Has anyone had any experience with this and could you advise me where I might be going wrong?
Thanks
Olly