Update 00_SetupFolderGlobals.do

Update 00_SetupFolderGlobals.do

/*-------------------------------------------------------------------------------
# Name:		00_SetupFolderGlobals
# Purpose:	Create series of folders Food for Uganda Vulnerability Analysis
# Author:	Tim Essam, Ph.D.
# Created:	10/31/2014; 02/19/2015.
# Owner:	USAID GeoCenter | OakStream Systems, LLC
# License:	MIT License
# Ado(s):	see below
#-------------------------------------------------------------------------------
*/

/* RUN/READ ME FIRST -- Make directories for the study.
 1. Requires root name for file folder structure
 2. Requires branch names for sub-folders
 3. Sets global macros for the study; These are used through the do files.
 4. TODO -- Script DOES NOT copy in raw data at this point.
 5. TODO -- Create program folder for calling custom programs.
 6. TODO -- Convert setup .do file into a program (inputs are project path & folder name)
*/

* install the confirm directory ado if not already installed
* list all known user-written .ados needed for project
local required_ados confirmdir mvfiles fs spatgsa  adolist labellist winsor2
foreach x of local required_ados {
	capture findfile `x'.ado
		if _rc==601 {
			cap ssc install `x'
		}
		else disp in yellow "`x' currently installed."
	}
*end

* Determine path for the study
* global projectpath "U:/"
* global projectpath "C:/Users/Tim/Documents/"
global projectpath "C:/Users/t/Documents/"
cd "$projectpath"

* Run a macro to set up study folder (needs to be modified)
* Name the file path below -- replace "nigerlsms" with your folder name
local pFolder Uganda
foreach dir in `pFolder' {
	confirmdir "`dir'"
	if `r(confirmdir)'==170 {
		mkdir "`dir'"
		display in yellow "Project directory named: `dir' created"
		}
	else disp as error "`dir' already exists, not created."
	cd "$projectpath/`dir'"
	}
* end

* Run initially to set up folder structure
* Choose your folders to set up as the local macro `folders'
local folders Rawdata Stata Datain Log Output Dataout Excel PDF Word Graph GIS Export R Python Programs Sensitive_Data FinalProducts
foreach dir in `folders' {
	confirmdir "`dir'"
	if `r(confirmdir)'==170 {
			mkdir "`dir'"
			disp in yellow "`dir' successfully created."
		}
	else disp as error "`dir' already exists. Skipped to next folder."
}
*end

/*---------------------------------
# Set Globals based on path above #
-----------------------------------*/
global date $S_DATE
local dir `c(pwd)'
global path "`dir'"
global pathdo "`dir'/Stata"
global pathdo2 "`dir'/Github\Uganda\Stata"
global pathlog  "`dir'/Log"
global pathin "`dir'/Datain"
global pathout "`dir'/Dataout"
global pathgraph "`dir'/Graph"
global pathxls "`dir'/Excel"
global pathreg "`dir'/Output"
global pathgis "`dir'/GIS"
global pathraw "`dir'/Rawdata"
global pathexport "`dir'/Export"
global pathR "`dir'/R"
global pathPython "`dir'/Python"
global pathProgram "`dir'/Program"
global pathPdrive "P:/GeoCenter/GIS/Projects/LVAM\Uganda"
global pathSensitive "`dir'/Sensitive_Data"
global pathProducts "`dir'/FinalProducts"
* Project macros are defined as:
macro list

* Add in subfolders for GIS and Final Products Folders
cd "$pathgis"
local gisfolders FeatureClass Shapefiles csv Layers mxd Rasters scratch
foreach dir in `gisfolders' {
	confirmdir "`dir'"
	if `r(confirmdir)'==170 {
			mkdir "`dir'"
			disp in yellow "`dir' successfully created."
		}
	else disp as error "`dir' already exists. Skipped to next folder."
}
*end

cd "$pathProducts"
local subfolders AI PDFs PosterJPG PPTJPG
foreach dir in `subfolders' {
	confirmdir "`dir'"
	if `r(confirmdir)'==170 {
			mkdir "`dir'"
			disp in yellow "`dir' successfully created."
		}
	else disp as error "`dir' already exists. Skipped to next folder."
}
*end

