Skip to content
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

Merged
merged 11 commits into from
May 30, 2018

Conversation

ninahakansson
Copy link
Contributor

@ninahakansson ninahakansson commented Jan 12, 2018

Improve CF-convention support to write files compatible with other software.

  • Tests added
  • Tests passed
  • Passes git diff origin/develop **/*py | flake8 --diff
  • Fully documented

@CLAassistant
Copy link

CLAassistant commented Jan 15, 2018

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ mraspaud
❌ Nina.Hakansson


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.

@coveralls
Copy link

coveralls commented Jan 15, 2018

Coverage Status

Coverage decreased (-0.08%) to 57.814% when pulling e58f413 on ninahakansson:feature-xarray into 718bd6c on pytroll:feature-xarray.

Nina.Hakansson added 2 commits January 17, 2018 11:15
One test for header attributes and one for encoding as a kwarg.
@coveralls
Copy link

coveralls commented Jan 17, 2018

Coverage Status

Coverage decreased (-0.2%) to 57.697% when pulling 25f13db on ninahakansson:feature-xarray into 718bd6c on pytroll:feature-xarray.

@coveralls
Copy link

coveralls commented Jan 17, 2018

Coverage Status

Coverage increased (+0.7%) to 58.546% when pulling 3eed0cf on ninahakansson:feature-xarray into 718bd6c on pytroll:feature-xarray.

@mraspaud mraspaud added this to the v0.9 milestone Jan 19, 2018
@mraspaud mraspaud changed the base branch from feature-xarray to develop January 25, 2018 07:29
@mraspaud
Copy link
Member

@ninahakansson what's the status on this PR ? Is it ready for review and merge ?

@mraspaud
Copy link
Member

@ninahakansson here is the way to have the time bounds, look at the last comments: pydata/xarray#1906

@mraspaud mraspaud self-assigned this May 4, 2018
@mraspaud mraspaud added enhancement code enhancements, features, improvements component:writers labels May 4, 2018
@mraspaud mraspaud changed the base branch from develop to master May 15, 2018 20:41
@@ -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,
Copy link
Contributor

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')])

Copy link
Contributor

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):
Copy link
Contributor

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])
Copy link
Contributor

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]))
Copy link
Contributor

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'),
Copy link
Contributor

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]})

Copy link
Contributor

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)

Copy link
Contributor

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)
Copy link
Contributor

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,
Copy link
Contributor

Choose a reason for hiding this comment

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

W291 trailing whitespace

@mraspaud mraspaud changed the base branch from master to fix-cf-writer May 30, 2018 08:58
@mraspaud mraspaud merged commit ac774c0 into pytroll:fix-cf-writer May 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:writers enhancement code enhancements, features, improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants