Skip to content

Commit

Permalink
Merge pull request #65 from oscarbranson/dev
Browse files Browse the repository at this point in the history
0.3.21
  • Loading branch information
oscarbranson authored May 25, 2021
2 parents 86ee458 + 4743330 commit 1295ace
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 296 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# Changelog
All significant changes to the software will be documented here.

## [0.3.20]
## [0.3.21] 25/05/2021

### Changed
- Mass fraction calculation functions updated to work with analyte ratio names.
- Reproduce now correctly handles mass fraction calculation.

### Flags
- Mass fraction calculation won't work well (at all?!) with multiple internal standards.

## [0.3.20] 24/05/2021

### New
- Integrated long file splitting into analysis function.
Expand Down
20 changes: 12 additions & 8 deletions latools/D_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,6 @@ def calibrate(self, calib_ps, analyte_ratios=None):
return

def calc_mass_fraction(self, internal_standard_conc, analytes=None, analyte_masses=None):
if analytes is None:
analytes = self.analytes.difference(self.internal_standard)
if 'mass_fraction' not in self.data.keys():
self.data['mass_fraction'] = Bunch()

Expand All @@ -588,12 +586,17 @@ def calc_mass_fraction(self, internal_standard_conc, analytes=None, analyte_mass

if np.isnan(internal_standard_conc):
for a in analytes:
self.data['mass_fraction'][a] = np.full(self.data['calibrated'][a].shape, np.nan)
num, denom = a.split('_')
self.data['mass_fraction'][num] = np.full(self.data['calibrated'][a].shape, np.nan)
else:
for a in analytes:
self.data['mass_fraction'][a] = to_mass_fraction(self.data['calibrated'][a], internal_standard_conc,
analyte_masses[a], analyte_masses[self.internal_standard])

num, denom = a.split('_')
self.data['mass_fraction'][num] = to_mass_fraction(molar_ratio=self.data['calibrated'][a], massfrac_denominator=internal_standard_conc,
numerator_mass=analyte_masses[num], denominator_mass=analyte_masses[denom])
if denom not in self.data['mass_fraction']:
self.data['mass_fraction'][denom] = np.full(self.data['calibrated'][a].shape, np.nan)
self.data['mass_fraction'][denom][~np.isnan(un.nominal_values(self.data['mass_fraction'][num]))] = internal_standard_conc

self.setfocus('mass_fraction')


Expand Down Expand Up @@ -669,15 +672,16 @@ def ablation_times(self):
ats[n - 1] = t.max() - t.min()
return ats

def get_individual_ablations(self, analytes=None, focus_stage=None):
def get_individual_ablations(self, analytes=None, filt=True, focus_stage=None):
analytes = self._analyte_checker(analytes)
if focus_stage is None:
focus_stage = self.focus_stage
out = []
ind = self.filt.grab_filt(filt)
for n in range(1, self.n + 1):
sub = {}
for a in analytes:
sub[a] = self.data[focus_stage][a][self.ns == n]
sub[a] = self.data[focus_stage][a][(self.ns == n) & ind]
out.append(sub)
return out

Expand Down
2 changes: 1 addition & 1 deletion latools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .helpers import chemistry
from . import preprocessing

__version__ = '0.3.20'
__version__ = '0.3.21'

def cite(output='text'):
"""
Expand Down
8 changes: 5 additions & 3 deletions latools/helpers/chemistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,17 @@ def analyte_mass(analyte, in_name=True):
If True, numbers in the analyte name are preferred.
"""
if isinstance(analyte, str):
if '_' in analyte:
return analyte_mass(analyte.split('_'))
nums = re.findall('[0-9]+', analyte)
if in_name and nums:
return float(nums[0])
return {analyte: float(nums[0])}
else:
return calc_M(re.findall('[A-z]+', analyte)[0])
return {analyte: calc_M(re.findall('[A-z]+', analyte)[0])}
else:
masses = {}
for i, a in enumerate(analyte):
masses[a] = analyte_mass(a, in_name)
masses.update(analyte_mass(a, in_name))
return masses


Expand Down
5 changes: 4 additions & 1 deletion latools/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ def unitpicker(a, denominator=None, focus_stage=None):
a = abs(a)
order = np.log10(a)
m = np.ceil(-order / 3) * 3
return float(10**m), udict[m]
if np.isnan(m):
return 1, ''
else:
return float(10**m), udict[m]

def collate_data(in_dir, extension='.csv', out_dir=None):
"""
Expand Down
4 changes: 4 additions & 0 deletions latools/helpers/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ def crossplot(dat, keys=None, lognorm=True, bins=25, figsize=(12, 12),
# determine ranges for all analytes
rdict = {a: (np.nanmin(focus[a] * udict[a][0]),
np.nanmax(focus[a] * udict[a][0])) for a in keys}
# check for nans
for k, v in rdict.items():
if any(np.isnan(v)):
rdict[k] = (-1,1)

for i, j in tqdm(zip(*np.triu_indices_from(axes, k=1)), desc='Drawing Plots',
total=sum(range(len(keys)))):
Expand Down
Loading

0 comments on commit 1295ace

Please sign in to comment.