-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathcreate_xarray_dataarray.py
More file actions
30 lines (30 loc) · 1012 Bytes
/
create_xarray_dataarray.py
File metadata and controls
30 lines (30 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import numpy as np
import xarray as xr
import pandas as pd
times = pd.date_range("2000-01-01", periods=1)
data = np.random.rand(1, 4, 3)
lats = np.arange(0,4,1)
lons = np.arange(0,3,1)
foo = xr.DataArray(data, coords=[times, lats, lons], dims=["time", "lat", "lon"])
ds = xr.Dataset({
'SWdown': xr.DataArray(
data = np.random.random(6), # enter data here
dims = ['time'],
coords = {'time': times},
attrs = {
'_FillValue': -999.9,
'units' : 'W/m2'
}
),
'LWdown': xr.DataArray(
data = np.random.random(6), # enter data here
dims = ['time'],
coords = {'time': times},
attrs = {
'_FillValue': -999.9,
'units' : 'W/m2'
}
)
},
attrs = {'example_attr': 'this is a global attribute'}
)