# GPS L1Cp code construction
#
# Copyright 2018 Peter Monta

import numpy as np
from sympy.ntheory import legendre_symbol

chip_rate = 1023000
code_length = 10230

l1cp_params = {
   1: (5111,412),    2: (5109,161),     3: (5108,1),      4: (5106,303),
   5: (5103,207),    6: (5101,4971),    7: (5100,4496),   8: (5098,5),
   9: (5095,4557),  10: (5094,485),    11: (5093,253),   12: (5091,4676),
  13: (5090,1),     14: (5081,66),     15: (5080,4485),  16: (5069,282),
  17: (5068,193),   18: (5054,5211),   19: (5044,729),   20: (5027,4848),
  21: (5026,982),   22: (5014,5955),   23: (5004,9805),  24: (4980,670),
  25: (4915,464),   26: (4909,29),     27: (4893,429),   28: (4885,394),
  29: (4832,616),   30: (4824,9457),   31: (4591,4429),  32: (3706,4771),
  33: (5092,365),   34: (4986,9705),   35: (4965,9489),  36: (4920,4193),
  37: (4917,9947),  38: (4858,824),    39: (4847,864),   40: (4790,347),
  41: (4770,677),   42: (4318,6544),   43: (4126,6312),  44: (3961,9804),
  45: (3790,278),   46: (4911,9461),   47: (4881,444),   48: (4827,4839),
  49: (4795,4144),  50: (4789,9875),   51: (4725,197),   52: (4675,1156),
  53: (4539,4674),  54: (4535,10035),  55: (4458,4504),  56: (4197,5),
  57: (4096,9937),  58: (3484,430),    59: (3481,5),     60: (3393,355),
  61: (3175,909),   62: (2360,1622),   63: (1852,6284),
  64: (5065,9429),  65: (5063,77),     66: (5055,932),   67: (5012,5973),
  68: (4981,377),   69: (4952,10000),  70: (4934,951),   71: (4932,6212),
  72: (4786,686),   73: (4762,9352),   74: (4640,5999),  75: (4601,9912),
  76: (4563,9620),  77: (4388,635),    78: (3820,4951),  79: (3687,5453),
  80: (5052,4658),  81: (5051,4800),   82: (5047,59),    83: (5039,318),
  84: (5015,571),   85: (5005,565),    86: (4984,9947),  87: (4975,4654),
  88: (4974,148),   89: (4972,3929),   90: (4962,293),   91: (4913,178),
  92: (4907,10142), 93: (4903,9683),   94: (4833,137),   95: (4778,565),
  96: (4721,35),    97: (4661,5949),   98: (4660,2),     99: (4655,5982),
 100: (4623,825),  101: (4590,9614),  102: (4548,9790), 103: (4461,5613),
 104: (4442,764),  105: (4347,660),   106: (4259,4870), 107: (4256,4950),
 108: (4166,4881), 109: (4155,1151),  110: (4109,9977), 111: (4100,5122),
 112: (4023,10074),113: (3998,4832),  114: (3979,77),   115: (3903,4698),
 116: (3568,1002), 117: (5088,5549),  118: (5050,9606), 119: (5020,9228),
 120: (4990,604),  121: (4982,4678),  122: (4966,4854), 123: (4949,4122),
 124: (4947,9471), 125: (4937,5026),  126: (4935,272),  127: (4906,1027),
 128: (4901,317),  129: (4872,691),   130: (4865,509),  131: (4863,9708),
 132: (4818,5033), 133: (4785,9938),  134: (4781,4314), 135: (4776,10140),
 136: (4775,4790), 137: (4754,9823),  138: (4696,6093), 139: (4690,469),
 140: (4658,1215), 141: (4607,799),   142: (4599,756),  143: (4596,9994),
 144: (4530,4843), 145: (4524,5271),  146: (4451,9661), 147: (4441,6255),
 148: (4396,5203), 149: (4340,203),   150: (4335,10070),151: (4296,30),
 152: (4267,103),  153: (4168,5692),  154: (4149,32),   155: (4097,9826),
 156: (4061,76),   157: (3989,59),    158: (3966,6831), 159: (3789,958),
 160: (3775,1471), 161: (3622,10070), 162: (3523,553),  163: (3515,5487),
 164: (3492,55),   165: (3345,208),   166: (3235,645),  167: (3169,5268),
 168: (3157,1873), 169: (3082,427),   170: (3072,367),  171: (3032,1404),