Latis#5
Conversation
| di = self.get_outdir(pp, strz=2) | ||
| single_flux_pdf = myspec.get_snapshot_list(base=di) | ||
| return single_flux_pdf | ||
|
|
There was a problem hiding this comment.
It is probably easier to just rename the variables in _get_fv to something generic. The functions are the same and if they are reused it means that fixes to one propagate to the others.
|
|
||
| def save_pdf_vectors(self, aparams, deltaF_bins, pdf_vectors, savefile="emulator_pdf_vectors.hdf5"): | ||
| """ Save the pdf vecotrs to a file, which is the only thing read on reload """ | ||
| save_Dir = "/work/06536/qezlou/stampede2/Spectra" |
There was a problem hiding this comment.
Please don't hard-code absolute paths!
| #Same in all boxes | ||
| self.save_pdf_vectors(aparams, deltaF_bins, deltaF_vectors, mfc=mfc) | ||
| assert np.shape(deltaF_vectors)[0] == np.shape(aparams)[0] | ||
| return aparams, deltaF_bins, deltaF_vectors |
There was a problem hiding this comment.
Is this just the same as the flux_vector function? In which case a better thing to do is to reuse that function with maybe slight changes to the default arguments.
| """Modules to generate the flux power spectrum from a simulation box.""" | ||
| from __future__ import print_function | ||
| import sys | ||
| sys.path.remove('/opt/apps/intel18/impi18_0/python2/2.7.15/lib/python2.7/site-packages') |
There was a problem hiding this comment.
What's up with this line? The emulator code is python3 only anyway.
| from fake_spectra import abstractsnapshot as absn | ||
| import spectra_mocking as sm | ||
|
|
||
| def rebin_power_to_kms(kfkms, kfmpc, flux_powers, zbins, omega_m, omega_l = None): |
There was a problem hiding this comment.
You can just import this function from flux_power.py
| flux_rebinned = [rebinned[ii](okmsbins[ii]*velfac(zz)) for ii, zz in enumerate(zbins)] | ||
| return okmsbins, flux_rebinned | ||
|
|
||
| class FluxPdf(object): |
There was a problem hiding this comment.
Why don't you subclass the FluxPower object and re-use the common functions? As in:
class FluxPdf(FluxPower):
and then only get_deltaF_pdf needs to change.
| for ss in self.spectrae: | ||
| ss.tau[('H',1,1215)] = np.array([0]) | ||
|
|
||
| class MySpectra(object): |
There was a problem hiding this comment.
You can just import this from flux_power.py
| @@ -0,0 +1,201 @@ | |||
| """Modules to generate the flux power spectrum from a simulation box.""" | |||
There was a problem hiding this comment.
Why do you have three copies of this code?
| kfkms = np.array([ self.kf / (ss.velfac * 3.085678e24/ss.units.UnitLength_in_cm) for ss in self.spectrae]) | ||
| return kfkms | ||
| for (i, ss) in enumerate(self.spectrae): | ||
| mbins, hist = sm.get_pdf_Wiener_filtered() |
There was a problem hiding this comment.
This is not the same as the FluxPdf class above: which one do you mean to use?
| #I have checked that for k < 0.1 the corrected version | ||
| #is identical to the unsmoothed version (without mean flux rescaling). | ||
| self.spec_res = 0. | ||
| self.spec_res = 127 |
There was a problem hiding this comment.
Please note the comment: "hence does not commute with mean flux rescaling": it doesn't make sense to correct for spectral resolution at the same time as doing mean flux rescaling, unfortunately, because they are both non-linear operations. So you have to do the spectral resolution correction on the observations but not the simulations.
| flux_dist = FluxPDF() | ||
| for snap in range(9,13): | ||
| ## Added a new adress for my directory because I have no write permission on Simeon's Directory | ||
| my_spectra_dir = '/work/06536/qezlou/stampede2/Spectra/' |
There was a problem hiding this comment.
Don't hard-code it: you can pass it as an argument.
| #We use a much smaller pixel resolution so that the window functions | ||
| #are small for mean flux rescaling, and also so that HCDs are confined. | ||
| self.pix_res = 10. | ||
| self.pix_res = 123.4 |
There was a problem hiding this comment.
The pix_res has to be smaller than the spec_res: spec_res is a Gaussian smoothing, pix_res is the size of a pixel. Smoothing over a window size < 1 pixel doesn't make sense.
| if not self._check_redshift(ss.red): | ||
| return None | ||
| except OSError: | ||
| except (OSError, AttributeError): |
There was a problem hiding this comment.
Under what circumstances does it throw AttributeError?
| import os | ||
| import subprocess | ||
|
|
||
| def plot_pdf_Wiener_filtered(map_file=['60_512', '60_1024', '120_1024'],bins=np.arange(-1.0, 1.0, 0.02)): |
There was a problem hiding this comment.
Docstring please. What is this function supposed to be doing? I can see what it does, but the docstring explains whether that is what you meant it to do.
|
|
||
| mbin = np.array([(bins[i]+bins[i+1])/2. for i in range(0,np.size(bins)-1)]) | ||
| m = np.fromfile(map_file) | ||
| hist = np.histogram(m, bins=bins, density=True)[0] |
There was a problem hiding this comment.
I'm confused by this: this is a histogram, not a Wiener filter. Did you intend to Wiener filter initially and then change your mind after seeing the results?
|
I took a look through and I had a few comments. Some of them are cleanups but these are important too - I often find real bugs when I'm doing a cleanup, because bugs can hide in duplicated code. |
Switch over to MCMC sampling with Cobaya
Creating a PR for the LATIS work so I can see differences more easily.