


from math import atan, cos, radians, sin, tan

from .haversine_distance import haversine_distance

_lowercase      :      Union[str, Any]            =					6378137.0
_lowercase      :      Optional[int]            =					6356752.314245
_lowercase      :      Tuple            =					6378137


def 				lowerCamelCase__				(	A       :      float				,       A       :      float				,       A       :      float				,       A       :      float					):




						'''simple docstring'''






						UpperCAmelCase					    =     (AXIS_A - AXIS_B) / AXIS_A
						# Parametric latitudes
						# https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
						UpperCAmelCase					    =     atan((1 - flattening) * tan(radians(SCREAMING_SNAKE_CASE_					)					)					)
						UpperCAmelCase					    =     atan((1 - flattening) * tan(radians(SCREAMING_SNAKE_CASE_					)					)					)

						# Compute central angle between two points
						# using haversine theta. sigma =  haversine_distance / equatorial radius
						UpperCAmelCase					    =     haversine_distance(SCREAMING_SNAKE_CASE_				,       SCREAMING_SNAKE_CASE_				,       SCREAMING_SNAKE_CASE_				,       SCREAMING_SNAKE_CASE_					) / EQUATORIAL_RADIUS

						# Intermediate P and Q values
						UpperCAmelCase					    =     (b_lata + b_lata) / 2
						UpperCAmelCase					    =     (b_lata - b_lata) / 2

						# Intermediate X value
						# X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
						UpperCAmelCase					    =     (sin(SCREAMING_SNAKE_CASE_					) ** 2) * (cos(SCREAMING_SNAKE_CASE_					) ** 2)
						UpperCAmelCase					    =     cos(sigma / 2					) ** 2
						UpperCAmelCase					    =     (sigma - sin(SCREAMING_SNAKE_CASE_					)) * (x_numerator / x_demonimator)

						# Intermediate Y value
						# Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
						UpperCAmelCase					    =     (cos(SCREAMING_SNAKE_CASE_					) ** 2) * (sin(SCREAMING_SNAKE_CASE_					) ** 2)
						UpperCAmelCase					    =     sin(sigma / 2					) ** 2
						UpperCAmelCase					    =     (sigma + sin(SCREAMING_SNAKE_CASE_					)) * (y_numerator / y_denominator)

						return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (x_value + y_value)))


if __name__ == "__main__":
	import doctest

	doctest.testmod()









'''simple docstring'''



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowercase      :      List[str]            =					{
    """configuration_time_series_transformer""": [
        """TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """TimeSeriesTransformerConfig""",
    ],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowercase      :      Dict            =					[
	    """TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """TimeSeriesTransformerForPrediction""",
	    """TimeSeriesTransformerModel""",
	    """TimeSeriesTransformerPreTrainedModel""",
	]


if TYPE_CHECKING:
	from .configuration_time_series_transformer import (
	    TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    TimeSeriesTransformerConfig,
	)

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_time_series_transformer import (
		    TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TimeSeriesTransformerForPrediction,
		    TimeSeriesTransformerModel,
		    TimeSeriesTransformerPreTrainedModel,
		)

else:
	import sys

	_lowercase      :      Tuple            =					_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





