Ignore:
Timestamp:
Mar 20, 2022 9:25:59 PM (18 months ago)
Author:
toby
Message:

all dependent params in sigDict
#

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2export_Bracket.py

    r5232 r5241  
    8181
    8282                # Get phase and weight fractions uncertainties, if they have been refined
    83                 for hist_num in range(0, len(self.Histograms.keys())):
     83                for hist_num,hist_name in enumerate(self.Histograms):
    8484                    try:
    8585                        # Get phase fraction uncertainty, if phase fractions have been refined
    8686                        phasefrac_unc = self.sigDict[str(phase_num) + ':' + str(hist_num) + ':Scale']
    8787                        # Get name of histogram associated with this phase, for later use
    88                         hist_name = list(self.Histograms.keys())[hist_num]
     88                        #hist_name = list(self.Histograms.keys())[hist_num]
    8989                        # Extract phase fraction value
    9090                        phasefrac = phasedict[1]['Histograms'][hist_name]['Scale'][0]
    91 
    92                         # Extract weight fraction and uncertainty
    93                         # weight_frac = self.OverallParms['Covariance']['depSig'][
    94                         #     str(phase_num) + ':' + str(hist_num) + ':WeightScale']
    95                         # weight_frac_unc = self.OverallParms['Covariance']['depSig'][
    96                         #     str(phase_num) + ':' + str(hist_num) + ':WeightScaleSig']
     91                        # Write phase if there is more than one histogram, specify which one
     92                        if len(self.Histograms) > 1:
     93                            model_parameters[phasenam + " Phase Fraction in: " + hist_name] = (
     94                                ValEsd(phasefrac, phasefrac_unc))
     95                        # If there is only one histogram, no need to specify which histogram the fraction is based on
     96                        else:
     97                            model_parameters[phasenam + " Phase Fraction"] = ValEsd(phasefrac, phasefrac_unc)
     98                    except:
     99                        pass
     100
     101                    try:
    97102                        var = str(phase_num) + ':' + str(hist_num) + ':WgtFrac'
    98103                        depSigDict = self.OverallParms['Covariance'].get('depSigDict',{})
     
    101106                        # Write phase + weight fractions in bracket notation to dictionary, to be exported as a CSV
    102107                        # If there is more than one histogram, specify which one the fraction is based on
    103                         if len(self.Histograms.keys()) > 1:
    104                             model_parameters[phasenam + " Phase Fraction in: " + hist_name] =\
    105                                 ValEsd(phasefrac, phasefrac_unc)
    106                             model_parameters[phasenam + " Weight Fraction in: " + hist_name] = \
    107                                 ValEsd(weight_frac, weight_frac_unc)
     108                        if len(self.Histograms) > 1:
     109                            model_parameters[phasenam + " Weight Fraction in: " + hist_name] = (
     110                                ValEsd(weight_frac, weight_frac_unc))
    108111                        # If there is only one histogram, no need to specify which histogram the fraction is based on
    109112                        else:
    110                             model_parameters[phasenam + " Phase Fraction"] = ValEsd(phasefrac, phasefrac_unc)
    111113                            model_parameters[phasenam + " Weight Fraction"] = ValEsd(weight_frac, weight_frac_unc)
    112114                    except:
     
    128130                           # Write MD ratio to dictionary to be exported
    129131                           model_parameters[phasenam + " March Dollase Ratio"] = MD_bracket
    130                         # Increment phase number counter
    131                         phase_num += 1
    132132                    except:
    133133                        pass
     134                # Increment phase number counter
     135                phase_num += 1
    134136
    135137# Extract sample displacements, zero offset and D(ij)s (if refined)
    136             for hist_num in range(0, len(self.Histograms.keys())):
    137                 hist_num = str(hist_num)
     138            for i,hist_name in enumerate(self.Histograms):
     139                hist_num = str(i)
    138140                # Extract zero offset, if refined
    139141                GetParamSig("", hist_num, ':Zero', "Zero Offset")
     
    145147                GetParamSig("", hist_num, ':DisplaceY', "Sample Y Displacement (micron)")
    146148                # Extract hydrostatic strains, if refined
    147                 for phase_num in range(0, len(self.Phases.keys())):
    148                     phase_name = list(self.Phases.keys())[phase_num]
     149                for phase_num,phase_name in enumerate(self.Phases):
    149150                    for d_i in range(1, 4):
    150151                        for d_j in range(1, 4):
     
    153154
    154155                # Extract atomic parameters, if refined
    155                 for phase_num in range(0, len(self.Phases.keys())):
    156                     phase_name = list(self.Phases.keys())[phase_num]
    157                     atom_list = list(self.Phases.values())[phase_num]["Atoms"]
    158                     for atom_num in range(0, len(atom_list)):
     156                for phase_num,phase_name in enumerate(self.Phases):
     157                    # atom_list = list(self.Phases.values())[phase_num]["Atoms"]
     158                    atom_list = self.Phases[phase_name]["Atoms"] #  same as above?
     159                    for atom_num,atom in enumerate(atom_list):
    159160                        # Extract isotropic thermal parameters, if refined
    160161                        GetParamSig(str(phase_num), ':', 'AUiso:' + str(atom_num),
    161                                     phase_name + ' ' + atom_list[atom_num][0] + ' Uiso')
     162                                    phase_name + ' ' + atom[0] + ' Uiso')
    162163                        # Extract anisotropic thermal parameters (Uijs), if refined
    163164                        for Ui in range(1, 4):
    164165                            for Uj in range(1, 4):
    165166                                GetParamSig(str(phase_num), ':', 'AU' + str(Ui) + str(Uj) + ':' + str(atom_num),
    166                                             phase_name + ' ' + atom_list[atom_num][0] + ' U' + str(Ui) + str(Uj))
     167                                            phase_name + ' ' + atom[0] + ' U' + str(Ui) + str(Uj))
    167168                        # Extract fractional occupancies, if refined
    168169                        GetParamSig(str(phase_num), ':', 'Afrac:' + str(atom_num),
    169                                     phase_name + ' ' + atom_list[atom_num][0] + ' Occupancy')
     170                                    phase_name + ' ' + atom[0] + ' Occupancy')
    170171                        # Extract atom X Y Z, if refined
    171172                        for atom_axis in ('x', 'y', 'z'):
     
    179180                                atom_axis_val = list(self.Phases.values())[phase_num]["Atoms"][atom_num][ord(atom_axis)-117]
    180181                                # Convert to bracket notation and add to dictionary, which will be exported as a CSV
    181                                 model_parameters[phase_name + ' ' + atom_list[atom_num][0] + ' ' + atom_axis] = \
     182                                model_parameters[phase_name + ' ' + atom[0] + ' ' + atom_axis] = \
    182183                                    ValEsd(atom_axis_val, atom_axis_sig)
    183184                            except: pass
Note: See TracChangeset for help on using the changeset viewer.