Tuesday, September 20, 2011

Wireless on Latitude D820

The wireless hasn't worked for awhile on this. Didn't know why, but when I investigated today, I looked at /etc/sysconfig/hwconf and modprobe.conf and found that the non-existent driver iwl3945 was associated with eth1. Not sure how that happened, but the result was that ifup-ifcfg-eth1 would tell me to connect a cable to the device -- I guess it assumed the tg3 or some wired driver as a substitute. I did the following and rebooted, which seemed to work:

modprobe -r ipw3945
modprobe ipw3945

And I may have not needed to do this, but in modeprobe.conf, I manually changed iwl3945 to ipw3945. The Wireless card comes and goes in hwconf, so I'm not sure that changing that file does much. Anyways, after doing these things and rebooting, (oh, and double checking that ifcfg-eth1 is assigned to eth1 and that the GUI Network interface also shows eth1 being tied to the same driver and hardware), it worked again.

Wednesday, April 6, 2011

Convert PNG to PDF

I forgot that PDF is supported in CONVERT.

convert file.png file.pdf

Wednesday, March 10, 2010

Reading Binary Files

To handle DNA data coming out of old and new generation sequencing machines, I needed to learn how to read the binary SCF files that are typically output by the software these machines use. To do so, I needed to know the byte format of these files, and I had to translate from C definitions of the data types to IDL data types.

The byte format page describes in detail how the bytes are ordered. There's a header, some comments, base calls, and traces. The base calls include probabilities and a cross-reference to the trace position where the base was called. The traces themselves are stored as consecutive differences as opposed to absolute values, so translating the SCF traces to something you're used to is non-trivial.

The biggest trick in this was figuring out how to use IDL's READU function, the OPENU function, the latter with the SWAP_ENDIAN keyword set. The byte-ordering (at least on the 3.00 version SCF files I used) is different from what IDL expects. Also note that READU shifts the file pointer according to the data type of the variable you'll be reading in, something I found out the hard way and later read in the documentation.

I found the POINT_LUN,unit,pos function was most useful for shifting and tracking the file pointer. Defining a variable = -1 * unit (i.e. the negative of the logical unit) makes POINT_LUN return the current position.

Thursday, March 4, 2010

Making GIF animations

I've done this enough times, but I still don't remember.

convert -delay 50 -loop 0 age*gif noscale.gif

Thursday, February 11, 2010

IRAF tasks

I had to add the XIDL tasks for Gemini data. At some point, you need to add the x_gmos packages.
1) mkiraf in a new directory (so you have a fresh set of parameter files)
2) To login.cl add: "set x_gmos = ""
3) Near the end, define the package:
task $x_gmos.pkg ".x_gmos.cl"
(the $ sign is necessary and signifies that there is no parameter file)
4) Now it should work to call it as "x_gmos".

Monday, December 28, 2009

iptables for ssh and gmote

Run these commands to open up incoming SSH and Gmote through iptables. Be sure to open the appropriate port/ip combination in the router.

SSH:
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT

Gmote (port 8889):
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8889 -j ACCEPT

I think it works to run simultaneously, but I haven't tested it yet.

Copying Tapes to DVD

