e-marshall/sentinel1_rtc

generalize setup functions in `open_mfdataset()` fn

Closed this issue · 5 comments

incorporate Scott's suggestions so that file path / name setup functions work for other directory structures / simplify fns

simplified making lists of filepaths but still having trouble extracting correct filename in preprocess function with `os.path.basename(da.encoding['source'])

I think open_mfdataset dispatches to open_dataset and therefore returns a dataset. rioxarray stores a different encoding per variable so you need to access it under the default band_data variable:

ds = xr.open_dataset(path, engine='rasterio')
# ds.encoding== {}
# ds['band_data'].encoding == {source:path, etc....}

ah, thanks! I'll give that a try

it looks like there's a weird stacking/nesting of filenames but maybe I'm misunderstanding the output.
this is what happens when I add a print('fname: ', vv_fn) where vv_fn = os.path.basename(da_orig['band_data'].encoding['source'])
the same thing happens without specifying the band_data var as well
Screenshot from 2022-09-29 12-57-14

i dont think this is necessary anymore