Skip to content

Instantly share code, notes, and snippets.

@Tsangares
Last active February 15, 2019 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tsangares/8bdc0033fa2c5696600097e1f1a2feae to your computer and use it in GitHub Desktop.
Save Tsangares/8bdc0033fa2c5696600097e1f1a2feae to your computer and use it in GitHub Desktop.
Phys 9a LGAD: Parsing XML

Here is the input xml file we will be manipulating:

You can do all the anlysis in your jupyter notebook as long as it has the pip packages pandas,matplotlib,scipi,xlrd.

Take the excel file and put it in your jupyter notebook, or in your working directory.

Import panda using import pandas as pd, then use the following example to import the excel file:

excelName = 'Gain_7_HPK_FBK_vs_fluence_modified.xlsx'
sheetName = 'HGTD_Type 3.1 n+p'
myData=pd.read_excel(excelName, sheetName)
dataFrame=pd.DataFrame(data=myData)

Now you should be able to access coulmns by using dataFrame like so:

 column=dataFrame('Row #')
 print(column[4]) #Will dispaly the number 417.9
 print(column) #Will display the whole column with row numbers

When you print column it will show the row number on the left and the value on the right. To get the number of rows in a column you can use len:

len(column)

In each sheet of the excel file is a new set of data. Please do your work on the HGTD 3.1 n+p but if you choose to analyize a different sheet that if fine.

The first parameter we would like to extract will be gain and the Signal to Noise ratio snr as a function of bias voltage, V. On the HGTD Type 3.1 page there is a column, H, with a yellow background labeled Bias Voltage. Extract these values for the detector:

HPK-SMPL-1-W9 SET-P1 LG1 SE5 #9 Readout-NB1 -30C  SET-P1 LG1 SE5 #9 20C

We also want to extract the values in the column, SNR (corrected), and Gain_ (along with Bias Voltage (V)). Once you have all of these values, plot them on two seperate scatter plots using matplotlib pyplot, with Bias Voltage (V) on the x-axis and SNR (corrected),Gain_ on the y-axis.

You can use the panda function isNull and iloc to select a row. Here is a link to the pandas user guide: LINK

Some other helpful python tools you might appricaite are, range:

range(10) #output an array with numbers from 0 to 9 like [0,1,2,3,4,5,6,7,8,9]
range(1,11) #outputs an array with numbers from 1 to 10 like [1,2,3,4,5,6,7,8,9,10]

If you have an array, myArray=['a','cat','dog'] and want to append you can use myArray.append("master"). Now print(myArray) would output ['a','cat','dog','master'].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment