damb / mseed

libmseed bindings for Rust
https://docs.rs/mseed
Apache License 2.0
2 stars 3 forks source link

Flexible sampling rate configuration #12

Closed damb closed 1 year ago

damb commented 1 year ago

In addition to that, it would be nice if we can provide sample_rate_factor and sample_rate_multipler as paramters to pack_raw method instead of sample rate to give more control to the user rather than miniseed crate decode these values from sample rate.

This is a follow-up issue of #11.

damb commented 1 year ago

@BIBIN-EUGINE, what's the difference between sample_rate_factor and sample_rate_multiplier? Isn't a multiplier a factor? Could you please provide a formula how to compute the final sample rate from these components?

Also, libmseed doesn't provide this kind of facility. Though, once it is clear how to compute the sample rate we might provide an utility function which computes the sample rate from the suggested components.

BIBIN-EUGINE commented 1 year ago

Hi @damb The relationship between sample_rate_factor and sample_rate_multipler mentioned in this doc page 110.

If libmseed doesn't provide this facilty, then yeah sure we can define a utlity function to get sample rate from sample rate factor and sample rate multiplier.

Optional: It would be nice to add a API to construct sample rate by providng integer period as factor and multiplier as one.

damb commented 1 year ago

Thank you for pointing me to the specs. Honestly, I never used libmseed with the v2.x API.

Providing a function implementing https://github.com/EarthScope/libmseed/blob/b17f7dc8632af430c8f41056d297cf75f6093a58/unpack.c#L1442-L1463 should do it. While this function was part of the public libmseed v2.x API it is not part of the public libmseed v3.0 API anymore.

damb commented 1 year ago

It would be nice to add a API to construct sample rate by providng integer period as factor and multiplier as one.

This is not clear to me. Could you clarify what you exactly mean with this? Thanks.

BIBIN-EUGINE commented 1 year ago

Thank you for pointing me to the specs. Honestly, I never used libmseed with the v2.x API.

Providing a function implementing https://github.com/EarthScope/libmseed/blob/b17f7dc8632af430c8f41056d297cf75f6093a58/unpack.c#L1442-L1463 should do it. While this function was part of the public libmseed v2.x API it is not part of the public libmseed v3.0 API anymore.

But, still it would be nice to define it as a utility function in mseed crate. Thanks

BIBIN-EUGINE commented 1 year ago

It would be nice to add a API to construct sample rate by providng integer period as factor and multiplier as one.

This is not clear to me. Could you clarify what you exactly mean with this? Thanks.

This mean, an another API for calculating sample rate.... instead of providing the sample rate factor in Hz provide sample rate period in Secs.

damb commented 1 year ago

Providing a function implementing https://github.com/EarthScope/libmseed/blob/b17f7dc8632af430c8f41056d297cf75f6093a58/unpack.c#L1442-L1463 should do it. While this function was part of the public libmseed v2.x API it is not part of the public libmseed v3.0 API anymore.

9a8db5a8d211d622998634a1ba9c5538d6e584e3 should provide the required facilities.

damb commented 1 year ago

This mean, an another API for calculating sample rate.... instead of providing the sample rate factor in Hz provide sample rate period in Secs.

Again, not completely clear to me what you mean. If I understand you correctly you would like to provide a conversion function converting from sample rate period to sampling frequency (i.e. samples per second). Something like

fn sample_rate_period_to_hz(period: f64) -> f64

Are you aware that negative sample rate values by libmseed convention are considered as a sample rate period while positive sample rate values are considered as a sampling frequency (i.e. sample rate as samples per second (Hz))? Therefore, I'd simply store the sample rate period as negative value and let libmseed do the job. Though, I agree that we may improve the documentation regarding this convention.

What's your opinion on this?

BIBIN-EUGINE commented 1 year ago

Providing a function implementing https://github.com/EarthScope/libmseed/blob/b17f7dc8632af430c8f41056d297cf75f6093a58/unpack.c#L1442-L1463 should do it. While this function was part of the public libmseed v2.x API it is not part of the public libmseed v3.0 API anymore.

9a8db5a should provide the required facilities.

Thanks @damb ..it works

BIBIN-EUGINE commented 1 year ago

This mean, an another API for calculating sample rate.... instead of providing the sample rate factor in Hz provide sample rate period in Secs.

Again, not completely clear to me what you mean. If I understand you correctly you would like to provide a conversion function converting from sample rate period to sampling frequency (i.e. samples per second). Something like

fn sample_rate_period_to_hz(period: f64) -> f64

Are you aware that negative sample rate values by libmseed convention are considered as a sample rate period while positive sample rate values are considered as a sampling frequency (i.e. sample rate as samples per second (Hz))? Therefore, I'd simply store the sample rate period as negative value and let libmseed do the job. Though, I agree that we may improve the documentation regarding this convention.

What's your opinion on this?

I agree with your statement, mentioning this deatils in the documentation can be sufficient.

damb commented 1 year ago

1432358996682c60f2791029ff7f7bfacc59e9dd documents how to configure a sample rate period.

Thanks @BIBIN-EUGINE.