baudren / montepython_public

Public repository for the Monte Python Code
MIT License
65 stars 115 forks source link

Error in defining path in class Likelihood_mpk() #90

Closed pchaubal closed 7 years ago

pchaubal commented 7 years ago

We were trying to use sdss likelihood and it showed error in path. Changing the path datafile = open(self.data_directory+self.windows_file, 'r') to datafile = open(os.path.join(self.data_directory,self.windows_file), 'r') seems to have fixed the problem. Are the two definitions equivalent and is this the correct way to handle the problem?

brinckmann commented 7 years ago

Yes it's fine, as you probably already saw, you need to do that for all three files, kbands, windows and measurements. This bugfix is already on the private version, sorry for your trouble! Also something else you need to fix is the indices that are looped over when loading the files, explained below. We have been working on the mpk likelihood recently and will be adding these bugfixes soon. Feel free to email me directly if you have any further questions about this.

Replace if i+2 > self.min_mpk_kbands_use and i < self.max_mpk_kbands_use: self.kh[i-self.min_mpk_kbands_use+1] = float(line.split()[0])

with

        if i+2 > self.min_mpk_kbands_use and i-1 < self.max_mpk_kbands_use:
                self.kh[i-self.min_mpk_kbands_use] = float(line.split()[0])

and replace for i in range(self.num_mpk_points_full): line = datafile.readline() if (i+2 > self.min_mpk_points_use and i < self.max_mpk_points_use): for j in range(self.k_size): self.window[i_region, i-self.min_mpk_points_use+1, j]=\ float(line.split()[j+self.min_mpk_kbands_use-1])

with

        for i in range(self.num_mpk_points_full+1):
            line = datafile.readline()
            if (i+2 > self.min_mpk_points_use and
                    i < self.max_mpk_points_use+1):
                for j in range(self.k_size):
                    self.window[i_region, i-self.min_mpk_points_use, j]=\
                        float(line.split()[j+self.min_mpk_kbands_use])

and replace for i in range(self.num_mpk_points_full): line = datafile.readline() if (i+2 > self.min_mpk_points_use and i < self.max_mpk_points_use): self.P_obs[i_region, i-self.min_mpk_points_use+1] = \ float(line.split()[3]) self.P_err[i_region, i-self.min_mpk_points_use+1] = \ float(line.split()[4])

with

        for i in range(self.num_mpk_points_full+1):
            line = datafile.readline()
            if (i+2 > self.min_mpk_points_use and
                    i < self.max_mpk_points_use+1):
                self.P_obs[i_region, i-self.min_mpk_points_use] = \
                    float(line.split()[3])
                self.P_err[i_region, i-self.min_mpk_points_use] = \
                    float(line.split()[4])
brinckmann commented 7 years ago

Revisiting the extra bugfix I suggested I find it was incorrect.

If the number of points is defined as starting from 1, as it is for SDSS DR4, so min_mpk_points_use=1 corresponds to skipping no points, =11 corresponds to skipping 10 points, etc., it should be as it is in the public version.

My apologies for any inconvenience.