-
Notifications
You must be signed in to change notification settings - Fork 42
/
sio_magic.py
executable file
·693 lines (658 loc) · 31.6 KB
/
sio_magic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
#!/usr/bin/env python
import string,sys,pmag
def main(command_line=True, **kwargs):
"""
NAME
sio_magic.py
DESCRIPTION
converts SIO .mag format files to magic_measurements format files
SYNTAX
sio_magic.py [command line options]
OPTIONS
-h: prints the help message and quits.
-usr USER: identify user, default is ""
-f FILE: specify .mag format input file, required
-fsa SAMPFILE : specify er_samples.txt file relating samples, site and locations names,default is none -- values in SAMPFILE will override selections for -loc (location), -spc (designate specimen), and -ncn (sample-site naming convention)
-F FILE: specify output file, default is magic_measurements.txt
-Fsy: specify er_synthetics file, default is er_sythetics.txt
-LP [colon delimited list of protocols, include all that apply]
AF: af demag
T: thermal including thellier but not trm acquisition
S: Shaw method
I: IRM (acquisition)
I3d: 3D IRM experiment
N: NRM only
TRM: trm acquisition
ANI: anisotropy experiment
D: double AF demag
G: triple AF demag (GRM protocol)
CR: cooling rate experiment.
The treatment coding of the measurement file should be: XXX.00,XXX.10, XXX.20 ...XX.70 etc. (XXX.00 is optional)
where XXX in the temperature and .10,.20... are running numbers of the cooling rates steps.
XXX.00 is optional zerofield baseline. XXX.70 is alteration check.
syntax in sio_magic is: -LP CR xxx,yyy,zzz,.....xx -A
where xx, yyy,zzz...xxx are cooling time in [K/minutes], seperated by comma, ordered at the same order as XXX.10,XXX.20 ...XX.70
if you use a zerofield step then no need to specify the cooling rate for the zerofield
It is important to add to the command line the -A option so the measurements will not be evraged.
But users need to make sure that there are no duplicate meaurements in the file
-V [1,2,3] units of IRM field in volts using ASC coil #1,2 or 3
-spc NUM : specify number of characters to designate a specimen, default = 0
-loc LOCNAME : specify location/study name, must have either LOCNAME or SAMPFILE or be a synthetic
-syn INST TYPE: sets these specimens as synthetics created at institution INST and of type TYPE
-ins INST : specify which demag instrument was used (e.g, SIO-Suzy or SIO-Odette),default is ""
-dc B PHI THETA: dc lab field (in micro tesla) and phi,theta, default is none
NB: use PHI, THETA = -1 -1 to signal that it changes, i.e. in anisotropy experiment
-ac B : peak AF field (in mT) for ARM acquisition, default is none
-ncn NCON: specify naming convention: default is #1 below
-A: don't average replicate measurements
Sample naming convention:
[1] XXXXY: where XXXX is an arbitrary length site designation and Y
is the single character sample designation. e.g., TG001a is the
first sample from site TG001. [default]
[2] XXXX-YY: YY sample from site XXXX (XXX, YY of arbitary length)
[3] XXXX.YY: YY sample from site XXXX (XXX, YY of arbitary length)
[4-Z] XXXX[YYY]: YYY is sample designation with Z characters from site XXX
[5] site name same as sample
[6] site is entered under a separate column
[7-Z] [XXXX]YYY: XXXX is site designation with Z characters with sample name XXXXYYYY
NB: all others you will have to customize your self
or e-mail ltauxe@ucsd.edu for help.
[8] synthetic - has no site name
[9] ODP naming convention
INPUT
Best to put separate experiments (all AF, thermal, thellier, trm aquisition, Shaw, etc.) in
seperate .mag files (eg. af.mag, thermal.mag, etc.)
Format of SIO .mag files:
Spec Treat CSD Intensity Declination Inclination [optional metadata string]
Spec: specimen name
Treat: treatment step
XXX T in Centigrade
XXX AF in mT
for special experiments:
Thellier:
XXX.0 first zero field step
XXX.1 first in field step [XXX.0 and XXX.1 can be done in any order]
XXX.2 second in-field step at lower temperature (pTRM check)
XXX.3 second zero-field step after infield (pTRM check step)
XXX.3 MUST be done in this order [XXX.0, XXX.1 [optional XXX.2] XXX.3]
AARM:
X.00 baseline step (AF in zero bias field - high peak field)
X.1 ARM step (in field step) where
X is the step number in the 15 position scheme
(see Appendix to Lecture 13 - http://magician.ucsd.edu/Essentials_2)
ATRM:
X.00 optional baseline
X.1 ATRM step (+X)
X.2 ATRM step (+Y)
X.3 ATRM step (+Z)
X.4 ATRM step (-X)
X.5 ATRM step (-Y)
X.6 ATRM step (-Z)
X.7 optional alteration check (+X)
TRM:
XXX.YYY XXX is temperature step of total TRM
YYY is dc field in microtesla
Intensity assumed to be total moment in 10^3 Am^2 (emu)
Declination: Declination in specimen coordinate system
Inclination: Declination in specimen coordinate system
Optional metatdata string: mm/dd/yy;hh:mm;[dC,mT];xx.xx;UNITS;USER;INST;NMEAS
hh in 24 hours.
dC or mT units of treatment XXX (see Treat above) for thermal or AF respectively
xx.xxx DC field
UNITS of DC field (microT, mT)
INST: instrument code, number of axes, number of positions (e.g., G34 is 2G, three axes,
measured in four positions)
NMEAS: number of measurements in a single position (1,3,200...)
"""
# initialize some stuff
mag_file = None
codelist = None
infile_type="mag"
noave=0
methcode,inst="LP-NO",""
phi,theta,peakfield,labfield=0,0,0,0
pTRM,MD,samp_con,Z=0,0,'1',1
dec=[315,225,180,135,45,90,270,270,270,90,180,180,0,0,0]
inc=[0,0,0,0,0,-45,-45,0,45,45,45,-45,-90,-45,45]
tdec=[0,90,0,180,270,0,0,90,0]
tinc=[0,0,90,0,0,-90,0,0,90]
missing=1
demag="N"
er_location_name=""
citation='This study'
args=sys.argv
fmt='old'
syn=0
synfile='er_synthetics.txt'
samp_infile,Samps='',[]
trm=0
irm=0
specnum=0
coil=""
mag_file=""
#
# get command line arguments
#
meas_file="magic_measurements.txt"
user=""
if not command_line:
user = kwargs.get('user', '')
meas_file = kwargs.get('meas_file', '')
syn_file = kwargs.get('syn_file', '')
mag_file = kwargs.get('mag_file', '')
labfield = kwargs.get('labfield', '')
if labfield:
labfield = float(labfield) *1e-6
else:
labfield = 0
phi = kwargs.get('phi', 0)
if phi:
phi = float(phi)
else:
phi = 0
theta = kwargs.get('theta', 0)
if theta:
theta=float(theta)
else:
theta = 0
peakfield = kwargs.get('peakfield', 0)
if peakfield:
peakfield=float(peakfield) *1e-3
else:
peakfield = 0
specnum = kwargs.get('specnum', 0)
samp_con = kwargs.get('samp_con', '1')
er_location_name = kwargs.get('er_location_name', '')
samp_infile = kwargs.get('samp_infile', '')
syn = kwargs.get('syn', 0)
institution = kwargs.get('institution', '')
syntype = kwargs.get('syntype', '')
inst = kwargs.get('inst', '')
noave = kwargs.get('noave', 0)
codelist = kwargs.get('codelist', '')
coil = kwargs.get('coil', '')
cooling_rates = kwargs.get('cooling_rates', '')
if command_line:
if "-h" in args:
print main.__doc__
return False
if "-usr" in args:
ind=args.index("-usr")
user=args[ind+1]
if '-F' in args:
ind=args.index("-F")
meas_file=args[ind+1]
if '-Fsy' in args:
ind=args.index("-Fsy")
synfile=args[ind+1]
if '-f' in args:
ind=args.index("-f")
mag_file=args[ind+1]
if "-dc" in args:
ind=args.index("-dc")
labfield=float(args[ind+1])*1e-6
phi=float(args[ind+2])
theta=float(args[ind+3])
if "-ac" in args:
ind=args.index("-ac")
peakfield=float(args[ind+1])*1e-3
if "-spc" in args:
ind=args.index("-spc")
specnum=int(args[ind+1])
if "-loc" in args:
ind=args.index("-loc")
er_location_name=args[ind+1]
if "-fsa" in args:
ind=args.index("-fsa")
samp_infile = args[ind+1]
if '-syn' in args:
syn=1
ind=args.index("-syn")
institution=args[ind+1]
syntype=args[ind+2]
if '-fsy' in args:
ind=args.index("-fsy")
synfile=args[ind+1]
if "-ins" in args:
ind=args.index("-ins")
inst=args[ind+1]
if "-A" in args: noave=1
if "-ncn" in args:
ind=args.index("-ncn")
samp_con=sys.argv[ind+1]
if '-LP' in args:
ind=args.index("-LP")
codelist=args[ind+1]
if "-V" in args:
ind=args.index("-V")
coil=args[ind+1]
# make sure all initial values are correctly set up (whether they come from the command line or a GUI)
if samp_infile:
Samps, file_type = pmag.magic_read(samp_infile)
if coil:
coil = str(coil)
methcode="LP-IRM"
irmunits = "V"
if coil not in ["1","2","3"]:
print main.__doc__
print 'not a valid coil specification'
return False, '{} is not a valid coil specification'.format(coil)
if mag_file:
try:
input=open(mag_file,'rU')
except:
print "bad mag file name"
return False, "bad mag file name"
if not mag_file:
print main.__doc__
print "mag_file field is required option"
return False, "mag_file field is required option"
if specnum!=0:
specnum=-specnum
#print 'samp_con:', samp_con
if samp_con:
if "4" == samp_con[0]:
if "-" not in samp_con:
print "naming convention option [4] must be in form 4-Z where Z is an integer"
print '---------------'
return False, "naming convention option [4] must be in form 4-Z where Z is an integer"
else:
Z=samp_con.split("-")[1]
samp_con="4"
if "7" == samp_con[0]:
if "-" not in samp_con:
print "option [7] must be in form 7-Z where Z is an integer"
return False, "option [7] must be in form 7-Z where Z is an integer"
else:
Z=samp_con.split("-")[1]
samp_con="7"
if codelist:
codes=codelist.split(':')
if "AF" in codes:
demag='AF'
if'-dc' not in args: methcode="LT-AF-Z"
if'-dc' in args: methcode="LT-AF-I"
if "T" in codes:
demag="T"
if '-dc' not in args: methcode="LT-T-Z"
if '-dc' in args: methcode="LT-T-I"
if "I" in codes:
methcode="LP-IRM"
irmunits="mT"
if "I3d" in codes:
methcode="LT-T-Z:LP-IRM-3D"
if "S" in codes:
demag="S"
methcode="LP-PI-TRM:LP-PI-ALT-AFARM"
trm_labfield=labfield
ans=raw_input("DC lab field for ARM step: [50uT] ")
if ans=="":
arm_labfield=50e-6
else:
arm_labfield=float(ans)*1e-6
ans=raw_input("temperature for total trm step: [600 C] ")
if ans=="":
trm_peakT=600+273 # convert to kelvin
else:
trm_peakT=float(ans)+273 # convert to kelvin
if "G" in codes: methcode="LT-AF-G"
if "D" in codes: methcode="LT-AF-D"
if "TRM" in codes:
demag="T"
trm=1
if "CR" in codes:
demag="T"
cooling_rate_experiment=1
if command_line:
ind=args.index("CR")
cooling_rates=args[ind+1]
cooling_rates_list=cooling_rates.split(',')
else:
cooling_rates_list=str(cooling_rates).split(',')
if demag=="T" and "ANI" in codes:
methcode="LP-AN-TRM"
if demag=="T" and "CR" in codes:
methcode="LP-CR-TRM"
if demag=="AF" and "ANI" in codes:
methcode="LP-AN-ARM"
if labfield==0: labfield=50e-6
if peakfield==0: peakfield=.180
SynRecs,MagRecs=[],[]
version_num=pmag.get_version()
##################################
if 1:
#if infile_type=="SIO format":
for line in input.readlines():
instcode=""
if len(line)>2:
SynRec={}
MagRec={}
MagRec['er_location_name']=er_location_name
MagRec['magic_software_packages']=version_num
MagRec["treatment_temp"]='%8.3e' % (273) # room temp in kelvin
MagRec["measurement_temp"]='%8.3e' % (273) # room temp in kelvin
MagRec["treatment_ac_field"]='0'
MagRec["treatment_dc_field"]='0'
MagRec["treatment_dc_field_phi"]='0'
MagRec["treatment_dc_field_theta"]='0'
meas_type="LT-NO"
rec=line.split()
if rec[1]==".00":rec[1]="0.00"
treat=rec[1].split('.')
if methcode=="LP-IRM":
if irmunits=='mT':
labfield=float(treat[0])*1e-3
else:
labfield=pmag.getfield(irmunits,coil,treat[0])
if rec[1][0]!="-":
phi,theta=0.,90.
else:
phi,theta=0.,-90.
meas_type="LT-IRM"
MagRec["treatment_dc_field"]='%8.3e'%(labfield)
MagRec["treatment_dc_field_phi"]='%7.1f'%(phi)
MagRec["treatment_dc_field_theta"]='%7.1f'%(theta)
if len(rec)>6:
code1=rec[6].split(';') # break e.g., 10/15/02;7:45 indo date and time
if len(code1)==2: # old format with AM/PM
missing=0
code2=code1[0].split('/') # break date into mon/day/year
code3=rec[7].split(';') # break e.g., AM;C34;200 into time;instr/axes/measuring pos;number of measurements
yy=int(code2[2])
if yy <90:
yyyy=str(2000+yy)
else: yyyy=str(1900+yy)
mm=int(code2[0])
if mm<10:
mm="0"+str(mm)
else: mm=str(mm)
dd=int(code2[1])
if dd<10:
dd="0"+str(dd)
else: dd=str(dd)
time=code1[1].split(':')
hh=int(time[0])
if code3[0]=="PM":hh=hh+12
if hh<10:
hh="0"+str(hh)
else: hh=str(hh)
min=int(time[1])
if min<10:
min= "0"+str(min)
else: min=str(min)
MagRec["measurement_date"]=yyyy+":"+mm+":"+dd+":"+hh+":"+min+":00.00"
MagRec["measurement_time_zone"]='SAN'
if inst=="":
if code3[1][0]=='C':instcode='SIO-bubba'
if code3[1][0]=='G':instcode='SIO-flo'
else:
instcode=''
MagRec["measurement_positions"]=code3[1][2]
elif len(code1)>2: # newest format (cryo7 or later)
if "LP-AN-ARM" not in methcode:labfield=0
fmt='new'
date=code1[0].split('/') # break date into mon/day/year
yy=int(date[2])
if yy <90:
yyyy=str(2000+yy)
else: yyyy=str(1900+yy)
mm=int(date[0])
if mm<10:
mm="0"+str(mm)
else: mm=str(mm)
dd=int(date[1])
if dd<10:
dd="0"+str(dd)
else: dd=str(dd)
time=code1[1].split(':')
hh=int(time[0])
if hh<10:
hh="0"+str(hh)
else: hh=str(hh)
min=int(time[1])
if min<10:
min= "0"+str(min)
else:
min=str(min)
MagRec["measurement_date"]=yyyy+":"+mm+":"+dd+":"+hh+":"+min+":00.00"
MagRec["measurement_time_zone"]='SAN'
if inst=="":
if code1[6][0]=='C':
instcode='SIO-bubba'
if code1[6][0]=='G':
instcode='SIO-flo'
else:
instcode=''
if len(code1)>1:
MagRec["measurement_positions"]=code1[6][2]
else:
MagRec["measurement_positions"]=code1[7] # takes care of awkward format with bubba and flo being different
if user=="":user=code1[5]
if code1[2][-1]=='C':
demag="T"
if code1[4]=='microT' and float(code1[3])!=0. and "LP-AN-ARM" not in methcode: labfield=float(code1[3])*1e-6
if code1[2]=='mT' and methcode!="LP-IRM":
demag="AF"
if code1[4]=='microT' and float(code1[3])!=0.: labfield=float(code1[3])*1e-6
if code1[4]=='microT' and labfield!=0. and meas_type!="LT-IRM":
phi,theta=0.,-90.
if demag=="T": meas_type="LT-T-I"
if demag=="AF": meas_type="LT-AF-I"
MagRec["treatment_dc_field"]='%8.3e'%(labfield)
MagRec["treatment_dc_field_phi"]='%7.1f'%(phi)
MagRec["treatment_dc_field_theta"]='%7.1f'%(theta)
if code1[4]=='' or labfield==0. and meas_type!="LT-IRM":
if demag=='T':meas_type="LT-T-Z"
if demag=="AF":meas_type="LT-AF-Z"
MagRec["treatment_dc_field"]='0'
if syn==0:
MagRec["er_specimen_name"]=rec[0]
MagRec["er_synthetic_name"]=""
MagRec["er_site_name"]=""
if specnum!=0:
MagRec["er_sample_name"]=rec[0][:specnum]
else:
MagRec["er_sample_name"]=rec[0]
if samp_infile and Samps: # if samp_infile was provided AND yielded sample data
samp=pmag.get_dictitem(Samps,'er_sample_name',MagRec['er_sample_name'],'T')
if len(samp)>0:
MagRec["er_location_name"]=samp[0]["er_location_name"]
MagRec["er_site_name"]=samp[0]["er_site_name"]
else:
MagRec['er_location_name']=''
MagRec["er_site_name"]=''
elif int(samp_con)!=6:
site=pmag.parse_site(MagRec['er_sample_name'],samp_con,Z)
MagRec["er_site_name"]=site
if MagRec['er_site_name']=="":
print 'No site name found for: ',MagRec['er_specimen_name'],MagRec['er_sample_name']
if MagRec["er_location_name"]=="":
print 'no location name for: ',MagRec["er_specimen_name"]
else:
MagRec["er_specimen_name"]=rec[0]
if specnum!=0:
MagRec["er_sample_name"]=rec[0][:specnum]
else:
MagRec["er_sample_name"]=rec[0]
MagRec["er_site_name"]=""
MagRec["er_synthetic_name"]=MagRec["er_specimen_name"]
SynRec["er_synthetic_name"]=MagRec["er_specimen_name"]
site=pmag.parse_site(MagRec['er_sample_name'],samp_con,Z)
SynRec["synthetic_parent_sample"]=site
SynRec["er_citation_names"]="This study"
SynRec["synthetic_institution"]=institution
SynRec["synthetic_type"]=syntype
SynRecs.append(SynRec)
if float(rec[1])==0:
pass
elif demag=="AF":
if methcode != "LP-AN-ARM":
MagRec["treatment_ac_field"]='%8.3e' %(float(rec[1])*1e-3) # peak field in tesla
if meas_type=="LT-AF-Z": MagRec["treatment_dc_field"]='0'
else: # AARM experiment
if treat[1][0]=='0':
meas_type="LT-AF-Z:LP-AN-ARM:"
MagRec["treatment_ac_field"]='%8.3e' %(peakfield) # peak field in tesla
MagRec["treatment_dc_field"]='%8.3e'%(0)
if labfield!=0 and methcode!="LP-AN-ARM": print "Warning - inconsistency in mag file with lab field - overriding file with 0"
else:
meas_type="LT-AF-I:LP-AN-ARM"
ipos=int(treat[0])-1
MagRec["treatment_dc_field_phi"]='%7.1f' %(dec[ipos])
MagRec["treatment_dc_field_theta"]='%7.1f'% (inc[ipos])
MagRec["treatment_dc_field"]='%8.3e'%(labfield)
MagRec["treatment_ac_field"]='%8.3e' %(peakfield) # peak field in tesla
elif demag=="T" and methcode == "LP-AN-TRM":
MagRec["treatment_temp"]='%8.3e' % (float(treat[0])+273.) # temp in kelvin
if treat[1][0]=='0':
meas_type="LT-T-Z:LP-AN-TRM"
MagRec["treatment_dc_field"]='%8.3e'%(0)
MagRec["treatment_dc_field_phi"]='0'
MagRec["treatment_dc_field_theta"]='0'
else:
MagRec["treatment_dc_field"]='%8.3e'%(labfield)
if treat[1][0]=='7': # alteration check as final measurement
meas_type="LT-PTRM-I:LP-AN-TRM"
else:
meas_type="LT-T-I:LP-AN-TRM"
# find the direction of the lab field in two ways:
# (1) using the treatment coding (XX.1=+x, XX.2=+y, XX.3=+z, XX.4=-x, XX.5=-y, XX.6=-z)
ipos_code=int(treat[1][0])-1
# (2) using the magnetization
DEC=float(rec[4])
INC=float(rec[5])
if INC < 45 and INC > -45:
if DEC>315 or DEC<45: ipos_guess=0
if DEC>45 and DEC<135: ipos_guess=1
if DEC>135 and DEC<225: ipos_guess=3
if DEC>225 and DEC<315: ipos_guess=4
else:
if INC >45: ipos_guess=2
if INC <-45: ipos_guess=5
# prefer the guess over the code
ipos=ipos_guess
MagRec["treatment_dc_field_phi"]='%7.1f' %(tdec[ipos])
MagRec["treatment_dc_field_theta"]='%7.1f'% (tinc[ipos])
# check it
if ipos_guess!=ipos_code and treat[1][0]!='7':
print "-E- ERROR: check specimen %s step %s, ATRM measurements, coding does not match the direction of the lab field!"%(rec[0],".".join(list(treat)))
elif demag=="S": # Shaw experiment
if treat[1][1]=='0':
if int(treat[0])!=0:
MagRec["treatment_ac_field"]='%8.3e' % (float(treat[0])*1e-3) # AF field in tesla
MagRec["treatment_dc_field"]='0'
meas_type="LT-AF-Z" # first AF
else:
meas_type="LT-NO"
MagRec["treatment_ac_field"]='0'
MagRec["treatment_dc_field"]='0'
elif treat[1][1]=='1':
if int(treat[0])==0:
MagRec["treatment_ac_field"]='%8.3e' %(peakfield) # peak field in tesla
MagRec["treatment_dc_field"]='%8.3e'%(arm_labfield)
MagRec["treatment_dc_field_phi"]='%7.1f'%(phi)
MagRec["treatment_dc_field_theta"]='%7.1f'%(theta)
meas_type="LT-AF-I"
else:
MagRec["treatment_ac_field"]='%8.3e' % ( float(treat[0])*1e-3) # AF field in tesla
MagRec["treatment_dc_field"]='0'
meas_type="LT-AF-Z"
elif treat[1][1]=='2':
if int(treat[0])==0:
MagRec["treatment_ac_field"]='0'
MagRec["treatment_dc_field"]='%8.3e'%(trm_labfield)
MagRec["treatment_dc_field_phi"]='%7.1f'%(phi)
MagRec["treatment_dc_field_theta"]='%7.1f'%(theta)
MagRec["treatment_temp"]='%8.3e' % (trm_peakT)
meas_type="LT-T-I"
else:
MagRec["treatment_ac_field"]='%8.3e' % ( float(treat[0])*1e-3) # AF field in tesla
MagRec["treatment_dc_field"]='0'
meas_type="LT-AF-Z"
elif treat[1][1]=='3':
if int(treat[0])==0:
MagRec["treatment_ac_field"]='%8.3e' %(peakfield) # peak field in tesla
MagRec["treatment_dc_field"]='%8.3e'%(arm_labfield)
MagRec["treatment_dc_field_phi"]='%7.1f'%(phi)
MagRec["treatment_dc_field_theta"]='%7.1f'%(theta)
meas_type="LT-AF-I"
else:
MagRec["treatment_ac_field"]='%8.3e' % ( float(treat[0])*1e-3) # AF field in tesla
MagRec["treatment_dc_field"]='0'
meas_type="LT-AF-Z"
# Cooling rate experient # added by rshaar
elif demag=="T" and methcode == "LP-CR-TRM":
MagRec["treatment_temp"]='%8.3e' % (float(treat[0])+273.) # temp in kelvin
if treat[1][0]=='0':
meas_type="LT-T-Z:LP-CR-TRM"
MagRec["treatment_dc_field"]='%8.3e'%(0)
MagRec["treatment_dc_field_phi"]='0'
MagRec["treatment_dc_field_theta"]='0'
else:
MagRec["treatment_dc_field"]='%8.3e'%(labfield)
if treat[1][0]=='7': # alteration check as final measurement
meas_type="LT-PTRM-I:LP-CR-TRM"
else:
meas_type="LT-T-I:LP-CR-TRM"
MagRec["treatment_dc_field_phi"]='%7.1f' % (phi) # labfield phi
MagRec["treatment_dc_field_theta"]='%7.1f' % (theta) # labfield theta
indx=int(treat[1][0])-1
# alteration check matjed as 0.7 in the measurement file
if indx==6:
cooling_time= cooling_rates_list[-1]
else:
cooling_time=cooling_rates_list[indx]
MagRec["measurement_description"]="cooling_rate"+":"+cooling_time+":"+"K/min"
elif demag!='N':
if len(treat)==1:treat.append('0')
MagRec["treatment_temp"]='%8.3e' % (float(treat[0])+273.) # temp in kelvin
if trm==0: # demag=T and not trmaq
if treat[1][0]=='0':
meas_type="LT-T-Z"
else:
MagRec["treatment_dc_field"]='%8.3e' % (labfield) # labfield in tesla (convert from microT)
MagRec["treatment_dc_field_phi"]='%7.1f' % (phi) # labfield phi
MagRec["treatment_dc_field_theta"]='%7.1f' % (theta) # labfield theta
if treat[1][0]=='1':meas_type="LT-T-I" # in-field thermal step
if treat[1][0]=='2':
meas_type="LT-PTRM-I" # pTRM check
pTRM=1
if treat[1][0]=='3':
MagRec["treatment_dc_field"]='0' # this is a zero field step
meas_type="LT-PTRM-MD" # pTRM tail check
else:
labfield=float(treat[1])*1e-6
MagRec["treatment_dc_field"]='%8.3e' % (labfield) # labfield in tesla (convert from microT)
MagRec["treatment_dc_field_phi"]='%7.1f' % (phi) # labfield phi
MagRec["treatment_dc_field_theta"]='%7.1f' % (theta) # labfield theta
meas_type="LT-T-I:LP-TRM" # trm acquisition experiment
MagRec["measurement_csd"]=rec[2]
MagRec["measurement_magn_moment"]='%10.3e'% (float(rec[3])*1e-3) # moment in Am^2 (from emu)
MagRec["measurement_dec"]=rec[4]
MagRec["measurement_inc"]=rec[5]
MagRec["magic_instrument_codes"]=instcode
MagRec["er_analyst_mail_names"]=user
MagRec["er_citation_names"]=citation
if "LP-IRM-3D" in methcode : meas_type=methcode
#MagRec["magic_method_codes"]=methcode.strip(':')
MagRec["magic_method_codes"]=meas_type
MagRec["measurement_flag"]='g'
MagRec["er_specimen_name"]=rec[0]
if 'std' in rec[0]:
MagRec["measurement_standard"]='s'
else:
MagRec["measurement_standard"]='u'
MagRec["measurement_number"]='1'
#print MagRec['treatment_temp']
MagRecs.append(MagRec)
MagOuts=pmag.measurements_methods(MagRecs,noave)
pmag.magic_write(meas_file,MagOuts,'magic_measurements')
print "results put in ",meas_file
if len(SynRecs)>0:
pmag.magic_write(synfile,SynRecs,'er_synthetics')
print "synthetics put in ",synfile
return True, meas_file
def do_help():
return main.__doc__
if __name__ == "__main__":
main()