# Wave Spectra

## Operational Wave Spectra Forecast

<mark style="color:blue;">`GET`</mark> `https://api.sofarocean.com/api/op-wave-spectra/:lat/:lon`

This endpoint returns a list of locations you have access to, or retrieves NetCDF data for a target location.

#### Path Parameters

| Name | Type   | Description                                                                  |
| ---- | ------ | ---------------------------------------------------------------------------- |
| lat  | number | <p>latitude of location in decimal degrees.<br>Must be 0.5º resolution.</p>  |
| lon  | number | <p>longitude of location in decimal degrees.<br>Must be 0.5º resolution.</p> |

{% tabs %}
{% tab title="200 Example response of the list request, with lat and lon path parameters excluded." %}

```
{
    "status": "success",
    "data": [
        {
            "latitude": 34.5,
            "longitude": 200.0,
            "url": "https://api.sofarocean.com/api/op-wave-spectra/34.5/200"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

#### Example List Request

```
curl https://api.sofarocean.com/api/op-wave-spectra -H 'token: YOUR_API_TOKEN'
```

#### Example Data File Request

Content-Type: application/octet-stream\
Content-Disposition: attachment; filename="34.50\_200.00\_2019-12-19T12:00:00Z\_data.netcdf"

```
curl https://api.sofarocean.com/api/op-wave-spectra/34.5/200 -H 'token: YOUR_API_TOKEN' -J -O
```

## **Spectral File Description**

A Sofar Spectral File contains the variance density spectrum at a single grid point of the Sofar global wave model at an hourly resolution for the duration of the forecast. The data is stored in NetCDF format, and the variables contained in each file are listed in Table 1. A detailed description of the variables is given below.

| **Variable Name**            | **Shape**          | **Type** | **Units**            |
| ---------------------------- | ------------------ | -------- | -------------------- |
| directions                   | ( Nd , )           | float    | Degrees              |
| frequencies                  | ( Nf , )           | float    | Hertz                |
| time                         | ( Nt , )           | integer  | Seconds              |
| latitude                     | ( 1 , )            | float    | Decimal degrees      |
| longitude                    | ( 1, )             | float    | Decimal degrees      |
| depth                        | ( 1, )             | float    | Meters               |
| frequency direction spectrum | ( Nt , Nd  , Nf  ) | float    | Meters2/Hertz/Degree |

{% hint style="info" %}
Table 1: The shape column indicates the shape of the array containing the variable, with Nt denoting the number of entries in time, Nf  the number of frequencies and Nd  the number of directions.
{% endhint %}

### **Directions**

The direction vector contains the model directions at which the spectrum is stored. The directions are stored as a single vector of *Nd*=36 entries. Directions are measured counterclockwise from East. Each direction is given in degrees and indicates the direction the waves are traveling in. The directional grid has a constant resolution of 10 degrees ranging between \[0,360].

### **Frequencies**

The frequency vector contains the model frequencies at which the spectrum is stored. The frequencies are stored as a single vector of *Nf*=36 entries. Frequencies are measured in Hertz. The frequencies are defined on a logarithmic grid (1.1 growth factor) with minimum frequency *f=0.035* Hz and maximum frequency *f=0.98* Hz.

### **Time**

The time vector denotes the time of the spectral entries. Time is denoted in Unix Epoch time, i.e. as seconds elapsed since Jan 1, 1970 (UTC). The time vector will be different lengths depending on the forecast initialization time. The first time denotes the initialization of the forecast.

### **Latitude, Longitude**

The latitude and longitude are denoted in decimal degrees and indicate the location of the model grid point where the spectra were output.

### **Depth**

Depth denotes the depth in meters at the location considered.

### **Frequency Direction Spectrum**

The frequency direction spectrum contains the variance density as a function of time, direction, and frequency. Spectra are stored as a three-dimensional array where the first dimension is time, the second dimension is direction, and the third is frequency. Entries are stored as density values with units m2/Hz/deg.
