Main Content

semread

Read data from SEM almanac file

Since R2022b

    Description

    [data,title] = semread(filename) reads data from the SEM (System Effectiveness Model) almanac file for the date specified by filename, and returns the parameters of each associated satellite as a timetable, as well as the almanac title.

    example

    [data,title] = semread(filename,GPSWeekEpoch=refdate) specifies the reference date from which the SEM almanac file counts the GPS (Global Positioning System) week number.

    Examples

    collapse all

    Download the SEM almanac file from NAVCEN website and parse it. Specify the date for which the file is to be downloaded.

    d = datetime("today") - 2;

    Create the URL.

    baseURL = "https://www.navcen.uscg.gov/sites/default/files/gps/almanac/";
    almanacType = "/sem/";
    almanacExtension = ".al3";
    url = baseURL + d.Year + almanacType + day(d,"dayofyear") + ...
          almanacExtension;

    Specify the file name.

    filename = "semalmanac" + "_" + d.Year + "-" + ...
               d.Month + "-" + d.Day + ".al3";
    

    Save the file.

    websave(filename,url);

    Get the orbital parameters from the downloaded SEM almanac file.

    [data,title] = semread(filename)
    data=31×16 timetable
                Time            GPSWeekNumber    GPSTimeOfApplicability    PRNNumber    SVN    AverageURANumber        Eccentricity         InclinationOffset      RateOfRightAscension     SqrtOfSemiMajorAxis    GeographicLongitudeOfOrbitalPlane    ArgumentOfPerigee        MeanAnomaly        ZerothOrderClockCorrection    FirstOrderClockCorrection    SatelliteHealth    SatelliteConfiguration
        ____________________    _____________    ______________________    _________    ___    ________________    ____________________    ____________________    _____________________    ___________________    _________________________________    __________________    __________________    __________________________    _________________________    _______________    ______________________
    
        17-Jul-2022 17:03:42        2219                 61440                 1        63            0              0.0120391845703125      0.0144615173339844    -2.48837750405073e-09     5153.61865234375               0.51555073261261             0.297461271286011     0.881654858589172       0.000319480895996094         -7.27595761418343e-12             0                     11          
        17-Jul-2022 17:03:42        2219                 61440                 2        61            1              0.0199451446533203       0.007476806640625    -2.53567122854292e-09     5154.81982421875              0.486109972000122            -0.446799159049988     0.925528883934021      -0.000651359558105469                             0             0                      9          
        17-Jul-2022 17:03:42        2219                 61440                 3        69            0             0.00439071655273438      0.0102882385253906    -2.56841303780675e-09     5153.53857421875              0.844612836837769             0.320030331611633     0.529847264289856      -0.000309944152832031         -1.09139364212751e-11             0                     11          
        17-Jul-2022 17:03:42        2219                 61440                 4        74            0             0.00190067291259766     0.00612449645996094    -2.46654963120818e-09     5153.54736328125             -0.811291694641113            -0.953091979026794    -0.536049604415894       -0.00014495849609375          3.63797880709171e-12             0                     12          
        17-Jul-2022 17:03:42        2219                 61440                 5        50            0             0.00610446929931641     0.00614738464355469    -2.61570676229894e-09     5153.70166015625              0.831113338470459             0.338927388191223    -0.287315726280212      -8.96453857421875e-05                             0             0                     10          
        17-Jul-2022 17:03:42        2219                 61440                 6        67            0             0.00243806838989258      0.0142459869384766    -2.48473952524364e-09           5153.71875              0.512914299964905            -0.275499105453491     0.955711841583252        0.00038909912109375          1.45519152283669e-11             0                     11          
        17-Jul-2022 17:03:42        2219                 61440                 7        48            0              0.0163321495056152     0.00248146057128906    -2.53567122854292e-09           5153.59375             -0.487354755401611            -0.716959476470947     0.676499962806702       0.000318527221679688                             0             0                     10          
        17-Jul-2022 17:03:42        2219                 61440                 8        72            0                0.00738525390625     0.00658035278320312    -2.48110154643655e-09          5153.515625              0.170664310455322            0.0531282424926758    -0.420778274536133         -7.62939453125e-05                             0             0                     11          
        17-Jul-2022 17:03:42        2219                 61440                 9        68            0             0.00224971771240234     0.00393486022949219    -2.49565346166492e-09     5153.74755859375             -0.828534364700317             0.607595086097717     -0.25430428981781      -0.000318527221679688          3.63797880709171e-12             0                     11          
        17-Jul-2022 17:03:42        2219                 61440                10        73            0             0.00771760940551758      0.0102214813232422    -2.56841303780675e-09     5153.63232421875              0.843742370605469            -0.797283291816711      0.24565315246582      -0.000494956970214844         -1.45519152283669e-11             0                     11          
        17-Jul-2022 17:03:42        2219                 61440                11        78            0            0.000565528869628906      0.0065765380859375    -2.57205101661384e-09      5153.5556640625              0.528360724449158             0.913978695869446    -0.423171401023865      -1.04904174804688e-05                             0             0                     12          
        17-Jul-2022 17:03:42        2219                 61440                12        58            0             0.00853252410888672     0.00836372375488281    -2.53567122854292e-09      5153.7099609375             -0.132869362831116             0.417471408843994     0.468230128288269      -0.000247955322265625         -7.27595761418343e-12             0                     10          
        17-Jul-2022 17:03:42        2219                 61440                13        43            0             0.00612878799438477     0.00843238830566406    -2.43380782194436e-09     5153.63427734375             -0.779114127159119             0.291950225830078    -0.548626184463501       0.000349998474121094          7.27595761418343e-12             0                      9          
        17-Jul-2022 17:03:42        2219                 61440                14        77            0             0.00212907791137695      0.0030670166015625    -2.58660293184221e-09      5153.5986328125             -0.143590927124023            -0.983529925346375      0.45069146156311      -0.000111579895019531                             0             0                     12          
        17-Jul-2022 17:03:42        2219                 61440                15        55            0              0.0142536163330078    -0.00369071960449219    -2.57205101661384e-09     5153.53564453125             -0.863561153411865             0.352016925811768    -0.718587875366211      -4.48226928710938e-05          3.63797880709171e-12             0                     10          
        17-Jul-2022 17:03:42        2219                 61440                16        56            0              0.0127029418945312     0.00832366943359375    -2.53567122854292e-09      5153.6240234375             -0.126978635787964             0.232561111450195    -0.108456969261169      -0.000515937805175781         -3.63797880709171e-12             0                      9          
          ⋮
    
    
    title = 
    'CURRENT.ALM'
    

    Read GPS navigation message data from a SEM almanac file.

    gpsData = semread("semalmanac_2022-4-10.al3");

    Get the satellite positions, velocities, and IDs at the first time step.

    t = gpsData.Time(1);
    [satPos,satVel,satID] = gnssconstellation(t,gpsData,GNSSFileType="SEM");

    Specify a GNSS receiver position in geodetic coordinates (latitude, longitude, and altitude).

    recPos = [42 -71 50]; % Natick, MA

    Get the azimuth and elevation look angles of the satellite positions for the specified receiver position. The isVis output indicates which satellites are visible. Find the total number of visible satellites by using nnz.

    [az,el,isVis] = lookangles(recPos,satPos);
    fprintf('%d satellites visible at %s.\n',nnz(isVis),t);
    9 satellites visible at 12-Apr-2022 16:50:54.
    

    Visualize all the visible satellites.

    skyplot(az(isVis),el(isVis),satID(isVis))

    Figure contains an object of type skyplot.

    Read GPS navigation message data from a SEM almanac file.

    gpsData = semread("semalmanac_2022-4-10.al3");

    Specify the relevant time-stepping information.

    startTime = gpsData.Time(1);
    numHours = 12;
    secondsPerHour = 3600;
    dt = 60;
    timeElapsed = 0:dt:(numHours*secondsPerHour);
    t = startTime + seconds(timeElapsed);

    Specify a GNSS receiver position in geodetic coordinates (latitude, longitude, and altitude).

    recPos = [42 -71 50]; % Natick, MA

    Get the azimuth and elevation look angles for the all the positions of the satellites for the specified receiver position.

    numSats = numel(gpsData.PRNNumber); % Number of satellites
    [allAz,allEl] = deal(NaN(numel(t),numSats));
    for i = 1:numel(t)
        [satPos,~,satID] = gnssconstellation(t(i),gpsData,GNSSFileType="SEM");
        [az,el,vis] = lookangles(recPos,satPos);
        allAz(i,:) = az;
        allEl(i,:) = el;
    end

    Mark all satellites below the horizon as NaN for no visibility.

    allEl(allEl < 0) = NaN;

    Visualize the trajectories of the satellites.

    figure
    skyplot(allAz,allEl,satID)

    Figure contains an object of type skyplot.

    Animate the trajectories of the satellites.

    figure
    sp = skyplot(allAz(1,:),allEl(1,:),satID);
    for i = 1:size(allAz, 1)
        set(sp,AzimuthData=allAz(1:i,:),ElevationData=allEl(1:i,:));
        drawnow
    end

    Figure contains an object of type skyplot.

    Input Arguments

    collapse all

    SEM almanac file name, specified as a string scalar or character vector. The file name can include an absolute path, relative path, or no path. The file name can also include the file extensions.

    Example: "semalmanac_2022-1-18.al3"

    Example: "mydir/semalmanac_2022-1-18.al3"

    Example: "C:/mydir/semalmanac_2022-1-18.al3"

    Data Types: char | string

    Reference date, specified as one of these valid datetime strings that coincide with the GPS week number rollover dates:

    • "06-Jan-1980"

    • "21-Aug-1999"

    • "06-Apr-2019"

    These dates occur every 1024 weeks, starting from January 6, 1980 at 00:00 (UTC). The default value is a datetime string that coincides with the most recent GPS week number rollover date before the current day.

    Example: GPSWeekEpoch="21-Aug-1999"

    Data Types: char | string

    Output Arguments

    collapse all

    Parameters of each satellite, returned as a timetable with a row for each record and a column for each parameter in that record. Find more information on the SEM almanac parameters definition, see the Table 40-II in ICD-GPS-240D [2].

    ParametersData TypeDescription
    Timedatetime

    GPS clock time, calculated using GPSWeekNumber and GPSTimeOfApplicability.

    GPSWeekNumberdouble

    GPS week number, continuous, not mod(1024).

    GPSTimeOfApplicabilitydouble

    Number of seconds since the beginning of the GPS week number.

    PRNNumberdouble

    Satellite pseudorandom noise number.

    SVNdouble

    Space vehicle reference number of the satellite.

    AverageURANumberdouble

    Average URA number of the satellite.

    Eccentricitydouble

    Eccentricity of the orbit.

    InclinationOffsetdouble

    Inclination angle offset from 54 degrees, in semicircles.

    RateOfRightAscensiondouble

    Rate of change in the measurement of the angle of right ascension, in semicircles per second.

    SqrtOfSemiMajorAxisdouble

    Square root of the semimajor axis, in meters1/2.

    GeographicLongitudeOfOrbitalPlanedouble

    Geographic longitude of the orbital plane at the weekly epoch, in semicircles.

    ArgumentOfPerigeedouble

    Angle from the equator to perigee, in semicircles.

    MeanAnomalydouble

    Angle of the position of the satellite in its orbit relative to perigee, in semicircles.

    ZerothOrderClockCorrectiondouble

    Satellite almanac zeroth-order clock correction term, in seconds.

    FirstOrderClockCorrectiondouble

    Satellite almanac first-order clock correction term, in seconds per second.

    SatelliteHealthdouble

    Satellite vehicle health data code.

    SatelliteConfigurationdouble

    Satellite vehicle configuration code.

    Almanac title, returned as a character vector.

    Tips

    • To download SEM almanac files from the NAVCEN website for the current date, you must specify a date 2 days before the current date because the GPS time of applicability is approximately 70 hours later than the transmission time of the almanac data set. See the Read GPS Navigation Message Data from SEM Almanac File example for more details.

    References

    [1] Science Applications International Corporation. NAVSTAR GPS Space Segment/Navigation User Interfaces. IS-GPS-200M. Los Angeles, CA: United States Space Force Space Systems Command, approved May 21, 2021. https://www.navcen.uscg.gov/sites/default/files/pdf/gps/IS_GPS_200M.pdf.

    [2] Science Applications International Corporation. NAVSTAR GPS Space Segment/Navigation User Interfaces. ICD-GPS-240D. Los Angeles, CA: United States Space Force Space Systems Command, approved May 21, 2021. https://www.navcen.uscg.gov/sites/default/files/pdf/gps/ICD_GPS_240D.pdf.

    [3] United States Coast Guard. "GPS Almanacs, NANUs, and OPS Advisories Archives." US Coast Guard Navigation Center. Accessed May 6, 2022. https://www.navcen.uscg.gov/archives.

    Version History

    Introduced in R2022b