source: issm/oecreview/Archive/24684-25833/ISSM-25401-25402.diff

Last change on this file was 25834, checked in by Mathieu Morlighem, 4 years ago

CHG: added 24684-25833

File size: 2.1 KB
RevLine 
[25834]1Index: ../trunk-jpl/src/m/contrib/adhikari/latelonge.m
2===================================================================
3--- ../trunk-jpl/src/m/contrib/adhikari/latelonge.m (nonexistent)
4+++ ../trunk-jpl/src/m/contrib/adhikari/latelonge.m (revision 25402)
5@@ -0,0 +1,49 @@
6+function [late,longe] = latelonge(md_mesh)
7+%latelonge :: computes lat,long at elemental centroids on spherical surface
8+%
9+% Usage:
10+% [late,longe]=latelonge(md.mesh)
11+
12+nv = md_mesh.numberofvertices;
13+if length(md_mesh.lat)~=nv | length(md_mesh.long)~=nv
14+ error('lat,long not defined properly at vertices.');
15+end
16+
17+% lat -> [0,180]; long -> [0,360] to compute centroids
18+lat=90-md_mesh.lat; lon=md_mesh.long;
19+lon(lon<0)=180+(180+lon(lon<0));
20+
21+ax_0=lat(md_mesh.elements(:,1)); ay_0=lon(md_mesh.elements(:,1));
22+bx_0=lat(md_mesh.elements(:,2)); by_0=lon(md_mesh.elements(:,2));
23+cx_0=lat(md_mesh.elements(:,3)); cy_0=lon(md_mesh.elements(:,3));
24+% find whether long is 0 or 360! This is important to compute centroids as well as elemental area
25+for ii=1:md_mesh.numberofelements
26+ if (min([ay_0(ii),by_0(ii),cy_0(ii)])==0 && max([ay_0(ii),by_0(ii),cy_0(ii)])>180)
27+ if ay_0(ii)==0
28+ ay_0(ii)=360;
29+ end
30+ if by_0(ii)==0
31+ by_0(ii)=360;
32+ end
33+ if cy_0(ii)==0
34+ cy_0(ii)=360;
35+ end
36+ end
37+end
38+% correction at the north pole
39+ay_0(ax_0==0)=(by_0(ax_0==0)+cy_0(ax_0==0))./2;
40+by_0(bx_0==0)=(cy_0(bx_0==0)+ay_0(bx_0==0))./2;
41+cy_0(cx_0==0)=(ay_0(cx_0==0)+by_0(cx_0==0))./2;
42+% correction at the south pole
43+ay_0(ax_0==180)=(by_0(ax_0==180)+cy_0(ax_0==180))./2;
44+by_0(bx_0==180)=(cy_0(bx_0==180)+ay_0(bx_0==180))./2;
45+cy_0(cx_0==180)=(ay_0(cx_0==180)+by_0(cx_0==180))./2;
46+%
47+late=(ax_0+bx_0+cx_0)/3;
48+longe=(ay_0+by_0+cy_0)/3;
49+
50+% bak to [-90 90] [-180 180] ranges.
51+late = 90-late;
52+longe(longe>180) = longe(longe>180)-360;
53+
54+
55
56Property changes on: ../trunk-jpl/src/m/contrib/adhikari/latelonge.m
57___________________________________________________________________
58Added: svn:executable
59## -0,0 +1 ##
60+*
61\ No newline at end of property
Note: See TracBrowser for help on using the repository browser.