Use the CyberLink PowerDirector v5 (not Producer!) supplied with the KWorld PCI Card. Plug the red/black audio feeds from the card into the audio out (L and R, doesn't really matter which, just be consistent) on the VCR. The yellow video out should be plugged into the yellow video out of the VCR.

Make sure the CyberLink PowerDirector is installed. Then open it on your computer. As a test run, plug in the USB end of the KWorld card into your computer, and the audio end into the microphone jack (Windows *should* automatically detect both). Click on 'capture' and then click the hammer/nail picture below the main box on the left hand side of the screen (it's a configuration menu). Make sure the video is coming in through USB and audio is coming in through "Line-in". Finally, check in control panel --> sound settings --> microphone that the "Line-in" is not muted, and that the sound is not turned down too far.

Now do a test run: Push play on the VCR. On the right side of hte screen, you should see your video playing, but you probably won't hear any sound -- don't panic. Press the record button on the left side of the screen to make a test recording for like 30 seconds. Press "stop" (you should be prompted to name the video clip you've just made), then also stop the VCR. Click on the new clip on the right side of the screen. It should open up a viewer screen where you just push 'play', after which the video should play and you should hear sound.

If you don't hear sound, be sure you're listening in the right place! Is the sound configured to go to the headphones or to the speakers? You can probably configure this somewhere in CyberDirector, but on my laptop, it went to the headphones by default (it only does this in CyberDirector?), so to listen to the video, I needed to plug in headphones. If the sound is OK, then you're good. If not, discard this video and try adjusting the Line-In volume and the volume on the video. Then repeat the test.

Once you're happy, select the 'quality' of the recording (DVD-HD, SP, LP, SLP; better quality means more disk space. You want to be sure the quality of the recording will not use too much of the laptop disk, and will *also* fit on the DVD you're going to copy to. There are some meters in the capture screen that give you estimates of the space consumed by the video, and that should be enough to calculate the approximate final size of the video. There's probably not much point in ever being higher than SP if you're recording from VCR tapes, but you can view the quality for yourself.

When all of that is set, make your recording. It will take as long as it takes the VCR to play the tape at normal speed. When done, press stop, and be sure the clip is saved. Then click 'Edit', which will take you to an interface for editting what you have recorded. Here, you can try various tools in the CyberDirector to clean up the video and audio (the audio clean-up of white noise seems to work pretty well for crappy old tapes). You can also carve up the video into chapters, edit the length, etc. The best thing to is to experiment, and to be sure you don't permanently screw up the ~2hr video you just made.

Next, you can prepare to copy to a DVD...

Thursday, December 10, 2009

Backing up CDs in Linux

1) Sound Juicer to copy as OGGs.
2) Sound converter to convert OGGs to mp3.

Here's a link to the latter, as it's an install option.

Tuesday, October 13, 2009

Line-by-line Sorting of a list in bash

Take "collab.lis" as the file with the list to sort, and route it to a file called "junk.lis"

less collab.lis | tr "" "\n" | sort > junk.lis

Simple as that.

Monday, May 25, 2009

CCfits

CCfits is a wrapper for the cfitsio C routines that are useful for manipulating fits images. I would like to see how useful C++ might be for astro applications, and maybe eventually adopt Python for prototyping code and C++ for writing fast, efficient code.

To install cfitsio and CCfits, I just followed the documentation with the normal configure/make/install steps. The only minor hitch was getting the CCfits ./configure script to point at the right cfitsio library locations.

I had to dust off my C++ books and remember a few things to actually get the gcc/g++ compiler up and running. For gcc/g++, I spent most of my time remembering the header/library system of doing things. Not sure my terminology is kosher here, but you need to point the compiler to the right "include" path (containing function declarations) correctly link to the library (containing the actual definitions). I ended up using something like:

g++ -I/usr/local/include/CCfits -lCCfits cookbook.cpp

to successfully compile and run the CCfits test routine. Without the include path, all kinds of errors involving the std:: namespace were returned, and with the "-lCCfits", the CCfits:: were compiled with numerous errors.

Finally, if you try to run the executable without setting the "LD_LIBRARY_PATH" environmental variable to the location of the shared library, it complains about not finding "lCCfits.so.0" during runtime.

Sunday, June 1, 2008

Use Wget through a proxy

This worked really well:
http://blog.taragana.com/index.php/archive/how-to-use-wget-through-proxy/

Since I'm in tcsh, I just used
setenv http_proxy ......

I'll make sure when I get home that it doesn't screw things up when not using the proxy, in which case we have to remember to comment things out.

Monday, May 26, 2008

apply pixel mask

This is going to be an on-going post about making this piece of code run, . I'm just going to add to it bit-by-bit until I have something complete. Usually the first thing to check is:

setenv LD_LIBRARY_PATH /usr/local/lib/

in your .cshrc. There are other steps required, but on my current libraries, installed on a new machine, this is the thing I forget to add most often. /usr/local/lib is where I usually keep all the needed C/C++ libraries, but it certainly change if you move to other machines.

Sunday, January 27, 2008

IDL color tables

It often happens that when I go to a new computer and run IDL, the color tables don't work. The simplest fix to try is usually the following:

IDL> device,decomposed=0

Then loading the color table is as simple as:

IDL> loadct,1 ;; or no number will list the available color tables

Wednesday, September 26, 2007

Running after Logout

I've had different levels of success with this. If you just place a command in the background with bg, it will still die after logout. Sometimes 'nohup' works, but I'm not sure when or why. It probably has something to do with display type or somthing.

The reason I'm so interested in this is that I often issue 'wget' commands from my laptop that transfer large amounts of data between two remote computers. This was where I got most of my help.

I used "screen", but I didn't do everything smoothly, which probably isn't smart. Screen opened up a different looking terminal in the shell, from which I issued the command. I couldn't get out of the window, so I just clicked "close" on my laptop. After logging back in, I saw that the command continued to run. I'm sure there's a more graceful way to do this, using some screen commands, etc.

Saturday, September 1, 2007

Mplayer/Mencoder

I like movies and music a lot. Mplayer is my tool of choice here. It's open source, supports many video formats, and has an endless array of options for playback. It's pretty easy to install too. I don't remember if it was automatic the last time I did it, or if I had to resolve dependencies, etc. That's one reason why I started this blog, so I don't HAVE to remember.

Oh yeah, I used yum to get mplayer and mencoder. I think it went to the freshpms repository:
yum -install mplayer
I had to do mplayer and mencoder separately. I don't know if they are supposed to come bundled together, but they didn't this time.

Anyways, I'm using 'mencoder' to copy DVD with video in VOB format, whatever the hell that is. I started here and branched out. I have 4 files of about 1.08 GB each. I ran the following:

mencoder -oac pcm -ovc x264 VTS_01_1.VOB -o VTS_01_1.mpg
-o: output file name
-ovc: output video
-oac: output audio
I think it identifies the output time by the extension you give it.

Friday, August 3, 2007

Favorite Emacs Shortcuts

Note that many of these commands depend on your terminal type. Here's a nice Emacs link, and here is some stuff explaining shortcut keys. These the ones I always forget (and the list keeps growing)

Replace: shift-alt-% Prompts user for string to replace, and replacement string, queries user to verify each instance.
Replace (non-interactively): M-x replace string RET remove string RET replace string RET This replaces all instances with no prompting. Good for replacing commas with spaces. For me "M-x" is usually just "Alt-x".

Monday, July 16, 2007

SciPy

It turns out there are a lot of resources out there for scientific computing with Python. I'm exploring rewriting various bits of code I use in Python, particularly those that call Perl and Shell Scripts and are not self-contained. I like that Python is freely available, unlike IDL, and easy to program and use regularly, unlike IRAF. In fact, I think this is the motivation behind PyRAF.

SciPy is located here. I haven't explored the library much, but I bet it will be useful. The other important package, Numpy, is also here, but I acquired it from the STSci Institute. From STSci, I also got a key set of libraries called PyFITS, which allows FITS table and image handling. As of this writing, those couple of libraries were no larger than a few MB.

It looks like SciPy is a bit involved. It requires LAPACK libraries, which require the g77 FORTRAN compiler or something similar. I need to read up on this a bit more before I proceed. SciPy won't be as easy to install as I had hoped.

UPDATE:
I got lucky and found that binaries for FC6 have been created and are posted here, after you follow some links to this . Many thanks to this guy. He rightly advises not building LAPACK youself if you don't have to. I think you can set this up as a yum repo, but I just downloaded, rpm'ed:
1) rpm -ivh cushello
2) rpm -ivh refblas*.rpm
3) rpm -ivh lapack-*.rpm
4) rpm -ivh lapack3-*.rpm --replacefiles
5) rpm -ivh python-numpy
6) rpm -ivh python-scipy

