Skip to content

Commit

Permalink
small upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Aug 16, 2024
1 parent e9d0ea6 commit b644712
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ocf_data_sampler/numpy_batch/nwp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def convert_nwp_to_numpy_batch(da: xr.DataArray, t0_idx: int | None = None) -> N
NWPBatchKey.nwp: da.values,
NWPBatchKey.nwp_channel_names: da.channel.values,
NWPBatchKey.nwp_init_time_utc: da.init_time_utc.values.astype(float),
NWPBatchKey.nwp_step: (da.step.values / pd.Timedelta("1H")).astype(int),
NWPBatchKey.nwp_step: (da.step.values / pd.Timedelta("1h")).astype(int),
}

if "target_time_utc" in da.coords:
Expand Down
6 changes: 4 additions & 2 deletions ocf_data_sampler/select/select_spatial_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ def _get_idx_of_pixel_closest_to_poi_geostationary(
center_geostationary = Location(x=x, y=y, coordinate_system="geostationary")

# Check that the requested point lies within the data
assert da[x_dim].min() < x < da[x_dim].max()
assert da[y_dim].min() < y < da[y_dim].max()
assert da[x_dim].min() < x < da[x_dim].max(), \
f"{x} not in {da[x_dim].min().values}: {da[x_dim].max().values}"
assert da[y_dim].min() < y < da[y_dim].max(), \
f"{y} not in {da[y_dim].min().values}: {da[y_dim].max().values}"

# Get the index into x and y nearest to x_center_geostationary and y_center_geostationary:
x_index_at_center = searchsorted(
Expand Down

0 comments on commit b644712

Please sign in to comment.