private static double getShoMag(Location loc, Astro astro, InternalTimeType type) {
		double lhour, M, sidG, ra0 = astro.getRa()[0], ra2 = astro.getRa()[2];
		double A, B, H, sunAlt, R, tH;
		
		double part1 = Math.sin(Utils.degToRad(loc.getDegreeLat()))
		* Math.sin(Utils.degToRad(astro.getDec()[1]));
		double part2a = Utils.CENTER_OF_SUN_ANGLE;
		double part2 = Math.sin(Utils.degToRad(part2a)) - part1;
		double part3 = Math.cos(Utils.degToRad(loc.getDegreeLat()))
		* Math.cos(Utils.degToRad(astro.getDec()[1]));
		
		double part4 = part2 / part3;
		
		if (part4 <= -1 || part4 >= 1)
			return 99;
		
		lhour = AstroLib.limitAngle180((Utils.radToDeg(Math.acos(part4))));
		M = ((astro.getRa()[1] - loc.getDegreeLong() - astro.getSid()[1]) / 360.0);
		
		if (type == InternalTimeType.SUNRISE)
			M = M - (lhour / 360.0);
		if (type == InternalTimeType.MAGHRIB)
			M = M + (lhour / 360.0);
		
		M = AstroLib.limitAngle111(M);
		
		sidG = AstroLib.limitAngle(astro.getSid()[1] + 360.985647 * M);
		
		ra0 = astro.getRa()[0];
		ra2 = astro.getRa()[2];
		
		if (astro.getRa()[1] > 350 && astro.getRa()[2] < 10)
			ra2 += 360;
		if (astro.getRa()[0] > 350 && astro.getRa()[1] < 10)
			ra0 = 0;
		
		A = astro.getRa()[1]
		                  + (M
		                		  * ((astro.getRa()[1] - ra0) + (ra2 - astro.getRa()[1]) + ((ra2 - astro
		                				  .getRa()[1]) - (astro.getRa()[1] - ra0))
		                				  * M) / 2.0);
		
		B = astro.getDec()[1]
		                   + (M
		                		   * ((astro.getDec()[1] - astro.getDec()[0])
		                				   + (astro.getDec()[2] - astro.getDec()[1]) + ((astro
		                						   .getDec()[2] - astro.getDec()[1]) - (astro
		                								   .getDec()[1] - astro.getDec()[0]))
		                								   * M) / 2.0);
		
		H = AstroLib.limitAngle180between(sidG + loc.getDegreeLong() - A);
		
		tH = H - Utils.radToDeg(astro.getDra()[1]);
		
		sunAlt = Utils.radToDeg(Math.asin(Math.sin(Utils.degToRad(loc
				.getDegreeLat()))
				* Math.sin(Utils.degToRad(B))
				+ Math.cos(Utils.degToRad(loc.getDegreeLat()))
				* Math.cos(Utils.degToRad(B))
				* Math.cos(Utils.degToRad(tH))));
		
		sunAlt += AstroLib.getRefraction(loc, sunAlt);
		
		R = (M + ((sunAlt - Utils.CENTER_OF_SUN_ANGLE + (Utils.ALTITUDE_REFRACTION * Math
				.pow(loc.getSeaLevel(), 0.5))) / (360.0
						* Math.cos(Utils.degToRad(B))
						* Math.cos(Utils.degToRad(loc.getDegreeLat())) * Math
						.sin(Utils.degToRad(tH)))));
		
		return (R * 24.0);
		
	}