Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor attribute definition and location #101

Merged
merged 6 commits into from
Apr 21, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more attrs to data variables
alexamici committed Apr 21, 2022
commit 4c42bc4b410b44f89abc709dca3dcc03499c0010
16 changes: 12 additions & 4 deletions xarray_sentinel/sentinel1.py
Original file line number Diff line number Diff line change
@@ -259,7 +259,8 @@ def open_attitude_dataset(

variables = ["q0", "q1", "q2", "q3", "wx", "wy", "wz", "pitch", "roll", "yaw"]
azimuth_time: T.List[T.Any] = []
data_vars: T.Dict[str, T.Any] = {var: ("azimuth_time", []) for var in variables}
data_vars: T.Dict[str, T.Any]
data_vars = {var: ("azimuth_time", [], attrs) for var in variables}
for attitude in attitudes:
azimuth_time.append(attitude["time"])
for var in variables:
@@ -312,6 +313,8 @@ def open_orbit_dataset(
"axis": [0, 1, 2],
},
)
for data_var in ds.data_vars:
ds[data_var].attrs = attrs

return ds

@@ -333,8 +336,8 @@ def open_dc_estimate_dataset(

ds = xr.Dataset(
data_vars={
"t0": ("azimuth_time", t0),
"data_dc_polynomial": (("azimuth_time", "degree"), data_dc_poly),
"t0": ("azimuth_time", t0, attrs),
"data_dc_polynomial": (("azimuth_time", "degree"), data_dc_poly, attrs),
},
coords={
"azimuth_time": [np.datetime64(at) for at in azimuth_time],
@@ -362,10 +365,15 @@ def open_azimuth_fm_rate_dataset(

ds = xr.Dataset(
data_vars={
"t0": ("azimuth_time", t0),
"t0": (
"azimuth_time",
t0,
attrs,
),
"azimuth_fm_rate_polynomial": (
("azimuth_time", "degree"),
azimuth_fm_rate_poly,
attrs,
),
},
coords={