def complete_postprocessing(config_filename=False, directory_path=False,
                            decay=True, extraction=True, reduction=True, delete=False):
    """
    Choose Experiment-folder from config-file.
    Apply beta-decay to all data-files, SAVE AS '*_decayed.npy'!!
    Extract Re-Os-data from data-files and decayed-data-files, SAVE AS 'extract_..._.npy'
    Reduce extracted data to reasonable pandas-csv-files, save in experiment-folder and results-folder!

    delete-option: execute extraction, with suboption "do not consider files were Y_Re-187 or Y_Os-187 = 0"
    """

    if config_filename:
        config = cp.ConfigParser()
        config.read(config_filename)
        dir_data = config["montecarlo parameters"]["directory_name"]
    elif directory_path:
        dir_data = directory_path
    else:
        raise TypeError("Wrong use of keyword arguments!"+
                        "'config_filename' or 'directory_path' must be given!")
    print "Mucking around in directory: %s"%(dir_data)

    if decay:
        print "Applying decay"
        decay_instance = Decay(dir_name=dir_data) #make instance of decay-class
        decay_instance() #do the stuff for Re-Os

    if extraction:
        print "Applying extraction"
        extract_instance = Extract(dir_name=dir_data) #make instance of extract-class
        extract_instance.check_filename_level = 1 #check Y_hat(Re-187) and Y_hat(Os-187) from pid-in filename
        extract_instance() #do the stuff for Re-Os
        extract_instance(nsm=True)
        
    if reduction:
        print "Applying reduction"
        reduce_instance = Reduce(dir_name=dir_data) #make instance of reduce-class
        reduce_instance() #do the stuff for Re-Os
        reduce_instance(nsm=True)

        results_folder = Foldermap().hume_folder() + "latex/thesis/results/" + dir_data.split("/")[-1]
        print "Results-folder: %s"%(results_folder)
        try:
            os.mkdir(results_folder)
        except OSError: #folder already exists
            pass
        reduce_instance.set_save_dir(results_folder)
        reduce_instance()
        reduce_instance(nsm=True)

    return
Example #2
0
### import modules ###
#local module for project
from directory_master import Foldermap
folder = Foldermap()
folder.activate_environ()
#GCE calculation and local visualization module
from omega import omega
from visualize import visualize
#get some bestfit-value from 'Eris'
from bestfit_param_omega.find_bestfit_param_v0.set_param_from_eris import *
#get values and filename from document
from read_parameter_space import read_param

#Set cmdline arguments
try:
    from sys import argv
    n = int(argv[1])
except IndexError:
    n = 10

#Run calculations of GCE with 'Omega'
timesteps = n
loa_inflow_vals, save_name = read_param(
    "inflow_rate")  #get values from 'parameter_space.txt'
