A blog for my notes on perl and various other programming languages and applications I work on.
Tuesday, July 7, 2015
My first application of the Perl Data Language
I've been installing and testing and playing with PDL for a few years now, but I've never had a need to use it for anything at work. Until now! Recently I needed to update the coordinate file for a set of devices to test. The layout editor showed that the centers of the devices were not rectangular shapes but polygons instead. That made it difficult for the software to give me a central coordinate of the object. What L-Edit does give me though are the vertices of the polygon that makes up that object, and that data was easy enough for me to copy and paste into TextPad. With a few regular expressions and search/replace commands I was able to format the data in a way that Perl could read. I then used PDL to quickly calculate the centroid of the coordinate set, and voila! I had my center coordinate for the device I needed to test. It was my first real use of PDL and I think it saved me a few lines of code. The cool thing was turning it into a PDL function, which could be called by the PDL REPL.
#!/usr/bin/env perl
use Modern::Perl;
use PDL;
sub FDC53_NE_9x9_X4Y0_Centroid() {
my @V;
push @V, [53028.301,22242.396];
push @V, [53028.477,22241.163];
push @V, [53028.532,22240.839];
push @V, [53028.646,22240.268];
push @V, [53028.958,22239.265];
push @V, [53029.368,22238.308];
push @V, [53029.672,22237.713];
push @V, [53029.932,22237.280];
push @V, [53030.687,22236.313];
push @V, [53031.811,22235.189];
push @V, [53032.783,22234.430];
push @V, [53033.207,22234.176];
push @V, [53033.814,22233.865];
push @V, [53034.769,22233.456];
push @V, [53035.763,22233.147];
push @V, [53036.373,22233.025];
push @V, [53036.628,22232.982];
push @V, [53037.896,22232.801];
push @V, [53038.608,22232.750];
push @V, [53127.893,22232.750];
push @V, [53128.603,22232.800];
push @V, [53129.865,22232.981];
push @V, [53130.134,22233.027];
push @V, [53130.732,22233.147];
push @V, [53131.735,22233.458];
push @V, [53132.692,22233.868];
push @V, [53133.287,22234.172];
push @V, [53133.720,22234.432];
push @V, [53134.687,22235.187];
push @V, [53135.815,22236.315];
push @V, [53136.566,22237.277];
push @V, [53136.824,22237.707];
push @V, [53137.134,22238.314];
push @V, [53137.544,22239.270];
push @V, [53137.852,22240.262];
push @V, [53137.972,22240.861];
push @V, [53138.020,22241.141];
push @V, [53138.199,22242.396];
push @V, [53138.250,22243.108];
push @V, [53138.250,22332.893];
push @V, [53138.200,22333.603];
push @V, [53138.019,22334.865];
push @V, [53137.973,22335.134];
push @V, [53137.853,22335.732];
push @V, [53137.542,22336.735];
push @V, [53137.132,22337.692];
push @V, [53136.828,22338.287];
push @V, [53136.568,22338.720];
push @V, [53135.813,22339.687];
push @V, [53134.681,22340.819];
push @V, [53133.727,22341.564];
push @V, [53133.293,22341.824];
push @V, [53132.686,22342.135];
push @V, [53131.731,22342.544];
push @V, [53130.737,22342.853];
push @V, [53130.127,22342.975];
push @V, [53129.872,22343.018];
push @V, [53128.604,22343.199];
push @V, [53127.892,22343.250];
push @V, [53038.607,22343.250];
push @V, [53037.897,22343.200];
push @V, [53036.635,22343.019];
push @V, [53036.366,22342.973];
push @V, [53035.768,22342.853];
push @V, [53034.765,22342.542];
push @V, [53033.808,22342.132];
push @V, [53033.213,22341.828];
push @V, [53032.780,22341.568];
push @V, [53031.813,22340.813];
push @V, [53030.686,22339.686];
push @V, [53029.933,22338.722];
push @V, [53029.676,22338.293];
push @V, [53029.365,22337.686];
push @V, [53028.956,22336.731];
push @V, [53028.647,22335.737];
push @V, [53028.525,22335.127];
push @V, [53028.482,22334.872];
push @V, [53028.301,22333.604];
push @V, [53028.250,22332.892];
push @V, [53028.250,22243.108];
my $data = pdl(@V);
my $mySums = sumover $data->xchg(0,1);
my @dims = $data->dims;
return $mySums / $dims[1];
}
1;
Tuesday, June 9, 2015
Converting Excel Macros to Perl
I'm currently working on porting our Excel macros at work to LabView. To get a quick prototype up and running I have been translating the Visual Basic code and the formulas in all of the spreadsheet cell to Perl 6. In the process I get to learn more about Perl 6 and see what all the fuss is about. The Excel macro takes a directory of data files from our transistor testing procedure and extracts certain model parameters for our design engineers. The data is located in tab separated plain text files. They contain voltage and current data for different aspects of the transistor. Each folder contains the data of over a dozen transistors. Here is what I've done so far:
#!/usr/bin/env perl6
use v6;
my $Append = False;
my $Test_Descriptor_Keys_File = "(compute)";
my $Lot_ID = "E1517-002";
my @Wafer_List = "Wafer_11", "Wafer_12";
my @Analysis_Master_Name = "AnalysisMaster_Autoprobe_Prod_20111005";
my $Test_Name_For_Processing = "COW";
my $Path_To_Data_File = "./";
my $Process_Reverse_Sweeps = 1; my $Print_Graphs = 1;
my $Print_Graphs_To_File = 1;
my $Delete_Summary_Filename_Sheets = 0;
my %Environment = Lot_ID => $Lot_ID, Wafer_List => @Wafer_List, Path_To_Data_File => $Path_To_Data_File,
Test_Name_For_Processing => $Test_Name_For_Processing, Analysis_Master_Name => $Analysis_Master_Name,
Test_Descriptor_Keys_File => $Test_Descriptor_Keys_File, Append => $Append, Process_Reverse_Sweeps => $Process_Reverse_Sweeps,
Print_Graphs => $Print_Graphs, Print_Graphs_To_File => $Print_Graphs_To_File, Delete_Summary_Filenames_Sheets => $Delete_Summary_Filename_Sheets;
sub main() {
say "Starting...";
my $myReturn = 1;
my $myInput = "";
my $PrintGraphsStatus = "(yes)";
my $PrintGraphsToFileStatus = "(yes)";
my $ProcessReverseSweeps = "(yes)";
my $AppendDataToSummary = "(no)";
while ($myReturn) {
say "Choose Function: ";
say "1. Process TFT Autoprobe Data";
say "2. Process TFT Princeton Data";
say "3. Print Graphs? " ~ $PrintGraphsStatus;
say "4. Print Graphs to File? " ~ $PrintGraphsToFileStatus;
say "5. Process TFT Data";
say "6. Delete Summary & Filenames Sheets";
say "7. Process Reverse Sweeps " ~ $ProcessReverseSweeps;
say "8. Append Data to Summary " ~ $AppendDataToSummary;
say "9. Quit";
$myInput = get();
given ($myInput) {
when 1 { $myReturn = &Process_TFT_Autoprobe_Data(%Environment); }
when 2 { $myReturn = &Process_TFT_Princeton_Data(%Environment); }
when 3 { $myReturn = &Print_Graphs(%Environment); }
when 4 { $myReturn = &Print_Graphs_To_File(%Environment); }
when 5 { $myReturn = &Process_TFT_Data(%Environment); }
when 6 { $myReturn = &Delete_Summary_Filenames_Sheets(%Environment); }
when 7 { $myReturn = &Process_Reverse_Sweeps(%Environment); }
when 8 { $myReturn = &Append_Data_to_Summary(%Environment); }
when 9 { exit(0); }
default { $myReturn = 1; }
}
}
}
sub Process_TFT_Autoprobe_Data() {
my %Environment = shift;
my $Lot_ID = %Environment{'Lot_ID'};
my @Wafer_List = %Environment{'Wafer_List'};
my $Path_To_Data_File = %Environement{'Path_To_Data_File'};
say "Enter your lot ID:";
$Lot_ID = get();
say "called Process TFT Autoprobe Data";
}
sub Process_TFT_Princeton_Data() {
my %Environment = shift;
say "called Process TFT Princeton Data";
}
sub Print_Graphs() {
my %Environment = shift;
say "called Print Graphs";
}
sub Print_Graphs_To_File() {
my %Environment = shift;
say "called Print Graphs to File";
}
sub Process_TFT_Data() {
my %Environment = shift;
say "called Process TFT Data";
}
sub Delete_Summary_Filenames_Sheets() {
my %Environment = shift;
say "called Delete Summary Filenames Sheets";
}
sub Process_Reverse_Sweeps() {
my %Environment = shift;
say "called Process Reverse Sweeps";
}
sub Append_Data_to_Summary() {
my %Environment = shift;
say "called Append Data to Summary";
}
main();
1;
Thursday, May 7, 2015
Whole Cell Simulation Project
Lately I've been thinking about computer simulations and what would be the most fruitful thing to simulate right now. I've read about simulating an entire bacterial cell at the molecular lever in the past, but only recently have I learned that the people who accomplished that feat have made their software available for free downloading. I was super excited and quickly installed the source code into three computers. The source code is found here: https://github.com/CovertLab/WholeCell
The code is written in Matlab 2010b. I've been successful at getting it to work on Matlab 2015a and Matlab 2010a, with Windows 7 and Redhat Linux respectively. Oddly I have not been able to get the software to work on Scientific Linux 6 running either Matlab 2012a or 2010b. That machine runs a dual core Pentium D processor and there seems to be something wrong at a deep level with one of the number crunching libraries.
The code is written in Matlab 2010b. I've been successful at getting it to work on Matlab 2015a and Matlab 2010a, with Windows 7 and Redhat Linux respectively. Oddly I have not been able to get the software to work on Scientific Linux 6 running either Matlab 2012a or 2010b. That machine runs a dual core Pentium D processor and there seems to be something wrong at a deep level with one of the number crunching libraries.
Subscribe to:
Posts (Atom)