def plotvar(self, var='Out. Compos.',R=[65,100]): m = np.zeros([16,24]) for index, row in self.PrintDat.iterrows(): rc = self.getRowCol(row['DW']) m[rc[0],rc[1]] = row[var] SimpleTools.plotMatrix(m,range=R,title=self.ClassifiedPlateType) return m
def createCustom( customfolder='\\\\fserver\\people\\Arne\\2016\\Lemonade\\MFG_Lemonade\\CUSTOM', srcfolder='../EPC/Calibration/Miscellaneous'): if not os.path.exists(customfolder): print('Folder ', customfolder, ' does not exists !') print('Exiting') return os.chdir(customfolder) epcfiles = SimpleTools.getFileList('*.epc') for file in epcfiles: folder = os.path.dirname(file) outputfolder = folder + './Miscellaneous' if not os.path.exists(outputfolder): os.mkdir(outputfolder) epc = editEPC.parseEPC(file) miscfiles = epc.getAllFiles() for filename in miscfiles: src = srcfolder + './' + filename dest = outputfolder + './' + filename if os.path.exists(src): shutil.copyfile(src, dest) else: print(' -- ERROR --- file ', src, ' does not exist !') zipfoldername = os.path.join(os.getcwd(), folder) # print( ' zipfoldername : ', zipfoldername, ' os.getcwd() = ' , os.getcwd()) SimpleTools.zipfolder(folder=zipfoldername) # now delete the miscellaneous folder shutil.rmtree(os.path.join(os.getcwd(), outputfolder)) return
def createCustom(self, Model='55X', Type='MFG', Tag=None): customfolder = os.path.join(self.rootfolder, Model, Type, 'Custom') srcfolder = os.path.join(self.rootfolder, './Miscellaneous') if not os.path.exists(customfolder): print('Folder ', customfolder, ' does not exists !') print('Exiting') return os.chdir(customfolder) epcfiles = SimpleTools.getFileList('*.epc') arenaPmDataFrame = pandas.DataFrame() if (Tag): arenaPmFile = Tag + '_PartNumber_List.csv' if os.path.isfile(arenaPmFile): arenaPmDataFrame = pandas.read_csv(arenaPmFile) for file in epcfiles: folder = os.path.dirname(file) platetype = os.path.splitext(os.path.basename(file))[0] # print('folder :: ', folder, ' file: ', file) PN, Z = self.getArenaPartNr(arenaPmDataFrame, platetype) epcxfile = os.path.join(folder, folder + '.epcx') if not os.path.exists(epcxfile): calsplit = folder.split('_') calsplit[0] = calsplit[0][0:-1] unclasplate = '_'.join(calsplit) self.createEPCX( epcxfilename=epcxfile, epcfilename=os.path.basename(file), platetype=os.path.basename(folder), unclassifiedplatetype=os.path.basename(unclasplate)) outputfolder = folder + './Miscellaneous' if not os.path.exists(outputfolder): os.mkdir(outputfolder) epc = editEPC.parseEPC(file) miscfiles = epc.getAllFiles() for filename in miscfiles: src = srcfolder + './' + filename dest = outputfolder + './' + filename if os.path.exists(src): shutil.copyfile(src, dest) else: print(' -- ERROR --- file ', src, ' does not exist !') zipfoldername = os.path.join(os.getcwd(), folder) # print( ' zipfoldername : ', zipfoldername, ' os.getcwd() = ' , os.getcwd()) prefix = PN + '-' + Z + '__' + Model + '__' if (Tag): prefix += Tag prefix += '__' enhanced_zipfilename = prefix + platetype + '.zip' SimpleTools.zipfolder(folder=zipfoldername) zipfilename = platetype + '.zip' # now delete the miscellaneous folder # print(' folder content:: ', os.listdir()) shutil.move(folder + '/' + zipfilename, folder + '/' + enhanced_zipfilename) shutil.rmtree(os.path.join(os.getcwd(), outputfolder)) return
def copyQC(month=1, year=2018): # get list of all os.chdir(SRCDIR) ALL = SimpleTools.getFileList('*EPAanalysis.csv') datestring = '%d_%02d' % (year, month) thisDESTDIR = DESTDIR + '/' + datestring if not os.path.exists(thisDESTDIR): os.makedirs(thisDESTDIR) ALL_DATE = [ f for f in ALL if (time.gmtime(os.path.getctime(f))[0] == year) and ( time.gmtime(os.path.getctime(f))[1] == month) ] if len(ALL_DATE) == 0: print(' No files found for year ', year, ' and month ', month) return print(' --- Copying ' + str(len(ALL_DATE)) + ' folders ----- ') M = pandas.read_csv(ALL_DATE[0]) for f in ALL_DATE[1:]: m = pandas.read_csv(f) M = M.append(m) thisfolder = os.path.dirname(f) for item in os.listdir(thisfolder): s = os.path.join(thisfolder, item) d = os.path.join(thisDESTDIR, item) shutil.copy2(s, d) M.to_csv(thisDESTDIR + '/QC_' + datestring + '.csv')
import matplotlib.pyplot as plt import pyCyte.ReadEchoFiles.ReadCSV as csv import pyCyte.ToolBox.SimpleTools as sbox SOS = 1495 #Speed of Sound m/sec or mm/msec or um/usec subdir = '20180413_96PPQ_Lot_Prints' os.chdir( '''\\\\seg\\data\\96SP_Feasibility\\Experiments\\{0}\\'''.format(subdir)) field = 'SR ToF (us)' ylimits = [32, 40] field = 'BottomEchoAmpRatio' ylimits = [0.5, 1.0] field = 'Bottom Thickness (us)' ylimits = [0.8, 1.0] fl = sbox.getFileList('*platesurvey.csv') hook = '2018' cIndex = -1 colors = [ 'green', 'blue', 'purple', 'red', 'brown', 'pink', 'black', 'orange', 'cyan', 'lightblue', 'mediumblue', 'lightgreen', 'forestgreen', 'yellow', 'orange', 'aliceblue', 'lavender', 'violet' ] title = """{0} - {2} {1}""".format(field, hook, subdir) plt.figure(figsize=(10, 6)) plt.xlim(0, 8) plt.ylim(ylimits) plt.title(title, fontsize='14') plt.xlabel('Current Fluid Thickness (mm)', fontsize=14)
Single = False cIndex = -1 subdir = '20180417_96PPQ_Lot_Prints\ReaderFiles_ES' os.chdir( '''\\\\seg\\data\\96SP_Feasibility\\Experiments\\{0}\\'''.format(subdir)) #os.chdir ('\\\\seg\\data\\96SP_Feasibility\\Experiments\\20180411_96PPQ_SysCal_Lot1\96PPQ_AQ_BP\EjectSweep') srcRows = [] for letter in range(65, 73): srcRows.append(chr(letter)) pwr = numpy.arange(-0.44, 0.52, 0.04) fillVols = [60, 100, 140, 180, 200, 220, 260, 300] from openpyxl import load_workbook fl = sbox.getFileList('*RawVolumeOutput.xlsx') plt.figure(figsize=(12, 7.5)) plt.suptitle('96PPQ - 3 Resin Lots - Print Volume vs. Fill Volume', fontsize=15) #for sub in range (1,5): # plt.subplot(2,2,sub) # plt.title('''Type = {0}'''.format (types[sub-1])) # plt.xlabel (xlabels[sub - 1], fontsize = 14); plt.ylim(90,120) # plt.ylim(-.15, 0.05); plt.xlim(0,9900) if EjectSweep: xLabel = 'Power Adjust (db)' xLim = [-0.5, 0.5] yLim = [75, 115]
#print (len(tmdat)) tmdat = tmdat[tmdat.Description == 1] #print (len(tmdat)) tmdat.drop(tmdat.columns[[0, 1, 2]], axis=1, inplace=True) tmdat = tmdat[['PlateTypeName', 'X', 'Y']] print(tmdat) return tmdat #2018 os.chdir('\\\\fserver\\people\\Lisa_Jungherr\\2018\\Python') # find either single-file .xls or many files .csv flx = sbox.getFileList('*.xls*') if (True): if len(flx) >= 1: f = flx[-1] # print (item, flx) if len(flx) > 1: notes = ''' Found 2 files, using:{0}'''.format(f) #load MEDMANdb if len(flx) >= 1: cf = ParseXLSSheet(f) # Here is where I want to read in the worksheet as a Dictionary; with Keys from Column Names # RESCF = [row for row in tmdat if row['LUTName'] == 'ToneX_CF_MHz' and '6RES' in row['PlateTypeName'] and row['Description'] =='1' ]
import matplotlib.pyplot as plt import pyCyte.ReadEchoFiles.ReadCSV as csv import pyCyte.ToolBox.SimpleTools as sbox m = 18059 thisDir = '''//fserver/people/Geeta/2017/1020201_384LDVS_Plus_AQ_GP_revamp/RnD_Pilot/E{0}'''.format( m) os.chdir(thisDir) field = 'FluidComposition' ylimits = [0, 55] xlimits = [0, 55] #field = 'ArbAmplitude (Volts)'; ylimits = [1.5,2.1] #ylimits = [2.4,3.1] #higher limits needed for A2 plates fl = sbox.getFileList('*print.csv') cIndex = -1 colors = [ 'green', 'blue', 'purple', 'red', 'brown', 'pink', 'black', 'darkgrey', 'cyan', 'lightblue', 'mediumblue', 'lightgreen', 'forestgreen', 'yellow', 'orange', 'aliceblue', 'lavender', 'violet' ] #legends = ['Lot 1', 'Lot 1', 'Lot 1', 'Lot 2','Lot 2','Lot 2','Lot 3','Lot 3','Lot 3',] #For a specific run title = """{0} {1} {2}""".format(m, 'Pilot', field) plt.figure(figsize=(10, 6)) plt.xlim(xlimits) #; plt.ylim (ylimits) plt.title(title, fontsize='14') plt.xlabel('Measured Conc.', fontsize=14)
subdir1 = '''\\\\mfg\\PROD_INSTRUMENTS\\2018_UNITS\\{0}\\Backups\\MEDMAN'''.format( item) subdir2 = '''\\\\mfg\\PROD_INSTRUMENTS\\2018_UNITS\\{0}\\Backups\\MEDMANdb'''.format( item) if (os.path.isdir(subdir1)): os.chdir(subdir1) # print ('Found dir for ',item) elif (os.path.isdir(subdir2)): os.chdir(subdir2) # print ('Found dir in Medmandb for ',item) if (os.path.isdir(subdir1)) and (os.path.isdir(subdir2)): notes = " Found 2 subdir, Using MEDMANdb" # find either single-file .xls or many files .csv if (os.path.isdir(subdir1)) or (os.path.isdir(subdir2)): flx = sbox.getFileList('*.xls*') if len(flx) >= 1: f = flx[-1] # print (item, flx) if len(flx) > 1: notes = ''' Found 2 files, using:{0}'''.format(f) #load MEDMANdb if len(flx) >= 1: print('looking at: ', item) cf = ParseXLSSheet(f) plt.plot(cf['X'], cf['Y']) cf['M'] = item AllFrame = pandas.concat([AllFrame, cf]) # If no wokrbook, look for a list of single sheets.
import pandas as pd import matplotlib.pyplot as plt import pyCyte.ReadEchoFiles.ReadCSV as csv import pyCyte.ToolBox.SimpleTools as sbox subdir = '20180825_E1445_Stability_Xcontam' os.chdir( '''\\\\seg\\data\\96SP_Feasibility\\Experiments\\{0}\\'''.format(subdir)) field = 'ArbAmplitude (Volts)' ylimits = [1.5, 2.1] field = 'NewEjectAmp (V)' ylimits = [1.2, 1.5] xlimits = [0, 7] fl = sbox.getFileList('*MIPOutput.csv') hook = 'SP' cIndex = -1 colors = [ 'green', 'blue', 'cyan', 'purple', 'red', 'brown', 'pink', 'orange', 'lightblue', 'yellow', 'cyan', 'mediumblue', 'lightgreen', 'forestgreen', 'yellow', 'orange', 'aliceblue', 'lavender', 'violet' ] title = """{2} in {1}""".format(hook, subdir, field) #title = """{0} -- {1}""".format (subdir, field) plt.figure(figsize=(9, 6)) plt.ylim(ylimits) plt.xlim(xlimits) plt.title(title, fontsize='15') plt.xlabel('Current Fluid Thickness (mm)', fontsize=14)
subdir1 = '''\\\\mfg\\PROD_INSTRUMENTS\\2018_UNITS\\{0}\\Backups\\MEDMAN'''.format( item) subdir2 = '''\\\\mfg\\PROD_INSTRUMENTS\\2018_UNITS\\{0}\\Backups\\MEDMANdb'''.format( item) if (os.path.isdir(subdir1)): os.chdir(subdir1) # print ('Found dir for ',item) elif (os.path.isdir(subdir2)): os.chdir(subdir2) # print ('Found dir in Medmandb for ',item) if (os.path.isdir(subdir1)) and (os.path.isdir(subdir2)): notes = " Found 2 subdir, Using MEDMANdb" # find either single-file .xls or many files .csv if (os.path.isdir(subdir1)) or (os.path.isdir(subdir2)): flx = sbox.getFileList('*.xls*') if len(flx) >= 1: f = flx[-1] # print (item, flx) if len(flx) > 1: notes = ''' Found 2 files, using:{0}'''.format(f) #load MEDMANdb if len(flx) >= 1: wb = xlrd.open_workbook(f, on_demand=True) worksheet = wb.sheet_by_name('FocalSweep') FocalToF = worksheet.cell(-1, 6).value print(item, FocalToF, notes) else: fl = sbox.getFileList('*FocalSweep*.csv') if len(fl) > 0:
def createSwissardPackage(self, Model='55X', Type='MFG'): os.chdir(self.rootfolder) os.chdir(Model) os.chdir(Type) for i, folder in enumerate( ['./Calibration', './HealthCheck', './Scaling']): if not os.path.exists(folder): print(' -- ERROR -- folder ', folder, ' does not exist in path ', os.getcwd()) return os.chdir(folder) if folder == './HealthCheck': d = '.' subfolders = [ os.path.join(d, o) for o in os.listdir(d) if os.path.isdir(os.path.join(d, o)) ] if len(subfolders) == 0: subfolders = ['./'] else: subfolders = ['./'] thisdir = os.getcwd() for subfolder in subfolders: os.chdir(subfolder) epcfiles = SimpleTools.getFileList('*.epc') miscfiles = [] for file in epcfiles: epc = editEPC.parseEPC(file) for miscfile in epc.getAllFiles(): if miscfile not in miscfiles: miscfiles.append(miscfile) outputfolder = './Miscellaneous' if not os.path.exists(outputfolder): os.mkdir(outputfolder) for filename in miscfiles: src = self.rootfolder + './Miscellaneous/' + filename dest = outputfolder + './' + filename if os.path.exists(src): shutil.copyfile(src, dest) else: print(' -- ERROR --- file ', src, ' does not exist !') os.chdir(thisdir) os.chdir('../') if (i == 0): zipmode = "w" else: zipmode = "a" zipfile = 'EPC_Protocols__' + Type + '_' + Model + '.zip' SimpleTools.zipfolder(folder=folder, zipFileFolder=os.getcwd(), zipFileName=zipfile, verbose=self.verbose, mode=zipmode) if (folder == './HealthCheck'): for f in subfolders: shutil.rmtree( os.path.join(os.getcwd(), folder, f, outputfolder)) else: shutil.rmtree(os.path.join(os.getcwd(), folder, outputfolder)) # SimpleTools.zipfolder(folder=outputfolder) return
def getFocalSweepFilename(): f = sbox.getFileList('*FocalSweep*.csv') return f
def getListOfPlateSurveyFiles(): """Finds all *platesurvey.csv files in all subfolders of cwd. Returns list""" return sbox.getFileList('*platesurvey.csv')
def calStatus(self): if (os.path.basename(os.getcwd()) != 'Calibration'): print(' **** ERROR ***, need to be in Calibration folder ') return thisdir = os.getcwd() TX = thisdir.split('\\')[-4] outfile = 'Calibration__Incomplete__' + TX + '.xlsx' sumFiles = st.getFileList('*Processed__DataSummary*.xlsx') writer = pd.ExcelWriter(outfile, engine='xlsxwriter') alldata = [] finalCal = [] for f in sumFiles: print('<< Processing' + f + ' >> ') platetype = f.split('\\')[1] FT = f.split('\\')[-3] status = f.split('__')[-1].split('.xlsx')[0] alldata.append([platetype, FT, status]) if 'FinalTest' in FT: ds = pd.read_excel(f) ds.to_excel(writer, sheet_name=platetype, index=False) workbook = writer.book worksheet = writer.sheets[platetype] lines = len(ds) + 1 ftst = lines + 1 self.applySheetFormat( platetype.split('_')[-1], workbook, worksheet, ds, lines, ftst) finalCal.append([platetype, FT, status]) df = pd.DataFrame(alldata) dfinal0 = pd.DataFrame(finalCal) dfinal0.columns = ['Platetype', 'Test', 'Status'] diff = set(dfinal0['Platetype']) & set(self.plateCal) for p in self.plateCal: if p not in diff: finalCal.append([p, 'NULL', 'Incomplete']) dfinal = pd.DataFrame(finalCal) dfinal.columns = ['Platetype', 'Test', 'Status'] dfinal.to_excel(writer, 'Calibration_Summary') # Add a format. Light red fill with dark red text. format1 = workbook.add_format({ 'bg_color': '#FFC7CE', 'font_color': '#9C0006' }) # Add a format. Green fill with dark green text. format2 = workbook.add_format({ 'bg_color': '#C6EFCE', 'font_color': '#006100' }) # Add a format. Yello fill with orange text. format3 = workbook.add_format({ 'bg_color': '#FFFF00', 'font_color': '#FF4500 ' }) ws = writer.sheets['Calibration_Summary'] ws.set_column('A:D', 20) condrange = 'D2:D' + str(lines + 5) ws.conditional_format(condrange, { 'type': 'cell', 'criteria': '==', 'value': '"FAIL"', 'format': format1 }) ws.conditional_format(condrange, { 'type': 'cell', 'criteria': '==', 'value': '"PASS"', 'format': format2 }) ws.conditional_format( condrange, { 'type': 'cell', 'criteria': '==', 'value': '"Incomplete"', 'format': format3 }) workbook.worksheets_objs.sort(reverse=True, key=lambda x: x.name) writer.save() if len(dfinal['Platetype']) == len(self.plateCal): if not 'Incomplete' in dfinal['Status'].values: if not 'FAIL' in dfinal['Status'].values: outfileFinal = outfile.replace( 'Incomplete', 'COMPLETE__' + time.strftime('%Y%m%d')) os.rename(outfile, outfileFinal) return dfinal