%% timut2ml2.m converts from univerisal time (UT) to local magnetic time.
%% Unlike my approximate method used in timut2ml.m, this method should
%% be exact. Magnetic local time is defined as (in degrees) 
%% MLT = 180 + geomagnetic longitude of point - geomagnetic longitude
%% of subsolar point. To determine the subsolar point, calculate the 
%% solar declination and from that determine its magnetic longitude. 
%% 

function timm=timut2ml2(timut,lonmatm,dno)

% timut = univerisal time
% lonmatm = magnetic longitude (rads)
% dno = day number matrix
% timm = local magnetic time of orbit

lonmats=longch(pi-(pi/12)*timut);               %geographic longitude of subsolar point 
dec=soco2(lonmats,timut,dno);                   %solar declination angle 
lonmatms=geo2mag3(lonmats,dec);                 %magnetic longitude of subsolar point
timm=12+(12/pi)*(lonmatm-lonmatms);             %magnetic local time of point of interest
timm=timch(timm);                               %corrected local time 0->24

