Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff==0.6.9 uvx
pip install ruff==0.6.9 uv

- name: Run linting
run: make lint
run: make lint
10 changes: 7 additions & 3 deletions scripts/inference_multidiffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def inference(arg_list=None, customized_dataset=None):
elif input_path:
ds = xr.open_dataset(input_path)
test_dataset = NetCDFWrapperV1(ds, hpx_level=hpx_level, healpixpad_order=False)
tasks = None
tasks = np.r_[WORLD_RANK : len(test_dataset) : WORLD_SIZE]
else:
test_dataset = HealpixDatasetV5(
path=config.RAW_DATA_URL,
Expand Down Expand Up @@ -190,7 +190,7 @@ def inference(arg_list=None, customized_dataset=None):
else:
print("Performing super-resolution over the entire globe")

for batch in tqdm.tqdm(loader):
for batch in tqdm.tqdm(loader, disable=WORLD_RANK != 0):
target = batch["target"]
target = target[0, :, 0]
# normalize inputs
Expand Down Expand Up @@ -252,7 +252,11 @@ def denoiser(x, t):
target = target.cpu() * test_dataset._scale + test_dataset._mean

def prepare(x):
ring_order = high_res_grid.reorder(earth2grid.healpix.PixelOrder.RING, x)
ring_order = healpix.reorder(
x,
earth2grid.healpix.PixelOrder.NEST,
earth2grid.healpix.PixelOrder.RING,
)
return {
test_dataset.batch_info.channels[c]: ring_order[:, c, None].cpu()
for c in range(x.shape[1])
Expand Down
16 changes: 13 additions & 3 deletions src/cbottle/datasets/dataset_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,10 @@ def get_ts_monmean_for_time_index(self, i: int) -> np.ndarray:
out = self.sst_ds.ts_monmean.interp(time=dtime).values
return np.expand_dims(out, axis=0)

def get_timestamp_for_time_index(self, i: int) -> cftime.DatetimeProlepticGregorian:
time = self.get_time(i)
return cftime_to_timestamp(time)

def __getitem__(self, i):
raw = self.get_nest_map_for_time_index(self.time_index[i])
raw = {k: torch.tensor(v) for k, v in raw.items()}
Expand Down Expand Up @@ -913,7 +917,7 @@ def __getitem__(self, i):
"condition": cond,
"second_of_day": raw["second_of_day"][None],
"day_of_year": raw["day_of_year"][None],
"timestamp": cftime_to_timestamp(self.get_time(i)),
"timestamp": self.get_timestamp_for_time_index(self.time_index[i]),
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes the netCDF to have the wrong metadata.

}

if self.yield_index:
Expand Down Expand Up @@ -959,8 +963,14 @@ def __init__(
"""
self.yield_index = yield_index
self._ds = ds
self.lr_level = int(np.log2(ds["crs"].healpix_nside))
if ds["crs"].healpix_order == "ring":

# fails if more than one crs_var detected
(crs_var,) = [
v for v in ds if ds[v].attrs.get("grid_mapping_name", "") == "healpix"
]

self.lr_level = int(np.log2(ds[crs_var].healpix_nside))
if ds[crs_var].healpix_order == "ring":
self.in_grid = earth2grid.healpix.Grid(
level=self.lr_level, pixel_order=earth2grid.healpix.PixelOrder.RING
)
Expand Down