Skip to content

Commit 1d8b09e

Browse files
committed
Add argument for netcdf path
1 parent 067b082 commit 1d8b09e

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

utils/PAD_dataset.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class PADDataset(Dataset):
4545
def __init__(
4646
self,
4747
coco: COCO,
48-
root_path_coco: Union[str, Path] = None,
48+
root_path_netcdf: Union[str, Path] = None,
4949
bands: list = None,
5050
transforms=None,
5151
compression: str = 'gzip',
@@ -71,6 +71,8 @@ def __init__(
7171
----------
7272
coco: COCO Object
7373
A COCO object containing the data.
74+
root_path_netcdf: Path or str, default None
75+
The path containing the netcdf files.
7476
bands: list of str, default None
7577
A list of the bands to use. If None, then all available bands are
7678
taken into consideration. Note that the bands are given in a two-digit
@@ -130,8 +132,10 @@ def __init__(
130132
self.coco = coco
131133
self.patch_ids = list(sorted(self.coco.imgs.keys()))
132134

133-
# Base root path, pointing to coco instance
134-
self.root_path_coco = Path(root_path_coco)
135+
if root_path_netcdf is not None:
136+
self.root_path_netcdf = Path(root_path_netcdf)
137+
else:
138+
self.root_path_netcdf = None
135139

136140
# number of total patches is given by number of patches in coco
137141
self.num_patches = len(self.patch_ids)
@@ -418,7 +422,7 @@ def __getitem__(self, idx: int) -> dict:
418422
medians, labels = self.load_medians(block_dir, subpatch_id, start_bin)
419423
else:
420424
# Find patch in COCO file
421-
patch = self.root_path_coco / self.coco.loadImgs(patch_id)[0]['file_name']
425+
patch = self.root_path_netcdf / self.coco.loadImgs(patch_id)[0]['file_name']
422426

423427
# Load patch netcdf4
424428
patch_netcdf = netCDF4.Dataset(patch, 'r')

0 commit comments

Comments
 (0)