Changes between Version 6 and Version 7 of shelf_thickness


Ignore:
Timestamp:
10/19/10 10:21:23 (14 years ago)
Author:
schodlok
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • shelf_thickness

    v6 v7  
    8787md.bed=md.surface-md.thickness;
    8888}}}
     89
     90 
     91== stereographic conversion part 1 ==
     92
     93{{{
     94#!m
     95  function [x,y] = map2ll(lat,lon,sgn) 
     96%     
     97% NAME:            map2ll
     98%===============================================================================   
     99%   
     100% USAGE:           [x,y] = map2ll(lat,lon,sgn)
     101%
     102% DESCRIPTION:
     103%                 Converts from geodetic latitude and longitude to Polar
     104%                 Stereographic (X,Y) coordinates for the polar regions.
     105%
     106% INPUT:   
     107%                 Lat         = Geodetic Latitude  (degrees, +90 to -90) 
     108%                 Lon         = Geodetic Longitude (degrees, 0 to 360)
     109%                 SGN         = Sign of latitude
     110%                                +1 : north latitude
     111%                                -1 : south latitude
     112%
     113%
     114% OUTPUT:         X  =  Polar Stereographic X Coordinate (km)
     115%                 Y  =  Polar Stereographic Y Coordinate (km)
     116%           
     117%
     118% AUTHOR:         The original equations are from Snyder, J. P.,
     119%                 1982,  Map Projections Used by the U.S. Geological Survey,
     120%                 Geological Survey Bulletin 1532, U.S. Government Printing
     121%                 Office.  See JPL Technical Memorandum 3349-85-101 for
     122%                 further details.
     123%
     124%                 Original FORTRAN program written by C. S. Morris,
     125%                 April 1985, Jet Propulsion Laboratory, California
     126%                 Institute of Technology
     127%
     128%                 IDL conversion by Helmut Schottmueller, September 1995,
     129%                 Institute for environmental physics, University of Bremen
     130%
     131%                 Matlab conversion by Michael P. Schodlok, December 2003,
     132%                 Alfred Wegener Institute for Polar and Marine Research, Bremerhaven
     133%
     134%                 Error correction for RHO: 1997-11-03 by LML
     135%====================================================================================
     136
     137%-------------
     138% CHECK INPUTS
     139%-------------
     140if nargin ~= 3
     141   error('map2ll.m: must pass 3 parameters lat, lon, hemisphere')
     142end %if
     143
     144% CHECK lat,lon,hems dimensions and verify consistent
     145[ma,na] = size(lat);
     146[mb,nb] = size(lon);
     147[mc,nc] = size(sgn);
     148
     149% CHECK THAT lat & lon HAVE SAME SHAPE
     150if (ma~=mb) | (na~=nb)
     151   error('check dims: lat & lon must have same dimensions')
     152end %if
     153
     154% CHECK THAT sgn IS A SCALAR
     155if     (mc~=1  & np~=1 )
     156   error('check sgn: sgn is either 1 or -1')
     157end %if   
     158
     159
     160%======
     161% BEGIN
     162%======
     163
     164
     165% Conversion constant from degrees to radians
     166  cde  = 57.29577951;
     167% Standard latitude for the SSM/I grid with no distorsion
     168  slat = 70.;
     169% Radius of the earth in kilometers
     170  re   = 6378.273;
     171% Eccentricity of the Hughes ellipsoid squared
     172  ex2   = .006693883;
     173% Eccentricity of the Hughes ellipsoid
     174  ex    =  sqrt(ex2);
     175 
     176  if sgn == 1
     177    delta = 45.;
     178  else
     179    delta = 0.0;
     180  end %if
     181
     182  latitude  = abs(lat) * pi/180.;
     183  longitude = (lon + delta) * pi/180.;
     184 
     185% compute X and Y in grid coordinates.
     186  T = tan(pi/4-latitude/2) ./ ((1-ex*sin(latitude))./(1+ex*sin(latitude))).^(ex/2);
     187
     188   if (90 - slat) <  1.e-5
     189    rho = 2.*re*T/sqrt((1.+ex)^(1.+ex)*(1.-ex)^(1.-ex));
     190   else
     191    sl  = slat*pi/180.;
     192    tc  = tan(pi/4.-sl/2.)/((1.-ex*sin(sl))/(1.+ex*sin(sl)))^(ex/2.);
     193    mc  = cos(sl)/sqrt(1.0-ex2*(sin(sl)^2));
     194    rho = re*mc*T/tc;
     195   end % if
     196 
     197 
     198  y = -rho .* sgn .* cos(sgn.*longitude);
     199  x =  rho .* sgn .* sin(sgn.*longitude);
     200
     201  [cnt1,cnt2] = find(latitude >= pi / 2.);
     202 
     203 if cnt1
     204   x(cnt1,1) = 0.0
     205   y(cnt1,1) = 0.0
     206 end %if
     207
     208 return
     209%=========================================================================
     210
     211}}}
     212
     213== stereographic conversion part 2 ==
     214
     215   function [lat,lon] = map2xy(x,y,sgn)
     216%     
     217% NAME:            map2xy
     218%===============================================================================   
     219%   
     220% USAGE:           [lat,lon] = map2xy(x,y,sgn)
     221%   
     222% DESCRIPTION:
     223%                 Converts from geodetic latitude and longitude to Polar
     224%                 Stereographic (X,Y) coordinates for the polar regions.
     225%
     226% INPUT:
     227%                 X  =  Polar Stereographic X Coordinate (km)
     228%                 Y  =  Polar Stereographic Y Coordinate (km)   
     229%                 SGN         = Sign of latitude
     230%                                +1 : north latitude
     231%                                -1 : south latitude
     232%
     233%
     234% OUTPUT:         
     235%                 Lat         = Geodetic Latitude  (degrees, +90 to -90) 
     236%                 Lon         = Geodetic Longitude (degrees, 0 to 360)
     237%           
     238%
     239% AUTHOR:         The original equations are from Snyder, J. P.,
     240%                 1982,  Map Projections Used by the U.S. Geological Survey,
     241%                 Geological Survey Bulletin 1532, U.S. Government Printing
     242%                 Office.  See JPL Technical Memorandum 3349-85-101 for
     243%                 further details.
     244%
     245%                 Original FORTRAN program written by C. S. Morris,
     246%                 April 1985, Jet Propulsion Laboratory, California
     247%                 Institute of Technology
     248%
     249%                 IDL conversion by Helmut Schottmueller, September 1995,
     250%                 Institute for environmental physics, University of Bremen
     251%
     252%                 Matlab conversion by Michael P. Schodlok, December 2003,
     253%                 Alfred Wegener Institute for Polar and Marine Research, Bremerhaven
     254%
     255%                 Error correction for RHO: 1997-11-03 by LML
     256%====================================================================================
     257
     258%-------------
     259% CHECK INPUTS
     260%-------------
     261if nargin ~= 3
     262   error('map2ll.m: must pass 3 parameters lat, lon, hemisphere')
     263end %if
     264
     265% CHECK lat,lon,hems dimensions and verify consistent
     266[ma,na] = size(x);
     267[mb,nb] = size(y);
     268[mc,nc] = size(sgn);
     269
     270% CHECK THAT lat & lon HAVE SAME SHAPE
     271if (ma~=mb) | (na~=nb)
     272   error('check dims: lat & lon must have same dimensions')
     273end %if
     274
     275% CHECK THAT sgn IS A SCALAR
     276if     (mc~=1  & np~=1 )
     277   error('check sgn: sgn is either 1 or -1')
     278end %if   
     279
     280
     281%======
     282% BEGIN
     283%======
     284
     285
     286% Conversion constant from degrees to radians
     287  cde  = 57.29577951;
     288% Standard latitude for the SSM/I grid with no distorsion
     289  slat = 70.;
     290% Radius of the earth in kilometers
     291  re   = 6378.273;
     292% Eccentricity of the Hughes ellipsoid squared
     293  ex2   = .006693883;
     294% Eccentricity of the Hughes ellipsoid
     295  ex    =  sqrt(ex2);
     296
     297  if sgn == 1
     298    delta = 45.;
     299  else
     300    delta = 0.0;
     301  end %if
     302 
     303 
     304  sl  = slat*pi/180.;
     305  rho = sqrt(x.^2 + y.^2);
     306  cm = cos(sl) / sqrt(1.0 - ex2 * (sin(sl)^2));
     307  T = tan((pi / 4.0) - (sl / 2.0)) / ((1.0 - ex * sin(sl)) / (1.0 + ex * sin(sl)))^(ex / 2.0);
     308 
     309  if  abs(slat-90.) < 1.e-5
     310    T = rho * sqrt((1. + ex)^(1. + ex) * (1. - ex)^(1. - ex)) / 2. / re;
     311  else
     312    T = rho * T / (re * cm);
     313  end %if
     314 
     315  chi = (pi / 2.0) - 2.0 * atan(T);
     316  lat = chi + ((ex2 / 2.0) + (5.0 * ex2^2.0 / 24.0) + (ex2^3.0 / 12.0)) * ...
     317         sin(2 * chi) + ((7.0 * ex2^2.0 / 48.0) + (29.0 * ex2^3 / 240.0)) * ...
     318         sin(4.0 * chi) + (7.0 * ex2^3.0 / 120.0) * sin(6.0 * chi) ;
     319
     320  lat = sgn * lat;
     321  lon = atan2(sgn * x,-sgn * y);
     322  lon = sgn * lon;
     323 
     324  [res1,res2] = find(rho <= 0.1);
     325  if res1
     326    lat(res1,1) = 90. * sgn;
     327    lon(res1,1) = 0.0;
     328  end %if
     329
     330  lon = lon * 180. / pi;
     331  lat = lat * 180. / pi;
     332  lon = lon - delta;
     333 
     334 return
     335%=========================================================================
     336 
     337}}}
     338
     339