print "Using inflow values: ", loa_inflow_vals
bestfit_mgal = 1.0e+10
loa_omega_inst = [
    omega(special_timesteps=timesteps,
          in_out_control=True,
          inflow_rate=inflow,
          imf_type=bestfit_imf_type,
"""
"""
#Import modules for plotting and modelling
#import sys; sys.path.append("/home/oyvind/github_uio/NuPyCEE")
from directory_master import Foldermap

Foldermap().activate_environ()  #set os.eviron to correct path
from omega import omega


#####################################################
### Class inheriting omega for experimental usage ###
#####################################################
class omega_new(omega):
    def __init__(self, bestfit_namespace):
        omega.__init__(
            self,
            galaxy=bestfit_namespace.bestfit_galaxy,
            in_out_control=bestfit_namespace.bestfit_in_out_control,
            SF_law=bestfit_namespace.bestfit_SF_law,
            DM_evolution=bestfit_namespace.bestfit_DM_evolution,
            Z_trans=bestfit_namespace.bestfit_Z_trans,
            f_dyn=bestfit_namespace.bestfit_f_dyn,
            sfe=bestfit_namespace.bestfit_sfe,
            outflow_rate=bestfit_namespace.bestfit_outflow_rate,
            inflow_rate=bestfit_namespace.bestfit_inflow_rate,
            rand_sfh=bestfit_namespace.bestfit_rand_sfh,
            cte_sfr=bestfit_namespace.bestfit_cte_sfr,
            m_DM_0=bestfit_namespace.bestfit_m_DM_0,
            mass_loading=bestfit_namespace.bestfit_mass_loading,
            t_star=bestfit_namespace.bestfit_t_star,
Example #4
0
    #fraction of os-187/Re-187 at the time of formation of the solar system (with absolute uncertainty)
    f_187_fsos = [0.136, 0.0032]
    #same for current time
    f_187_now = [0.226, 57.9e-3]
    if fsos:
        ax.axhspan(f_187_fsos[0]+f_187_fsos[1], f_187_fsos[0]-f_187_fsos[1],
                   alpha=0.5, label="$f_{187}(t_{f,sos})$", color="g")
    if now:
        ax.axhspan(f_187_now[0]+f_187_now[1], f_187_now[0]-f_187_now[1],
                   alpha=0.5, label="$f_{187}(t_{now})$", color="g")
    return

if __name__ == '__main__':
    #find app. directory
    from directory_master import Foldermap
    directory = Foldermap().results + "MCExperiment_revised_2_delmax/"
    #find app. data
    loa_filenames = os.listdir(directory)
    for filename in loa_filenames:
        if ("reduce" in filename) and ("div" in filename) \
        and ("timeevol" in filename) and ("decay" in filename):
            app_filename = filename
    time, mean, uncertainty_up, uncertainty_down = get_data(directory+app_filename)
    
    #plot data
    fig = pl.figure()
    ax = fig.gca()
    bool_std = True
    add_meteor_data(ax=ax)
    plot_timeevol((time, mean, mean+uncertainty_up, mean-uncertainty_down), ax, color='k-', bool_std=bool_std, plot_string="data")
    
"""
Go through /stornext/-directories and plot various data-sets
with mean + regions and such.
Decide which data is to be stored in /results/
"""
from directory_master import Foldermap
from plot_data_files import plot_all_mean_sigma_extrema, plot_all_time_hist
import matplotlib.pyplot as pl

#Get relevant directory-names for uio-systems
folder_instance = Foldermap()
dir_stornext = folder_instance.stornext_folder()
dir_hume = folder_instance.hume_folder()

#decide on variables to plot!
loa_elem = ["Re", "Os"]
loa_re_isos = ["Re-187", "Re-185"]
loa_os_isos = ["Os-187", "Os-188"]
loa_ism_isos = ["ism_iso_" + iso for iso in loa_re_isos + loa_os_isos]
loa_ism_elem = ["ism_elem_" + elem for elem in loa_elem]
loa_yield_isos = ["yield_" + iso for iso in loa_re_isos + loa_os_isos]
loa_array_strings = ["num_nsm", "m_locked"] + \
                    loa_ism_elem + \
                    loa_ism_isos + \
                    loa_yield_isos

if __name__ == '__main__':
    print "Plotting data for the following arrays:"
    print loa_array_strings

    dir_experiment = dir_stornext + "MCExperiment1/"
Example #6
0
def add_meteor_data(ax, fsos=True, now=False):
    #fraction of os-187/Re-187 at the time of formation of the solar system (with absolute uncertainty)
    f_187_fsos = [0.136, 0.0323]
    #same for current time
    f_187_now = [0.226, 57.9e-3]
    if fsos:
        ax.axhspan(f_187_fsos[0]+f_187_fsos[1], f_187_fsos[0]-f_187_fsos[1],
                   alpha=0.5, label="obs. $f_{187}(t_{f,sos})$", color="g")
    if now:
        ax.axhspan(f_187_now[0]+f_187_now[1], f_187_now[0]-f_187_now[1],
                   alpha=0.5, label="obs. $f_{187}(t_{now})$", color="g")
    return

if __name__ == '__main__':
    from directory_master import Foldermap
    result_dir = Foldermap().results #.hume_folder() + "latex/thesis/results/"
    # result_dir = result_dir+"MCExperiment_revised_2_delmax/"
    # result_dir = result_dir+"MCExperiment_revised_2_imfslope/"
    result_dir = result_dir+"MCExperiment_revised_2_numnsm/"
    loa_fullpaths = get_full_filenames(result_dir)

    print "All paths in %s:"%(result_dir)
    for fullpath in loa_fullpaths:
        print fullpath.split('/')[-1]
    if raw_input("continue? y/n\t") == "y":
        pass
    else:
        sys.exit("Exiting!")

    # plot_all_single_paths(loa_fullpaths=loa_fullpaths)
    doa_figs = plot_combined_plots(loa_fullpaths=loa_fullpaths, save_dir=result_dir)
    #add '/' to experiment_folder if necessary
    if experiment_folder[-1] != '/':
        experiment_folder = experiment_folder + '/'

    #get list of filenames with desired quantities
    csv_file_list = [
        experiment_folder + filename for filename in file_list
        if (".csv" in filename)
    ]

    return csv_file_list


if __name__ == '__main__':
    from directory_master import Foldermap
    result_dir = Foldermap(
    ).results  #.hume_folder() + "latex/thesis/results/" #.stornext_folder() +...
    result_dir = result_dir + "MCExperiment_revised_2_numnsm/"
    loa_fullpaths = get_full_filenames(result_dir)

    print "All paths in %s:" % (result_dir)
    for fullpath in loa_fullpaths:
        print fullpath.split('/')[-1]
    if True:
        #if raw_input("continue? y/n\t") == "y":
        pass
    else:
        sys.exit("Exiting!")

    loa_num_paths = [
        path for path in loa_fullpaths if "num" in path.split("/")[-1]
    ]