
//=========================================================
//
// A whole slew of initialisation routines to gather basic data on date, solar position, etc
//
//=========================================================

function initialiseDatasets(init) {
  getUTCData (UTCDateCurr, UTCTimeCurr)
  calcDSTStartDayOfYear(UTCYear)
	calcDSTEndDayOfYear(UTCYear)
	getLSTData (UTCYear, UTCMonth, UTCDay, UTCDecimalHour)
  getLocalTimeData (UTCYear, UTCMonth, UTCDay, UTCDecimalHour, UTCDayOfYearDecimal)
  getLSTTomorrow(LocalYear, LocalMonth, LocalDay)
//=========================================================
//
// Get sunrise & set for today and tomorrow
//
//=========================================================
	
	calcSunRiseSet(LocalYear, LocalMonth, LocalDay, "Rise", SolarRiseSetElev)
	calcSunRiseSet(LocalYear, LocalMonth, LocalDay, "Set", SolarRiseSetElev)
	UTSunriseToday = UTSunrise
  UTSunsetToday = UTSunset
  LSTSunriseToday = UTSunrise + UTC_LSTOffset
  LSTSunsetToday = UTSunset + UTC_LSTOffset
  
	calcSunRiseSet(LocalYearTomorrow, LocalMonthTomorrow, LocalDayTomorrow, "Rise", SolarRiseSetElev)
	calcSunRiseSet(LocalYearTomorrow, LocalMonthTomorrow, LocalDayTomorrow, "Set", SolarRiseSetElev)
	UTSunriseTomorrow = UTSunrise
	UTSunsetTomorrow = UTSunset
	
//=========================================================
//
// Get first and last light for today and tomorrow
//
//=========================================================
	
	calcSunRiseSet(LocalYear, LocalMonth, LocalDay, "Rise", SolarFirstLastLightElev)
	calcSunRiseSet(LocalYear, LocalMonth, LocalDay, "Set", SolarFirstLastLightElev)
	UTFirstLightToday = UTSunrise
  UTLastLightToday = UTSunset
  
	calcSunRiseSet(LocalYearTomorrow, LocalMonthTomorrow, LocalDayTomorrow, "Rise", SolarFirstLastLightElev)
	calcSunRiseSet(LocalYearTomorrow, LocalMonthTomorrow, LocalDayTomorrow, "Set", SolarFirstLastLightElev)
	UTFirstLightTomorrow = UTSunrise
	UTLastLightTomorrow = UTSunset

//=========================================================
//
// Get current solar positions
//
//=========================================================
	
  calcSunTime(UTSunriseToday, UTSunsetToday, UTCDecimalHour) 
	calcSolarDecl(UTCJulianDay)
	calcSolarAltitude(SunDecl, SunTime, StationLat)
	calcSolarAzimuth(SunDecl, SunTime, StationLat)
	getMoonAge(UTCJulianDay)
	calcMaxSolar(SunAltitude)
	
	return}
	
	
