-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Improve compatibility of cf_writer with CF-conventions #153
[WIP] Improve compatibility of cf_writer with CF-conventions #153
Conversation
Nina.Hakansson seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
…o feature-xarray Conflicts: satpy/writers/cf_writer.py
One test for header attributes and one for encoding as a kwarg.
@ninahakansson what's the status on this PR ? Is it ready for review and merge ? |
@ninahakansson here is the way to have the time bounds, look at the last comments: pydata/xarray#1906 |
@@ -40,7 +40,65 @@ | |||
class TestCFWriter(unittest.TestCase): | |||
def test_init(self): | |||
from satpy.writers.cf_writer import CFWriter | |||
w = CFWriter() | |||
import satpy.config | |||
w = CFWriter(config_files=[os.path.join(satpy.config.CONFIG_PATH, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F841 local variable 'w' is assigned to but never used
W291 trailing whitespace
import satpy.config | ||
w = CFWriter(config_files=[os.path.join(satpy.config.CONFIG_PATH, | ||
'writers', 'cf.yaml')]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W293 blank line contains whitespace
'writers', 'cf.yaml')]) | ||
|
||
|
||
def test_save_array(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E303 too many blank lines (2)
import xarray as xr | ||
import tempfile | ||
scn = Scene() | ||
scn['test-array'] = xr.DataArray([1,2,3]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E231 missing whitespace after ','
scn.save_datasets(filename=filename, writer='cf') | ||
import h5netcdf as nc4 | ||
f = nc4.File(filename) | ||
self.assertTrue(all(f['test-array'][:] == [1,2,3])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E231 missing whitespace after ','
dtnp64 = dataarray['time'].data[0] | ||
time_bnds = [(np.datetime64(start_time) - dtnp64), | ||
(np.datetime64(end_time) - dtnp64)] | ||
return xr.DataArray(np.array(time_bnds) / np.timedelta64(1, 's'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E271 multiple spaces after keyword
W291 trailing whitespace
(np.datetime64(end_time) - dtnp64)] | ||
return xr.DataArray(np.array(time_bnds) / np.timedelta64(1, 's'), | ||
dims=['time_bnds'], coords={'time_bnds': [0, 1]}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W293 blank line contains whitespace
datas[new_ds.attrs['name']] = self.da2cf(new_ds, | ||
kwargs.get('epoch', | ||
EPOCH)) | ||
|
||
dataset = xr.Dataset(datas) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W293 blank line contains whitespace
|
||
dataset = xr.Dataset(datas) | ||
|
||
dataset = xr.Dataset(datas) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W291 trailing whitespace
dataset = xr.Dataset(datas) | ||
|
||
dataset = xr.Dataset(datas) | ||
dataset['time_bnds'] = make_time_bounds(dataset, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W291 trailing whitespace
Improve CF-convention support to write files compatible with other software.
git diff origin/develop **/*py | flake8 --diff