Computing Notes

ArcINFO
    Permanently delete a flawed coverage or grid: Arc: kill <file> all.
    Convert ascii file to grid: Arc: asciigrid <in_asciifile> <out_gridfile> {INT | FLOAT}
    Merge grids: Grid: <out_grid> = merge (<in_grid1>, ..., <in_gridn>)
    Merge grid data in same grid file:
        <out_grid> = con ( input==1 || input == 2 || ... || input == n, 1, -9999 )
    Combine select values from two grids (example):
        ******NOTE: grids must have exact dimensions********
         <out_grid> = con ( ingrid1 == 0, 0, ingrid2)
    Change coordinate range (if new range is larger, NODATA_values will be assigned to new grid cells):
       Arc: gridclip <ingrid>  <out_grid>  <x1> <y1> <x2> <y2>
    Hint: ArcINFO does NOT recognize file names with capital letters or spaces in them.
To make a coverage from a generate file: Arc: generate linecov Generate: input linegenfile Generate: lines Generate: quit Externalling BND and TIC... Arc: Also works for points, polygons

ArcGIS
    Available on PCs.
    To add point data from Lat-Lon list:
       List should be either tab-delimited or comma separated text file with .tab or .txt extention with headers
       (i.e. lat    lon    data). In ArcCatalog, right click on the name of list file. Select "Create Feature Class from
       XY table". On the dialogue box that appears, select lat for Y filed and lon for X field.
    To project coverage or shapefile:
       Call ArcToolbox from ArcCatalog or main menu. Select Data Management tools -> projections -> project wizard
       and follow instructions.


Invaluable GIS utilities available at this site

Change Text Terminals on Unix Machine
    This is really useful if one of your terminals freezes or if you want to use a machine that someone else is already logged into.
    Ctrl-Alt (F1, F2, ..., F8) will bring you to terminals 1, 2, ..., 8
    You can have multiple X terminals running at a time. On my system:
    startx --:1 takes you to terminal 8
    startx --:0 is the default of terminal 7

R "Random Fields" (information from Kostas Andreadis)
   
Installation:Start R
                          >install.packages("RandomFields","DIRECTORY YOU HAVE WRITE ACCESS")
                          >library("RandomFields",lib.loc="DIR WHERE IT WAS INSTALLED")
    Using Random Fields (tailored to VIC application):
   
  # Read in lat-lon
            > x<-read.table("SOIL FILE")
            > lat<-as.numeric(x[,3])
            > lon<-as.numeric(x[,4])
            > z<-rep(1,length(lat))
       # Generate Gaussian spatially correlated random fields using Turning Bands with 3 turning layers
            > x<-GaussRF(lat,lon,z,NULL,FALSE,"exponential",c(0,1,0,1),method="TBM3",n=1)
       # Notes on the Gaussian Random Field:
             You can use any function you want in place of exponential.
             > help(CovarianceFct) # shows other functions
             c(0,1,0,1) are model parameters c(MEAN,VARIANCE,NUGGET,SCALE).
       # Write data into files
             > for(i in 1:length(lat)) {
             + name<-paste("grf_",sprintf("%.4f",lat[i]),"_",sprintf("%.4f",lon[i]),sep="")
             + write.table(x[i],file=name,append=TRUE,quote=FALSE,row.names=FALSE,col.names=FALSE)
             +}


Working with Functions
To tell R where a function is if it is defined in a file, use source("function_file_name")


Fitting Distributions
library("MASS",,"/usr/lib/R/library/")
fitdistr(x,"gamma")

Distributions available:
help("fitdistr")
beta
cauchy
chi-squared
exponential
f
gamma
geometric
log-normal
lognormal
logistic
negative binomial
normal
Poisson
t
weibull


General UNIX Commands:
    ln -s : create symbolic link
    df -lk : shows percent of disk that is full
    scp -rpq -c blowfish <dir1> <dir2>: copies large sets of files from one computer to next>faster than cp, dir2 frmt is graph:/raid/eclark
    rsync -av file dir1/ dir2/ : syncs file from dir1 to dir2; useful alernative to scp. See man rsync for options
    display file.png : displays png type file
    find . -name '*gz' : recursively search directory for all files ending in gz.
    convert a file from .eps to .gif : convert *.eps *.gif
    alias <new_command> <old_command> : creates alias (or shortcut) for common commands--be careful not to use an
        existing command
    \<alias> : uses command without alias
    (vicnl -g <global_file> >log) >& err : saves messages that are otherwise print to screen when running VIC or other
        command
    To loop in shell script:
        set i =0
        for($i<10)
            ...
            @ i++
        end
 nice +20 command : run a process at 20th priority to keep it from slowing down the system
 renice +20 PID : lower the priority of a process

To tar contents of a folder: BE CAREFUL...if a tar directory is too big and you try to zip it, you may lose data!!!
Check after tarring & zipping using tar -tvzf before deleting the original directory!!
  • tar -cvf dir.tar file_names Tars files
    tar -tvf dir.tar Lists files in tar directory
    tar -tvzf dir.tar.gz 
    Lists files in zipped tar directory
    tar -xvf dir.tar Extracts files
    tar -tvf <tarfile> | grep <filename>
    Find file name in tar file
    tar -xf <tarfile> <filename>
    Extracts single file
    tar -xzvf dir.tar.gz
    Extracts files from zipped tar directory

  •    If those random labels on your Xemacs window are driving you crazy, try this handy fix in your ~.emacs       file - comment out (add ";" at beginning of each row) the following (from Andy Wood):

       ;          (if (equal frame-title-format "%S: %b")
       ;              (setq frame-title-format
       ;                    (concat "%S: " invocation-directory invocation-name
       ;                            " [" emacs-version "]"
       ;                            (if nil ; (getenv "NCD")
       ;                                ""
       ;                              "  %b"))))

    To get the size of float, integer, etc.:
    #include <stdio.h>
    #include <stdlib.h>
    main()
    {
      printf("%d\n",sizeof(float));  //4
      printf("%d\n",sizeof(short int));  //2
      printf("%d\n",sizeof(unsigned short int));  // 2
      printf("%d\n",sizeof(int));  //4
      printf("%d\n",sizeof(char));  //1
    }

        Python Memory issues
          Try enabling automatic garbage collection: gc.enable()



    Last updated 05/15/2015 by Elizabeth Clark