Home > matutils > sunposmjd.m

sunposmjd

PURPOSE ^

%%%%%%

SYNOPSIS ^

function sunupdown=sunUpDown(datemjd,lat,long,buffer)

DESCRIPTION ^

%%%%%%
function that returns 1 if the sun is up and 0 if the sun is down for a
given lat long (in degrees) and mjd CJC 18/5/2010
Inputs datemjd
 latitude (degrees)
 longitude (degrees)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function sunupdown=sunUpDown(datemjd,lat,long,buffer)
0002 %%%%%%%
0003 %function that returns 1 if the sun is up and 0 if the sun is down for a
0004 %given lat long (in degrees) and mjd CJC 18/5/2010
0005 %Inputs datemjd
0006 % latitude (degrees)
0007 % longitude (degrees)
0008 [year,month,day,hour,minute,second]=mjd2date(datemjd);
0009 
0010 date = datenum(year,month,day,hour,minute,second);
0011 [rhr,rmin,shr,smin]=sunrise(day,month,year,lat,long);
0012 sunupdown=1;
0013 hourd=hour;
0014 mind=minute;
0015 timed = hourd+mind/60;
0016 time_rise = rhr+rmin/60;
0017 time_set = shr+smin/60;
0018 %buffer = 0; %interval after and before sunrise to use as data points
0019 time_up=mod(time_set-time_rise,24);
0020 time_diff = (mod(timed-time_rise-buffer/60,24));
0021 
0022 if (time_diff<=time_up+buffer/60)
0023     sunupdown = 1;
0024 else
0025     sunupdown=0;
0026 end

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005