[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6997S526K22V0D6R2D3PJK6":3,"skill-same:01M6997S526K22V0D6R2D3PJK6":71},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":21,"linkOnly":22,"markdownContent":23,"markdownBody":24,"frontMatter":25,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M6997S526K22V0D6R2D3PJK6","ion-2026-analyze-gnss",null,"Use this skill to understand the data format and logic for parsing and interpreting Android GNSS Logger text files, including converting raw measurements into pseudoranges, handling GLONASS\u002FGPS time, and mapping frequencies.","google\u002Fgps-measurement-tools","google","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1342004?v=4","01M698VYEFDM0VJBZDYYJ2T83S","Google","01M6997PYCT96DFCFAMF9JF2V5",842,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fgps-measurement-tools\u002Fblob\u002Fmaster\u002Fgnss_analysis_with_skills\u002FSKILL.md",[],[19,20],"ion 2026 analyze gnss","android","2026-11-10 10:12:30",false,"---\nname: ion-2026-analyze-gnss\ndescription: >-\n  Use this skill to understand the data format and logic for parsing and interpreting Android GNSS Logger text files, including converting raw measurements into pseudoranges, handling GLONASS\u002FGPS time, and mapping frequencies.\n---\n\n# Analyze Android GNSS Logger Data\n\nThis skill contains the domain knowledge required to correctly parse and\ninterpret Android GNSS Logger text files.\n\nYou are an expert Python data scientist. Write a clean, well-structured Colab\nNotebook that reads an Android GNSS Logger file and parses its contents into\npandas DataFrames ready for analysis. All code blocks to be self-contained,\nwell-commented, and start with a `# @title` comment\n\nWhen asked to calculate averages or aggregates, you MUST write a short Python\nsnippet to compute and print the final value. Do not attempt to calculate\naverages mentally.\n\n#### 1. Context and Data Format\n\n-   **Input**: An Android GNSS Logger text file containing metadata and column\n    definitions starting with `#`.\n-   **Dynamic Headers**: Extract column headers dynamically from `# Raw,...`, `#\n    Fix,...`, and `# Nav,...` lines. Keep the message identifier (e.g., `'Raw'`,\n    `'Fix'`, `'Nav'`) as the first column for perfect row alignment.\n-   **Data Cleaning**: Rows often have trailing empty fields or extra commas.\n    Pad or truncate all row arrays to exactly match the target header length to\n    prevent parsing errors.\n-   **Target Records**: Parse `Raw` and `Fix` datasets, and reconstruct full\n    byte payload lists from `Nav` sentences.\n\n#### 2. Required Notebook Structure & Tasks\n\n##### **Cell 1: Setup and File Upload**\n\n-   **Title**: `# @title Setup and File Upload`\n-   **Details**: Import `pandas`, `numpy`, `plotly.express`,\n    `plotly.graph_objects`, `folium`, and `datetime`. Prompt user to upload the\n    log file using `google.colab.files.upload()`.\n\n##### **Cell 2: Data Parsing & Summary**\n\n-   **Title**: `# @title Parse Data and Print Summary`\n-   **Details**:\n    -   Parse into `df_raw`, `df_fix`, and `df_nav` DataFrames.\n    -   Ensure dynamic header mapping and row padding logic are implemented.\n    -   Prevent String-to-Float Errors: Empty CSV fields (`,,`) parse as `\"\"`\n        strings, causing `.astype(float)` to fail. Immediately during parsing in\n        Cell 2, replace `\"\"` with `np.nan` and run `pd.to_numeric(df[col],\n        errors='coerce')` on EVERY column in `df_raw` (except `'Raw'`,\n        `'CodeType'`) and `df_fix` (except `'Fix'`, `'Provider'`,\n        `'SolutionType'`, `'ExtraKeyValuePairs'`) to guarantee float\u002Fnumeric\n        types.\n    -   Print the extracted Metadata (Version, Platform, Manufacturer).\n    -   Print a summary report of `df_raw` in this exact format: `Successfully\n        loaded %d Raw GNSS records, over %d seconds, from time hh:mm:ss to\n        hh:mm:ss UTC`\n\n##### **Cell 3: Constellation & Frequency Mapping**\n\n-   **Title**: `# @title Map Constellations and Frequencies`\n-   **Details**:\n    -   In `df_raw`, map numeric `ConstellationType` to names using `{1: 'GPS',\n        2: 'SBAS', 3: 'GLONASS', 4: 'QZSS', 5: 'BDS', 6: 'Galileo', 7: 'IRNSS'}`\n        under a new `ConstellationName` column.\n    -   Create a `FrequencyBand` column by evaluating `CarrierFrequencyHz` using\n        this exact tolerance mapping function:\n\n```python\ndef get_band_name(constellation, freq_hz):\n    if pd.isna(freq_hz): return 'Unknown'\n    freq_mhz = freq_hz \u002F 1e6\n    if constellation == 'GPS' or constellation == 'QZSS':\n        if abs(freq_mhz - 1575.42) \u003C 5: return 'L1'\n        if abs(freq_mhz - 1176.45) \u003C 5: return 'L5'\n        if abs(freq_mhz - 1227.60) \u003C 5: return 'L2'\n    elif constellation == 'Galileo':\n        if abs(freq_mhz - 1575.42) \u003C 5: return 'E1'\n        if abs(freq_mhz - 1176.45) \u003C 5: return 'E5a'\n        if abs(freq_mhz - 1207.14) \u003C 5: return 'E5b'\n        if abs(freq_mhz - 1278.75) \u003C 5: return 'E6'\n    elif constellation == 'GLONASS':\n        if 1598 \u003C freq_mhz \u003C 1606: return 'G1'\n        if 1242 \u003C freq_mhz \u003C 1249: return 'G2'\n    elif constellation == 'BDS':\n        if abs(freq_mhz - 1561.098) \u003C 5: return 'B1I'\n        if abs(freq_mhz - 1575.42) \u003C 5: return 'B1C'\n        if abs(freq_mhz - 1176.45) \u003C 5: return 'B2a'\n        if abs(freq_mhz - 1207.14) \u003C 5: return 'B2b'\n        if abs(freq_mhz - 1268.52) \u003C 5: return 'B3'\n    return 'Other'\n```\n\n##### **Cell 4: Navigation Message Full Byte Stream Extraction**\n\n-   **Title**: `# @title Extract Full Navigation Bytes`\n-   **Details**:\n    -   Implement a dedicated parser to handle the dynamic length of trailing\n        `Nav` fields.\n    -   The standard header specifies `Data(Bytes)` as the 7th column, but the\n        actual file contains arbitrary comma-separated payload bytes extending\n        to the end of the line.\n    -   Extract all bytes from column index 6 onwards into a single python\n        `list` under a new column `FullBytes` and record the length of this list\n        in a `ByteCount` column.\n    -   Save the output in a DataFrame named `df_nav_full` containing: `['Svid',\n        'Type', 'Status', 'MessageId', 'SubMessageId', 'ByteCount',\n        'FullBytes']`\n\nGeneral Rules Libraries: Use plotly.express for charts and folium for maps. No\nstatic matplotlib. Time formatting: Always convert utcTimeMillis to readable UTC\npandas datetime. Numeric types: Raw logs may leave numeric columns containing\nempty strings ('') as object\u002Fstr dtype. Before any math, transforms, or\nplotting, always coerce target columns in df_raw and df_fix using\npd.to_numeric(df[col], errors='coerce').\n\n# @title Plotting Fixes\n\nPlot the given positions on a map using folium. To avoid OpenStreetMap 403\nForbidden errors, initialize the map with\ntiles='https:\u002F\u002Fserver.arcgisonline.com\u002FArcGIS\u002Frest\u002Fservices\u002FCanvas\u002FWorld_Light_Gray_Base\u002FMapServer\u002Ftile\u002F{z}\u002F{y}\u002F{x}'\nand attr='Tiles &copy; Esri'. Style: Position dots connected by light thin\nlines. Make the first position dot green and the last one red. Group traces by\nthe Provider column and add folium.LayerControl() to toggle them. Tooltip: When\nadding CircleMarkers, configure the tooltip to display the Fix number (index),\nUTC Time, Provider, and the coordinates on a single line formatted exactly as\n`LLA = {lat:.6f}, {lon:.6f}, {alt:.1f}` (e.g., LLA = xx.xxxxxx, yyy.yyyyyy,\nh.h). Computed Positions: When plotting WLS or KF positions, match the styling\nof df_fix maps (dots + thin lines, legends, layer controls).\n\nSignal Counts: Time plots showing signal or satellite counts MUST use a stairs\nline shape. In plotly, use line_shape='hv'\n\n# @title GNSS Performance Plots\n\nCN0 Histograms: Plotly facet grid by Constellation Name. Overlay Frequency Bands\nusing different colors (barmode='overlay'). Satellite Tracking: Stairs-style\ntime series of satellite counts vs. time, organized\u002Fcolored by signal type\n(constellation + frequency band).\n\n# @title Interactive Time Series Explorer\n\nUI: Use a native Colab Form (fields_to_plot = \"AgcDb, Cn0DbHz\" #@param\n{type:\"string\"}). Never use ipywidgets or input(). Menu: Print all valid,\nnon-empty plot fields from df_raw (excluding 'Raw'). Format: alphabetical,\ncomma-separated, new line for each new starting letter. Plots: Generate time\nseries for the selected fields, organized by constellation and frequency type;\nand within each of these categories, plot the values by signal, so each separate\nsignal has a unique line.\n\n# @title Sky Plot of Satellite Positions\n\nAz\u002FEl Calculation: First coerce `df_raw[['SvPositionEcefXMeters',\n'SvPositionEcefYMeters', 'SvPositionEcefZMeters']]` and\n`df_fix[['LatitudeDegrees', 'LongitudeDegrees', 'AltitudeMeters']]` to float via\n`pd.to_numeric(..., errors='coerce')` and drop rows with NaN ECEF coordinates\n(prevents `TypeError: unsupported operand type(s) for -: 'str' and 'float'`).\nUse median Lat\u002FLon\u002FAlt (default Alt=0) from df_fix as reference. Calculate\nAzimuth and Elevation using df_raw ECEF columns (SvPositionEcefXMeters, Y, Z).\nStrict Vectorization: Use !pip install pymap3d and its vectorized functions\n(CRITICAL: `pymap3d.ecef2aer` returns values in the exact order `azimuth,\nelevation, slant_range`), or vectorized numpy. No for-loops. Missing Data: If\nECEF columns are NaN\u002Fempty, print: \"SvPositionEcef[XYZ]Meters are needed in the\nlog file for the skyplot.\" SatLabels: Create standard RINEX labels: prefix\n(GPS:G, GLO:R, QZS:J, BDS:C, GAL:E, IRNSS:I, SBAS:S) + 2-digit zero-padded Svid\n(e.g., G01). To show them on the polar plot, DO NOT use standard annotations\n(like fig.add_annotation). Instead, add a new `go.Scatterpolar` trace with\n`mode='text'`, `showlegend=False`, and `hoverinfo='skip'` , and\ntextposition='bottom right', using the final elevation\u002Fazimuth (r\u002Ftheta)\npositions of each satellite to display the label in small font next to it. Polar\nPlot: px.scatter_polar (r=Elevation, theta=Azimuth). Color by constellation.\nLayout: range=[90, 0](zenith center), direction='clockwise', rotation=90 (North\ntop). Explicitly set `tickfont=dict(color='lightgray')` for both radialaxis and\nangularaxis to make the axis text labels lightgray.\n\nCompute pseudoranges directly from GNSS Logger 'Raw' fields and apply validation\nlogic to filter out bad measurements prior to using them for positioning. All\ncode blocks to start with a # @title comment\n\n**CRITICAL DATA TYPE INSTRUCTION:** When computing nanosecond values\n(`tRxNanos`, `WeekNumberNanos`, `pseudorangeNanos`, etc.) and processing clock\nbiases, you **MUST** ensure all calculations use 64-bit floating point precision\n(`float64` \u002F `np.float64`). Do not allow Pandas or NumPy to default to `int64`\ncomputations, as this will lead to integer truncation and massive coordinate\ndrift.\n\nDefine physical constant: LIGHT_SPEED = 299792458.0\n\nNote on GNSS State Flags: For validation, use the exact\nandroid.location.GnssMeasurement state flag bitmask constants: STATE_CODE_LOCK =\n1 (1 \u003C\u003C 0), STATE_TOW_DECODED = 8 (1 \u003C\u003C 3), STATE_GLO_TOD_DECODED = 128 (1 \u003C\u003C\n7), STATE_GAL_E1BC_CODE_LOCK = 1024 (1 \u003C\u003C 10), STATE_TOW_KNOWN = 16384 (1 \u003C\u003C\n14), STATE_GLO_TOD_KNOWN = 32768 (1 \u003C\u003C 15).\n\nStep 1: Clock Bias Management (Vectorized, no for-loops) Group by\n`HardwareClockDiscontinuityCount` and anchor `StableFullBiasNanos` to the first\nepoch's `FullBiasNanos` in each group using `.transform('first')`:\n`df['StableFullBiasNanos'] =\ndf.groupby('HardwareClockDiscontinuityCount')['FullBiasNanos'].transform('first')`\n**CRITICAL**: NEVER use `.ffill()` on `FullBiasNanos`! Because `FullBiasNanos`\nis non-NaN on every row and drifts across epochs, `.ffill()` is a no-op and\ncauses a >200m pseudorange error.\n\nStep 2: Calculate Base Rx Time Compute the week number in nanoseconds:\nWeekNumberNanos = np.floor(-df['StableFullBiasNanos'] * 1e-9 \u002F 604800) *\n604800 * 1e9 Compute the receiver time: tRxNanos = TimeNanos -\n(StableFullBiasNanos + BiasNanos) - WeekNumberNanos (Treat missing BiasNanos as\n0). Step 3: GPS, Galileo, BeiDou, QZSS For these constellations,\nReceivedSvTimeNanos is measured since the beginning of the GPS week.\n\nFilter the measurements: Use only rows where State has the bits set for\nSTATE_TOW_KNOWN OR STATE_TOW_DECODED. NOTE\n\nWhen doing bitwise operations in pandas like (df['State'] & bitmask) != 0,\nensure you explicitly evaluate it as a boolean by checking != 0 so it chains\ncorrectly with other pandas boolean masks.\n\nCompute: pseudorangeNanos = tRxNanos - ReceivedSvTimeNanos Step 4: GLONASS For\nGLONASS, ReceivedSvTimeNanos is measured since the beginning of the GLONASS day\n(UTC+3 Moscow Time). To adjust for this, you must offset tRxNanos to match\nGLONASS Time of Day:\n\nFilter the measurements: Use only rows where State has the bits set for\nSTATE_GLO_TOD_KNOWN OR STATE_GLO_TOD_DECODED. Handle Leap Seconds: GLONASS time\nis UTC+3 (10,800 seconds). GPS time is UTC + LeapSeconds. If the LeapSecond\ncolumn is missing from the raw data, create it and default it to 18 for all rows\nbefore doing the math to avoid Pandas broadcasting errors. Apply the Offset &\nCompute: Offset tRxNanos by adding (10800 - LeapSecond) * 1e9 nanoseconds.\nCompute the difference: diff_nanos = (tRxNanos + offset_nanos) -\nReceivedSvTimeNanos Apply modulo arithmetic to handle GLONASS time of day\nboundaries seamlessly: pseudorangeNanos = diff_nanos % (86400 * 1e9) Step 5:\nConversion and Plotting Convert to Meters: Compute the pseudoranges (in meters)\nfor all signals using: PseudorangeMeters = pseudorangeNanos * 1e-9 * LIGHT_SPEED\nAdd this to the data frame. Prepare for Plotting: Create a TimeUTC column by\nconverting utcTimeMillis to Pandas datetime. Filter for realistic bounds (e.g.,\nbetween 1e6 and 1e8 meters). Plot: Plot all these pseudoranges vs time\n(TimeUTC), grouping by constellation and by frequency band. Use plotly.express.\nDisplay the plots as side-by-side subplots (faceting by ConstellationName)\nstrictly in a single row without wrapping to new rows (do NOT use\nfacet_col_wrap). Ensure that the y-axes are matched (shared) across all\nsubplots. Step 6: Pseudorange Selection and Validation Before using a\nmeasurement to compute downstream positioning, verify that the pseudorange is\ncompletely valid by inspecting its state flags:\n\nGalileo E1 Signals (GAL_E1_UNKNOWN, GAL_E1_B, GAL_E1_C): Must have either\nSTATE_CODE_LOCK or STATE_GAL_E1BC_CODE_LOCK.\n\nAll Other Signals: Must have STATE_CODE_LOCK. Time of Week (TOW) Check: For\nGLONASS: Must have either STATE_GLO_TOD_KNOWN or STATE_GLO_TOD_DECODED. For all\nothers: Must have either STATE_TOW_DECODED or STATE_TOW_KNOWN.\n\nCreate a field ‘pr_uncertainty_m’ = ReceivedSvTimeUncertaintyNanos *\nLIGHT_SPEED * 1e-9.\n\nAll code blocks must be self-contained, well-commented, and start with a `#\n@title` comment so cells can be easily minimized.\n\n## 1. WLS Position Solver\n\n```python\ndef compute_wls_positions(df_raw, known_xyz_m=None, known_isrbs_m=None, max_iter=15, convergence_threshold=1e-4):\n    # df_raw inputs: PseudorangeMeters, SvClockBiasMeters, ReceivedSvTimeUncertaintyNanos, SvPositionEcef[XYZ]Meters.\n    # Returns: df_wls (epoch states), df_wls_meas (measurement-level df with 'PostFitResidualMeters').\n```\n\n### Rules\n\n*   **Setup**: Coerce all required numeric columns in `df_raw` with\n    `pd.to_numeric(..., errors='coerce')` and drop NaNs. `df['Signal'] =\n    df['ConstellationName'] + '_' + df['FrequencyBand']`. Index unique signals\n    per epoch (`signal_tau_idx`), `GPS_L1` = 0. Stack satellite coordinates\n    before loop: `sv_xyz = meas_df[['SvPositionEcefXMeters',\n    'SvPositionEcefYMeters', 'SvPositionEcefZMeters']].to_numpy(dtype=float)`.\n    Exit with message if empty.\n*   **State Vector**: States are `X, Y, Z, rx_clock_bias`, plus active ISRB\n    states.\n*   **Constraints**:\n    *   If `known_xyz_m` is given: Fix coordinates to it, remove first 3 columns\n        from $H$, and solve only for clock\u002FISRBs.\n    *   If `known_isrbs_m` is given: Correct pseudoranges with those biases,\n        remove relevant ISRB columns from $H$, and solve remaining states.\n*   **Geometry & Sagnac**:\n\n    ```python\n    def calculate_geometry(obs_ecef_m, sv_xyz_at_ttx):\n        delta = sv_xyz_at_ttx - obs_ecef_m\n        l2_norm = np.linalg.norm(delta, axis=1)\n        los = delta \u002F l2_norm[:, None]\n        EARTH_ROTATION_RPS = 7.2921151467e-5\n        LIGHTSPEED = 299792458.0\n        trx = (EARTH_ROTATION_RPS * (sv_xyz_at_ttx[:,0]*obs_ecef_m[1] - sv_xyz_at_ttx[:,1]*obs_ecef_m[0]) \u002F LIGHTSPEED)\n        return l2_norm + trx, los\n    ```\n*   **Solver**: Loop until `dx \u003C convergence_threshold`. Formulate design matrix\n    `H` and weight matrix `W = np.diag(w_pr**2)` (weights `w_pr = 1.0 \u002F\n    pr_uncertainty_m` from `ReceivedSvTimeUncertaintyNanos` in meters). Compute\n    unweighted `PostFitResidualMeters = corrected_pr_m - pr_hat` from final\n    states and return in `df_wls_meas`.\n\nWLS Convergence Rule: Do not save a WLS epoch to df_wls if updates fail to\nconverge within max_iter or if singular matrix math (poor GDOP) causes a\nLinAlgError. Discard the epoch completely if the final position is near the\nEarth's center (ECEF distance from [0,0,0] \u003C 10,000 m) instead of saving default\nvalues.\n\n## 2. WLS Velocity Solver\n\n```python\ndef compute_wls_velocities(df_raw, df_wls, known_vxyz_mps=None):\n    # df_raw inputs: PseudorangeRateMetersPerSecond, SvVelocityEcef[XYZ]MetersPerSecond, PseudorangeRateUncertaintyMetersPerSecond, SvClockDriftMetersPerSecond.\n    # df_wls inputs: Epoch positions (X,Y,Z) to compute LOS vectors.\n    # Returns: df_wls_vel (epoch metrics: Vx, Vy, Vz, Ve, Vn, Vu, speed, clock drift), df_wls_vel_meas (measurement-level residuals).\n```\n\n### Rules\n\n*   **States**: Solve for `Vx, Vy, Vz` and receiver clock frequency drift (m\u002Fs).\n    Use positions from `df_wls` for line-of-sight unit vectors $\\mathbf{a}_i$.\n*   **Model**: Expected pseudorange rate: `prr_hat = (sv_vel - obs_vel) . los +\n    clock_drift`. Design matrix $H_{vel}[:, 0:3] = -\\mathbf{a}_i^T$ and\n    $H_{vel}[:, 3] = 1.0$. Apply `SvClockDriftMetersPerSecond` to correct\n    observations.\n*   **Constraints**: If `known_vxyz_mps` is provided, fix velocity to it, remove\n    the first 3 columns from $H_{vel}$, and solve only for clock drift.\n*   **Residuals**: Compute unweighted `PostFitResidualMps = corrected_prr_m -\n    prr_hat` using final states. Return these in `df_wls_vel_meas`.\n\nPlotting GNSS Data: Plot the given positions on a map using folium. To avoid\nOpenStreetMap 403 Forbidden errors, initialize the map with\ntiles='https:\u002F\u002Fserver.arcgisonline.com\u002FArcGIS\u002Frest\u002Fservices\u002FCanvas\u002FWorld_Light_Gray_Base\u002FMapServer\u002Ftile\u002F{z}\u002F{y}\u002F{x}'\nand attr='Tiles &copy; Esri'. Style: Position dots connected by light thin\nlines. Make the first position dot green and the last one red. Group traces by\nthe Provider column and add folium.LayerControl() to toggle them. Tooltip: When\nadding CircleMarkers, configure the tooltip to display the Fix number (index),\nUTC Time, Provider, and the coordinates on a single line formatted exactly as\n`LLA = {lat:.6f}, {lon:.6f}, {alt:.1f}` (e.g., LLA = xx.xxxxxx, yyy.yyyyyy,\nh.h).\n\nPlotting: Plot horizontal speed and clock frequency in 2 subplots, using plotly,\nFor clock frequency, make the left y-axis m\u002Fs, and the right y-axis ns\u002Fs\n","# Analyze Android GNSS Logger Data\n\nThis skill contains the domain knowledge required to correctly parse and\ninterpret Android GNSS Logger text files.\n\nYou are an expert Python data scientist. Write a clean, well-structured Colab\nNotebook that reads an Android GNSS Logger file and parses its contents into\npandas DataFrames ready for analysis. All code blocks to be self-contained,\nwell-commented, and start with a `# @title` comment\n\nWhen asked to calculate averages or aggregates, you MUST write a short Python\nsnippet to compute and print the final value. Do not attempt to calculate\naverages mentally.\n\n#### 1. Context and Data Format\n\n-   **Input**: An Android GNSS Logger text file containing metadata and column\n    definitions starting with `#`.\n-   **Dynamic Headers**: Extract column headers dynamically from `# Raw,...`, `#\n    Fix,...`, and `# Nav,...` lines. Keep the message identifier (e.g., `'Raw'`,\n    `'Fix'`, `'Nav'`) as the first column for perfect row alignment.\n-   **Data Cleaning**: Rows often have trailing empty fields or extra commas.\n    Pad or truncate all row arrays to exactly match the target header length to\n    prevent parsing errors.\n-   **Target Records**: Parse `Raw` and `Fix` datasets, and reconstruct full\n    byte payload lists from `Nav` sentences.\n\n#### 2. Required Notebook Structure & Tasks\n\n##### **Cell 1: Setup and File Upload**\n\n-   **Title**: `# @title Setup and File Upload`\n-   **Details**: Import `pandas`, `numpy`, `plotly.express`,\n    `plotly.graph_objects`, `folium`, and `datetime`. Prompt user to upload the\n    log file using `google.colab.files.upload()`.\n\n##### **Cell 2: Data Parsing & Summary**\n\n-   **Title**: `# @title Parse Data and Print Summary`\n-   **Details**:\n    -   Parse into `df_raw`, `df_fix`, and `df_nav` DataFrames.\n    -   Ensure dynamic header mapping and row padding logic are implemented.\n    -   Prevent String-to-Float Errors: Empty CSV fields (`,,`) parse as `\"\"`\n        strings, causing `.astype(float)` to fail. Immediately during parsing in\n        Cell 2, replace `\"\"` with `np.nan` and run `pd.to_numeric(df[col],\n        errors='coerce')` on EVERY column in `df_raw` (except `'Raw'`,\n        `'CodeType'`) and `df_fix` (except `'Fix'`, `'Provider'`,\n        `'SolutionType'`, `'ExtraKeyValuePairs'`) to guarantee float\u002Fnumeric\n        types.\n    -   Print the extracted Metadata (Version, Platform, Manufacturer).\n    -   Print a summary report of `df_raw` in this exact format: `Successfully\n        loaded %d Raw GNSS records, over %d seconds, from time hh:mm:ss to\n        hh:mm:ss UTC`\n\n##### **Cell 3: Constellation & Frequency Mapping**\n\n-   **Title**: `# @title Map Constellations and Frequencies`\n-   **Details**:\n    -   In `df_raw`, map numeric `ConstellationType` to names using `{1: 'GPS',\n        2: 'SBAS', 3: 'GLONASS', 4: 'QZSS', 5: 'BDS', 6: 'Galileo', 7: 'IRNSS'}`\n        under a new `ConstellationName` column.\n    -   Create a `FrequencyBand` column by evaluating `CarrierFrequencyHz` using\n        this exact tolerance mapping function:\n\n```python\ndef get_band_name(constellation, freq_hz):\n    if pd.isna(freq_hz): return 'Unknown'\n    freq_mhz = freq_hz \u002F 1e6\n    if constellation == 'GPS' or constellation == 'QZSS':\n        if abs(freq_mhz - 1575.42) \u003C 5: return 'L1'\n        if abs(freq_mhz - 1176.45) \u003C 5: return 'L5'\n        if abs(freq_mhz - 1227.60) \u003C 5: return 'L2'\n    elif constellation == 'Galileo':\n        if abs(freq_mhz - 1575.42) \u003C 5: return 'E1'\n        if abs(freq_mhz - 1176.45) \u003C 5: return 'E5a'\n        if abs(freq_mhz - 1207.14) \u003C 5: return 'E5b'\n        if abs(freq_mhz - 1278.75) \u003C 5: return 'E6'\n    elif constellation == 'GLONASS':\n        if 1598 \u003C freq_mhz \u003C 1606: return 'G1'\n        if 1242 \u003C freq_mhz \u003C 1249: return 'G2'\n    elif constellation == 'BDS':\n        if abs(freq_mhz - 1561.098) \u003C 5: return 'B1I'\n        if abs(freq_mhz - 1575.42) \u003C 5: return 'B1C'\n        if abs(freq_mhz - 1176.45) \u003C 5: return 'B2a'\n        if abs(freq_mhz - 1207.14) \u003C 5: return 'B2b'\n        if abs(freq_mhz - 1268.52) \u003C 5: return 'B3'\n    return 'Other'\n```\n\n##### **Cell 4: Navigation Message Full Byte Stream Extraction**\n\n-   **Title**: `# @title Extract Full Navigation Bytes`\n-   **Details**:\n    -   Implement a dedicated parser to handle the dynamic length of trailing\n        `Nav` fields.\n    -   The standard header specifies `Data(Bytes)` as the 7th column, but the\n        actual file contains arbitrary comma-separated payload bytes extending\n        to the end of the line.\n    -   Extract all bytes from column index 6 onwards into a single python\n        `list` under a new column `FullBytes` and record the length of this list\n        in a `ByteCount` column.\n    -   Save the output in a DataFrame named `df_nav_full` containing: `['Svid',\n        'Type', 'Status', 'MessageId', 'SubMessageId', 'ByteCount',\n        'FullBytes']`\n\nGeneral Rules Libraries: Use plotly.express for charts and folium for maps. No\nstatic matplotlib. Time formatting: Always convert utcTimeMillis to readable UTC\npandas datetime. Numeric types: Raw logs may leave numeric columns containing\nempty strings ('') as object\u002Fstr dtype. Before any math, transforms, or\nplotting, always coerce target columns in df_raw and df_fix using\npd.to_numeric(df[col], errors='coerce').\n\n# @title Plotting Fixes\n\nPlot the given positions on a map using folium. To avoid OpenStreetMap 403\nForbidden errors, initialize the map with\ntiles='https:\u002F\u002Fserver.arcgisonline.com\u002FArcGIS\u002Frest\u002Fservices\u002FCanvas\u002FWorld_Light_Gray_Base\u002FMapServer\u002Ftile\u002F{z}\u002F{y}\u002F{x}'\nand attr='Tiles &copy; Esri'. Style: Position dots connected by light thin\nlines. Make the first position dot green and the last one red. Group traces by\nthe Provider column and add folium.LayerControl() to toggle them. Tooltip: When\nadding CircleMarkers, configure the tooltip to display the Fix number (index),\nUTC Time, Provider, and the coordinates on a single line formatted exactly as\n`LLA = {lat:.6f}, {lon:.6f}, {alt:.1f}` (e.g., LLA = xx.xxxxxx, yyy.yyyyyy,\nh.h). Computed Positions: When plotting WLS or KF positions, match the styling\nof df_fix maps (dots + thin lines, legends, layer controls).\n\nSignal Counts: Time plots showing signal or satellite counts MUST use a stairs\nline shape. In plotly, use line_shape='hv'\n\n# @title GNSS Performance Plots\n\nCN0 Histograms: Plotly facet grid by Constellation Name. Overlay Frequency Bands\nusing different colors (barmode='overlay'). Satellite Tracking: Stairs-style\ntime series of satellite counts vs. time, organized\u002Fcolored by signal type\n(constellation + frequency band).\n\n# @title Interactive Time Series Explorer\n\nUI: Use a native Colab Form (fields_to_plot = \"AgcDb, Cn0DbHz\" #@param\n{type:\"string\"}). Never use ipywidgets or input(). Menu: Print all valid,\nnon-empty plot fields from df_raw (excluding 'Raw'). Format: alphabetical,\ncomma-separated, new line for each new starting letter. Plots: Generate time\nseries for the selected fields, organized by constellation and frequency type;\nand within each of these categories, plot the values by signal, so each separate\nsignal has a unique line.\n\n# @title Sky Plot of Satellite Positions\n\nAz\u002FEl Calculation: First coerce `df_raw[['SvPositionEcefXMeters',\n'SvPositionEcefYMeters', 'SvPositionEcefZMeters']]` and\n`df_fix[['LatitudeDegrees', 'LongitudeDegrees', 'AltitudeMeters']]` to float via\n`pd.to_numeric(..., errors='coerce')` and drop rows with NaN ECEF coordinates\n(prevents `TypeError: unsupported operand type(s) for -: 'str' and 'float'`).\nUse median Lat\u002FLon\u002FAlt (default Alt=0) from df_fix as reference. Calculate\nAzimuth and Elevation using df_raw ECEF columns (SvPositionEcefXMeters, Y, Z).\nStrict Vectorization: Use !pip install pymap3d and its vectorized functions\n(CRITICAL: `pymap3d.ecef2aer` returns values in the exact order `azimuth,\nelevation, slant_range`), or vectorized numpy. No for-loops. Missing Data: If\nECEF columns are NaN\u002Fempty, print: \"SvPositionEcef[XYZ]Meters are needed in the\nlog file for the skyplot.\" SatLabels: Create standard RINEX labels: prefix\n(GPS:G, GLO:R, QZS:J, BDS:C, GAL:E, IRNSS:I, SBAS:S) + 2-digit zero-padded Svid\n(e.g., G01). To show them on the polar plot, DO NOT use standard annotations\n(like fig.add_annotation). Instead, add a new `go.Scatterpolar` trace with\n`mode='text'`, `showlegend=False`, and `hoverinfo='skip'` , and\ntextposition='bottom right', using the final elevation\u002Fazimuth (r\u002Ftheta)\npositions of each satellite to display the label in small font next to it. Polar\nPlot: px.scatter_polar (r=Elevation, theta=Azimuth). Color by constellation.\nLayout: range=[90, 0](zenith center), direction='clockwise', rotation=90 (North\ntop). Explicitly set `tickfont=dict(color='lightgray')` for both radialaxis and\nangularaxis to make the axis text labels lightgray.\n\nCompute pseudoranges directly from GNSS Logger 'Raw' fields and apply validation\nlogic to filter out bad measurements prior to using them for positioning. All\ncode blocks to start with a # @title comment\n\n**CRITICAL DATA TYPE INSTRUCTION:** When computing nanosecond values\n(`tRxNanos`, `WeekNumberNanos`, `pseudorangeNanos`, etc.) and processing clock\nbiases, you **MUST** ensure all calculations use 64-bit floating point precision\n(`float64` \u002F `np.float64`). Do not allow Pandas or NumPy to default to `int64`\ncomputations, as this will lead to integer truncation and massive coordinate\ndrift.\n\nDefine physical constant: LIGHT_SPEED = 299792458.0\n\nNote on GNSS State Flags: For validation, use the exact\nandroid.location.GnssMeasurement state flag bitmask constants: STATE_CODE_LOCK =\n1 (1 \u003C\u003C 0), STATE_TOW_DECODED = 8 (1 \u003C\u003C 3), STATE_GLO_TOD_DECODED = 128 (1 \u003C\u003C\n7), STATE_GAL_E1BC_CODE_LOCK = 1024 (1 \u003C\u003C 10), STATE_TOW_KNOWN = 16384 (1 \u003C\u003C\n14), STATE_GLO_TOD_KNOWN = 32768 (1 \u003C\u003C 15).\n\nStep 1: Clock Bias Management (Vectorized, no for-loops) Group by\n`HardwareClockDiscontinuityCount` and anchor `StableFullBiasNanos` to the first\nepoch's `FullBiasNanos` in each group using `.transform('first')`:\n`df['StableFullBiasNanos'] =\ndf.groupby('HardwareClockDiscontinuityCount')['FullBiasNanos'].transform('first')`\n**CRITICAL**: NEVER use `.ffill()` on `FullBiasNanos`! Because `FullBiasNanos`\nis non-NaN on every row and drifts across epochs, `.ffill()` is a no-op and\ncauses a >200m pseudorange error.\n\nStep 2: Calculate Base Rx Time Compute the week number in nanoseconds:\nWeekNumberNanos = np.floor(-df['StableFullBiasNanos'] * 1e-9 \u002F 604800) *\n604800 * 1e9 Compute the receiver time: tRxNanos = TimeNanos -\n(StableFullBiasNanos + BiasNanos) - WeekNumberNanos (Treat missing BiasNanos as\n0). Step 3: GPS, Galileo, BeiDou, QZSS For these constellations,\nReceivedSvTimeNanos is measured since the beginning of the GPS week.\n\nFilter the measurements: Use only rows where State has the bits set for\nSTATE_TOW_KNOWN OR STATE_TOW_DECODED. NOTE\n\nWhen doing bitwise operations in pandas like (df['State'] & bitmask) != 0,\nensure you explicitly evaluate it as a boolean by checking != 0 so it chains\ncorrectly with other pandas boolean masks.\n\nCompute: pseudorangeNanos = tRxNanos - ReceivedSvTimeNanos Step 4: GLONASS For\nGLONASS, ReceivedSvTimeNanos is measured since the beginning of the GLONASS day\n(UTC+3 Moscow Time). To adjust for this, you must offset tRxNanos to match\nGLONASS Time of Day:\n\nFilter the measurements: Use only rows where State has the bits set for\nSTATE_GLO_TOD_KNOWN OR STATE_GLO_TOD_DECODED. Handle Leap Seconds: GLONASS time\nis UTC+3 (10,800 seconds). GPS time is UTC + LeapSeconds. If the LeapSecond\ncolumn is missing from the raw data, create it and default it to 18 for all rows\nbefore doing the math to avoid Pandas broadcasting errors. Apply the Offset &\nCompute: Offset tRxNanos by adding (10800 - LeapSecond) * 1e9 nanoseconds.\nCompute the difference: diff_nanos = (tRxNanos + offset_nanos) -\nReceivedSvTimeNanos Apply modulo arithmetic to handle GLONASS time of day\nboundaries seamlessly: pseudorangeNanos = diff_nanos % (86400 * 1e9) Step 5:\nConversion and Plotting Convert to Meters: Compute the pseudoranges (in meters)\nfor all signals using: PseudorangeMeters = pseudorangeNanos * 1e-9 * LIGHT_SPEED\nAdd this to the data frame. Prepare for Plotting: Create a TimeUTC column by\nconverting utcTimeMillis to Pandas datetime. Filter for realistic bounds (e.g.,\nbetween 1e6 and 1e8 meters). Plot: Plot all these pseudoranges vs time\n(TimeUTC), grouping by constellation and by frequency band. Use plotly.express.\nDisplay the plots as side-by-side subplots (faceting by ConstellationName)\nstrictly in a single row without wrapping to new rows (do NOT use\nfacet_col_wrap). Ensure that the y-axes are matched (shared) across all\nsubplots. Step 6: Pseudorange Selection and Validation Before using a\nmeasurement to compute downstream positioning, verify that the pseudorange is\ncompletely valid by inspecting its state flags:\n\nGalileo E1 Signals (GAL_E1_UNKNOWN, GAL_E1_B, GAL_E1_C): Must have either\nSTATE_CODE_LOCK or STATE_GAL_E1BC_CODE_LOCK.\n\nAll Other Signals: Must have STATE_CODE_LOCK. Time of Week (TOW) Check: For\nGLONASS: Must have either STATE_GLO_TOD_KNOWN or STATE_GLO_TOD_DECODED. For all\nothers: Must have either STATE_TOW_DECODED or STATE_TOW_KNOWN.\n\nCreate a field ‘pr_uncertainty_m’ = ReceivedSvTimeUncertaintyNanos *\nLIGHT_SPEED * 1e-9.\n\nAll code blocks must be self-contained, well-commented, and start with a `#\n@title` comment so cells can be easily minimized.\n\n## 1. WLS Position Solver\n\n```python\ndef compute_wls_positions(df_raw, known_xyz_m=None, known_isrbs_m=None, max_iter=15, convergence_threshold=1e-4):\n    # df_raw inputs: PseudorangeMeters, SvClockBiasMeters, ReceivedSvTimeUncertaintyNanos, SvPositionEcef[XYZ]Meters.\n    # Returns: df_wls (epoch states), df_wls_meas (measurement-level df with 'PostFitResidualMeters').\n```\n\n### Rules\n\n*   **Setup**: Coerce all required numeric columns in `df_raw` with\n    `pd.to_numeric(..., errors='coerce')` and drop NaNs. `df['Signal'] =\n    df['ConstellationName'] + '_' + df['FrequencyBand']`. Index unique signals\n    per epoch (`signal_tau_idx`), `GPS_L1` = 0. Stack satellite coordinates\n    before loop: `sv_xyz = meas_df[['SvPositionEcefXMeters',\n    'SvPositionEcefYMeters', 'SvPositionEcefZMeters']].to_numpy(dtype=float)`.\n    Exit with message if empty.\n*   **State Vector**: States are `X, Y, Z, rx_clock_bias`, plus active ISRB\n    states.\n*   **Constraints**:\n    *   If `known_xyz_m` is given: Fix coordinates to it, remove first 3 columns\n        from $H$, and solve only for clock\u002FISRBs.\n    *   If `known_isrbs_m` is given: Correct pseudoranges with those biases,\n        remove relevant ISRB columns from $H$, and solve remaining states.\n*   **Geometry & Sagnac**:\n\n    ```python\n    def calculate_geometry(obs_ecef_m, sv_xyz_at_ttx):\n        delta = sv_xyz_at_ttx - obs_ecef_m\n        l2_norm = np.linalg.norm(delta, axis=1)\n        los = delta \u002F l2_norm[:, None]\n        EARTH_ROTATION_RPS = 7.2921151467e-5\n        LIGHTSPEED = 299792458.0\n        trx = (EARTH_ROTATION_RPS * (sv_xyz_at_ttx[:,0]*obs_ecef_m[1] - sv_xyz_at_ttx[:,1]*obs_ecef_m[0]) \u002F LIGHTSPEED)\n        return l2_norm + trx, los\n    ```\n*   **Solver**: Loop until `dx \u003C convergence_threshold`. Formulate design matrix\n    `H` and weight matrix `W = np.diag(w_pr**2)` (weights `w_pr = 1.0 \u002F\n    pr_uncertainty_m` from `ReceivedSvTimeUncertaintyNanos` in meters). Compute\n    unweighted `PostFitResidualMeters = corrected_pr_m - pr_hat` from final\n    states and return in `df_wls_meas`.\n\nWLS Convergence Rule: Do not save a WLS epoch to df_wls if updates fail to\nconverge within max_iter or if singular matrix math (poor GDOP) causes a\nLinAlgError. Discard the epoch completely if the final position is near the\nEarth's center (ECEF distance from [0,0,0] \u003C 10,000 m) instead of saving default\nvalues.\n\n## 2. WLS Velocity Solver\n\n```python\ndef compute_wls_velocities(df_raw, df_wls, known_vxyz_mps=None):\n    # df_raw inputs: PseudorangeRateMetersPerSecond, SvVelocityEcef[XYZ]MetersPerSecond, PseudorangeRateUncertaintyMetersPerSecond, SvClockDriftMetersPerSecond.\n    # df_wls inputs: Epoch positions (X,Y,Z) to compute LOS vectors.\n    # Returns: df_wls_vel (epoch metrics: Vx, Vy, Vz, Ve, Vn, Vu, speed, clock drift), df_wls_vel_meas (measurement-level residuals).\n```\n\n### Rules\n\n*   **States**: Solve for `Vx, Vy, Vz` and receiver clock frequency drift (m\u002Fs).\n    Use positions from `df_wls` for line-of-sight unit vectors $\\mathbf{a}_i$.\n*   **Model**: Expected pseudorange rate: `prr_hat = (sv_vel - obs_vel) . los +\n    clock_drift`. Design matrix $H_{vel}[:, 0:3] = -\\mathbf{a}_i^T$ and\n    $H_{vel}[:, 3] = 1.0$. Apply `SvClockDriftMetersPerSecond` to correct\n    observations.\n*   **Constraints**: If `known_vxyz_mps` is provided, fix velocity to it, remove\n    the first 3 columns from $H_{vel}$, and solve only for clock drift.\n*   **Residuals**: Compute unweighted `PostFitResidualMps = corrected_prr_m -\n    prr_hat` using final states. Return these in `df_wls_vel_meas`.\n\nPlotting GNSS Data: Plot the given positions on a map using folium. To avoid\nOpenStreetMap 403 Forbidden errors, initialize the map with\ntiles='https:\u002F\u002Fserver.arcgisonline.com\u002FArcGIS\u002Frest\u002Fservices\u002FCanvas\u002FWorld_Light_Gray_Base\u002FMapServer\u002Ftile\u002F{z}\u002F{y}\u002F{x}'\nand attr='Tiles &copy; Esri'. Style: Position dots connected by light thin\nlines. Make the first position dot green and the last one red. Group traces by\nthe Provider column and add folium.LayerControl() to toggle them. Tooltip: When\nadding CircleMarkers, configure the tooltip to display the Fix number (index),\nUTC Time, Provider, and the coordinates on a single line formatted exactly as\n`LLA = {lat:.6f}, {lon:.6f}, {alt:.1f}` (e.g., LLA = xx.xxxxxx, yyy.yyyyyy,\nh.h).\n\nPlotting: Plot horizontal speed and clock frequency in 2 subplots, using plotly,\nFor clock frequency, make the left y-axis m\u002Fs, and the right y-axis ns\u002Fs\n",{"name":5,"description":7},"master","15d6daedd120d622c4a53c498b7d61e1abbdb478","gnss_analysis_with_skills",371,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fgps-measurement-tools","https:\u002F\u002Fgithub.com\u002Fgoogle","https:\u002F\u002Fopensource.google\u002F","Google ❤️ Open Source","2026-10-19 20:59:44",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add google\u002Fgps-measurement-tools --skill ion-2026-analyze-gnss",{"tool":41,"command":42},"bunx","bunx skills add google\u002Fgps-measurement-tools --skill ion-2026-analyze-gnss",{"tool":44,"command":45},"pnpm","pnpm dlx skills add google\u002Fgps-measurement-tools --skill ion-2026-analyze-gnss","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fgps-measurement-tools\u002Fblob\u002Fmaster\u002Fgnss_analysis_with_skills\u002FSKILL.md",true,[49,55,61,67],{"path":50,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":53,"sourceHtmlUrl":54},"10_epoch_test.txt","REFERENCE","参考文档",254214,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fgps-measurement-tools\u002Fblob\u002Fmaster\u002Fgnss_analysis_with_skills\u002F10_epoch_test.txt",{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"gnss_analysis_colab_with_skills.gif","ASSET","资产文件",34230108,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fgps-measurement-tools\u002Fblob\u002Fmaster\u002Fgnss_analysis_with_skills\u002Fgnss_analysis_colab_with_skills.gif",{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},"gnss_analysis_with_skills.ipynb","OTHER","其他",20973,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fgps-measurement-tools\u002Fblob\u002Fmaster\u002Fgnss_analysis_with_skills\u002Fgnss_analysis_with_skills.ipynb",{"path":68,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":69,"sourceHtmlUrl":70},"README.md",12224,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fgps-measurement-tools\u002Fblob\u002Fmaster\u002Fgnss_analysis_with_skills\u002FREADME.md",[]]