<commit_before>
import unittest
import math
import numpy as np
from osgeo import gdal, osr, ogr


DEFAULT_EPSG = 32610 # UTM 10N

class WindowedTemplateTestCase(unittest.TestCase):





class ScarpTestCase(unittest.TestCase):


class MorletTestCase(unittest.TestCase):




def generate_synthetic_scarp(a, b, kt, nx, ny, de=1, sig2=0, theta=0):
    """ Generate DEM of synthetic scarp for testing """
    
    x = np.linspace(-nx/2, nx/2, num=nx)
    y = np.linspace(-ny/2, ny/2, num=ny)
    xv, yv = np.meshgrid(x, y)
    
    xrot = xv*np.cos(theta) + yv*np.sin(theta)
    yrot = -xv*np.sin(theta) + yv*np.cos(theta)
    

    z = -math.erf(yrot/(2*np.sqrt(kt))) + b*yrot
    z = z + sig2*np.random.randn(ny, nx)

    synthetic = dem.DEMGrid()
    geo_tranform = (0, de, 0, 0, 0, -de) 
    projection = osr.SpatialReference()
    projection.ImportFromEPSG(DEFAULT_EPSG)

    synthetic._griddata = z
    synthetic._georef_info.geo_transform = geo_transform
    synthetic._georef_info.projection = projection
    synthetic._georef_info.dx = de 
    synthetic._georef_info.dy = de 
    synthetic._georef_info.nx = nx 
    synthetic._georef_info.ny = ny
    synthetic._georef_info.xllcenter = 0 
    synthetic._georef_info.yllcenter = 0 

    return synthetic


<commit_msg>Refactor to set up synthetic DEM as DEMGrid<commit_after>
import dem
import unittest
import numpy as np
from scipy.special import erf
from osgeo import gdal, osr, ogr

DEFAULT_EPSG = 32610 # UTM 10N


class WindowedTemplateTestCase(unittest.TestCase):
    pass    


class ScarpTestCase(unittest.TestCase):
    pass

class MorletTestCase(unittest.TestCase):
    pass


def generate_synthetic_scarp(a, b, kt, x_max, y_max, de=1, sig2=0, theta=0):
    """ Generate DEM of synthetic scarp for testing """
    
    nx = 2*x_max/de
    ny = 2*y_max/de
    x = np.linspace(-x_max, x_max, num=nx)
    y = np.linspace(-y_max, y_max, num=ny)
    x, y = np.meshgrid(x, y)
    
    xrot = x*np.cos(theta) + y*np.sin(theta)
    yrot = -x*np.sin(theta) + y*np.cos(theta)

    z = -erf(yrot/(2*np.sqrt(kt))) + b*yrot
    z = z + sig2*np.random.randn(ny, nx)

    return set_up_grid(z, nx, ny, de) 

def set_up_grid(data, nx, ny, de):

    synthetic = dem.DEMGrid()
    geo_transform = (0, de, 0, 0, 0, -de) 
    projection = osr.SpatialReference()
    projection.ImportFromEPSG(DEFAULT_EPSG)

    synthetic._griddata = data 
    synthetic._georef_info.geo_transform = geo_transform
    synthetic._georef_info.projection = projection
    synthetic._georef_info.dx = de 
    synthetic._georef_info.dy = de 
    synthetic._georef_info.nx = nx 
    synthetic._georef_info.ny = ny
    synthetic._georef_info.xllcenter = 0 
    synthetic._georef_info.yllcenter = 0 

    return synthetic

{'fraction_non_alphanumeric': 0.11646586345381527, 'fraction_numerical': 0.01606425702811245, 'mean_word_length': 3.2546583850931676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '220906', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1068, 'n_words': 224}