Exemplo n.º 1
0
    def __init__(self, filename):
        pwrspec_compilation = shelve.open(filename, "r")
        case_key = "combination:treatment"
        self.pwr_cases = dp.unpack_cases(pwrspec_compilation.keys(),
                                         case_key, divider=":")

        # gather the lists if pair combinations and treatments (cleaning)
        self.comb_cases = self.pwr_cases["combination"]
        self.comb_cases.sort()
        self.treatment_cases = self.pwr_cases["treatment"]
        self.treatment_cases.sort()

        #print self.comb_cases, self.treatment_cases

        # the 2D power can be binned onto 1D
        # this is not done automatically because one can apply transfer
        # functions in 2D, etc. before this rebinning
        self.pwrspec_1d = {}
        self.pwrspec_1d_from_2d = {}
        self.pwrspec_2d = {}

        self.counts_1d = {}
        self.counts_1d_from_2d = {}
        self.gauss_errors_1d_from_2d = {}
        self.counts_2d = {}

        for pwrspec_case in pwrspec_compilation:
            pwrspec_entry = pwrspec_compilation[pwrspec_case]
            self.parameters = pwrspec_entry[0]
            pwrdata_2d = pwrspec_entry[1][0]
            pwrdata_1d = pwrspec_entry[1][1]

            self.pwrspec_1d[pwrspec_case] = pwrdata_1d["binavg"]
            self.counts_1d[pwrspec_case] = pwrdata_1d["counts_histo"]
            self.pwrspec_2d[pwrspec_case] = pwrdata_2d["binavg"]
            self.counts_2d[pwrspec_case] = pwrdata_2d["counts_histo"]

        self.k_1d = {}
        self.k_1d["left"] = pwrdata_1d["bin_left"]
        self.k_1d["center"] = pwrdata_1d["bin_center"]
        self.k_1d["right"] = pwrdata_1d["bin_right"]
        self.k_1d_from_2d = {}

        self.kx_2d = {}
        self.kx_2d["left"] = pwrdata_2d["bin_x_left"]
        self.kx_2d["center"] = pwrdata_2d["bin_x_center"]
        self.kx_2d["right"] = pwrdata_2d["bin_x_right"]
        self.ky_2d = {}
        self.ky_2d["left"] = pwrdata_2d["bin_y_left"]
        self.ky_2d["center"] = pwrdata_2d["bin_y_center"]
        self.ky_2d["right"] = pwrdata_2d["bin_y_right"]

        self.num_kx = pwrdata_2d["bin_x_center"].shape[0]
        self.num_ky = pwrdata_2d["bin_y_center"].shape[0]
        self.num_k_1d = pwrdata_1d["bin_center"].shape[0]
        self.num_k_1d_from_2d = None
        self.num_comb = len(self.comb_cases)
        self.num_treat = len(self.treatment_cases)

        pwrspec_compilation.close()
Exemplo n.º 2
0
    def return_maplist(self, db_key, map_type, tack_on=None,
                       ignore=['firstpass']):
        template_flist = self.datapath_db.fetch(db_key, tack_on=tack_on)
        map_combinations = data_paths.unpack_cases(template_flist[0],
                                                   "sec;map_type")

        print map_combinations
        assert map_type in map_combinations['map_type'], \
               "no weight maps!"

        maplist = []
        seclist = map_combinations['sec']
        if ignore is not None:
            seclist = [tag for tag in seclist if tag not in ignore]

        seclist.sort()

        for sec in seclist:
            mapname = "%s;%s" % (sec, map_type)
            maplist.append(template_flist[1][mapname])

        return maplist