示例#1
0
def GenerateChart(obj_key):
    ##############################################################################
    ############   Program parameters   ##########################################
    ##############################################################################
    logging.info("Start with processing...")
    ludo = obj_key.get()
    # logging.debug(ludo)

    # Logic with simple file upload
    filename = ludo.sampleFilename

    # Calibration parameters
    Lambda = ludo.qlambda
    Target = ludo.qtarget

    if(Lambda > 2.2 or Lambda == 0):
        Lambda = ''
    
    logging.debug("Filename: {}".format(filename))
    logging.debug("Target: %s", Target)
    logging.debug("Lambda: %s", Lambda)
    # Logic to parse correct file
    
    # Logic with simple file upload
    XRDdata = StringIO.StringIO(ludo.sampleBlob)
    logging.debug(XRDdata)
    
    phaselistname = 'phaselist.csv'
    phaselist = open(phaselistname, 'r').readlines()
    selectedPhases = ludo.selected
    
    DBname = "reduced_difdata.txt"
    difdata = open(DBname, 'r').readlines()

    # logging.debug(XRDdata)
    logging.info("Start Quant.phase...")
    
    rv_plot = StringIO.StringIO()
    twoT, diff = Conductor.openXRD(XRDdata, filename)
    results, rv_plot = Conductor.Qanalyze(twoT, diff, difdata, phaselist, selectedPhases, Lambda, Target)
    rv_plot.seek(0)
    image = Image.open(rv_plot)
    width, height = image.size
    # logging.info("w: {} h: {}".format(width, height))
    ludo.avatar = rv_plot.getvalue()
    
    # ludo.selected = results
    ludo.results = results
    ludo.put()
    # logging.debug(ludo)

    logging.debug(results)
    logging.info("Done with processing")

    return diff
示例#2
0

#datafilepath='/home/philippe/Documents/Projects/Python/Autoquant-Web/XRD_data'
#datafilename = "Mix3B-film.txt"
DBfilepath=''
DBname="../reduced_difdata.txt"
phaselistname = 'phaselistall.csv'
Lambda = 0
Target = ''


datafilepath, datafilename = os.path.split(askopenfilename(filetypes=[("TXT files","*.txt")], title="Open XRD .txt file"))

Tk().withdraw()
t0=time.time()
difdata = open((os.path.join(DBfilepath, DBname)), 'r').readlines()
phaselist = open(os.path.join(DBfilepath, phaselistname), 'r').readlines()
selectedphases = ['Actinolite','Aegirine','Alabandite','Albite','Almandine','Aluminotaramite','Alunite','Analcime','Andalusite','Andesine','Andradite','Anhydrite','AnhydriteGamma','Ankerite','Annite','Anorthite','Anorthoclase','Anthophyllite','Antigorite','Apatite','Aragonite','Arfvedsonite','Arsenic','Arsenopyrite','Augite','Autunite','Azurite','Barite','Barroisite','Beryl','Biotite','Bismuth','Bismuthinite','Bornite','Brannerite','Brucite','Bytownite','Calcio-olivine','Calcite','Carnotite','Carpholite','Cassiterite','Celadonite','Celsian','Cerussite','Chabazite','Chamosite','Chalcanthite','Chalcocite-alpha','Chalcocite','Chalcopyrite','Chromite','Cinnabar','Clinochlore','Clinoenstatite','Clinoferrosilite','Clinozoisite','Coffinite','Copper','Cordierite','Corundum','Covellite','Cubanite','Cummingtonite','Davidite-(La)','Diaspore','Dickite','Diopside','Dolomite','Dravite','Eckermannite','Elbaite','Enstatite','Epidote','Epsomite','Fayalite','Ferri-clinoholmquistite','Ferrohornblende','Ferrosilite','Fluorite','Fluor-liddicoatite','Fluorocannilloite','Fluoroleakeite','Foitite','Forsterite','Galena','Geikielite','Gersdorffite','Gibbsite','Glaucophane','Goethite','Gold','Graphite','Grossular','Grunerite','Gypsum','Halite','Halloysite-7A','Halloysite-10A','Hastingsite','Hedenbergite','Hematite','Hercynite','Holmquistite','Illite','Ilmenite','Iron','Jadeite','Jarosite','Kaersutite','Kaolinite','Kyanite','Labradorite','Laumontite','Lawsonite','Leucite','Lizardite','Magnesiofoitite','Magnesiohornblende','Magnesiosadanagaite','Magnesite','Magnetite','Malachite','Manganite','Margarite','Marialite','Meionite','Melanterite','Microcline','Millerite','Molybdenite','Molybdite','Monazite','Monticellite','Montmorillonite','Muscovite','Natrolite','Nepheline','Nyboite','Olenite','Oligoclase','Omphacite','Orpiment','Orthoclase','Pargasite','Pedrizite','Pentlandite','Periclase','Phlogopite','Prehnite','Pumpellyite','Pyrite','Pyrolusite','Pyrope','Pyrophyllite','PyrrhotiteMon','PyrrhotiteHex','Quartz','Realgar','Rhodochrosite','Richterite','Riebeckite','Rutile','Sanidine','Sapphirine','Scheelite','Schorl','Siderite','Sillimanite','Silver','Smithsonite','Sodalite','Spessartine','Sphalerite','Spinel','Spodumene','Staurolite','Stibnite','Stilbite','Strontianite','Sudoite','Sylvanite','Sylvite','Talc','Tephroite','Tetrahedrite','Thenardite','Thorianite','Thorite','Titanite','Topaz','Tremolite','Tschermakite','Uraninite','Uranophane-alpha','Uranophane-beta','Uvarovite','Uvite','Vesuvianite','Winchite','Xenotime','Zincite','Zircon','Zoisite']
#selectedphases = ['Actinolite','Albite','Almandine','Andalusite','Andesine','Anhydrite','Ankerite','Anorthite','Anthophyllite','Apatite','Aragonite','Augite','Barite','Beryl','Biotite','Calcite','Cerussite','Chabazite','Chamosite','Chalcopyrite','Chromite','Clinochlore','Cordierite','Corundum','Dickite','Diopside','Dolomite','Epsomite','Fayalite','Ferrohornblende','Fluorite','Forsterite','Galena','Gibbsite','Goethite','Grossular','Gypsum','Halite','Hematite','Illite','Ilmenite','Kaolinite','Labradorite','Lizardite','Magnesiofoitite','Magnesiohornblende','Magnesiosadanagaite','Magnesite','Magnetite','Microcline','Montmorillonite','Muscovite','Oligoclase','Periclase','Pyrite','Quartz']
#selectedphases = ['Albite','Microcline','Quartz']

#print "number of phase: ", len(selectedphases)

twoT, diff = Conductor.openXRD(os.path.join(datafilepath, datafilename))
results, plot = Conductor.Qanalyze(twoT, diff ,difdata, phaselist, selectedphases, Lambda, Target)


#print plot, results

print "time of computation = %.2fs" %(time.time()-t0)