#main code that initial directories 

def create_dirs(home,project_name,overwrite=False):
    import os
    import shutil

    #check file/dir exist,otherwise mkdir
    if not(os.path.exists(home+'/'+project_name)):
        os.makedirs(home+'/'+project_name) #main dir
        os.makedirs(home+'/'+project_name+'/'+'waveforms') #put all the waveforms in here
        os.makedirs(home+'/'+project_name+'/'+'waveforms_template') #put all the waveforms in here
        os.makedirs(home+'/'+project_name+'/'+'stations') #put station table here (generated by data_proc.make_sta_table)
        os.makedirs(home+'/'+project_name+'/'+'structure') #put velocity model .mod file here
        main_REPEQ=os.environ['REPEQ'] #the uppest dir of the REPEQ
        shutil.copy(main_REPEQ+'/examples/model/example.mod',home+'/'+project_name+'/'+'structure/example.mod')
        os.makedirs(home+'/'+project_name+'/'+'catalog') #catalog file in USGS format
        os.makedirs(home+'/'+project_name+'/'+'output')
        os.makedirs(home+'/'+project_name+'/'+'output'+'/'+'Template_match')
        os.makedirs(home+'/'+project_name+'/'+'output'+'/'+'Template_match'+'/'+'Figs')
        os.makedirs(home+'/'+project_name+'/'+'output'+'/'+'Template_match'+'/'+'Measure_lag')
        os.makedirs(home+'/'+project_name+'/'+'output'+'/'+'Template_match'+'/'+'Detections')
        os.makedirs(home+'/'+project_name+'/'+'output'+'/'+'Template_match'+'/'+'Data_detection_cut') #data cut from daily waveforms
        os.makedirs(home+'/'+project_name+'/'+'output'+'/'+'Template_match'+'/'+'CCF_records')
        os.makedirs(home+'/'+project_name+'/'+'output'+'/'+'logs')
        shutil.copy(main_REPEQ+'/examples/notes/Format_log.txt',home+'/'+project_name+'/'+'output/logs/Format_log.txt')
        os.makedirs(home+'/'+project_name+'/'+'output'+'/'+'lags')

    else:
        if overwrite:
            print('Careful!!!!! do you really want to delete all the project?:%s'%(home+'/'+project_name))
            print('Too risky...Please delete them manually')
            return 1
        else:
            print('Directory already exist:%s'%(home+'/'+project_name))
            return 1

