Skip to content

Conversation

@tristpinsm
Copy link
Contributor

I've yet to test this on a SMuRF system (working on getting that going), and that will involve confirming that I've correctly set the default filter parameters, but I figured it would be useful in the meantime to get feedback on how I've implemented this.

@tristpinsm tristpinsm requested a review from jlashner March 4, 2025 20:58
Copy link
Collaborator

@jlashner jlashner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Tristan, thanks for this! It looks good for the most part, see comments below. Mainly I think we need to talk with Matthew / Max about whether its ok to start specifying filter behavior using filter_cutoff if that means the default filter parameters don't match exactly what's currently used.

We'll also want to investigate what filter cutoff was used to generate the default parameters that we currently use.

@tristpinsm
Copy link
Contributor Author

Thanks for the comments!

Between the two options of specifying the filter parameters as coefficients or order/frequency I chose the latter because it seems more user-friendly, but I agree it's less obvious that it guarantees the standard behaviour. I have investigated how the filter parameters are generated, and the ones I put in the defaults reproduce the filter parameters from SmurfProcessor exactly. I would still like to confirm this on a live system though.

@tristpinsm
Copy link
Contributor Author

But I'm also happy to store the filter coefficients in the device config and have a user pass order / cutoff to the function. I guess it isn't super clear to me if the device config is meant to be user-facing or not.

@jlashner
Copy link
Collaborator

jlashner commented Mar 5, 2025

Ah ok that's great! If this produces the exact same filter params then I don't see any problem with setting the default using the cutoff freq like you're doing here. Thanks for checking!

@tristpinsm
Copy link
Contributor Author

I've confirmed that the filter parameters in the device config produce the default coefficients on a live SMuRF system now.

The coefficients queried before running S.set_downsample_filter(filter_params["order"], filter_params["cutoff_freq"])

[ 1.         -3.74145562  5.25726624 -3.28776591  0.77203984  0.
  0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.        ]
[5.28396689e-06 2.11358676e-05 3.17038014e-05 2.11358676e-05
 5.28396689e-06 0.00000000e+00 0.00000000e+00 0.00000000e+00
 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]

and after

[ 1.         -3.74145562  5.25726624 -3.28776591  0.77203984]
[5.28396689e-06 2.11358676e-05 3.17038014e-05 2.11358676e-05
 5.28396689e-06]

I also checked that they are different if I change the cutoff frequency :)

@tristpinsm
Copy link
Contributor Author

@swh76 may have an opinion on this change?

@jlashner
Copy link
Collaborator

jlashner commented Mar 5, 2025

Great. We should also check with shawn / make sure we test this, but I believe its ok that we don't pad with zeros when we update the filter params. I think that is just done so the initial buffer is set to a large enough length.

@tristpinsm
Copy link
Contributor Author

@swh76 @msilvafe Should we try to get this merged before we release a new software stack with the RSSI fix?

@msilvafe
Copy link
Contributor

msilvafe commented May 1, 2025

@swh76 @msilvafe Should we try to get this merged before we release a new software stack with the RSSI fix?

I'm happy with it, remind me how you've tested it so far?

@tristpinsm
Copy link
Contributor Author

I'm happy with it, remind me how you've tested it so far?

A few comments upstream I checked that the parameters were exactly the same as before using the default values stored in the config. I haven't looked at any data, do you think that is necessary?

@msilvafe
Copy link
Contributor

msilvafe commented May 1, 2025

I'm happy with it, remind me how you've tested it so far?

A few comments upstream I checked that the parameters were exactly the same as before using the default values stored in the config. I haven't looked at any data, do you think that is necessary?

I think what you checked above seems good. But I have Jack's same uncertainty about the zero padding. Perhaps to stay consistent we zero pad the arrays?

@tristpinsm
Copy link
Contributor Author

I'm happy with it, remind me how you've tested it so far?

A few comments upstream I checked that the parameters were exactly the same as before using the default values stored in the config. I haven't looked at any data, do you think that is necessary?

I think what you checked above seems good. But I have Jack's same uncertainty about the zero padding. Perhaps to stay consistent we zero pad the arrays?

I think this is just a quirk of EPICS (see here). The actual filter doesn't care about the length (here).

The fact I was able to set it and it didn't complain suggests that EPICS is happy without zero-padding.

Would still be nice to get @swh76 opinion.

@tristpinsm
Copy link
Contributor Author

Should we go ahead and merge? In any case, one reviewer will need to approve :)

Copy link
Contributor

@msilvafe msilvafe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to hold ya up!

@tristpinsm tristpinsm merged commit 16ac273 into master May 6, 2025
1 check passed
@tristpinsm tristpinsm deleted the tpm/filter-param branch May 6, 2025 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants