<commit_before>
def readFVCOM(file, varList, noisy=False):
    """
    Read in the FVCOM results file and spit out numpy arrays for
    each of the variables.
    """

    from netCDF4 import Dataset, MFDataset

    rootgrp = Dataset(file, 'r')
    mfdata = MFDataset(file)

    if noisy:
        print "File format: " + rootgrp.file_format

    FVCOM = {}
    for key, var in rootgrp.variables.items():
        if noisy:
            print 'Found ' + key,

        if key in varList:
            if noisy:
                print '(extracted)'
            FVCOM[key] = mfdata.variables[key][:]
        else:
            if noisy:
                print

    return FVCOM

def getSurfaceElevation(Z, idx):
    """
    Extract the surface elevation from Z at index ind. If ind is multiple
    values, extract and return the surface elevations at all those locations.

    Z is usually extracted from the dict created when using readFVCOM() on a
    NetCDF file.

    """

    import numpy as np

    nt, nx = np.shape(Z)

    surfaceElevation = np.empty([nt,np.shape(idx)[0]])
    for cnt, i in enumerate(idx):
        surfaceElevation[:,cnt] = Z[:,i]

    return surfaceElevation<commit_msg>Removed the MFDataset usage and instead use only Dataset to read the NetCDF output. This way both input files generated by MATLAB and output files generated by FVCOM can both be read by readFVCOM<commit_after>
def readFVCOM(file, varList, noisy=False):
    """
    Read in the FVCOM results file and spit out numpy arrays for
    each of the variables.
    """

    from netCDF4 import Dataset

    rootgrp = Dataset(file, 'r')

    if noisy:
        print "File format: " + rootgrp.file_format

    FVCOM = {}
    for key, var in rootgrp.variables.items():
        if noisy:
            print 'Found ' + key,

        if key in varList:
            if noisy:
                print '(extracted)'
            FVCOM[key] = rootgrp.variables[key][:]
        else:
            if noisy:
                print

    return FVCOM

def getSurfaceElevation(Z, idx):
    """
    Extract the surface elevation from Z at index ind. If ind is multiple
    values, extract and return the surface elevations at all those locations.

    Z is usually extracted from the dict created when using readFVCOM() on a
    NetCDF file.

    """

    import numpy as np

    nt, nx = np.shape(Z)

    surfaceElevation = np.empty([nt,np.shape(idx)[0]])
    for cnt, i in enumerate(idx):
        surfaceElevation[:,cnt] = Z[:,i]

    return surfaceElevation
{'fraction_non_alphanumeric': 0.08541914978148589, 'fraction_numerical': 0.0015891934843067143, 'mean_word_length': 2.2743823146944084, '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': '620988', 'n_tokens_mistral': 787, 'n_tokens_neox': 737, 'n_words': 277}