Xarray

Numpy to Xarray

Numpy N-dimensional Array to Xarray

The following python 3 modules will be used:

import numpy as np
import xarray as xr
import pandas as pd

An outline of the data format as derived from

We know that the shape of the data is (136, 994), this data will be stored in an ndarray across all 4 frequencies. Using the following guide

we know that the data needs to have dimension:

136 vertical samples x 994 horizonal samples x 4 frequencies

numOberservations = data.shape[0] # represents vertical pixels
numWatercolumns = data.shape[1] # represents horizontal pixels
numFrequencies = 5
frequencyNames = ['18 kHz', '38 kHz', '70 kHz', '120 kHz', '200 kHz']

Generate some synthetic data:

## generate some synthetic data
data_00 = np.random.rand(numFrequencies, numOberservations, numWatercolumns)
data_01 = np.random.rand(numFrequencies, numOberservations*5, numWatercolumns)
data_02 = np.random.rand(numFrequencies, numOberservations*5, numWatercolumns)

time = pd.date_range('2000-01-01', periods=numWatercolumns)

latitude = np.arange(numWatercolumns) + 1
longitude = np.arange(numWatercolumns) + 2

raw_depth = (np.arange(numOberservations) + 1.) / 2
resampled_depth = (np.arange(numOberservations*5) + 1.) / 2

To read an products at level 0, level 1, etc., the user can parse those entries as follows:

The dtype of the data can be modified for products beyond level 0. See here for reference:

To get the raw data from the level 1 product:

Last updated

Was this helpful?