Step 4 is a bit risky, but I forged ahead and have noticed no ill effects yet. If you don't RPM with this option, conflicts arise. I chose to brute force past the problem.

Reading NTFS on a USB hard disk (Part I)

This was done on Keren's LG computer, running FC2, with some 2.6 kernel. The USB disk is a Maxtor 320 GB. I'll add the model number later. The goal was to be able to read/write on the disk. Only the read part worked. Writing will come in part 2:
1) Enable NTFS reading, which required me to go here.
a) Check the docs here to be sure NTFS is enabled in your kernel.
b) Get the RPM for the kernel you're using and install it (rpm -ivh *.rpm).
2) Plug in the USB drive, check /var/log/messages to see which /dev or /udev
it was assigned to.
3) Simply run "mount -t ntfs /udev/sda1 /mnt/usbdisk/"
a) /udev/sda1 was returned by /var/log/messages
b) I made the directory /mnt/usbdisk

This was all quite easy. It doesn't mount automatically when plugged in, so you need to run step 3 each time. In the future, I'll enable automounting, if it's possible.
No matter which mask options or r/w permissions I tried, I could not write to the disk. It looks like this may be a general problem. The two options are to format the full disk FAT32, as some have suggested that this works, or to partition the disk into ext3 and NTFS/FAT32. The latter is probably the way to go, but I need to consult with my wife, since it's her disk. I will conclude this tiny little project in forthcoming post.

