100 Lens Sample with Substructure#1
Conversation
Deleting files that are not needed
…potential differences
…r in terms of standard deviation
|
Two high level comments to start (scribing for @drphilmarshall):
Let us know when this is done, and we'll take another look! |
…sample generation
…ts. Initial code for finding the fermat potential differences of the predicted image locations.
| "sample_num = 101\n", | ||
| "\n", | ||
| "#Define how many parameters each lens has\n", | ||
| "param_num = 10\n", |
There was a problem hiding this comment.
This doesn't match # of params listed right below, prob just remove? (It's not used in this cell)
Code/Notebooks/Substructure.ipynb
Outdated
| "outputs": [], | ||
| "source": [ | ||
| "# Add timing\n", | ||
| "import time\n", |
There was a problem hiding this comment.
Package imports should always be in the top cell of the notebook
Code/Notebooks/Substructure.ipynb
Outdated
| "import time\n", | ||
| "tick = time.time()\n", | ||
| "\n", | ||
| "im_WoS, metadata = paltas_model.PaltasModelWoS(path,sample_num)\n", |
There was a problem hiding this comment.
I see that you're passing a folder rather than the full path to the config file. I think it would be more clear if you pass the whole path to the config file '.../Configs/substructure_WoS_config.py', so you can easily change the config file you're passing in. This will just require a minor change to the interface of PaltasModelWoS
Code/Scripts/paltas_model.py
Outdated
| Dictionary of corresponding sampled values. | ||
|
|
||
| """ | ||
| test_sample_i = ConfigHandler(path+'Configs/perturber_sample_wpl_config.py') |
There was a problem hiding this comment.
So this only returns one image, as opposed to PaltasModelWoS below, which returns a list of images. Why the difference? I think PaltasModelWoS makes sense, but I'm confused about what you would use this function for, especially since new_sample=False.
Code/Scripts/paltas_model.py
Outdated
|
|
||
| return im,metadata | ||
|
|
||
| def PaltasModelWoS(path,sample_num): |
There was a problem hiding this comment.
Linked to my previous comment in the notebook, if you change the argument to file_path here instead of path, and just have that be the full path to the config file, you should be able to use the same function to do both PaltasModelWoS and PaltasModelWS, right? Then you can avoid code duplication.
Code/Scripts/network_predictions.py
Outdated
| from paltas import generate | ||
|
|
||
| #define a function for a general case of n situations | ||
| def Predictions(sample_num, path, config_path, image_path): |
There was a problem hiding this comment.
Overall note: the two functions in this file could be condensed into one function (to avoid duplication). If you write one function that takes in the path to the data.tfrecord, and returns y_test, y_pred, ... for the lenses in that one data.tfrecord, you can just call that function one time for each test set to avoid code duplication.
Code/Scripts/fermat_potentials.py
Outdated
| cosmo=FlatLambdaCDM(H0=70.0, Om0=0.3) | ||
| ) | ||
| lens_model = LensModel(['EPL', 'SHEAR']) | ||
| td_cosmo = TDCosmography(0.5, 2., kwargs_model, cosmo_fiducial=FlatLambdaCDM(H0=70.0, Om0=0.3)) |
There was a problem hiding this comment.
This line is unused, you can remove this line and line 9 (the import)
Code/Scripts/fermat_potentials.py
Outdated
| from lenstronomy.LensModel.Solver.lens_equation_solver import LensEquationSolver | ||
|
|
||
| # Declaring arrays | ||
| kwargs_model = dict( |
There was a problem hiding this comment.
Note that the lens model components are hard-coded here. When switching to include substructure, this will need to be flexible.
|
|
||
| ##Msigma - Mean Standard Deviation | ||
| sum=0 | ||
| for i in std_pred_WoS: |
There was a problem hiding this comment.
you should be able to call np.mean() here to do this concisely / with numpy built-ins which are the usually preferred
| mean_metrics = [ME_WoS, ME_WS, Mstd_WoS, Mstd_WS] | ||
| #median_metrics = [Median_wop, Median_wpl, MDstd_wop, MDstd_wpl] | ||
|
|
||
| return mean_metrics No newline at end of file |
There was a problem hiding this comment.
If you return the metrics without labels like this (which is ok, you could also return a dict like {'mean_error_wos':ME_WoS, etc...} but you don't have to), make sure in the function docstring, you clearly spell out what you return and in what order.
… WS cases using correct truth values. Remove duplicate image generation code.
|
When you compute ground truth fermat potentials with fermat_potentials.fermat.fermat_potential_at_image_positions(), this isn't capable of using the LensModel that has substructure components in it, so this cannot create the ground truth fermat potentials with substructure. This function always uses a LensModel with an EPL + SHEAR profile. You can see this by tracing back through the code. Note at line 186, this uses the LensModel hardcoded at line 20. We need a LensModel that, when a substructure is present, also contains a 'TNFW' profile. I suggest we implement the computation of ground truth fermat potentials during image generation, since paltas already constructs this LensModel with 'TNFW' components for us. Then, we can just write that information to the metadata.csv during image generation. |
|
I'm also confused in Substructures.ipynb, in your "# Plotting histograms" cell, I don't see the two vertical lines you showed us in plots last Friday. Maybe this commit is missing that? Or should I be looking somewhere else? |
…anup. Change cornerplot distribution colors.
…ing unnecessary file paths
…(moved to a temporary notebook)
…bution. Remove unnecessary imports
…t residual with different normalization and color map
I am creating a new notebook (Substructure.ipynb) to generate two samples of 100 gravitationally lensed quasars with one sample comprised of a smooth mass distribution of a single main deflector and the other sample including substructure to the main deflector. Metrics for the precision, accuracy, bias, and standard deviation will be calculated as well.