<commit_before>'''
Collection of geodesy/pyproj algorithms for PyRate.
Author:  <NAME>
Created: 13/3/13
'''


from math import floor

import pyproj


def utm_zone(longitude):
	'''Returns basic UTM zone for given longitude in degrees. Currently does NOT
	handle the sub-zoning around Scandanavian countries.
	See http://www.dmap.co.uk/utmworld.htm
	'''
	if longitude == 180:
		return 60.0
	return floor((longitude + 180)/6.0) + 1


def cell_size(lat, lon, x_step, y_step):
	'''Converts X|Y_STEP in degrees to X & Y cell length/width in metres.
	lat - latitude in degrees
	lon - longitude in degrees
	x_step - horizontal step size in degrees
	y_step - vertical step size in degrees
	'''
	if lat > 84.0 or lat < -80:
		msg = "No UTM zone for polar region: > 84 degrees N or < 80 degrees S"
		raise ValueError(msg)

	zone = utm_zone(lon)
	p0 = pyproj.Proj(proj='latlong', ellps='WGS84')
	p1 = pyproj.Proj(proj='utm', zone=zone, ellps='WGS84')
	assert p0.is_latlong()
	assert not p1.is_latlong()

	x0, y0 = pyproj.transform(p0, p1, lon, lat)
	x1, y1 = pyproj.transform(p0, p1, lon + x_step, lat + y_step)
	return (abs(e) for e in (x1 - x0, y1 - y0))<commit_msg>Fixed cell_size to return tuple instead of a generator.<commit_after>'''
Collection of geodesy/pyproj algorithms for PyRate.
Author:  <NAME>
Created: 13/3/13
'''


from math import floor

import pyproj


def utm_zone(longitude):
	'''Returns basic UTM zone for given longitude in degrees. Currently does NOT
	handle the sub-zoning around Scandanavian countries.
	See http://www.dmap.co.uk/utmworld.htm
	'''
	if longitude == 180:
		return 60.0
	return floor((longitude + 180)/6.0) + 1


def cell_size(lat, lon, x_step, y_step):
	'''Converts X|Y_STEP in degrees to X & Y cell length/width in metres.
	lat - latitude in degrees
	lon - longitude in degrees
	x_step - horizontal step size in degrees
	y_step - vertical step size in degrees
	'''
	if lat > 84.0 or lat < -80:
		msg = "No UTM zone for polar region: > 84 degrees N or < 80 degrees S"
		raise ValueError(msg)

	zone = utm_zone(lon)
	p0 = pyproj.Proj(proj='latlong', ellps='WGS84')
	p1 = pyproj.Proj(proj='utm', zone=zone, ellps='WGS84')
	assert p0.is_latlong()
	assert not p1.is_latlong()

	x0, y0 = pyproj.transform(p0, p1, lon, lat)
	x1, y1 = pyproj.transform(p0, p1, lon + x_step, lat + y_step)
	return tuple(abs(e) for e in (x1 - x0, y1 - y0))
{'fraction_non_alphanumeric': 0.12081390419669351, 'fraction_numerical': 0.03899957609156422, 'mean_word_length': 3.87603305785124, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4587504', 'n_tokens_mistral': 964, 'n_tokens_neox': 877, 'n_words': 293}