import numpy as np
import subprocess
import time 

#sim=np.array(['tng','ill'])
sim=np.array(['tng'])

mass=np.array([10**12]) #These matter for mass option 2
mcenter_power=np.array([12]) 

#cut=np.array(['no_cut','color','sfr','mstar'])
cut=np.array(['no_cut'])

prof1='dmdens'
prof2='gasdens'
prof3='gaspth'
type1='pres'
type2='dens'
type3='pres_av'
type4='dens_av'

red_dict_tng={'059':0.7,'060':0.68, '061':0.64,'062':0.62,'063':0.60,'064':0.58,'065':0.55,
              '066':0.52,'067':0.50,'068':0.48,'069':0.46,'070':0.44,'071':0.42,'072':0.40,'077':0.31,'099':0.0}
red_dict_ill={'101':0.55,'120':0.2}

start=time.time()
for k in np.arange(len(sim)):
    if sim[k]=='ill':
        snap=np.array(['101'])
    else:
        #snap=red_dict_tng.keys() #for all snaps
        #snap=np.array(['065'])
        snap=np.array(['099','077','063'])
    for j in np.arange(len(snap)):
        for i in np.arange(len(mass)):
            f=open('getprof_temp_profiles.sh','w')
            print >>f, '#!/bin/bash'
            print >> f, 'python', '../scripts/profiles_mult.py', 'istk-params_'+sim[k]+'.txt', prof2, str(mass[i]), snap[j], sim[k]
            print >> f, 'python', '../scripts/profiles_mult.py', 'istk-params_'+sim[k]+'.txt', prof3, str(mass[i]), snap[j], sim[k]
            #print >> f, 'python', '../scripts/profiles_mult_ill.py', 'istk-params_'+sim[k]+'.txt', prof3, str(mass[i]), snap[j], sim[k]
            f.close()
            print("*******************************************************************************************")
            print("profile shell generated for sim = %s, mass= %s, snap= %s"%(sim[k],str(mcenter_power[i]),str(snap[j])))
            print("*******************************************************************************************")
            subprocess.call(['./getprof_temp_profiles.sh'],shell=True)
            '''
            for m in np.arange(len(cut)):
                f=open('getprof_temp_plotting.sh','w')
                print >>f, '#!/bin/bash'
                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_'+str(mcenter_power[i])+'.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_'+str(mcenter_power[i])+'.npz', str(mass[i]), snap[j], sim[k],type1

                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', str(mass[i]), snap[j], sim[k],type1
                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type2
                print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type3
                print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type4


                f.close()
                print "-------------------------------------------------------------------------------------------"
                print "plotting shell generated for sim = %s, mass= %s, snap= %s"%(sim[k],str(mcenter_power[i]),str(snap[j]))
                print "now running the shell script"
                print "-------------------------------------------------------------------------------------------"
                #subprocess.call(['./getprof_temp_plotting.sh'],shell=True)
            '''
end = time.time()
time_elapsed=end-start
print("time elapsed", time_elapsed/60., "minutes")

9b2ae1167ddac22db546ca592e496607d59fcf73
<mask token>

<mask token>
for k in np.arange(len(sim)):
    if sim[k] == 'ill':
        snap = np.array(['101'])
    else:
        snap = np.array(['099', '077', '063'])
    for j in np.arange(len(snap)):
        for i in np.arange(len(mass)):
            f = open('getprof_temp_profiles.sh', 'w')
            print >> f, '#!/bin/bash'
            print >> f, 'python', '../scripts/profiles_mult.py', 'istk-params_' + sim[
                k] + '.txt', prof2, str(mass[i]), snap[j], sim[k]
            print >> f, 'python', '../scripts/profiles_mult.py', 'istk-params_' + sim[
                k] + '.txt', prof3, str(mass[i]), snap[j], sim[k]
            f.close()
            print(
                '*******************************************************************************************'
                )
            print(
                'profile shell generated for sim = %s, mass= %s, snap= %s' %
                (sim[k], str(mcenter_power[i]), str(snap[j])))
            print(
                '*******************************************************************************************'
                )
            subprocess.call(['./getprof_temp_profiles.sh'], shell=True)
            """
            for m in np.arange(len(cut)):
                f=open('getprof_temp_plotting.sh','w')
                print >>f, '#!/bin/bash'
                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_'+str(mcenter_power[i])+'.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_'+str(mcenter_power[i])+'.npz', str(mass[i]), snap[j], sim[k],type1

                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', str(mass[i]), snap[j], sim[k],type1
                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type2
                print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type3
                print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type4


                f.close()
                print "-------------------------------------------------------------------------------------------"
                print "plotting shell generated for sim = %s, mass= %s, snap= %s"%(sim[k],str(mcenter_power[i]),str(snap[j]))
                print "now running the shell script"
                print "-------------------------------------------------------------------------------------------"
                #subprocess.call(['./getprof_temp_plotting.sh'],shell=True)
            """
