Skip to content

Commit

Permalink
Merge pull request #600 from wright-group/development
Browse files Browse the repository at this point in the history
3.0.2
  • Loading branch information
untzag committed May 31, 2018
2 parents 530cf45 + 4236961 commit a802aba
Show file tree
Hide file tree
Showing 22 changed files with 6,186 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Require review from one maintainer for pushes to Development and Master

* @untzag @ksunden @p770193
* @untzag @ksunden @p770193 @darienmorrow
3 changes: 2 additions & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Maintainers (alphabetical by last name)
Daniel Kohler (@p770193)
Darien Morrow <darienmorrow@gmail.com> (@darienmorrow)
Kyle Sunden <sunden@wisc.edu> (@ksunden)
Blaise Thompson <blaise@untzag.com> (@untzag)

Contributors (alphabetical by last name)
Kyle Czech (@kjczech)
Darien Morrow <darienmorrow@gmail.com> (@darienmorrow)
Nathan Neff-Mallon (@neffmallon)
Thomas Parker (@parkertomf)
Rachel Swedin (@RachelSwedin)
File renamed without changes.
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

1 change: 1 addition & 0 deletions WrightTools/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.2
File renamed without changes.
4 changes: 2 additions & 2 deletions WrightTools/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


# read from VERSION file
with open(os.path.join(os.path.dirname(here), 'VERSION')) as f:
with open(os.path.join(here, 'VERSION')) as f:
__version__ = f.read().strip()


Expand All @@ -30,6 +30,6 @@
with open(p) as f:
__branch__ = f.readline().rstrip().split(r'/')[-1]
if __branch__ != 'master':
__version__ += '-' + __branch__
__version__ += '+' + __branch__
else:
__branch__ = None
2 changes: 1 addition & 1 deletion WrightTools/__wt5_version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@


# read from VERSION file
with open(os.path.join(os.path.dirname(here), 'WT5_VERSION')) as f:
with open(os.path.join(here, 'WT5_VERSION')) as f:
__wt5_version__ = f.read().strip()
13 changes: 11 additions & 2 deletions WrightTools/collection/_cary.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,16 @@ def from_Cary(filepath, name=None, parent=None, verbose=True):
if line == '\n' or line == '':
break
else:
# Note, it is necessary to call this twice, as a single call will
# result in something like ',,,,' > ',nan,,nan,'.
line = line.replace(',,', ',nan,')
line = line.replace(',,', ',nan,')
# Ensure that the first column has nan, if necessary
if line[0] == ',':
line = 'nan' + line
clean = line[:-2] # lines end with ',/n'
lines.append(np.fromstring(clean, sep=','))
lines = [line for line in lines if len(line) > 0]
header = header.split(',')
columns = columns.split(',')
arr = np.array(lines).T
Expand All @@ -83,8 +91,9 @@ def from_Cary(filepath, name=None, parent=None, verbose=True):
ax = spl[0].lower() if len(spl) > 0 else None
units = spl[1].lower() if len(spl) > 1 else None
dat = datas.create_data(header[i], kind='Cary', source=filepath)
dat.create_variable(ax, arr[i], units=units)
dat.create_channel(columns[i + 1].lower(), arr[i + 1], label=columns[i + 1].lower())
dat.create_variable(ax, arr[i][~np.isnan(arr[i])], units=units)
dat.create_channel(columns[i + 1].lower(), arr[i + 1][~np.isnan(arr[i + 1])],
label=columns[i + 1].lower())
dat.transform(ax)
# finish
if verbose:
Expand Down
36 changes: 22 additions & 14 deletions WrightTools/data/_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,29 @@ def join(datas, *, name='join', parent=None, verbose=True):
datas = list(datas)
# check if variables are valid
axis_expressions = datas[0].axis_expressions
variable_names = set(datas[0].variable_names)
channel_names = set(datas[0].channel_names)
for d in datas:
variable_names &= set(d.variable_names)
channel_names &= set(d.channel_names)
variable_names = list(variable_names)
channel_names = list(channel_names)
variable_units = []
variable_names = []
for a in datas[0].axes:
for v in a.variables:
variable_names.append(v.natural_name)
variable_units.append(v.units)
# TODO: check if all other datas have the same variable names
# check if channels are valid
# TODO: this is a hack
channel_units = []
channel_names = []
for c in datas[0].channels:
channel_names.append(c.natural_name)
channel_units.append(c.units)
for v in variable_names:
variable_units.append(datas[0][v].units)
for c in channel_names:
channel_units.append(datas[0][v].units)
# axis variables
axis_variable_names = []
axis_variable_units = []
for a in datas[0].axes:
for v in a.variables:
axis_variable_names.append(v.natural_name)
axis_variable_units.append(v.units)

vs = collections.OrderedDict()
for n, units in zip(variable_names, variable_units):
for n, units in zip(axis_variable_names, axis_variable_units):
values = np.concatenate([d[n][:].flat for d in datas])
rounded = values.round(8)
_, idxs = np.unique(rounded, True)
Expand All @@ -90,11 +96,13 @@ def from_dict(d, parent=None):
var = out.create_variable(values=values, **datas[0][k].attrs)
i += 1
return out


out = from_dict(vs, parent=parent)
for channel_name, units in zip(channel_names, channel_units):
# **attrs passes the name and units as well
out.create_channel(**datas[0][channel_name].attrs)
for variable_name in datas[0].variable_names:
for variable_name in variable_names:
if variable_name not in vs.keys():
shape = tuple(1 if i == 1 else n for i, n in zip(datas[0][variable_name].shape,
out.shape))
Expand Down
25 changes: 17 additions & 8 deletions WrightTools/data/_pycmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@
# --- import --------------------------------------------------------------------------------------


import collections
import warnings

import numpy as np

from scipy.interpolate import griddata

import tidy_headers

from ._data import Data
from .. import kit as wt_kit
from .. import units as wt_units


# --- define --------------------------------------------------------------------------------------
Expand Down Expand Up @@ -82,6 +76,16 @@ def from_PyCMDS(filepath, name=None, parent=None, verbose=True):
'centers': centers}
axes.append(axis)
shape = tuple([a['points'].size for a in axes])
for i, ax in enumerate(axes):
sh = [1] * len(shape)
sh[i] = len(ax['points'])
data.create_variable(name=ax['name'] + '_points',
values=np.array(ax['points']).reshape(sh))
if ax['centers'] is not None:
sh = [1] * len(shape)
sh[i - 1] = len(axes[i - 1]['points'])
data.create_variable(name=ax['name'] + '_centers',
values=np.array(ax['centers']).reshape(sh))
# get assorted remaining things
# variables and channels
for index, kind, name in zip(range(len(arr)), headers['kind'], headers['name']):
Expand Down Expand Up @@ -112,8 +116,13 @@ def from_PyCMDS(filepath, name=None, parent=None, verbose=True):
tolerance = 3.
if 'zero' in name:
tolerance = 1e-10
if name in headers['axis names']:
tolerance = 1e-5
try:
assert i == headers['axis names'].index(name)
tolerance = 0
except (ValueError, AssertionError):
if (name in headers['axis names'] and
'%s_centers' % name not in data.variable_names):
tolerance = np.inf
mean = np.nanmean(values, axis=i)
mean = np.expand_dims(mean, i)
values, meanexp = wt_kit.share_nans(values, mean)
Expand Down

0 comments on commit a802aba

Please sign in to comment.