Skip to content

Commit 6383e58

Browse files
committed
Grammar and formatting changes
1 parent b7b4b16 commit 6383e58

3 files changed

Lines changed: 90 additions & 86 deletions

File tree

gnss_lib_py/parsers/precise_ephemerides.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def parse_clockfile(input_path, constellation = 'gps'):
296296

297297
return clkdata
298298

299-
def extract_sp3_func(sp3data, sidx, ipos = 10, \
299+
def extract_sp3(sp3data, sidx, ipos = 10, \
300300
method = 'CubicSpline', verbose = False):
301301
"""Computing interpolated function over sp3 data for any GNSS
302302
@@ -341,7 +341,7 @@ def extract_sp3_func(sp3data, sidx, ipos = 10, \
341341

342342
return func_satpos
343343

344-
def extract_clk_func(clkdata, sidx, ipos = 10, \
344+
def extract_clk(clkdata, sidx, ipos = 10, \
345345
method='CubicSpline', verbose = False):
346346
"""Computing interpolated function over clk data for any GNSS
347347
@@ -378,7 +378,7 @@ def extract_clk_func(clkdata, sidx, ipos = 10, \
378378

379379
return func_satbias
380380

381-
def compute_sp3_snapshot(func_satpos, cxtime, hstep = 5e-1, method='CubicSpline'):
381+
def sp3_snapshot(func_satpos, cxtime, hstep = 5e-1, method='CubicSpline'):
382382
"""Compute satellite 3-D position and velocity from sp3 interpolated function
383383
384384
Parameters
@@ -415,7 +415,7 @@ def compute_sp3_snapshot(func_satpos, cxtime, hstep = 5e-1, method='CubicSpline'
415415

416416
return satpos_sp3, (satvel_sp3 * 1e3)
417417

418-
def compute_clk_snapshot(func_satbias, cxtime, hstep = 5e-1, method='CubicSpline'):
418+
def clk_snapshot(func_satbias, cxtime, hstep = 5e-1, method='CubicSpline'):
419419
"""Compute satellite clock bias and drift from clk interpolated function
420420
421421
Parameters
@@ -447,7 +447,7 @@ def compute_clk_snapshot(func_satbias, cxtime, hstep = 5e-1, method='CubicSpline
447447

448448
return satbias_clk, (satdrift_clk * 1e3)
449449

450-
def compute_single_gnss_from_precise_eph(navdata, sp3_parsed_file, \
450+
def single_gnss_from_precise_eph(navdata, sp3_parsed_file, \
451451
clk_parsed_file, verbose = False):
452452
"""Compute satellite information using .sp3 and .clk for any GNSS constellation
453453
@@ -546,14 +546,14 @@ def compute_single_gnss_from_precise_eph(navdata, sp3_parsed_file, \
546546
# if does not hold, recompute the interpolation function based on current iref
547547
if verbose:
548548
print('SP3: Computing new interpolation!')
549-
func_satpos = extract_sp3_func(sp3_parsed_file[prn], \
549+
func_satpos = extract_sp3(sp3_parsed_file[prn], \
550550
sp3_iref, method = interp_method)
551551
# Update the relevant interp function and iref values
552552
satfunc_xyz_old[prn] = func_satpos
553553
sp3_iref_old[prn] = sp3_iref
554554

555555
# Compute satellite position and velocity using interpolated function
556-
satpos_sp3, satvel_sp3 = compute_sp3_snapshot(func_satpos, \
556+
satpos_sp3, satvel_sp3 = sp3_snapshot(func_satpos, \
557557
(timestep - navdata_offset), \
558558
method = interp_method)
559559

@@ -572,15 +572,15 @@ def compute_single_gnss_from_precise_eph(navdata, sp3_parsed_file, \
572572
# if does not hold, recompute the interpolation function based on current iref
573573
if verbose:
574574
print('CLK: Computing new interpolation!')
575-
func_satbias = extract_clk_func(clk_parsed_file[prn], \
575+
func_satbias = extract_clk(clk_parsed_file[prn], \
576576
clk_iref, method = interp_method)
577577
# Update the relevant interp function and iref values
578578
satfunc_t_old[prn] = func_satbias
579579
clk_iref_old[prn] = clk_iref
580580

581581
# Compute satellite clock bias and drift using interpolated function
582582
satbias_clk, \
583-
satdrift_clk = compute_clk_snapshot(func_satbias, \
583+
satdrift_clk = clk_snapshot(func_satbias, \
584584
(timestep - navdata_offset), \
585585
method = interp_method)
586586
if verbose:
@@ -656,7 +656,7 @@ def compute_single_gnss_from_precise_eph(navdata, sp3_parsed_file, \
656656

657657
return navdata
658658

659-
def compute_multi_gnss_from_precise_eph(navdata, sp3_path, clk_path, \
659+
def multi_gnss_from_precise_eph(navdata, sp3_path, clk_path, \
660660
gnss_consts, verbose = False):
661661
"""Compute satellite information using .sp3 and .clk for multiple GNSS
662662
@@ -685,15 +685,15 @@ def compute_multi_gnss_from_precise_eph(navdata, sp3_path, clk_path, \
685685

686686
sp3_parsed_gnss = parse_sp3(sp3_path, constellation = sv)
687687
clk_parsed_gnss = parse_clockfile(clk_path, constellation = sv)
688-
derived_prcs_gnss = compute_single_gnss_from_precise_eph(navdata_prcs_gnss, \
688+
derived_prcs_gnss = single_gnss_from_precise_eph(navdata_prcs_gnss, \
689689
sp3_parsed_gnss, \
690690
clk_parsed_gnss, \
691691
verbose = verbose)
692692
navdata_prcs_merged.concat(navdata_prcs_gnss, inplace=True)
693693

694694
return navdata_prcs_merged
695695

696-
def compute_sv_gps_from_brdcst_eph(navdata, verbose = False):
696+
def sv_gps_from_brdcst_eph(navdata, verbose = False):
697697
"""Compute satellite information using .n for any GNSS constellation
698698
699699
Parameters

notebooks/tutorials/parsers.ipynb

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -556,25 +556,22 @@
556556
"id": "3c5de62f",
557557
"metadata": {},
558558
"source": [
559-
"The data required associated with precise ephemerides involves .sp3 and .clk files, which can be downloaded from [CDDIS](https://cddis.nasa.gov/Data_and_Derived_Products/GNSS/gnss_mgex.html) or [CORS](https://geodesy.noaa.gov/UFCORS/).\n",
559+
"The data required to calculate with precise ephemerides uses .sp3 and .clk files, which can be downloaded from [CDDIS](https://cddis.nasa.gov/Data_and_Derived_Products/GNSS/gnss_mgex.html) or [CORS](https://geodesy.noaa.gov/UFCORS/).\n",
560560
"\n",
561-
"The .sp3 files provides post-processed, accurate and precise information regarding the 3-D satellite position in Earth-Centered Earth-Fixed (ECEF) frame at intervals of 15mins each. \n",
561+
"The .sp3 files provide post-processed, accurate, and precise information regarding 3-D satellite position in the Earth-Centered Earth-Fixed (ECEF) frame at intervals of 15mins each. \n",
562562
"\n",
563-
"Similarly, the .clk files provides post-processed, accurate and precise information on satellite clock errors at intervals of 30secs each. \n",
563+
"Similarly, the .clk files provide post-processed, accurate and precise information on satellite clock errors at intervals of 30secs each. \n",
564564
"\n",
565-
"These .sp3 and .clk files are available for any GNSS constellation, and hence, provides a common processing platform for applications that involve multi-GNSS satellite signals (without requiring to parse the individual broadcast ephemeris in a separate, individual manner). Also, unlike broadcast ephemeris that can suffer from signal-in-space anomalies, the .sp3 and .clk files are guaranteed to provide accurate satellite information. However, note that, these files are only available in a post-processed manner, and not in real-time"
565+
"These .sp3 and .clk files are available for any GNSS constellation, and hence, provide a common processing platform for applications that involve multi-GNSS satellite signals (without requiring to parse the broadcast ephemeris from each constellation separately one at a time). Also, unlike broadcast ephemeris that can suffer from signal-in-space anomalies, the .sp3 and .clk files are guaranteed to provide accurate satellite information. However, note that, these files are only available in a post-processed manner, and not in real-time"
566566
]
567567
},
568568
{
569569
"cell_type": "markdown",
570570
"id": "67fc4f2e",
571571
"metadata": {},
572572
"source": [
573-
"To analyze this precise ephemerides functionality, \n",
574-
"1. Load the derived data from AndroidDerived\n",
575-
"2. Remove the rows in NavData class that refer to satellite information (3-D satellite position, 3-D satellite velocity, clock bias and clock drift), i.e., SV_KEYS =['x_sv_m', 'y_sv_m', 'z_sv_m', 'vx_sv_mps','vy_sv_mps','vz_sv_mps', 'b_sv_m', 'b_dot_sv_mps']\n",
576-
"3. Specify the .sp3 and .clk files, as well as the desired constellations from which one intends to extract satellite information\n",
577-
"4. Populate the columns of SV_KEYS with information extracted via precise ephemerides"
573+
"We show how to analyze this precise ephemerides functionality for the Android derived dataset in the following cells, \n",
574+
"1. Load the derived data from AndroidDerived"
578575
]
579576
},
580577
{
@@ -584,48 +581,51 @@
584581
"metadata": {},
585582
"outputs": [],
586583
"source": [
587-
"from gnss_lib_py.parsers.precise_ephemerides import compute_multi_gnss_from_precise_eph\n",
588-
"import numpy as np"
584+
"from gnss_lib_py.parsers.precise_ephemerides import multi_gnss_from_precise_eph\n",
585+
"import numpy as np\n",
586+
"\n",
587+
"# load Android Google Challenge data\n",
588+
"!wget https://raw.githubusercontent.com/Stanford-NavLab/gnss_lib_py/ramya/multiGNSS_sp3/data/unit_test/android_2021/Pixel4_derived_clkdiscnt.csv --quiet -O \"Pixel4_derived_clkdiscnt.csv\"\n",
589+
"derived_data = AndroidDerived2021(\"Pixel4_derived_clkdiscnt.csv\", remove_timing_outliers=False)"
589590
]
590591
},
591592
{
592-
"cell_type": "code",
593-
"execution_count": null,
594-
"id": "e62ed8ee",
593+
"cell_type": "markdown",
594+
"id": "4e4ee7c8",
595595
"metadata": {},
596-
"outputs": [],
597596
"source": [
598-
"# download .sp3 data file\n",
599-
"!wget https://raw.githubusercontent.com/Stanford-NavLab/gnss_lib_py/ramya/multiGNSS_sp3/data/unit_test/precise_ephemeris/grg21553_short.sp3 --quiet -O \"grg21553_short.sp3\"\n",
600-
"\n",
601-
"# Specify .sp3 file path to extract precise ephemerides\n",
602-
"sp3_path = \"grg21553_short.sp3\""
597+
"2. Specify the paths to the .sp3 and .clk files, as well as the desired constellations from which one intends to extract satellite information"
603598
]
604599
},
605600
{
606601
"cell_type": "code",
607602
"execution_count": null,
608-
"id": "50467c3f",
603+
"id": "e62ed8ee",
609604
"metadata": {},
610605
"outputs": [],
611606
"source": [
607+
"# download .sp3 data file\n",
608+
"!wget https://raw.githubusercontent.com/Stanford-NavLab/gnss_lib_py/ramya/multiGNSS_sp3/data/unit_test/precise_ephemeris/grg21553_short.sp3 --quiet -O \"grg21553_short.sp3\"\n",
609+
"# Specify .sp3 file path to extract precise ephemerides\n",
610+
"sp3_path = \"grg21553_short.sp3\"\n",
611+
"\n",
612612
"# download .clk data file\n",
613613
"!wget https://raw.githubusercontent.com/Stanford-NavLab/gnss_lib_py/ramya/multiGNSS_sp3/data/unit_test/precise_ephemeris/grg21553_short.clk --quiet -O \"grg21553_short.clk\"\n",
614-
"\n",
615614
"# Specify .clk file path to extract precise ephemerides\n",
616-
"clk_path = \"grg21553_short.clk\""
615+
"clk_path = \"grg21553_short.clk\"\n",
616+
"\n",
617+
"# Specify the GNSS constellations for which you want to extract precise ephemeris\n",
618+
"gnss_constellations = {'gps', 'glonass'}"
617619
]
618620
},
619621
{
620-
"cell_type": "code",
621-
"execution_count": null,
622-
"id": "cadb1cf1",
622+
"cell_type": "markdown",
623+
"id": "2567ff0f",
623624
"metadata": {},
624-
"outputs": [],
625625
"source": [
626-
"# load Android Google Challenge data\n",
627-
"!wget https://raw.githubusercontent.com/Stanford-NavLab/gnss_lib_py/ramya/multiGNSS_sp3/data/unit_test/android_2021/Pixel4_derived_clkdiscnt.csv --quiet -O \"Pixel4_derived_clkdiscnt.csv\"\n",
628-
"derived_data = AndroidDerived2021(\"Pixel4_derived_clkdiscnt.csv\", remove_timing_outliers=False)"
626+
"3. Remove the rows in NavData class that refer to satellite information (3-D satellite position, 3-D satellite velocity, clock bias and clock drift), \n",
627+
"\n",
628+
" i.e., `SV_KEYS =['x_sv_m', 'y_sv_m', 'z_sv_m', 'vx_sv_mps','vy_sv_mps','vz_sv_mps', 'b_sv_m', 'b_dot_sv_mps']`"
629629
]
630630
},
631631
{
@@ -641,7 +641,15 @@
641641
" 'b_sv_m', 'b_dot_sv_mps']\n",
642642
"\n",
643643
"for sv in SV_KEYS:\n",
644-
" derived_data[sv] = 0*derived_data[sv]"
644+
" derived_data[sv] = 0"
645+
]
646+
},
647+
{
648+
"cell_type": "markdown",
649+
"id": "458b0a46",
650+
"metadata": {},
651+
"source": [
652+
"4. Populate the columns of SV_KEYS with information extracted via precise ephemerides"
645653
]
646654
},
647655
{
@@ -651,12 +659,9 @@
651659
"metadata": {},
652660
"outputs": [],
653661
"source": [
654-
"# Specify the GNSS constellations for which you want to extract precise ephemeris\n",
655-
"gnss_consts = {'gps', 'glonass'}\n",
656-
"\n",
657662
"# Update derived_data class with satellite information computed via precise ephemerides\n",
658-
"derived_multi_gnss = compute_multi_gnss_from_precise_eph(derived_data, sp3_path, \\\n",
659-
" clk_path, gnss_consts, verbose = False)"
663+
"derived_multi_gnss = multi_gnss_from_precise_eph(derived_data, sp3_path, \\\n",
664+
" clk_path, gnss_constellations, verbose = False)"
660665
]
661666
},
662667
{
@@ -668,13 +673,13 @@
668673
"source": [
669674
"# Check that all the desired fields related to satellite information have useful\n",
670675
"# information, and norm of computed satellite position matches the altitude of GNSS constellation\n",
671-
"norm_val = np.linalg.norm(np.transpose([derived_multi_gnss[SV_KEYS[0]][0:2],\n",
676+
"sat_alt = np.linalg.norm(np.transpose([derived_multi_gnss[SV_KEYS[0]][0:2],\n",
672677
" derived_multi_gnss[SV_KEYS[1]][0:2], \n",
673678
" derived_multi_gnss[SV_KEYS[2]][0:2]]), axis=1)\n",
674-
"print(derived_multi_gnss[\"gnss_id\"][0:2], norm_val)\n",
675-
"print(\" \")\n",
679+
"print('Distance of two satellites from the center of the Earth (expected around 26000000 m):', derived_multi_gnss[\"gnss_id\"][0:2], sat_alt)\n",
680+
"print(\"Extracted values for same satellites: \")\n",
676681
"for sv in SV_KEYS:\n",
677-
" print(sv, derived_multi_gnss[sv][0:2])"
682+
" print(sv, ':', derived_multi_gnss[sv][0:2])"
678683
]
679684
}
680685
],

0 commit comments

Comments
 (0)