source:
issm/oecreview/Archive/24684-25833/ISSM-25401-25402.diff
Last change on this file was 25834, checked in by , 4 years ago | |
---|---|
File size: 2.1 KB |
-
../trunk-jpl/src/m/contrib/adhikari/latelonge.m
1 function [late,longe] = latelonge(md_mesh) 2 %latelonge :: computes lat,long at elemental centroids on spherical surface 3 % 4 % Usage: 5 % [late,longe]=latelonge(md.mesh) 6 7 nv = md_mesh.numberofvertices; 8 if length(md_mesh.lat)~=nv | length(md_mesh.long)~=nv 9 error('lat,long not defined properly at vertices.'); 10 end 11 12 % lat -> [0,180]; long -> [0,360] to compute centroids 13 lat=90-md_mesh.lat; lon=md_mesh.long; 14 lon(lon<0)=180+(180+lon(lon<0)); 15 16 ax_0=lat(md_mesh.elements(:,1)); ay_0=lon(md_mesh.elements(:,1)); 17 bx_0=lat(md_mesh.elements(:,2)); by_0=lon(md_mesh.elements(:,2)); 18 cx_0=lat(md_mesh.elements(:,3)); cy_0=lon(md_mesh.elements(:,3)); 19 % find whether long is 0 or 360! This is important to compute centroids as well as elemental area 20 for ii=1:md_mesh.numberofelements 21 if (min([ay_0(ii),by_0(ii),cy_0(ii)])==0 && max([ay_0(ii),by_0(ii),cy_0(ii)])>180) 22 if ay_0(ii)==0 23 ay_0(ii)=360; 24 end 25 if by_0(ii)==0 26 by_0(ii)=360; 27 end 28 if cy_0(ii)==0 29 cy_0(ii)=360; 30 end 31 end 32 end 33 % correction at the north pole 34 ay_0(ax_0==0)=(by_0(ax_0==0)+cy_0(ax_0==0))./2; 35 by_0(bx_0==0)=(cy_0(bx_0==0)+ay_0(bx_0==0))./2; 36 cy_0(cx_0==0)=(ay_0(cx_0==0)+by_0(cx_0==0))./2; 37 % correction at the south pole 38 ay_0(ax_0==180)=(by_0(ax_0==180)+cy_0(ax_0==180))./2; 39 by_0(bx_0==180)=(cy_0(bx_0==180)+ay_0(bx_0==180))./2; 40 cy_0(cx_0==180)=(ay_0(cx_0==180)+by_0(cx_0==180))./2; 41 % 42 late=(ax_0+bx_0+cx_0)/3; 43 longe=(ay_0+by_0+cy_0)/3; 44 45 % bak to [-90 90] [-180 180] ranges. 46 late = 90-late; 47 longe(longe>180) = longe(longe>180)-360; 48 49
Note:
See TracBrowser
for help on using the repository browser.