<mask token>
print('time elapsed', time_elapsed / 60.0, 'minutes')

<mask token>
sim = np.array(['tng'])
mass = np.array([10 ** 12])
mcenter_power = np.array([12])
cut = np.array(['no_cut'])
prof1 = 'dmdens'
prof2 = 'gasdens'
prof3 = 'gaspth'
type1 = 'pres'
type2 = 'dens'
type3 = 'pres_av'
type4 = 'dens_av'
red_dict_tng = {'059': 0.7, '060': 0.68, '061': 0.64, '062': 0.62, '063': 
    0.6, '064': 0.58, '065': 0.55, '066': 0.52, '067': 0.5, '068': 0.48,
    '069': 0.46, '070': 0.44, '071': 0.42, '072': 0.4, '077': 0.31, '099': 0.0}
red_dict_ill = {'101': 0.55, '120': 0.2}
start = time.time()
for k in np.arange(len(sim)):
    if sim[k] == 'ill':
        snap = np.array(['101'])
    else:
        snap = np.array(['099', '077', '063'])
    for j in np.arange(len(snap)):
        for i in np.arange(len(mass)):
            f = open('getprof_temp_profiles.sh', 'w')
            print >> f, '#!/bin/bash'
            print >> f, 'python', '../scripts/profiles_mult.py', 'istk-params_' + sim[
                k] + '.txt', prof2, str(mass[i]), snap[j], sim[k]
            print >> f, 'python', '../scripts/profiles_mult.py', 'istk-params_' + sim[
                k] + '.txt', prof3, str(mass[i]), snap[j], sim[k]
            f.close()
            print(
                '*******************************************************************************************'
                )
            print(
                'profile shell generated for sim = %s, mass= %s, snap= %s' %
                (sim[k], str(mcenter_power[i]), str(snap[j])))
            print(
                '*******************************************************************************************'
                )
            subprocess.call(['./getprof_temp_profiles.sh'], shell=True)
            """
            for m in np.arange(len(cut)):
                f=open('getprof_temp_plotting.sh','w')
                print >>f, '#!/bin/bash'
                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_'+str(mcenter_power[i])+'.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_'+str(mcenter_power[i])+'.npz', str(mass[i]), snap[j], sim[k],type1

                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', str(mass[i]), snap[j], sim[k],type1
                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type2
                print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type3
                print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type4


                f.close()
                print "-------------------------------------------------------------------------------------------"
                print "plotting shell generated for sim = %s, mass= %s, snap= %s"%(sim[k],str(mcenter_power[i]),str(snap[j]))
                print "now running the shell script"
                print "-------------------------------------------------------------------------------------------"
                #subprocess.call(['./getprof_temp_plotting.sh'],shell=True)
            """
end = time.time()
time_elapsed = end - start
print('time elapsed', time_elapsed / 60.0, 'minutes')

import numpy as np
import subprocess
import time
sim = np.array(['tng'])
mass = np.array([10 ** 12])
mcenter_power = np.array([12])
cut = np.array(['no_cut'])
prof1 = 'dmdens'
prof2 = 'gasdens'
prof3 = 'gaspth'
type1 = 'pres'
type2 = 'dens'
type3 = 'pres_av'
type4 = 'dens_av'
red_dict_tng = {'059': 0.7, '060': 0.68, '061': 0.64, '062': 0.62, '063': 
    0.6, '064': 0.58, '065': 0.55, '066': 0.52, '067': 0.5, '068': 0.48,
    '069': 0.46, '070': 0.44, '071': 0.42, '072': 0.4, '077': 0.31, '099': 0.0}
