#cp docheckups.py do_vary_fittedcortical.py
import sys
import os
from os.path import exists

#mystrs = 'python3 sim_mmns_2pm_sep_savespikesonly.py 40 0.3 140 120 25.0 40.0 100.0 0.0 0.0 0.0 30.0 30.0 1000 0.0 0.9 10.0 10.0 10.0 140.0'.split(' ')
goodOnes = ['python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 150 130 17.5 30.0 80.0 5.827500000000001 9.99 26.64 35.0 35.0 1000 0.0 0.95 10.0 10.0 10.0 250.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 150 130 17.5 30.0 80.0 5.827500000000001 9.99 26.64 35.0 35.0 1000 0.0 0.9 10.0 10.0 10.0 250.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 150 130 17.5 30.0 80.0 5.827500000000001 9.99 26.64 30.0 30.0 1000 0.0 0.95 10.0 10.0 10.0 250.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 150 130 17.5 30.0 80.0 5.827500000000001 9.99 26.64 30.0 30.0 1000 0.0 0.9 10.0 10.0 10.0 250.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 150 130 17.5 30.0 80.0 5.827500000000001 9.99 26.64 25.0 25.0 1000 0.0 0.95 10.0 10.0 10.0 250.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 150 130 17.5 30.0 80.0 5.827500000000001 9.99 26.64 25.0 25.0 1000 0.0 0.9 10.0 10.0 10.0 250.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 150 130 17.5 30.0 80.0 5.827500000000001 9.99 26.64 20.0 20.0 1000 0.0 0.9 10.0 10.0 10.0 250.0 ',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 150 130 17.5 30.0 80.0 5.827500000000001 9.99 26.64 15.0 15.0 1000 0.0 0.95 10.0 10.0 10.0 250.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 150 130 17.5 30.0 80.0 5.827500000000001 9.99 26.64 15.0 15.0 1000 0.0 0.9 10.0 10.0 10.0 250.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 140 120 17.5 30.0 80.0 5.827500000000001 9.99 26.64 35.0 35.0 1000 0.0 0.9 10.0 10.0 10.0 250.0 ',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 140 120 17.5 30.0 80.0 5.827500000000001 9.99 26.64 30.0 30.0 1000 0.0 0.9 10.0 10.0 10.0 250.0 ',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 140 120 17.5 30.0 80.0 5.827500000000001 9.99 26.64 10.0 10.0 1000 0.0 0.9 10.0 10.0 10.0 250.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 125 105 17.5 40.0 140.0 5.827500000000001 13.32 46.620000000000005 25.0 25.0 1000 0.0 0.9 10.0 10.0 10.0 250.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 125 105 17.5 40.0 140.0 5.827500000000001 13.32 46.620000000000005 10.0 10.0 1000 0.0 0.9 10.0 10.0 10.0 250.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 125 105 17.5 40.0 100.0 5.827500000000001 13.32 33.300000000000004 25.0 25.0 1000 0.0 0.9 10.0 10.0 10.0 200.0',
            'python3 sim_mmns_2pm_sep_noISDIDD_savespikesonly.py 40 0.3 125 105 17.5 40.0 100.0 5.827500000000001 13.32 33.300000000000004 10.0 10.0 1000 0.0 0.9 10.0 10.0 10.0 200.0'] 

imodel = 0
myseed = 1
if len(sys.argv) > 1:
  imodel = int(sys.argv[1])%16
  myseed = 1 + int(int(sys.argv[1])/16)

attrs = goodOnes[imodel].split(' ')

gcortAMPAs = [2000.0, 3000.0, 4000.0, 5000.0, 6000.0]
noiseCoeffs = [1000.0,1250.0,1500.0,1750.0,2000.0,2250.0,2500.0]

NMDA_AMPAratio = float(attrs[10])/float(attrs[7])
for igcortAMPA in range(0,len(gcortAMPAs)):
  for inoiseCoeff in range(0,len(noiseCoeffs)):
    myseedAdd = '' if myseed == 1 else '_seed'+str(myseed)
    if exists('MMNs_2pm_sep_noISDIDD_limtau_CTRL_gcortAMPA'+str(gcortAMPAs[igcortAMPA])+'_noise'+str(noiseCoeffs[inoiseCoeff])+'_model'+str(imodel)+myseedAdd+'.mat'):
      print('MMNs_2pm_sep_noISDIDD_limtau_CTRL_gcortAMPA'+str(gcortAMPAs[igcortAMPA])+'_noise'+str(noiseCoeffs[inoiseCoeff])+'_model'+str(imodel)+myseedAdd+'.mat exist')
      continue
    these_attrs = attrs[:]
    these_attrs[1] = 'sim_mmns_2pm_sep_noISDIDD_withnoisyfittedcortical_savespikesonly_limtau.py'
    these_attrs.insert(9,str(gcortAMPAs[igcortAMPA]))
    these_attrs.insert(13,str(gcortAMPAs[igcortAMPA]*NMDA_AMPAratio))
    these_attrs.insert(23,'590.0')
    these_attrs.insert(24,str(noiseCoeffs[inoiseCoeff]))
    these_attrs.insert(25,str(myseed))
    this_str = ' '.join(these_attrs)
    print(this_str)
    os.system(this_str)

    print('mv MMNs_2pm_sep_noISDIDD_limtau_Nperpop'+these_attrs[2]+'_paramSD'+these_attrs[3]+'_stimA'+these_attrs[4]+'_'+these_attrs[5]+'_gAMPA'+these_attrs[6]+'_'+these_attrs[7]+'_'+these_attrs[8]+'_'+these_attrs[9]+'_gNMDA'+these_attrs[10]+'_'+these_attrs[11]+'_'+these_attrs[12]+'_'+these_attrs[13]+'_gGABA'+these_attrs[14]+'_'+these_attrs[15]+'_dep'+these_attrs[16]+'_'+these_attrs[17]+'_'+these_attrs[18]+'_tau'+these_attrs[19]+'_'+these_attrs[20]+'_'+these_attrs[21]+'_'+these_attrs[22]+'_'+these_attrs[23]+'_noise'+these_attrs[24]+myseedAdd+'.mat MMNs_2pm_sep_noISDIDD_limtau_CTRL_gcortAMPA'+str(gcortAMPAs[igcortAMPA])+'_noise'+str(noiseCoeffs[inoiseCoeff])+'_model'+str(imodel)+myseedAdd+'.mat')
    os.system('mv MMNs_2pm_sep_noISDIDD_limtau_Nperpop'+these_attrs[2]+'_paramSD'+these_attrs[3]+'_stimA'+these_attrs[4]+'_'+these_attrs[5]+'_gAMPA'+these_attrs[6]+'_'+these_attrs[7]+'_'+these_attrs[8]+'_'+these_attrs[9]+'_gNMDA'+these_attrs[10]+'_'+these_attrs[11]+'_'+these_attrs[12]+'_'+these_attrs[13]+'_gGABA'+these_attrs[14]+'_'+these_attrs[15]+'_dep'+these_attrs[16]+'_'+these_attrs[17]+'_'+these_attrs[18]+'_tau'+these_attrs[19]+'_'+these_attrs[20]+'_'+these_attrs[21]+'_'+these_attrs[22]+'_'+these_attrs[23]+'_noise'+these_attrs[24]+myseedAdd+'.mat MMNs_2pm_sep_noISDIDD_limtau_CTRL_gcortAMPA'+str(gcortAMPAs[igcortAMPA])+'_noise'+str(noiseCoeffs[inoiseCoeff])+'_model'+str(imodel)+myseedAdd+'.mat')