Tuesday, November 19, 2013

drafting with CAD and DraftSight

For my research, I needed to learn how to make CAD drawings as a step towards making some micro-devices. The procedure for making the devices involves ordering a transparency with high-precision, high-detail designs on it. Mine came from http://www.outputcity.com/. This "mask" is used in a photo-polymerization step to make micro-devices with the right ins and outs.

In any case... I needed to learn CAD. Luckily, my friend Don gave me the 1-hour lesson. Here is what I learned:

CAD is a very methodical, logical way way to make precise drawings. BUT, it's entirely different than any other computer drawing software I used. I had to learn the new paradigm. Once I realized how different it is, I learned quickly. Here are my notes.

commands and tips (type, then hit enter or space):
Type commands, and they will appear after the : at the bottom panel of DraftSight. Hit enter or space to run the command.
pan - to grab the workspace and move it around
*or move around drawing by zooming in and out with mouse wheel
trim - to cut off excess bits of lines
copy - to copy features
move - to move features
array - to create a grid replicating a single unit already drawn
offset - to replicate a feature some distance away
fillet - extends to lines to a point where they meet
mirror - create a mirror image of an existing feature (keep or remove original)
rotate  - rotate a feature
zoom - followed by e zooms out to show the full extent of the drawing
can set up reference lines to use to guide real lines, then trim references
right and left drag boxes are different-- to the left selects any object that partially sticks into the area selected. dragging to the right only selects objects entirely within the selected region.
use esc to deselect what you have selected

details for my application:
can't print features less than 7 microns
nothing smaller than 50 to 75 microns is cheaper
wide and flat features are easy, features with a 1x1 aspect ratio are good
the printers are 10,000 dpi and 25,400 dpi, and you want to have 7 dots per feature
in the proof, check for polarity (dark vs. clear) and check for missing features
the edge of the drawing will be clear, crossing the first line coming in from an edge brings you into a dark region
dimensions are in microns
20 micron text is OK, height = 800 is readable by eye
around height = 100 is good for my 90x magnified microscope with 120 micron x 100 micron field of view
save as 2007-2009 .dwg, send a dxf to the printer

Thursday, September 12, 2013

PyQt, building my first GUI

The lab I'm in wrote and maintains a software package for analyzing microscope images generated with a laser microscope. The software is all command line and would really benefit from guis in a couple key spots. Towards this end, I'm writing my first gui! I decided to work in PyQt, and there's a lot to learn! Most of all, I need to get familiar with the modules available and their options (best reference I've found so far: http://pyqt.sourceforge.net/Docs/PyQt4/classes.html):

So far, I've played with:

QtGui.QLabel
QtGui.QSlider
QtGui.QLCDNumber
QtGui.QFrame

Here is how I'm using them:

I'm using QLabel just to display some text in my window:
# number of pixels are measured from top left corner
red = QtGui.QLabel(self)
red.setGeometry(10,10,100,30) # pixels over, pixels down, pixels wide, pixels tall
red.setText('Red')

Note, it seems oddly hard to change the color of the text, fontsize, etc. It is strange that it is not a clear option, but at least, I can get plain, black text displayed!

I'm using sliders as a way for the user to change the input, QtGui.QSlider:
sld = QtGui.QSlider(QtCore.Qt.Horizontal, self) # slider horizontal rather than default vertical
sld.setGeometry(60,40,100,30) # pixels over, pixels down, pixels wide, pixels tall
sld.setMinimum(0) # redefine what numbers the endpoints of the slider stand for
sld.setMaximum(255)
#EVENT HANDLERS
sld.valueChanged.connect(lcd.display) #connects the value of the sld to the lcd display

The lcd-style number display had to be defined before the slider was connectd to it:
lcd = QtGui.QLCDNumber(self)
lcd.setGeometry(60, 80,100,30)

I used QtGui.QFrame to display a solid purple square in the window:
square = QtGui.QFrame(self)
square.setGeometry(100, 100, 30, 30)   
square.setStyleSheet("QWidget { background-color: %s }" %  
         QtGui.QColor(100, 0, 100).name() ) 

Note, using the style sheet, I was able to change the color via the QColor module!

Thursday, August 29, 2013

Network File Access 2

Ok, so I left off yesterday satisfied with branching from bazaar repositories on the network, but not with file mounting. I'll figure it out!

mkdir <local directory>
sudo mount -t nfs <network>:/<share name> <local directory>

Great! But when I try to cd into the <local directory>, I get permission denied. Apparently this is an id problem.

Running id at the command line gives me a uid and a gid. These need to be the same as my uid and gid on my network account. I also need to make my own computer be a member of the lab group.

To check id's locally or after ssh'ing into the network:
id
getent passwd <username>

I logged in as root and changed the id's following instructions from l0b0 and Esteis:
http://askubuntu.com/questions/16700/how-can-i-change-my-own-user-id

Alternatively, you can edit the documents directly:
cd /etc
sudo gedit group
sudo gedit passwd

Important!
To unmount drives:
umount <path to drive>

Don't delete the directory.... that really deletes it from the network.



Wednesday, August 28, 2013

Network File Access

One of the most frustrating things about my existence as a graduate student is figuring out how to access files that are on the schools network. My desktop was helpfully set up by trusty Tom. BUT, I want to be able to use my new laptop to smoothly deal with network files. So, here is how the setup goes:

1) I set up an ssh key pair and places the public half on in my home directory on the network
I know this worked because I can: ssh rperry@login.<network name>
ssh -v rperry@login.<network name> shows you more verbose information about the completed process of logging into the ssh session
The ssh key is important for almost all ways of accessing the network.

