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

Patch 1 changes #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion plugins/import_data/icpmsImport.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,25 @@ def add_Ft_comb(self, analysis_obj, Fts):
Ft_comb_dict= {'value': Ft_comb, 'error': None,
'type': {'parameter': 'Combined Ft', 'unit': ''},
'analysis': analysis_obj}
self.db.load_data('datum', Ft_comb_dict)
self.db.load_data('datum', Ft_comb_dict)
# Here we will caluclate ESR_Ft and it's associated uncertainty. It will call upon FT_constants defined in picking_specs.yaml
# which are material (mineral) and isotope specific. I'll refer to these as S_238, etc, but they will need to vary depending on the mineral.
Sbar = a_238*S_238 + a_232*S_232 + (1-a_238-a_235)*S_235
S_R = 1.681-2.428*FT_comb+1.153*(Ft_comb^2)-0.406*(Ft_comb^3)
ESR_Ft = Sbar/S_R
IF Mineral (material?) = 'apatite'
IF shape = 'Hexagonal'
ESR_Ft_Corr = 0.93*ESR_Ft
ESR_Ft_Corr_err = 0.06*ESR_Ft_Corr
IF shape = 'ellipsoid'
ESR_Ft_Corr = 0.85*ESR_Ft
ESR_Ft_Corr_err = 0.10*ESR_Ft_Corr
IF Mineral (material?) = 'zircon'
IF shape = 'Hexagonal'
ESR_Ft_Corr = 0.92*ESR_Ft
ESR_Ft_Corr_err = 0.08*ESR_Ft_Corr
IF shape = 'ellipsoid'
ESR_Ft_Corr = 0.98*ESR_Ft
ESR_Ft_Corr_err = 0.08*ESR_Ft_Corr
IF Mineral is otherwise...

70 changes: 68 additions & 2 deletions plugins/import_data/pickingImport.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

# Replicates Ketcham et al., 2011 for Ft calculation
def get_Ft(l1, w1, l2, w2, Np, shape, Ft_constants, material):
# We need to make sure that we know the maximum width. I think we should define that here as
Wmax = Greater(w1,w2)

Ft_dat = {}
for iso in ['238U', '235U','232Th', '147Sm']:
R = Ft_constants[material][iso]
Expand Down Expand Up @@ -63,6 +66,66 @@ def get_Ft(l1, w1, l2, w2, Np, shape, Ft_constants, material):
Ft_dat['Rs'] = Rs
return Ft_dat

# First correct the Volume (V) values. This depends upon the mineral and the geometry. Right now we have this for apatite and zircon, so if
# the material is something else then Vcorr should just equal V, and Vcorr_err should be XX.
IF Mineral (material?) = zircon
IF shape == 'Orthorhombic'
Then Vcorr = 0.81*V
Vcorr_err = 0.13*VCorr
IF shape == 'Ellipsoid'
Then Vcorr = 1.04*V
VCorr_err = 0.21*VCorr
IF Mineral (material?) = apatite
IF shape == 'Hexagonal'
Then Vcorr = 0.83*V
Vcorr_err = 0.20*VCorr
IF shape == 'Ellipsoid'
Then Vcorr = 0.74*V
VCorr_err = 0.23*VCorr

# Now correct the Ft. This will depend upon the material, geometry, and maximum width.
IF Mineral (material?) = 'zircon'
IF shape = 'Orthorhombic'
Then 238Ftcorr = 0.97*238Ft
IF Wmax < 100, Then 238Fterr = 0.03*238Ftcorr, else 238Fterr = 0.02*238Ftcorr
235Ftcorr = 0.97*235Ft
IF Wmax < 100, Then 235Fterr = 0.04*235Ftcorr, else 235Fterr = 0.03*235Fterr
232Ftcorr = 0.97*232Ft
IF Wmax < 100, Then 232Fterr = 0.05*232Ftcorr, else 232Fterr = 0.02*232Fterr
147Ftcorr = 0.96*147Ft
147Fterr = 0.01*147Ftcorr
IF shape = 'Ellipsoid'
Then 238Ftcorr = 238Ft
238Fterr = 0.03*238Ftcorr
235Ftcorr = 235Ft
235Fterr = 0.04*235Ftcorr
232Ftcorr = 232Ft
232Fterr = 0.04*232Ftcorr
147Ftcorr = 147Ft
147Fterr = 0.01*147Ftcorr

