Feat time domain solar wind covariance - #1966
Conversation
…uble; add tests for time domain solar wind; add tests for noise design matrix precision
…are not changing; add tests
scottransom
left a comment
There was a problem hiding this comment.
There's a lot in here and it is beyond me to go through carefully line-by-line! We definitely need to make sure that there are some test cases and/or examples available that provide results that you believe are correct.
|
thanks for the comments, Scott ! I will take a look and see about implementing them. |
|
Maybe @abhisrkckl can look at this, since it involves changes to the noise model and some of the whitened residual pieces he put in recently? |
|
Is this ready to be looked at? |
Yes ! I just need to get the black to pass. I think I have been using the wrong line length settings. |
|
@abhisrkckl some of the tests are now failing but I think that is from the rebases above. this is still ready to be looked at, but in the mean time i will get the tests passing. |
|
For the |
Okay, yea. Somehow I had a bad version of black installed which was part of the issue. Seems to be fixed now as the black is passing. |
| def get_tdb_seconds(tbl) -> np.ndarray: | ||
| """Return TOA TDB times in seconds as float64.""" | ||
| return np.asarray((tbl["tdbld"].quantity * u.day).to(u.s).value, dtype=np.float64) |
There was a problem hiding this comment.
I think this makes more sense as a method in the TOAs class.
There was a problem hiding this comment.
yep. I have moved this to a method there !
| def project_basis_covariance(U: np.ndarray, Phi: np.ndarray) -> np.ndarray: | ||
| """Project basis-space covariance to data-space covariance.""" | ||
| if np.ndim(Phi) == 1: | ||
| return np.dot(U * Phi[None, :], U.T) | ||
| return np.dot(U, np.dot(Phi, U.T)) |
There was a problem hiding this comment.
Please add an assert to make sure that Phi is 1D or 2D.
There was a problem hiding this comment.
Done. I have elaborated in that docstring on the cases in which Phi should be 1D or 2D as well as specifically checking that the dimensions match between phi and U appropriately.
| return np.asarray((tbl["tdbld"].quantity * u.day).to(u.s).value, dtype=np.float64) | ||
|
|
||
|
|
||
| def _add_tdsw_node_component(model, node, index=None): |
There was a problem hiding this comment.
Our usual convention for utility functions like this is to put them as methods in the component class. For example, see add_dmx_range method in DispersionDMX. The code will be better organized that way.
There was a problem hiding this comment.
This is a good suggestion. The helper function is unnecessary and could be useful as a method.
|
|
||
| def _add_tdsw_node_component(model, node, index=None): | ||
| """Add one TDSWNODE_ prefix parameter to a time-domain SW noise component.""" | ||
| dct = model.get_prefix_mapping_component("TDSWNODE_") |
There was a problem hiding this comment.
what does dct stand for? maybe rename this variable?
There was a problem hiding this comment.
just dictionary. updated !
| """Add one TDSWNODE_ prefix parameter to a time-domain SW noise component.""" | ||
| dct = model.get_prefix_mapping_component("TDSWNODE_") | ||
| if index is None: | ||
| available = [ |
There was a problem hiding this comment.
available --> available_indices
| "ridge": {"required": ["TDSWLOGSIG"], "optional": []}, | ||
| "sqexp": {"required": ["TDSWLOGSIG", "TDSWLOGELL"], "optional": []}, | ||
| "matern": { | ||
| "required": ["TDSWLOGSIG", "TDSWLOGELL"], | ||
| "optional": ["TDSWNU"], | ||
| }, | ||
| "quasi_periodic": { | ||
| "required": ["TDSWLOGSIG", "TDSWLOGELL", "TDSWLOGGAMP", "TDSWLOGP"], | ||
| "optional": [], | ||
| }, |
There was a problem hiding this comment.
par files usually use all caps by default for parameter names and values.
| self.add_param( | ||
| strParameter( | ||
| name="TDSWKERNEL", | ||
| value="ridge", |
There was a problem hiding this comment.
par files usually use all caps by default.
There was a problem hiding this comment.
Sorry I don’t understand this comment. Do you want ‘ridge’ to be in all caps ?
There was a problem hiding this comment.
ah okay. the above comment seems to clarify my confusion. switching the kernel names and interpolation kinds to all caps.
| index : int or None | ||
| Integer index label for the node. If None, increments max index by 1. | ||
| """ | ||
| return _add_tdsw_node_component(self, node=node, index=index) |
There was a problem hiding this comment.
This code can be brought inside the class.
| toas, | ||
| nodes=None, | ||
| dt=None, | ||
| kind="linear", |
| return K | ||
|
|
||
|
|
||
| def se_kernel( |
There was a problem hiding this comment.
se_kernel ---> squared_exp_kernel (?)
There was a problem hiding this comment.
updated as such. ( I copied se_kernel from enterprise extensions, but I agree that square_exponential_kernel is clearer )
|
I haven't gone through the entire code yet. |
|
The black issue should be taken care if you |
|
The new component does not appear in this documentation page: |
Okay I just added a docs page which describes the solar wind as well as the differences between the Fourier basis and the time domain bases. |
|
@abhisrkckl |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1966 +/- ##
==========================================
+ Coverage 70.45% 70.60% +0.15%
==========================================
Files 109 109
Lines 25765 26051 +286
Branches 4114 4170 +56
==========================================
+ Hits 18152 18393 +241
- Misses 6441 6464 +23
- Partials 1172 1194 +22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Needed for NG20.
Major changes
np.linalg.inversefallback.More work should really explore additional caching of various parts of the GLS fit when the noise model is being held constant. This might be sub blocks of the design matrix. Or a refactorization of the GLS implementation.
TODO
Disclosure that I used co-pilot for generating the unit tests as well as some docstrings and type hinting.