Wednesday, July 13, 2011

Command Line Program II

More command line coding!

Today I learned about this function called getopt(), which will hopefully allow me to enter arguments (optional arguments) that will specify things such as the spacing between an annulus and aperture, the size of a cropped image, etc.

I've received another challenge: To make my program accept an arbitrary number of fits files in the command line window. Basically, we're hoping the input will look something like this:

C:\[your directory to saved InteractivePhot file]> InteractivePhot file1.fits file2.fits -d 0.95 -w 40 -h 40 -s 0

-d = darkpix percentage
-w = width of sub image (xsz variable in my python code)
-h = height of sub image (ysz variable)
-s = annulus spacing, or the space between the aperture and innermost annulus radius (ann_space variable)

If these are not specified, the program will run them with default values and create graphs of all the fits files entered preceding these arguments.

I haven't quite completely finished coding yet, so I won't be putting an example here today; however, I hope to get it done by tomorrow and have something more interesting to blog about. =]

I also learned about this neat thing called regular expressions. Not the Perl kind, but the Python kind. Basically regular expressions is a pretty powerful tool used to search for strings. You can set all sorts of restrictions to make sure that you are searching for the string that you want. I'm hoping to use regular expressions to create a list of all the .fits files the user has entered in command line so that I can make those graphs one by one.

-Regular expressions
-How to use getopt(...)
-Finish program

No comments:

Post a Comment