IF Mineral (material?) = 'apatite'
IF shape = 'Orthorhombic'
Then 238Ftcorr = 0.97*238Ft
IF Wmax < 100, Then 238Fterr = 0.03*238Ftcorr, else 238Fterr = 0.02*238Ftcorr
235Ftcorr = 0.96*235Ft
IF Wmax < 100, Then 235Fterr = 0.04*235Ftcorr, else 235Fterr = 0.02*235Fterr
232Ftcorr = 0.96*232Ft
IF Wmax < 100, Then 232Fterr = 0.04*232Ftcorr, else 232Fterr = 0.02*232Fterr
147Ftcorr = 0.99*147Ft
147Fterr = 0.01*147Ftcorr
IF shape = 'Ellipsoid'
Then 238Ftcorr = 0.92*238Ft
238Fterr = 0.05*238Ftcorr
235Ftcorr = 0.91*235Ft
235Fterr = 0.06*235Ftcorr
232Ftcorr = 0.91*232Ft
232Fterr = 0.06*232Ftcorr
147Ftcorr = 0.97*147Ft
147Fterr = 0.01*147Ftcorr



# Function to make datum
def make_datum(datum, error, parameter, unit):
return {'value': datum, 'error': error,
Expand Down Expand Up @@ -144,10 +207,11 @@ def import_datafile(self, fn, rec, **kwargs):
geometry = data.iloc[d][self.picking_specs['Metadata']['Crystal geometry']]

# Generate Ft and dimensional mass
# This needs to be modified to use Vcorr values as described above. I changed that
Fts = get_Ft(length1, width1, length2, width2,
int(terminations), self.picking_specs['geometry_key'][geometry],
self.picking_specs['Ft_constants'], material)
dimensional_mass = self.picking_specs['Ft_constants'][material]['density']*Fts['V']/1e6
dimensional_mass = self.picking_specs['Ft_constants'][material]['density']*Fts['Vcorr']/1e6

# create datum and attributes for shape analysis
shape_data = []
Expand Down Expand Up @@ -189,6 +253,8 @@ def import_datafile(self, fn, rec, **kwargs):
# make analysis dictionary, exclude missing data if shards
if shard != 'Y' and shard != 'y':
# First, get uncertainty for each derived parameter
# We have defined some of these already. Ft_err is defined in my calcs above, and dim_mass_err should just be dim_mass*(Vcorrerr/Vcorr). Rs_err
# will be done on the ICPMS import phase
for l in chars_attributes:
for i in l:
# get derived data uncertainties for later
Expand Down Expand Up @@ -257,4 +323,4 @@ def import_datafile(self, fn, rec, **kwargs):
})

print('')
self.db.load_data('sample', sample_schema, strict=True)
self.db.load_data('sample', sample_schema, strict=True)
7 changes: 5 additions & 2 deletions plugins/manipulate_data/dataReduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def get_input_data(self, d):
.filter_by(sample_id=d,
technique='Dates and other derived data')
.all())
# The Ft values and uncertainties below should reference Ft_Corr and Ft_corr_err for each isotope now if the mineral is apatite or zircon. If the mineral is
# something else, then we need to note that we aren't using corrected values. The values we calculated earlier though are 1s.
if len(Ft_session) > 0:
get_corrected = True
Ft238_datum = self.query_ID(sample_obj.lab_id, '238U Ft (±2σ)')
Expand All @@ -166,6 +168,7 @@ def get_input_data(self, d):

def calculate_date(self, He4, He4_s, U238, U238_s, Th232, Th232_s, Sm147, Sm147_s,
Ft238, Ft238_s, Ft235, Ft235_s, Ft232, Ft232_s, Ft147, Ft147_s, get_corrected, d, sample_obj):
#This is a typo, but I don't know if it matters. Should be U238_mol_per_ng not 328
U328_mol_per_ng = 1/(238.03*1e9)
Th232_mol_per_ng = 1/(232*1e9)
Sm147_mol_per_ng = 1/(157*1e9)
Expand Down Expand Up @@ -240,7 +243,7 @@ def calculate_date(self, He4, He4_s, U238, U238_s, Th232, Th232_s, Sm147, Sm147_
'235Ft-147Ft': Ft235_s*Ft147_s,
'232Ft-147Ft': Ft232_s*Ft147_s
}

# These also need to be referencing the corrected valyes and proper uncertainties
date = hecalc.get_date(He4_mol, U238=U238_mol, U235=None, Th232=Th232_mol, Sm147=Sm147_mol,
Ft238=Ft238, Ft235=Ft235, Ft232=Ft232, Ft147=Ft147)

Expand Down Expand Up @@ -362,4 +365,4 @@ def calculate_date(self, He4, He4_s, U238, U238_s, Th232, Th232_s, Sm147, Sm147_
}]
}
session_dict['sample'] = sample_obj
self.db.load_data('session', session_dict)
self.db.load_data('session', session_dict)