Add new noise model for discrete cosine transform (DCT)#226
Conversation
8d73a65 to
5cb1ed9
Compare
mhasself
left a comment
There was a problem hiding this comment.
Thanks.
Please add comments to the top of these two functions, to explain their distinct use cases. It is a good idea to point out what args are treated differently by the two, because the body of the code is very similar for the two functions.
|
Ah, that was not clear. Ya, I don't see any reason to break existing code. Please leave original function intact and add the new thing you need, with an informative function name. |
5cb1ed9 to
17cc324
Compare
|
The difference between @@ -1,4 +1,4 @@
-void nmat_detvecs_apply(const bp::object & ft, const bp::object & bins, const bp::object & iD, const bp::object & iV, float s, float norm) {
+void nmat_detvecs_apply_no2xbins(const bp::object & ft, const bp::object & bins, const bp::object & iD, const bp::object & iV, float s, float norm) {
// Should pass in this too
BufferWrapper<float> ft_buf ("ft", ft, false, std::vector<int>{-1,-1});
BufferWrapper<int32_t> bins_buf("bins", bins, false, std::vector<int>{-1, 2});
@@ -14,8 +14,7 @@
throw buffer_exception("iD must be C-contiguous along last axis");
if (iV_buf->strides[2] != iV_buf->itemsize || iV_buf->strides[1] != iV_buf->itemsize*nvec || iV_buf->strides[0] != iV_buf->itemsize*nvec*ndet)
throw buffer_exception("iV must be C-contiguous along last axis");
- // Internally we work with a real view of ft, with twice as many elements to compensate
- //int nmode = 2*nfreq;
+
float * ft_ = (float*) ft_buf->buf;
int32_t * bins_ = (int32_t*) bins_buf->buf;
float * iD_ = (float*) iD_buf->buf;
@@ -23,8 +22,8 @@
// Ok, actually do the work
for(int bi = 0; bi < nbin; bi++) {
- int b1 = min(2*bins_[2*bi+0],nmode-1);
- int b2 = min(2*bins_[2*bi+1],nmode);
+ int b1 = min(bins_[2*bi+0],nmode-1);
+ int b2 = min(bins_[2*bi+1],nmode);
int nm = b2-b1;
float * biD = iD_ + bi*ndet;
float * biV = iV_ + bi*ndet*nvec; |
17cc324 to
d1fd067
Compare
|
Ok ... if there's really only these 2 little differences, can I propose:
Then you'll just have 1 function, and minimal duplicated code. I'm open to other switch names instead of "dct_binning". Sorry for the thrashing here -- just trying to end up with easy future maintenance! |
|
Yes, that does make code cleaner. I didn't know C++ could declare default args. I merged these two functions. But get these error when testing the code. Do you know where I forgot to change in either so3g or sotodlib? |
I think boost python might require you to specify the default explicitly; see G3SuperTimestream.cxx where this is done a bunch. Will be something like Also please make sure you smoke test the default as well as dct_binning=True! |
|
It seems there's not test script testing Lines 8 to 12 in 75a01c0 |
Add `dct_binning` boolean option to `nmat_detvecs_apply` with default value being false. `nmat_detvecs_apply` would disable internal double binning when `dct_binning` is set to true. Co-authored-by: Bai-Chiang <contact@bai-chiang.com>
dc03003 to
694a5cd
Compare
code required for enabling discrete cosine transform in mlmapmaker simonsobs/sotodlib#1449