<jupyter_start><jupyter_text>dep.py<jupyter_code>grd_fname = None

f = open(dfname, 'r')
lines = f.readlines()

if '\t' in lines[0]:
    delimiter = '\t'
else:
    delimiter = 'space'
print('Delimiter = %s' % delimiter)


z = []

if delimiter != 'space':
    for line in lines:
        for s in line.split('%s' % delimiter):
            z.append(float(s))
else:
    for line in lines:
        for s in line.split():
            z.append(float(s))

# Reshape depth
if grd_fname:
    grid = grd.grd()
    grid.read_grd(grd_fname)
    z = np.ma.masked_equal(z, -999.)
    z = np.ma.compressed(z)
    z = np.reshape(z, (grid.m, grid.n))
else:
    if delimiter != 'space':
        z = np.reshape(z, (np.size(lines),
            np.size(line.split('%s' % delimiter))))
        z = z[:-1, :-1] # get rid of -999. Nans
        z = np.reshape(z, (np.size(lines)-1, np.size(line.split())-1))

        z = z[:-1, :-1] # get rid of -999. Nans
    else:
        a = np.where(np.array(z) == -999.)
        cols = np.max(np.ediff1d(a))
        rows = np.size(np.array_split(a[0],np.where(np.diff(a[0])!=1)[0]+1))
        z = np.reshape(z, (rows, cols))
np.shape(z)<jupyter_output><empty_output><jupyter_text>Test functionality<jupyter_code>sedanka_grid = grd.grd()
sedanka_depth = dep.dep()

sedanka_grid.read_grd(gfname)
sedanka_depth.read_dep(dfname)
sedanka_depth = dep(dfname, gfname)
sedanka_depth.plot_dep()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18067226890756302, 'fraction_numerical': 0.01750700280112045, 'mean_word_length': 2.915068493150685, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '133333', 'license': 'MIT', 'n_tokens_mistral': 613, 'n_tokens_neox': 598, 'n_words': 111, 'path': 'dev/notebooks/.ipynb_checkpoints/read and plot grid and depth-checkpoint.ipynb', 'repo_name': 'spmls/pydelft', 'size': '1428'}