/*------------------------------------------------------------
# Manually copy raw data  into Datain Folder #

/*-------------------------------------------------------------------------------
# Name:		00_SetupFolderGlobals
# Purpose:	Create series of folders Food for Uganda Vulnerability Analysis
# Author:	Tim Essam, Ph.D.
# Created:	10/31/2014; 02/19/2015.
# Owner:	USAID GeoCenter | OakStream Systems, LLC
# License:	MIT License
# Ado(s):	see below
#-------------------------------------------------------------------------------
*/

/* RUN/READ ME FIRST -- Make directories for the study.
 1. Requires root name for file folder structure
 2. Requires branch names for sub-folders
 3. Sets global macros for the study; These are used through the do files.
 4. TODO -- Script DOES NOT copy in raw data at this point.
 5. TODO -- Create program folder for calling custom programs.
 6. TODO -- Convert setup .do file into a program (inputs are project path & folder name)
*/

* install the confirm directory ado if not already installed
* list all known user-written .ados needed for project
local required_ados confirmdir mvfiles fs spatgsa  adolist labellist winsor2
foreach x of local required_ados {
	capture findfile `x'.ado
		if _rc==601 {
			cap ssc install `x'
		}
		else disp in yellow "`x' currently installed."
	}
*end

* Determine path for the study
* global projectpath "U:\"
* global projectpath "C:\Users\Tim\Documents\"
global projectpath "C:\Users\t\Documents\"
cd "$projectpath"

* Run a macro to set up study folder (needs to be modified)
* Name the file path below -- replace "nigerlsms" with your folder name
local pFolder Uganda
foreach dir in `pFolder' {
	confirmdir "`dir'"
	if `r(confirmdir)'==170 {
		mkdir "`dir'"
		display in yellow "Project directory named: `dir' created"
		}
	else disp as error "`dir' already exists, not created."
	cd "$projectpath\`dir'"
	}
* end

* Run initially to set up folder structure
* Choose your folders to set up as the local macro `folders'
local folders Rawdata Stata Datain Log Output Dataout Excel PDF Word Graph GIS Export R Python Programs Sensitive_Data FinalProducts
foreach dir in `folders' {
	confirmdir "`dir'"
	if `r(confirmdir)'==170 {
			mkdir "`dir'"
			disp in yellow "`dir' successfully created."
		}
	else disp as error "`dir' already exists. Skipped to next folder."
}
*end

/*---------------------------------
# Set Globals based on path above #
-----------------------------------*/
global date $S_DATE
local dir `c(pwd)'
global path "`dir'"
global pathdo "`dir'\Stata"
global pathdo2 "`dir'\Github\Uganda\Stata"
global pathlog  "`dir'\Log"
global pathin "`dir'\Datain"
global pathout "`dir'\Dataout"
global pathgraph "`dir'\Graph"
global pathxls "`dir'\Excel"
global pathreg "`dir'\Output"
global pathgis "`dir'\GIS"
global pathraw "`dir'\Rawdata"
global pathexport "`dir'\Export"
global pathR "`dir'\R"
global pathPython "`dir'\Python"
global pathProgram "`dir'\Program"
global pathPdrive "P:\GeoCenter\GIS\Projects\LVAM\Uganda"
global pathSensitive "`dir'\Sensitive_Data"
global pathProducts "`dir'\FinalProducts"
* Project macros are defined as:
macro list

* Add in subfolders for GIS and Final Products Folders
cd "$pathgis"
local gisfolders FeatureClass Shapefiles csv Layers mxd Rasters scratch
foreach dir in `gisfolders' {
	confirmdir "`dir'"
	if `r(confirmdir)'==170 {
			mkdir "`dir'"
			disp in yellow "`dir' successfully created."
		}
	else disp as error "`dir' already exists. Skipped to next folder."
}
*end

cd "$pathProducts"
local subfolders AI PDFs PosterJPG PPTJPG
foreach dir in `subfolders' {
	confirmdir "`dir'"
	if `r(confirmdir)'==170 {
			mkdir "`dir'"
			disp in yellow "`dir' successfully created."
		}
	else disp as error "`dir' already exists. Skipped to next folder."
}
*end

