Last active
April 12, 2020 03:44
-
-
Save nihalpasham/ef0245ff91106b4aa61efcaff4091c3e to your computer and use it in GitHub Desktop.
DSSS code synchronization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| number_of_code_samples = len(us1) | |
| print(len(us1)) | |
| correlation_magnitude_buffer = [] | |
| squared_correlation_magnitude_buffer = [] | |
| # so that we dont overshoot when sliding the code signal forward | |
| range_ = (int(number_of_complex_samples/number_of_code_samples)-1)*number_of_code_samples | |
| for i in range(0, int(range_)): | |
| real_correl = np.correlate(us1, re[ i : i + len(us1) ])[0] | |
| imag_correl = np.correlate(us1, im[ i : i + len(us1) ])[0] | |
| correlation_magnitude = real_correl + imag_correl | |
| squared_correl_magnitude = correlation_magnitude**2 | |
| correlation_magnitude_buffer.append(correlation_magnitude) | |
| squared_correlation_magnitude_buffer.append(squared_correl_magnitude) | |
| print(len(correlation_magnitude_buffer)) | |
| print(max(correlation_magnitude_buffer)) | |
| print(len(squared_correlation_magnitude_buffer)) | |
| print(max(squared_correlation_magnitude_buffer)) | |
| plt.figure(figsize=(20,10)) | |
| plt.plot((squared_correlation_magnitude_buffer[100000:150000])) | |
| plt.xlabel('Sample Number', fontsize=12, fontweight="bold") | |
| plt.ylabel('Correlation Magnitude', fontsize=12, fontweight="bold") | |
| plt.title('Code-Signal Cross Correlation', fontsize=12, fontweight="bold") | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment