-
Notifications
You must be signed in to change notification settings - Fork 19
Add counter 1/f and common mode subtraction to preprocess #1396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
With this change, get_pca_model returns weight with imaginary part when the given input signal is Q+iU.
I guess it would be better to modify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few requests and questions inline
sotodlib/tod_ops/fft_ops.py
Outdated
overwrite=True, | ||
subscan=False, | ||
full_output=False, | ||
LabelAxis='dets', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add a description for this new LabelAxis
variable in the docstring. Also do not use capitals in the function arguments that's reserved for class definitions.
sotodlib/tod_ops/fft_ops.py
Outdated
Signal sized nsamps or ndets x nsamps. | ||
When signal is given in 2D shape, the common mode across detectors | ||
is calculated with median method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also valid to pass in a precomputed common mode signal with shape 1 x nsamps. That option should be explained here in the docstring.
sotodlib/tod_ops/filters.py
Outdated
if np.isscalar(fk) and np.isscalar(n): | ||
return 1/(1+(fk/freqs)**n) | ||
|
||
if fk is None and n is None and noise_fit_stats is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you should raise an error if all 3 (fk
, n
and noise_fit_stats
) are None
at this point in the code and describe this combination of inputs in the docstring.
E, R = np.linalg.eigh(cov) | ||
E[np.isnan(E)] = 0. | ||
E, R = E.real, R.real | ||
if np.isrealobj(signal): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add this isrealobj
check? What issue were you running into?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't make any issue as long as the input signal is real object.
I thought that we need this kind of change if we want to derive the common mode of Q+iU, for example.
But I didn't implement an option for the complex common mode derivation in the pipeline so far.
if self.noise_fit: | ||
common_aman = tod_ops.fft_ops.get_common_noise_params(aman, signal=common_mode, | ||
f_max=self.f_max) | ||
samps = core.OffsetAxis('samps', aman.samps.count) | ||
common_aman.wrap(self.wrap_name, common_mode, [(0, samps)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This noise_fit option should be described better in the docstring here.
In the following places, here:
and here:
You mention downsampling but that's not implemented here do you just mean demodulated and/or low pass filtered? |
Also why do you need these 3 different rotation steps, especially for telescope vs radial Q/U rotation shouldn't it be one or the other not both?
|
These steps operate,
respectively. |
I'm sorry! Exactly, downsample is a mistake for low pass filtering. |
This PR modifies the scripts to enable fancy counter 1/f filter and common mode subtraction.
The changes for counter 1/f filter:
The filter function 'counter_1_over_f' is modified to accept the array-like input of parameters.
This enables to apply independent 1/f parameters to individual detectors.
The changes for common mode subtraction:
The PCAFilter is modified to have
signal
andmodel_signal
independently.This enables to estimate PCA model from the down sampled signal, and then subtract it from the signal.
For the fancy operations, I introduced
get_common_noise_params
to estimate knee frequency of the common noise.The estimated knee frequency is applied to the down sample frequency of
model_signal
.However, this deployment requires many changes in
fft_ops
.(As common mode aman doesn't have 'dets' LabelAxis, aman.dets is changed to aman[LabelAxis].)
These changes can be discarded if they are too much.
The following lines are the example of the process pipeline after the demodulation.
I have confirmed the processes run with this config.