/*------------------------------------------------------------
# Manually copy raw data  into Datain Folder #


bar, points

bar, points

program chart_qual

use ${stash}master, clear

local isbaseball `1'
local isbaseball "1"

local var img
keep if isbaseball == `isb'

gen tvar = treat

xtreg `var' tvar##post##quality i.$fe, vce(robust) fe level(90)

qui parmest, label list(parm estimate min* max* p) saving(${stash}pars_tmp, replace) level(90)

clear
use ${stash}pars_tmp, clear

keep if regexm(parm, "[0-9].*tvar.*post.*quality") == 1
drop if estimate == 0

gen quality = regexs(1) if regexm(parm, ".*post.*\#([0-9]+)\.quality")
list quality estimate max min

gen xaxis = 0
destring quality, replace

graph twoway (bar estimate quality, msize(small) lpattern(solid) lcolor(edkblue) lwidth(thin) barwidth(0.08)) (rcap min max quality) (line xaxis quality), legend(off) title("") xtitle("")

graph export "${tables}quality_`var'_`isbaseball'.eps", replace

shell epstopdf  "${tables}quality_`var'_`isbaseball'.eps"

end

use ${stash}master, clear

local isbaseball `1'
local isbaseball "1"

local var img
keep if isbaseball == `isb'

gen tvar = treat

xtreg `var' tvar##post##quality i.$fe, vce(robust) fe level(90)

qui parmest, label list(parm estimate min* max* p) saving(${stash}pars_tmp, replace) level(90)

clear
use ${stash}pars_tmp, clear

keep if regexm(parm, "[0-9].*tvar.*post.*quality") == 1
drop if estimate == 0

gen quality = regexs(1) if regexm(parm, ".*post.*\#([0-9]+)\.quality")
list quality estimate max min
gen xaxis = 0
destring quality, replace

graph twoway (bar estimate quality, msize(small) lpattern(solid) lcolor(edkblue) lwidth(thin) barwidth(0.08)) (rcap min max quality), legend(off) title("") xtitle("")

graph export "${tables}quality_`var'_`isbaseball'.eps", replace

shell epstopdf  "${tables}quality_`var'_`isbaseball'.eps"

end


Pushed from nova Sat Nov 14 06:36:34 PST 2015

= to.do: =

o Some dotfiles, e.g. .gitconfig, really need to be modified by a script rather than
  simply symlinked.  That's because things like username and email address change from one
  system to another.  So use a file full of, e.g., git config --global ...  An alternative
  would be to include them.

o regular dotfiles should start with "_" rather than ".", to make them visible.

==============================================================================
Work Log:
========

1111We
  @ OpenSSH/Cookbook/Multiplexing - Wikibooks
    Makes ssh much faster, and circumvents dreamhost's connection limits.
    > mkdir ~/.ssh/controlmasters; chmod 700 ~/.ssh/controlmasters
  * Add the following to .ssh/config, in the global section at the top:
      ControlPath ~/.ssh/controlmasters/%r@%h:%p
      ControlPersist 10m
      ControlMaster auto
  @ https://github.com/blipvert/ljupdate/commits/master marginally more up to date
    * update emacs/depends.make

==============================================================================
Local Variables:
    fill-column:90
End:

= to.do: =

o Some dotfiles, e.g. .gitconfig, really need to be modified by a script rather than
  simply symlinked.  That's because things like username and email address change from one
  system to another.  So use a file full of, e.g., git config --global ...  An alternative
  would be to include them.

o regular dotfiles should start with "_" rather than ".", to make them visible.

1111We
  @ https://github.com/blipvert/ljupdate/commits/master marginally more up to date
    o update emacs/depends.make

==============================================================================
Work Log:
========

1111We
  @ OpenSSH/Cookbook/Multiplexing - Wikibooks
    Makes ssh much faster, and circumvents dreamhost's connection limits.
    > mkdir ~/.ssh/controlmasters; chmod 700 ~/.ssh/controlmasters
  * Add the following to .ssh/config, in the global section at the top:
      ControlPath ~/.ssh/controlmasters/%r@%h:%p
      ControlPersist 10m
      ControlMaster auto

==============================================================================
Local Variables:
    fill-column:90
End: