Skip to content

Commit

Permalink
make sure test and coloc code aligned and datasets contain name
Browse files Browse the repository at this point in the history
  • Loading branch information
agrouaze committed Jan 16, 2025
1 parent 515fc01 commit 17d98f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion slcl1butils/coloc/coloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def coloc_tiles_from_l1bgroup_with_raster(l1b_ds, raster_bb_ds, apply_merging=Tr
projected_field = upscaled_da.interp(
x=lonsar, y=latsar, assume_sorted=False
).drop_vars(["x", "y"])
projected_field.attrs['source'] = raster_bb_ds.attrs['name']
if 'name' in raster_bb_ds.attrs:
projected_field.attrs['source'] = raster_bb_ds.attrs['name']
else:
projected_field.attrs['source'] = 'unknown'
mapped_ds_list.append(projected_field)
raster_mapped = xr.merge(mapped_ds_list)

Expand Down
7 changes: 4 additions & 3 deletions slcl1butils/tests/test_resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
field_ww3_with_nan[1,2] = np.nan
xa_ww3 = xr.DataArray(field_ww3, dims=('x','y'),
coords={'y':np.linspace(20,50,N),
'x':np.linspace(100,150,M)})
'x':np.linspace(100,150,M)},
)
xa_ww3_with_nan = xr.DataArray(field_ww3, dims=('x','y'),
coords={'y':np.linspace(20,50,N),
'x':np.linspace(100,150,M)})
ds_ww3 = xr.Dataset({'hs':xa_ww3,'wl':xa_ww3})
ds_ww3_with_nan = xr.Dataset({'hs':xa_ww3_with_nan,'wl':xa_ww3_with_nan})
ds_ww3 = xr.Dataset({'hs':xa_ww3,'wl':xa_ww3},attrs={'name':'xa_ww3'})
ds_ww3_with_nan = xr.Dataset({'hs':xa_ww3_with_nan,'wl':xa_ww3_with_nan},attrs={'name':'xa_ww3'})
# ww3 = xr.DataArray(np.random.rand(N,M), dims=('lons','lats'), coords={'lats':np.linspace(20,50,N), 'lons':np.linspace(100,150,M)})
# ww3

Expand Down

0 comments on commit 17d98f4

Please sign in to comment.