Service Project

No sleeping in this Saturday. This Saturday is Longview Blitz. Longview Blitz is a once a year service day where their entire campus goes out and expresses our love for the surrounding community of Longview Texas. About 55 people came from our dorm to clean and restore a park. I repainted a number of surfaces at the park and helped clean up any accidental paint spills. Jovita made sure I had something to remember the day. A number of the other painters also received a painted heart. The less willing individuals received red paint smears. 

Astronomy and the Venus transit

Wanted to share some photos of the work I have been doing this summer. I got a job as an astronomy lab assistant. Most of my job involves grading about 23 lab notebooks, but sometimes I get to do observing. We did a lot of solar observing, some lunar observing and one evening of dark sky observing. It's always exciting to do work that is really enjoyable.

regex in python

I ran across this neat little regex trick the other day. My goal was to match three kinds of lines with one regex and extract all of the data from line. The lines are formatted as follows:

4 STRETCH   4  1                     2.0586112       1.0893702
5 BEND      4  1  2                  1.9052943     109.1653223
6 TORSION   4  1  2  3               3.1415927     180.0000000

The first column is coordinate number (positive integer). The second column is a coordinate type (string). The third column through the sixth columns are atom numbers (positive integers). The seventh is a coordinate value in either bohrs or radians (floating point). The eighth column is a coordinate value in either angstroms or degrees (floating point).

"(\d+) +([A-Z]+) +(\d+) +(\d+) +(\d+)? +(\d+)? +(-?\d+\.\d+) +(-?\d+\.\d+)"

This regex has three distinct parts:

 

  1. \d+ represents any positive integer
  2. [A-Z]+ represents any string of all capital letters
  3. -?\d+\.\d+ represents any floating point number
regex_groups = re.search(LONG_REGEX,line.strip())
if regex_groups:
	regex_groups = list(regex_groups.groups())
	if regex_groups[5]:
		# This is a torsion line
	elif regex_groups[4]:
		# This is a bend line
	elif regex_groups[3]:
		# This is a stretch line
	else:
		# This is some other line
	

The fifth and sixth columns are made optional in the regex with the ? character. The result was the ability to recognize and parse the contents of three similar, but distinct types of lines. I was also able to setup syntax highlighting for the blog.

I ran across this neat little regex trick the other day. My goal was to match three kinds of lines with one regex and extract all of the data from line. The lines are formatted as follows:

4 STRETCH   4  1                     2.0586112       1.0893702
5 BEND      4  1  2                  1.9052943     109.1653223
6 TORSION   4  1  2  3               3.1415927     180.0000000

The first column is coordinate number (positive integer). The second column is a coordinate type (string). The third column through the sixth columns are atom numbers (positive integers). The seventh is a coordinate value in either bohrs or radians (floating point). The eighth column is a coordinate value in either angstroms or degrees (floating point).

"(\d+) +([A-Z]+) +(\d+) +(\d+) +(\d+)? +(\d+)? +(-?\d+\.\d+) +(-?\d+\.\d+)"

This regex has three distinct parts:

 

  1. \d+ represents any positive integer
  2. [A-Z]+ represents any string of all capital letters
  3. -?\d+\.\d+ represents any floating point number
regex_groups = re.search(LONG_REGEX,line.strip())
if regex_groups:
	regex_groups = list(regex_groups.groups())
	if regex_groups[5]:
		# This is a torsion line
	elif regex_groups[4]:
		# This is a bend line
	elif regex_groups[3]:
		# This is a stretch line
	else:
		# This is some other line
	

The fifth and sixth columns are made optional in the regex with the ? character. The result was the ability to recognize and parse the contents of three similar, but distinct types of lines. I was also able to setup syntax highlighting for the blog.

Research

Every time I tell someone, "I am working as a full time research assistant this summer" I get blank stares or awkward grins. I thought I should explain what I do for research. Molecules have energy. I am studying some exotic molecules using computers to calculate energies. I want to find what makes a molecules energy a minimum and what makes a maximum.

A majority of the work I do is preparing input files for the computer to perform calculations on. Once the computer completes the calculations(sometimes this takes over two hours) I exam the output to make sure that everything looks reasonable. Repeat this process several hundred times and I will hopefully have enough data for my professor to finish his paper.

While I am waiting for the computer to finish its calculations I am writing a python script to automate my job. The script will eventually save me 2 to 5 minutes for each file I make. It will also automatically submit files to the computer around the clock. 

This job has been incredibly enjoyable. It is the perfect blend of Chemistry and Computer Science. It is just the right fit for me. So instead of giving me a blank stare or awkward grin you can now say with a broad smile, "I am glad you enjoy being a nerd and doing cool nerdy things!"

Best before solution

I listen to music on spotify. Turns out spotify has coding puzzles on their website. While I was busy installing windows on a friend's computer I decided to try one of the puzzles. The puzzle is called best before. You can find the puzzle description here. You can find my solution in python here