2) bzr with network files. There is a paper written in latex that is on the group share in a bazaar repository that I would like the edit. I thought bzr+ssh would work, but it did not since the server doesn't have bazaar installed. Instead, I can use sftp:
after cd'ing to the directory where I wanted to put the branch:

bzr branch sftp://<username>@login.<network name>/group/<rest of path to directory>

Ok, so now I want to make this tied back to the main repository so that I can make changes and check them in:

Workflow:
In my lab, we use a "decentralized with shared mainline" workflow:
bzr pull
...[make changes]...
bzr commit -m "commit message here"(commits to local branch)
bzr push :parent --remember (pushes to main branch, can just use bzr push in the future)
...[if there are conflicts it will tell you]...
bzr merge (or if you are the sole owner and are confident that you want your version, bzr push --overwrite)

This main repository shouldn't have a working tree associated with it, but it does and it tells me that it will not be updated since I am pushing remotely. If you want to update it and work from there (not suggested), then you can update the working tree by doing something like this:
ssh rperry@login.<network name>
cd <repository>
bzr update

In practice, you should just branch from the main repository rather than accessing the main repository to see the files.

Yay!!!!! I can work on tex files from the lab network share from anywhere!

3) When on campus, it would be really nice just to have the whole network folder mounted. For this, I'm going to figure out how to do NFS or CIFS... but that's for the next post.





Monday, August 26, 2013

Zenbook Surgery

I bought an ASUS Zenbook UX32VD! My toughest criteria in picking an ultrabook was that I need an NVIDIA graphics card for parallel computing. I think it's awesome that I have this parallel computing power in a light little ultrabook! Here are the specs as it arrived, but I quickly did some surgery to upgrade it!
Screen Size13.3 inches
Screen Resolution1366 x 768
Max Screen Resolution1920x1080 pixels
Processor1.9 GHz Core i7-3517U
RAM4 GB DDR3
Memory Speed 1600 MHz
Hard Drive500 GB
Graphics CoprocessorNVIDIA_GeForce_GT_620M
Chipset BrandIntel, NVIDIA
Wireless Type802.11bgn
Number of USB 3.0 Ports 3
Brand NameAsus
SeriesUX32VD
Item model numberUX32VD-DH71
Hardware PlatformPC
Operating SystemWindows 8
Item Weight3.2 pounds
Item Dimensions L x W x H12.80 x 8.78 x 0.71 inches
Color Silver Aluminum
Processor BrandIntel
Processor Count2
Computer Memory TypeDDR3 SDRAM
Flash Memory Size24
Hard Drive InterfaceSerial ATA
Hard Drive Rotational Speed5400 RPM
Optical Drive TypeNo
Audio-out Ports (#)1
Battery TypeLithium Polymer (LiPo)
Batteries:1 Lithium ion batteries required. (included)

I had  never opened up a laptop before, but I wanted to upgrade the HD to completely SSD and replace one of the 2GB RAM sticks with an 8GB stick for a total of 10GB of RAM. (good instructions here: http://youtu.be/8xC-osS0scU) I installed Ubuntu 13.04 on this new hard drive and had no trouble booting!

Checked the ram with this terminal command:
free -m
and I have 9.999 GB. It's recognizing the new RAM!

When it was installing it asked if I wanted to use the 250.1 GB drive. So, it's recognizing that too!

Saturday, June 22, 2013

Software Carpentry

I'm taking a Software Carpentry bootcamp on Monday and Tuesday. It is a two-day workshop to make you a more productive programming. I'm most comfortable programming in Ubuntu (what we use in lab), so I'm borrowing my friend's laptop for the course (until I get my own dedicated Ubuntu programming machine). I need to install required software for the course. I'll be installing this on my machine once I get it, so I'm keeping a record of how to do the installations here:

6 required packages:
1) Bash. This is the default shell in linux! Win #1 for using linux! No intallation needed here.
2) Git. I checked the version with "git --version" and got "git version 1.8.1.2" Latest stable release is 1.8.3.1. I'll run "sudo apt-get upgrade" just to make sure there isn't a newer version in the Ubuntu package manater.
3) Code editor. I've been looking for a better code editor. The course staff recommends Kate. I'll download that and give it a try. "sudo apt-get install kate." I also want gedit... my old stand-by, just in case. It was already installed! There is a warning when I start it, but other people in web forum say just to ignore.
4) Python version 2.7. They recommend Anaconda for an all-in-one installation. I have used enthought before. I have Python 2.7.4 ("python --version"). But, I don't have ipython. I'll try installing Anaconda and see if that gets me all the way. Download took about 20 minutes, but the installation is running well after accepting a user agreement.
5) SQL. Install SQLite manager (requires firefox). This is just a firefox add on. Needed to make the bookmarks toolbar visible before I could see the SQLite icon.
6) Lastly, virtual box and a virtual machine in case the rest didn't work.

The test script passed! Success!

The only other things I know I want are LaTex and Mayavi.

Thursday, June 20, 2013

"The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"

I see the error in the post title a lot when I'm trying to check values in arrays. I'm finally going to really figure out what it means by a.any() and a.all()!

I have a four element array, and I want to know if it has any 1's in it:

a = array([2, 3, 3, 2])
a.any()

This will return True, because it is checking to see if any of the elements in a are greater than zero. This is not helpful. We need to define an intermediate matrix that has truth values for the condition we want to test.

a = array([2, 3, 3, 2])
b =  a==0
b.any()

works!

Or,

a = array([2, 3, 3, 2])
any(a>0)

works!

a.all()  and all() should work in the same way, but be testing for ALL the values to be true.