<commit_before>import pandas as pd

from monitorframe.monitor import BaseDataModel

from cosmo.filesystem import FileDataFinder
from cosmo import FILES_SOURCE
from cosmo.monitor_helpers import explode_df


class OSMDataModel(BaseDataModel):

    def get_data(self):
        header_keys = (
            'ROOTNAME', 'EXPSTART', 'DETECTOR', 'LIFE_ADJ', 'OPT_ELEM', 'CENWAVE', 'FPPOS', 'PROPOSID', 'OBSET_ID'
        )
        header_extensions = (0, 1, 0, 0, 0, 0, 0, 0, 0)

        data_keys = ('TIME', 'SHIFT_DISP', 'SHIFT_XDISP', 'SEGMENT')
        data_extensions = (1, 1, 1, 1)

        finder = FileDataFinder(
            FILES_SOURCE,
            '*lampflash*',
            header_keys,
            header_extensions,
            data_keys=data_keys,
            data_extensions=data_extensions
        )

        df = pd.DataFrame(finder.data_from_files())

        return explode_df(df, list(data_keys))<commit_msg>Add comments and docstring to OSMDataModel<commit_after>import pandas as pd

from monitorframe.monitor import BaseDataModel

from cosmo.filesystem import FileDataFinder
from cosmo import FILES_SOURCE
from cosmo.monitor_helpers import explode_df


class OSMDataModel(BaseDataModel):
    """Data model for all OSM Shift monitors."""

    def get_data(self):
        header_keys = (
            'ROOTNAME', 'EXPSTART', 'DETECTOR', 'LIFE_ADJ', 'OPT_ELEM', 'CENWAVE', 'FPPOS', 'PROPOSID', 'OBSET_ID'
        )
        header_extensions = (0, 1, 0, 0, 0, 0, 0, 0, 0)

        data_keys = ('TIME', 'SHIFT_DISP', 'SHIFT_XDISP', 'SEGMENT')
        data_extensions = (1, 1, 1, 1)

        # Find data from lampflash files
        finder = FileDataFinder(
            FILES_SOURCE,
            '*lampflash*',
            header_keys,
            header_extensions,
            data_keys=data_keys,
            data_extensions=data_extensions
        )

        df = pd.DataFrame(finder.data_from_files())

        return explode_df(df, list(data_keys))
{'fraction_non_alphanumeric': 0.10392256749872644, 'fraction_numerical': 0.013245033112582781, 'mean_word_length': 2.7056603773584906, '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': '1190252', 'n_tokens_mistral': 661, 'n_tokens_neox': 624, 'n_words': 150}