red_dict_ill = {'101': 0.55, '120': 0.2}
start = time.time()
for k in np.arange(len(sim)):
    if sim[k] == 'ill':
        snap = np.array(['101'])
    else:
        snap = np.array(['099', '077', '063'])
    for j in np.arange(len(snap)):
        for i in np.arange(len(mass)):
            f = open('getprof_temp_profiles.sh', 'w')
            print >> f, '#!/bin/bash'
            print >> f, 'python', '../scripts/profiles_mult.py', 'istk-params_' + sim[
                k] + '.txt', prof2, str(mass[i]), snap[j], sim[k]
            print >> f, 'python', '../scripts/profiles_mult.py', 'istk-params_' + sim[
                k] + '.txt', prof3, str(mass[i]), snap[j], sim[k]
            f.close()
            print(
                '*******************************************************************************************'
                )
            print(
                'profile shell generated for sim = %s, mass= %s, snap= %s' %
                (sim[k], str(mcenter_power[i]), str(snap[j])))
            print(
                '*******************************************************************************************'
                )
            subprocess.call(['./getprof_temp_profiles.sh'], shell=True)
            """
            for m in np.arange(len(cut)):
                f=open('getprof_temp_plotting.sh','w')
                print >>f, '#!/bin/bash'
                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_'+str(mcenter_power[i])+'.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_'+str(mcenter_power[i])+'.npz', str(mass[i]), snap[j], sim[k],type1

                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', str(mass[i]), snap[j], sim[k],type1
                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type2
                print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type3
                print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type4


                f.close()
                print "-------------------------------------------------------------------------------------------"
                print "plotting shell generated for sim = %s, mass= %s, snap= %s"%(sim[k],str(mcenter_power[i]),str(snap[j]))
                print "now running the shell script"
                print "-------------------------------------------------------------------------------------------"
                #subprocess.call(['./getprof_temp_plotting.sh'],shell=True)
            """
end = time.time()
time_elapsed = end - start
print('time elapsed', time_elapsed / 60.0, 'minutes')

import numpy as np
import subprocess
import time 

#sim=np.array(['tng','ill'])
sim=np.array(['tng'])

mass=np.array([10**12]) #These matter for mass option 2
mcenter_power=np.array([12]) 

#cut=np.array(['no_cut','color','sfr','mstar'])
cut=np.array(['no_cut'])

prof1='dmdens'
prof2='gasdens'
prof3='gaspth'
type1='pres'
type2='dens'
type3='pres_av'
type4='dens_av'

red_dict_tng={'059':0.7,'060':0.68, '061':0.64,'062':0.62,'063':0.60,'064':0.58,'065':0.55,
              '066':0.52,'067':0.50,'068':0.48,'069':0.46,'070':0.44,'071':0.42,'072':0.40,'077':0.31,'099':0.0}
red_dict_ill={'101':0.55,'120':0.2}

start=time.time()
for k in np.arange(len(sim)):
    if sim[k]=='ill':
        snap=np.array(['101'])
    else:
        #snap=red_dict_tng.keys() #for all snaps
        #snap=np.array(['065'])
        snap=np.array(['099','077','063'])
    for j in np.arange(len(snap)):
        for i in np.arange(len(mass)):
            f=open('getprof_temp_profiles.sh','w')
            print >>f, '#!/bin/bash'
            print >> f, 'python', '../scripts/profiles_mult.py', 'istk-params_'+sim[k]+'.txt', prof2, str(mass[i]), snap[j], sim[k]
            print >> f, 'python', '../scripts/profiles_mult.py', 'istk-params_'+sim[k]+'.txt', prof3, str(mass[i]), snap[j], sim[k]
            #print >> f, 'python', '../scripts/profiles_mult_ill.py', 'istk-params_'+sim[k]+'.txt', prof3, str(mass[i]), snap[j], sim[k]
            f.close()
            print("*******************************************************************************************")
            print("profile shell generated for sim = %s, mass= %s, snap= %s"%(sim[k],str(mcenter_power[i]),str(snap[j])))
            print("*******************************************************************************************")
            subprocess.call(['./getprof_temp_profiles.sh'],shell=True)
            '''
            for m in np.arange(len(cut)):
                f=open('getprof_temp_plotting.sh','w')
                print >>f, '#!/bin/bash'
                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_'+str(mcenter_power[i])+'.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_'+str(mcenter_power[i])+'.npz', str(mass[i]), snap[j], sim[k],type1

                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', str(mass[i]), snap[j], sim[k],type1
                #print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type2
                print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type3
                print >> f, 'python', '../scripts/showstacks_'+cut[m]+'.py', prof2+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz', prof3+'_scaled_'+sim[k]+'_'+str(snap[j])+'_mstar_total.npz',str(mass[i]), snap[j], sim[k],type4


                f.close()
                print "-------------------------------------------------------------------------------------------"
                print "plotting shell generated for sim = %s, mass= %s, snap= %s"%(sim[k],str(mcenter_power[i]),str(snap[j]))
                print "now running the shell script"
                print "-------------------------------------------------------------------------------------------"
                #subprocess.call(['./getprof_temp_plotting.sh'],shell=True)
            '''
end = time.time()
time_elapsed=end-start
print("time elapsed", time_elapsed/60., "minutes")
