from importer import *

import os

def log_file_exists(plateifu):
    status_file_dir = os.path.join(
        os.environ['STELLARMASS_PCA_RESULTSDIR'], 'results',
        plateifu)

    return os.path.exists(os.path.join(status_file_dir, '{}.log'.format(plateifu)))

def write_log_file(plateifu, msg):
    '''write a log file
    '''
    status_file_dir = os.path.join(
        os.environ['STELLARMASS_PCA_RESULTSDIR'], 'results',
        plateifu)

    if not os.path.exists(status_file_dir):
        os.makedirs(status_file_dir)

    with open(os.path.join(status_file_dir, '{}.log'.format(plateifu)), 'w') as logf:
        logf.write(msg)



@@ -636,9 +636,376 @@
 e(msg)%0A%0A
-%0A
+def summary_remaining(drpall, group_col='ifudesignsize'): %0A    remaining = drpall%5B %0A        ~np.array(list(map(log_file_exists, drpall%5B'plateifu'%5D)))%5D %0A    ifusize_grps = remaining.group_by(group_col) %0A    print('remaining galaxies by %7B%7D'.format(group_col)) %0A    for k, g in zip(ifusize_grps.groups.keys, ifusize_grps.groups): %0A        print(k%5Bgroup_col%5D, ':', len(g))

add summarize remaining