Skip to content

Commit

Permalink
compute needed in qa for export with RexOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
bnb32 committed Aug 12, 2024
1 parent c5f0dec commit 5805bd4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions sup3r/preprocessing/cachers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
import os
from typing import Dict, Optional, Union

import numpy as np
import netCDF4 as nc4 # noqa
import h5py
import dask
Expand Down Expand Up @@ -306,7 +306,6 @@ def write_netcdf(cls, out_file, feature, data, chunks=None):
)

if dset in data.coords:
data_var = data_var.compute()
ncfile.variables[dset][:] = data_var.data
ncfile.variables[dset][:] = np.asarray(data_var.data)

cls.write_netcdf_chunks(out_file, feature, data, chunks=chunks)
6 changes: 3 additions & 3 deletions sup3r/qa/qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def get_dset_out(self, name):
Returns
-------
out : Union[np.ndarray, da.core.Array]
out : np.ndarray
A copy of the high-resolution output data as a numpy
array of shape (spatial_1, spatial_2, temporal)
"""
Expand All @@ -294,7 +294,7 @@ def get_dset_out(self, name):
# data always needs to be converted from (t, s1, s2) -> (s1, s2, t)
data = np.transpose(data, axes=(1, 2, 0))

return data
return np.asarray(data)

def coarsen_data(self, idf, feature, data):
"""Re-coarsen a high-resolution synthetic output dataset
Expand Down Expand Up @@ -421,7 +421,7 @@ def export(self, qa_fp, data, dset_name, dset_suffix=''):
logger.info('Adding dataset "{}" to output file.'.format(dset_name))

# transpose and flatten to typical h5 (time, space) dimensions
data = np.transpose(data, axes=(2, 0, 1)).reshape(shape)
data = np.transpose(np.asarray(data), axes=(2, 0, 1)).reshape(shape)

RexOutputs.add_dataset(
qa_fp,
Expand Down

0 comments on commit 5805bd4

Please sign in to comment.