pycbc icon indicating copy to clipboard operation
pycbc copied to clipboard

issue when using PSD from a file

Open aleynaakyuz opened this issue 1 year ago • 4 comments

I am working with the strain sensitivity curves for Cosmic Explorer, which are available here. When I read the data files using the pycbc.psd.read.from_txt function with df=0.1, low_freq_cutoff=5.1, and length=4000, I observed that the resulting curves appear flat, as shown in the attached plot.

After examining the issue, I found that this issue does not occur with different values for low_freq_cutoff. The problem arises due to floating point arithmetic. Specifically, the value of low_freq_cutoff is 5.1 and delta_f is 0.1, so kmin should ideally be 51. However, in Python, the calculation 5.1 / 0.1 yields 50.99999999999999, and since the code uses the int function, kmin is set to 50. This causes flow to be 5 and data_start to be -1 because the first value of freq_data is slightly above 50 for Cosmic Explorer.

I would suggest that you resolve this issue by replacing the int function with the round function in the relevant part of the code. This change will ensure that kmin is correctly calculated as 51 when low_freq_cutoff is 5.1 and delta_f is 0.1.

low_freq_cutoff5_1_40km

aleynaakyuz avatar Jun 10 '24 01:06 aleynaakyuz

Thanks, I know this f_lower issue, I just use 5.05 Hz for CE. Any comments from @ahnitz?

WuShichao avatar Jun 10 '24 08:06 WuShichao

@aleynaakyuz Can you please rebase this PR from master and check on the code climate report afterwards?

ahnitz avatar Jun 26 '24 17:06 ahnitz

@WuShichao Can you verify your case as well, to see that you no longer have this restriction?

ahnitz avatar Jun 26 '24 17:06 ahnitz

@ahnitz I just realized that my issue was not caused by this, just because the initial frequency of CE asd file is 5.000000000000000888e+00 not 5. I have checked Aleyna's case, this PR can fix her issue.

WuShichao avatar Jul 01 '24 14:07 WuShichao

@aleynaakyuz You'll need to rebase this PR and make sure the unittests pass along with the code climate report (found as a link towards the bottom of the checks).

ahnitz avatar Jul 12 '24 17:07 ahnitz