Skip to content

Commit 827749b

Browse files
committed
fix Jacob comments
1 parent fdd3862 commit 827749b

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

content/data_work/io.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"cell_type": "markdown",
1717
"metadata": {},
1818
"source": [
19-
"In your chemistry studies, you will inevitably gather data. Should you want to interrogate that data using Python, you need a means to parse that data. Perhaps you collected some data from a pratical lab, and have copied into Excel, and would now like to analyse it in a Jupyter notebook. Or perhaps you are using a computer program to run simulations, and need to load the data in to a notebook to check your results. In this section, we'll going in to the basics of dealing with data files."
19+
"While studying chemistry, we will inevitably gather data. If we want to interrogate that data using Python, we need a means to parse that data. Perhaps you have collected some data from a pratcical lab, and have copied said data into Excel, and would now like to analyse it in a Jupyter notebook. Or perhaps you are using a computer program to run simulations, and need to load the data into a notebook to check your results. In this section, we'll going into the basics of dealing with data files."
2020
]
2121
},
2222
{
@@ -25,7 +25,7 @@
2525
"source": [
2626
"## Parsing text files\n",
2727
"\n",
28-
"For our first example: imagine we have run a program to compute the relative energies of three conformers of the same molecule. This is stored in the file \"computational_output.txt\". We want to read in the results as python variables, to determine our ground state, and do any subsequent analysis we might like. We open files using the open function, starting with an example of **what not to do**."
28+
"For our first example: imagine we have run a program to compute the relative energies of three conformers of the same molecule. This is stored in the file \"computational_output.txt\". We want to read in the results as python variables to determine our ground state, and do any subsequent analysis we might require. We open files using the open function, starting with an example of **what not to do**."
2929
]
3030
},
3131
{
@@ -70,7 +70,7 @@
7070
"cell_type": "markdown",
7171
"metadata": {},
7272
"source": [
73-
"The above clearly works for printing the file, so why is it bad practice? It's easy to forget to `close` the file at the end. Much like having too many applications running at once on your computer, too many opened files in python is going to drain your computers resources. Not so bad for a 7 line text file, but the outputs of popular computational analysis packages can eaisly be as large as a few gigabytes. We ensure the file is always closed by wrapping our file processing in a `with` statement. The `with` statement will automatically close the file when the code within it has finished running. To achieve the exact same as above, but emplying best practice, we can instead write"
73+
"The above clearly works for printing the file, so why is it bad practice? It's easy to forget to `close` the file at the end. Much like having too many applications running at once on your computer, too many opened files in python is going to drain your computers resources. Not so bad for a 7 line text file, but the outputs of popular computational analysis packages can easily be as large as a few gigabytes. We ensure the file is always closed by wrapping our file processing in a `with` statement. The `with` statement will automatically close the file when the code within it has finished running. To achieve the exact same as above, but employing best practice, we can instead write"
7474
]
7575
},
7676
{
@@ -182,7 +182,7 @@
182182
"\n",
183183
"## Excercise\n",
184184
"\n",
185-
"copy the code above to retrive the energies from the data file, but rather than storing the energies as a list, store them in a dictonary with the format `{conformer_1_energy: ..., conformer_2_energy: ..., conformer_3_energy: ...}`. Do this in a way that ensures if we change the number of conformers, the code will still store all the energies in a dictionary.\n",
185+
"Copy the code above to retrieve the energies from the data file, but rather than storing the energies as a list, store them in a dictonary with the format `{'conformer_1_energy': ..., 'conformer_2_energy': ..., 'conformer_3_energy': ...}`. Do this in a way that ensures if we change the number of conformers, the code will still store all the energies in a dictionary.\n",
186186
"\n"
187187
]
188188
},
@@ -206,7 +206,7 @@
206206
},
207207
{
208208
"cell_type": "code",
209-
"execution_count": 24,
209+
"execution_count": 1,
210210
"metadata": {},
211211
"outputs": [
212212
{
@@ -322,7 +322,7 @@
322322
"source": [
323323
"import numpy as np\n",
324324
"\n",
325-
"# first argument is the filename, the second is the 'delimeter'\n",
325+
"# first argument is the filename, the second is the 'delimiter'\n",
326326
"# i.e. what seperates the values, in our case, ',', we need to \n",
327327
"# also add skiprows = 1 as the first line of the file is strings\n",
328328
"# that cannot be converted to floats\n",
@@ -336,7 +336,7 @@
336336
"cell_type": "markdown",
337337
"metadata": {},
338338
"source": [
339-
"`benzene_data` now contains the content of the file `benzene_data.csv`, that is to say the density of a benzene sample in $\\mathrm{mol~m}^{-3}$ as a function of temperature in $\\mathrm{K}$. It is a array of arrays. Each sub array contains two values, a temperature and a density. The csv file has been read 'row-wise'. If we wanted to read it 'column-wise' (which we often do), and return an array of two sub-arrays: all temperatures, and all densities, we add one argument to out `loadtxt()` call, "
339+
"`benzene_data` now contains the content of the file `benzene_data.csv`, that is to say the density of a benzene sample in $\\mathrm{mol~m}^{-3}$ as a function of temperature in $\\mathrm{K}$. It is an array of arrays. Each sub array contains two values, a temperature and a density. The csv file has been read 'row-wise'. If we wanted to read it 'column-wise' (which we often do), and return an array of two sub-arrays: all temperatures, and all densities, we add one argument to out `loadtxt()` call, "
340340
]
341341
},
342342
{
@@ -393,7 +393,7 @@
393393
"cell_type": "markdown",
394394
"metadata": {},
395395
"source": [
396-
"We can then do whatever we like with these arrays, such as plot against eachother."
396+
"We can then do whatever we like with these arrays, such as plot against each other."
397397
]
398398
},
399399
{
@@ -431,7 +431,7 @@
431431
"\n",
432432
"## Excercise\n",
433433
"\n",
434-
"read in the benzene_data.csv file, and convert the temeperature array from Kelvin to Celcius, then, using the [`np.savetext`](https://numpy.org/doc/stable/reference/generated/numpy.savetxt.html) fucntion, write that information back to a `.csv` file. If you can't understand how to do this from the numpy documentation, re-read the chapter on reading and understanding python documentation to get help.\n",
434+
"Read in the benzene_data.csv file, and convert the temperature array from Kelvin to Celcius, then, using the [`np.savetext`](https://numpy.org/doc/stable/reference/generated/numpy.savetxt.html) fucntion, write that information back to a `.csv` file. If you can't understand how to do this from the numpy documentation, re-read the chapter on reading and understanding python documentation to get help.\n",
435435
"\n"
436436
]
437437
},

0 commit comments

Comments
 (0)