For future reference, here's the man page for mount.

Alternatively, if you have an external USB disk, most if not all linux distros recognize fat32 right off the bat, and both linux and windows can read and write to fat32. This is key for Fedora Core 2, which is what my wife is using. I'm finding that I can't get FC2 to write to NTFS.
1) Format the disk as FAT32, and in linux
2) 'less /var/log/messages' and look for something like /udev/sda1 or /udev/sdb1
3) mount the volume with "mount -t vfat -o umask=000 /udev/sdb1 /mnt/usbdisk/"

I think she was able to read and write fine with this. One problem we ran into was filenaming: it doesn't know the difference between AAA and aaa. We tried using the shortname option, but it is probably a limitation of vfat, that caps and smalls are indistinguishable. Bummer, but that's tradeoff for being able to read and write from both linux and windows with fat32.

Saturday, July 7, 2007

IRAF/PyRAF

IRAF is a free, widely-used image analysis tool. Installation went off without hitch (at least so far), following their instructions. I would love to rewrite them to be a little more transparent, at least to me. You could almost write a wrapper to install everything, except for maybe the creation of the IRAF user. It would be great if they could do away with that step, and I'm actually not sure why it's needed.

PyRAF was a different story this time around. I've installed it before with success, but this time has been more troublesome. There was a recent update (15 Jun 2007), which may be why things are things are different. I'm using their source dist'ns everywhere (instructions) I hit a problem when running the config step for tcl/tk, in which I get an error at line 6208. I'm not sure what the problem is here. Is it FC6? Or maybe I don't have all the right paths defined? I've tried dumb things like commenting this text out, but it doesn't fix the problem. I also tried using rpms and yum repositories for later versions of tcl/tk, but I think I really need to compile from source. I'm dropping this for now, and I'll come back to it when I have more patience.

Friday, July 6, 2007

SciSoft

While I'm busy installing stuff on this new laptop, my officemate pointed out a very cool astronomical mega-package: SciSoft with a huge list of free astronomical tools, some great, some pretty good. I'm trying the yum version. The repository is quite big, so make sure you have enough space in /var, or whereever your local repository lives. There are also rpm and tarball options. The yum and rpm versions are setup for FC6, while the tarball can be compiled for whatever.