Exemple #1
0
import ntpath
import os

import read_parameterfile as rp

def path_leaf(path):
    head, tail = ntpath.split(path)
    return tail or ntpath.basename(head)

#def create_result_dir(infile):
inifile = sys.argv[1]

lines = rp.read_inifile(inifile)
solve_he = rp.identify_int(lines, rp.solve_he_str, rp.splitting_str)

directory = rp.get_directory(inifile)
basename = os.path.splitext(path_leaf(inifile))[0]

if(directory==''):
    newdir = 'results_' + basename
else:
    newdir = directory + '/results_' + basename

if not os.path.exists(newdir):
    os.makedirs(newdir)
    
dir_21cm = newdir + '/21cm'
if not os.path.exists(dir_21cm):
    os.makedirs(dir_21cm)
    
dir_ion = newdir + '/ion'
Exemple #2
0
def plot_field_HeII(infile, i, toPlot, cut_slice, str_time, str_redshift,
                    str_meanIon):
    fig = plt.figure()

    image = plt.imshow(toPlot[:, :, cut_slice:cut_slice + 1].mean(axis=-1),
                       origin='lower',
                       interpolation='nearest',
                       extent=[0, boxsize, 0, boxsize],
                       cmap="afmhot_r")

    plt.clim([-8., 0.])

    ax = plt.gca()
    ax.set_xlabel('x  [h$^{-1}$ Mpc]')
    ax.set_ylabel('y  [h$^{-1}$ Mpc]')
    clb = plt.colorbar(image)  #, ticks=[0,0.5,1])
    clb.set_label('Log ( $\chi_\mathrm{HeI}$ )')

    font = FontProperties()
    font.set_weight('bold')
    t1 = plt.text(3.,
                  75.,
                  str_time,
                  fontsize=12,
                  color="black",
                  fontproperties=font,
                  bbox={
                      'facecolor': 'white',
                      'alpha': 0.7,
                      'edgecolor': 'none',
                      'pad': 2
                  })
    t2 = plt.text(68.,
                  75.,
                  str_redshift,
                  fontsize=12,
                  color="black",
                  fontproperties=font,
                  bbox={
                      'facecolor': 'white',
                      'alpha': 0.7,
                      'edgecolor': 'none',
                      'pad': 2
                  })
    t3 = plt.text(3.,
                  3.,
                  str_meanIon,
                  fontsize=12,
                  color="black",
                  fontproperties=font,
                  bbox={
                      'facecolor': 'white',
                      'alpha': 0.7,
                      'edgecolor': 'none',
                      'pad': 2
                  })

    directory = rp.get_directory(inifile)
    ininame = os.path.splitext(path_leaf(inifile))[0]
    if (directory == ''):
        newdir = 'results_' + ininame
    else:
        newdir = directory + '/results_' + ininame
    newdir = newdir + '/HeI_fields/'
    basename = newdir + os.path.splitext(path_leaf(infile))[0]

    if (i < 10):
        outfile = basename + '_0' + str(i) + '_x' + str(cut_slice) + '.png'
    else:
        outfile = basename + '_' + str(i) + '_x' + str(cut_slice) + '.png'

    plt.savefig(outfile, format='png', dpi=512, transparent=True)
    plt.close()