Changes made to make mogi and cdm run properly#11
Changes made to make mogi and cdm run properly#11gracebato wants to merge 7 commits intoAlTarFramework:masterfrom
Conversation
gracebato
commented
Mar 24, 2019
- proper calculation of LLK (e.g. LLK = normalization - normeval**2.0 / 2.0 )
- avoiding 0 values in the random generator within Metropolis.py
- dV is now treated as a non-Jeffrey parameter to allow negative source (deflation).
- LOS matrix for the EW component should have a negative sign.
… 2) avoiding 0 values in the random generator within Metropolis.py, 3) dV is treated as a non-Jeffrey parameter.
|
The framework changes were also included in my previous pull request.
|
| libcdm.layout(source, | ||
| model.xIdx, model.dIdx, | ||
| model.openingIdx, model.aXIdx, model.omegaXIdx, | ||
| model.xIdx, model.dIdx, model.openingIdx, model.aXIdx, model.omegaXIdx, |
There was a problem hiding this comment.
Modified function variable referencing/order for consistency.
There was a problem hiding this comment.
this looks like merging two lines into one; am i missing something
| # compute the norm, and normalize it | ||
| llk = normalization - norm.eval(v=residuals, sigma_inv=cd_inv) / 2 | ||
| normeval = norm.eval(v=residuals, sigma_inv=cd_inv) | ||
| llk = normalization - normeval**2.0 / 2.0 |
There was a problem hiding this comment.
Corrected the calculation of LLK.
| xIdx = model.xIdx | ||
| yIdx = model.yIdx | ||
| dIdx = model.dIdx | ||
| openingIdx = model.openingIdx |
There was a problem hiding this comment.
Nothing significant. Just reordered the variable for consistency.
|
|
||
| # make a source using the sample parameters | ||
| cdm = source(x=x, y=y, d=d, | ||
| cdm = source(x=x, y=y, d=d, opening=opening, |
There was a problem hiding this comment.
Modified function variable referencing/order for consistency.
There was a problem hiding this comment.
with python pass-by-name, the order of arguments is not important
| normeval = norm.eval(v=u, sigma_inv=cd_inv) | ||
| # normalize and store it as the data log likelihood | ||
| dataLLK[sample] = normalization - residual/2 | ||
| dataLLK[sample] = normalization - normeval**2.0 /2 |
There was a problem hiding this comment.
Corrected the calculation of the LLK.
| ue, un, uv = CDM(Xf, Yf, x_src, y_src, d_src, | ||
| omegaX_src, omegaY_src, omegaZ_src, ax_src, ay_src, az_src, | ||
| opening, v) | ||
| ue, un, uv = CDM(Xf, Yf, x_src, y_src, d_src, opening, |
There was a problem hiding this comment.
Lines 81-83: Modified function variable referencing/order for consistency.
| # meta-methods | ||
| def __init__(self, x=x, y=y, d=d, omegaX=omegaX, omegaY=omegaY, omegaZ=omegaZ, | ||
| ax=ax, ay=ay, az=az, opening=opening, v=v, **kwds): | ||
| def __init__(self, x=x, y=y, d=d, opening=opening, ax=ax, ay=ay, az=az, |
There was a problem hiding this comment.
Lines 95-96: Same here--modified function variable referencing/order for consistency.
|
|
||
|
|
||
| def CDM(X, Y, X0, Y0, depth, omegaX, omegaY, omegaZ, ax, ay, az, opening, nu): | ||
| def CDM(X, Y, X0, Y0, depth, opening, ax, ay, az, omegaX, omegaY, omegaZ, nu): |
There was a problem hiding this comment.
Also here--modified function variable referencing/order for consistency.
| import itertools | ||
| # build a set of points on a grid | ||
| stations = itertools.product(range(-5,6), range(-5,6)) | ||
| import numpy as np |
There was a problem hiding this comment.
Line 171-177: I think for the synthetic case, this is better to constrain the number of points.
| # make a source | ||
| source = altar.models.cdm.source( | ||
| x=self.x, y=self.y, d=self.d, | ||
| x=self.x, y=self.y, d=self.d, opening=self.opening, |
There was a problem hiding this comment.
Lines 99-102: Modified function variable referencing/order for consistency.
| for idx, observation in enumerate(data): | ||
| # set the covariance to a fraction of the "observed" displacement | ||
| correlation[idx,idx] = 1.0 #.01 * observation.d | ||
| correlation[idx,idx] = 0.0001 #1.0 #.01 * observation.d |
There was a problem hiding this comment.
1.0 m is quite large for an observation error (variance).
| // compute the displacements | ||
| cdm(_locations, | ||
| xSrc, ySrc, dSrc, | ||
| openingSrc, |
There was a problem hiding this comment.
Modified function variable referencing/order for consistency.
models/cdm/lib/libcdm/Source.cc
Outdated
| auto uy = gsl_matrix_get(disp, loc, 1); | ||
| auto ud = gsl_matrix_get(disp, loc, 2); | ||
|
|
||
| // project; don't forget {ud} is positive into the ground |
There was a problem hiding this comment.
This is not a depth value. It is the vertical component.
| // project; don't forget {ud} is positive into the ground | ||
| auto u = ux*nx + uy*ny - ud*nz; | ||
| // project | ||
| auto u = ux*nx + uy*ny + ud*nz; |
There was a problem hiding this comment.
This is not a depth value and should be '+' sign.
| double opening, | ||
| double aX, double aY, double aZ, | ||
| double omegaX, double omegaY, double omegaZ, | ||
| double opening, |
There was a problem hiding this comment.
Modified function variable referencing/order for consistency.
| namespace cdm { | ||
| void cdm(const gsl_matrix * locations, | ||
| double X0, double Y0, double depth, | ||
| double opening, |
There was a problem hiding this comment.
Modified function variable referencing/order for consistency.