MaodongGao / pycosh

correlated self-heterodyne (COSH) optical noise analyzer
https://opg.optica.org/oe/fulltext.cfm?uri=oe-30-14-25147&id=477387
MIT License
2 stars 0 forks source link

Run error #1

Closed ZhimingShi closed 7 months ago

ZhimingShi commented 7 months ago

Hello!I always get the following error when I run this code to calculate laser frequency noise, how can I get rid of this error? image

image

MaodongGao commented 7 months ago

Hi Zhiming,

It looks like the processing time it reported is very short. What is the size of your raw data?


From: ZhimingShi @.> Sent: Thursday, April 18, 2024 9:08:13 AM To: MaodongGao/pycosh @.> Cc: Subscribed @.***> Subject: [MaodongGao/pycosh] Run error (Issue #1)

Hello!I always get the following error when I run this code to calculate laser frequency noise, how can I get rid of this error? image.png (view on web)https://github.com/MaodongGao/pycosh/assets/121110294/81ecc0ff-5272-4204-aa9c-2965e0686423

image.png (view on web)https://github.com/MaodongGao/pycosh/assets/121110294/452181f0-c3ce-48c6-8658-0de1b582415f

— Reply to this email directly, view it on GitHubhttps://github.com/MaodongGao/pycosh/issues/1, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APBH6KGZIBLXW4O2V6LGFDTY57VW3AVCNFSM6AAAAABGNSR57WVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI2TCMBWHE3TQNI. You are receiving this because you are subscribed to this thread.Message ID: @.***>

ZhimingShi commented 7 months ago

Hello! Thank you very much for your reply. The very short time is because I tested this code with very small raw data, and now I've increased the data a lot, with a sampling rate of 250MHz/s, and an AOM frequency of 55MHz, and then a sampling time of 0.4ms. I ran this re-captured data, and it's still reporting the same error as before. I read the literature on Optics Express carefully. The parameter settings in CoshConfig.py are basically the same as in the literature, this range_start, range_stop and offset_start_ratio I have not changed, is it possible that I need to change them here depending on the amount of data I have? image Can you give me your email address, I would like to show you the data and processing code to find out the reason for this error. I think the test method for laser phase noise on this article is very good, I would appreciate it if you could reply. image image

MaodongGao commented 7 months ago

Hi Zhiming,

One thing I am worried about is the segment count it is reporting are always 0. The correct behavior should not be like this. This parameter means for this bandwidth segment, how many data slices are involved. You can see details in CoshXcorr.py line 69.

Given the behavior you described, I recommend try to run the following code:

np.mod(np.diff(np.angle(scipy.signal.hilbert(YOURDATA - np.mean(YOURDATA)))), 2 * np.pi)

And see if the phase is correctly calculated. Let me know what you get, Thanks.

Maodong

MaodongGao commented 7 months ago

Hi Zhiming,

I realized another thing: your data 250MHz, 0.4ms only contains 1e5 data point. You can not calculate low-bandwidth data in this case. In order to calculate low bandwidth data you need to increase your sampling time.

You can see from the debug info: some segment_length is even more than total num of points you have, for those cases it is not surprising you see a failed processing.

The subsequent failure is probably the phase change data is erased when it tries to reshape to a segment_count=0 dimension array.

Try:

  1. Delete the low bandwidth components in bandwidth segment. (self.config.bw_segment)
  2. Increase offset_start_ratio
  3. Make sure the segment length you see is smaller than total data length you have.
  4. Ultimately, you may want to increase your data collection time. In our experiment, we typically take data for 1-2 seconds.

Maodong

ZhimingShi commented 7 months ago

Sorry, my previous expression was wrong, the sampling time is 0.4s not 0.4ms. Each channel has 1001e6 points of data. run the following code: `np.mod(np.diff(np.angle(scipy.signal.hilbert(YOURDATA - np.mean(YOURDATA)))), 2 np.pi)` image image

I have modified the bandwidth segment and offset_start_ratio as follows image

But the result of running is still wrong. image

MaodongGao commented 7 months ago

Your data is a 1 1 list of list, not a n1 list of raw data. You may need to add

data1 = data1[0] data2 = data2[0]

Let me know if this solved your problem.

Additionally, you are not supposed to modify the default configuration parameters directly in the source code. Doing this may cause unexpected behavior in the future. Modify your configurations by:

xcorr_obj = CoshXcorr(data1, data2) xcorr_obj.config.bw_segment = YOUR CONFIGURATIONS HERE

Other parameters you can modify are all listed in the debug info printed under "Cosh configuration summary"

ZhimingShi commented 7 months ago

Well, it ran successfully without any errors, thank you very much for your patience! image