<commit_before>
import os
from astropy import log
from datetime import datetime

from .masking import pb_masking, signal_masking, common_beam_convolve
from .moments import make_moments


def run_pipeline(cube_name, output_folder, pb_file=None, pb_lim=0.5,
                 convolve_to_common_beam=False, combeam_kwargs={},
                 masking_kwargs={}, moment_kwargs={}):
    '''
    Mask and create moment arrays for a given PPV cube.
    '''

    if not os.path.exists(cube_name):
        raise IOError("Given cube name doesn't exist: {}".format(cube_name))

    # if not os.path.exists(output_folder):
    #     os.mkdir(output_folder)
    # else:
    #     inp = raw_input("This path already exists! To proceed and overwrite"
    #                     " files, enter 'y':")
    #     if inp != 'y':
    #         raise OSError("Remove the folder {} before running."
    #                       .format(output_folder))

    tstamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    log.info("Starting PB masking at {}".format(tstamp))
    if pb_file is None:
        log.info("No PB file given. No PB masking applied.")
        cube_name_pbmask = cube_name
    else:
        pb_masking(cube_name, pb_file, pb_lim, output_folder)
        cube_name_pbmask = \
            "{0}.pbcov_gt_{1}_masked.fits".format(cube_name.rstrip(".fits"),
                                                  pb_lim)<commit_msg>Skip pbmask if it already exists<commit_after>
import os
from astropy import log
from datetime import datetime

from .masking import pb_masking, signal_masking, common_beam_convolve
from .moments import make_moments


def run_pipeline(cube_name, output_folder, pb_file=None, pb_lim=0.5,
                 convolve_to_common_beam=False, combeam_kwargs={},
                 masking_kwargs={}, moment_kwargs={}):
    '''
    Mask and create moment arrays for a given PPV cube.
    '''

    if not os.path.exists(cube_name):
        raise IOError("Given cube name doesn't exist: {}".format(cube_name))

    # if not os.path.exists(output_folder):
    #     os.mkdir(output_folder)
    # else:
    #     inp = raw_input("This path already exists! To proceed and overwrite"
    #                     " files, enter 'y':")
    #     if inp != 'y':
    #         raise OSError("Remove the folder {} before running."
    #                       .format(output_folder))

    tstamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    log.info("Starting PB masking at {}".format(tstamp))
    if pb_file is None:
        log.info("No PB file given. No PB masking applied.")
        cube_name_pbmask = cube_name
    else:
        cube_name_pbmask = \
            "{0}.pbcov_gt_{1}_masked.fits".format(cube_name.rstrip(".fits"),
                                                  pb_lim)

        if os.path.exists(cube_name_pbmask):
            log.info("PB masked cube already exists")
        else:
            pb_masking(cube_name, pb_file, pb_lim, output_folder)
{'fraction_non_alphanumeric': 0.11238609517381033, 'fraction_numerical': 0.0026999662504218697, 'mean_word_length': 2.3378378378378377, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1971404', 'n_tokens_mistral': 969, 'n_tokens_neox': 930, 'n_words': 226}