def collect_nonperiodic_features(<EOL>featuresdir,<EOL>magcol,<EOL>outfile,<EOL>pklglob='<STR_LIT>',<EOL>featurestouse=NONPERIODIC_FEATURES_TO_COLLECT,<EOL>maxobjects=None,<EOL>labeldict=None,<EOL>labeltype='<STR_LIT>',<EOL>):
<EOL>pklist = glob.glob(os.path.join(featuresdir, pklglob))<EOL>if maxobjects:<EOL><INDENT>pklist = pklist[:maxobjects]<EOL><DEDENT>if TQDM:<EOL><INDENT>listiterator = tqdm(pklist)<EOL><DEDENT>else:<EOL><INDENT>listiterator = pklist<EOL><DEDENT>feature_dict = {'<STR_LIT>':[],'<STR_LIT>':magcol, '<STR_LIT>':[]}<EOL>LOGINFO('<STR_LIT>' % magcol)<EOL>for pkl in listiterator:<EOL><INDENT>with open(pkl,'<STR_LIT:rb>') as infd:<EOL><INDENT>varf = pickle.load(infd)<EOL><DEDENT>objectid = varf['<STR_LIT>']<EOL>if objectid not in feature_dict['<STR_LIT>']:<EOL><INDENT>feature_dict['<STR_LIT>'].append(objectid)<EOL><DEDENT>thisfeatures = varf[magcol]<EOL>if featurestouse and len(featurestouse) > <NUM_LIT:0>:<EOL><INDENT>featurestoget = featurestouse<EOL><DEDENT>else:<EOL><INDENT>featurestoget = NONPERIODIC_FEATURES_TO_COLLECT<EOL><DEDENT>for feature in featurestoget:<EOL><INDENT>if ((feature not in feature_dict['<STR_LIT>']) and<EOL>(feature in thisfeatures)):<EOL><INDENT>feature_dict['<STR_LIT>'].append(feature)<EOL>feature_dict[feature] = []<EOL><DEDENT>if feature in thisfeatures:<EOL><INDENT>feature_dict[feature].append(<EOL>thisfeatures[feature]<EOL>)<EOL><DEDENT><DEDENT><DEDENT>for feat in feature_dict['<STR_LIT>']:<EOL><INDENT>feature_dict[feat] = np.array(feature_dict[feat])<EOL><DEDENT>feature_dict['<STR_LIT>'] = np.array(feature_dict['<STR_LIT>'])<EOL>feature_array = np.column_stack([feature_dict[feat] for feat in<EOL>feature_dict['<STR_LIT>']])<EOL>feature_dict['<STR_LIT>'] = feature_array<EOL>if isinstance(labeldict, dict):<EOL><INDENT>labelarray = np.zeros(feature_dict['<STR_LIT>'].size, dtype=np.int64)<EOL>for ind, objectid in enumerate(feature_dict['<STR_LIT>']):<EOL><INDENT>if objectid in labeldict:<EOL><INDENT>if labeltype == '<STR_LIT>':<EOL><INDENT>if labeldict[objectid]:<EOL><INDENT>labelarray[ind] = <NUM_LIT:1><EOL><DEDENT><DEDENT>elif labeltype == '<STR_LIT>':<EOL><INDENT>labelarray[ind] = labeldict[objectid]<EOL><DEDENT><DEDENT><DEDENT>feature_dict['<STR_LIT>'] = labelarray<EOL><DEDENT>feature_dict['<STR_LIT>'] = {'<STR_LIT>':pklglob,<EOL>'<STR_LIT>':featurestouse,<EOL>'<STR_LIT>':maxobjects,<EOL>'<STR_LIT>':labeltype}<EOL>with open(outfile,'<STR_LIT:wb>') as outfd:<EOL><INDENT>pickle.dump(feature_dict, outfd, pickle.HIGHEST_PROTOCOL)<EOL><DEDENT>return feature_dict<EOL>
This collects variability features into arrays for use with the classifer.

    Parameters
    ----------

    featuresdir : str
        This is the directory where all the varfeatures pickles are. Use
        `pklglob` to specify the glob to search for. The `varfeatures` pickles
        contain objectids, a light curve magcol, and features as dict
        key-vals. The :py:mod:`astrobase.lcproc.lcvfeatures` module can be used
        to produce these.

    magcol : str
        This is the key in each varfeatures pickle corresponding to the magcol
        of the light curve the variability features were extracted from.

    outfile : str
        This is the filename of the output pickle that will be written
        containing a dict of all the features extracted into np.arrays.

    pklglob : str
        This is the UNIX file glob to use to search for varfeatures pickle files
        in `featuresdir`.

    featurestouse : list of str
        Each varfeatures pickle can contain any combination of non-periodic,
        stellar, and periodic features; these must have the same names as
        elements in the list of strings provided in `featurestouse`.  This tries
        to get all the features listed in NONPERIODIC_FEATURES_TO_COLLECT by
        default. If `featurestouse` is provided as a list, gets only the
        features listed in this kwarg instead.

    maxobjects : int or None
        The controls how many pickles from the featuresdir to process. If None,
        will process all varfeatures pickles.

    labeldict : dict or None
        If this is provided, it must be a dict with the following key:val list::

            '<objectid>':<label value>

        for each objectid collected from the varfeatures pickles. This will turn
        the collected information into a training set for classifiers.

        Example: to carry out non-periodic variable feature collection of fake
        LCS prepared by :py:mod:`astrobase.fakelcs.generation`, use the value
        of the 'isvariable' dict elem from the `fakelcs-info.pkl` here, like
        so::

            labeldict={x:y for x,y in zip(fakelcinfo['objectid'],
                                          fakelcinfo['isvariable'])}

    labeltype : {'binary', 'classes'}
        This is either 'binary' or 'classes' for binary/multi-class
        classification respectively.

    Returns
    -------

    dict
        This returns a dict with all of the features collected into np.arrays,
        ready to use as input to a scikit-learn classifier.