2013年9月26日木曜日

Rワークショップ1

大学でプログラム言語「R」の初心者向けワークショップに行ったのでそのときとったノート。

#Introduction to R (Workshop 1)

2 + 3 #In Mac, "Command+Enter" will execute the highlighted field
log(1000,10) #log base 10
weight <- c(3,1,4,1,5,4,2,9); #assign a value to "weight"
weight #view value
max(weight)
min(weight)
mean(weight)
sd(weight)
var(weight)
length(weight);
weight[1] #indexing values
weight[1:5] #index starts from 1 in R
1:10 # a sequence from 1 to 10
seq(1,21,0.9)
plot(weight)
barplot(weight,las=1,names=seq(1,8)); #las adjusts labels
title(xlab="Individual")
title(ylab="Mass [g]")
title(main="Snails")

weight <- scan() #entering values to weight from keyboard
weight[1] <- 4 #edit a value

#Random numbers
X <- rnorm(20,mean=0,sd=1)
Y <- rnorm(20,mean=0,sd=1)
plot(X,Y,pch=2, col="blue", xlab="",ylab="title y",las=1) #pch = plot character, choose from 1 to 20
cor(X,Y,method="spearman")
rank(X) #rank in the increasing order
cor(rank(X),rank(Y))
?cor #Get help on "cor"
cor.test(X,Y);
t.test(X,Y,var.equal=TRUE)
t.test(X,Y,paired=TRUE)

volcano
persp(volcano); #a 3-d plot
contour(volcano);
image(volcano,col= terrain.colors(100),axes=FALSE); #color plot

contour(volcano, add=TRUE)
title(main="volcano 22",font.main=5,cex.main=2)

#Linear regression

X <- 1:10
Y <- 0.5 * X + 2 + rnorm(10,0,1)
plot(X,Y)
LM <- lm(Y ~ X)
LM #View coefficients
summary(LM) #more information
LM$residuals
plot(X,Y)
abline(LM,col="red",lty=2)

#Loading Data File
getwd() #your current working directory
load("~/Documents/R/ArcticData.rda")
names(ArcticData)
ArcticData$metadata
names(ArcticData$data)
ArcticData2 <- read.csv("~/Documents/R/ArcticData.csv",skip=5,header=TRUE) #the first line after "skip" is the header (variable names).
ArcticData2 <- read.csv(file.choose(),skip=5,header=TRUE)
plot(ArcticData2)
DATA <- ArcticData$data
names(ArcticData2)
plot(DATA$day, DATA$water.temp, col="red",type="l",ylab="Temperature") #l=line plot
with(DATA,plot(day,ice,col="blue",type="l",ylab="Ice Draft [m]",xlab="Day of Year"))
attach(DATA)
plot(day,chlorophyll,col="green",type="l",ylab="Chl")
detach(DATA)
head(DATA)
tail(DATA)
dim(DATA)
DATA[1,]
DATA$salinity[5] #fifth salinity value
attach(DATA)
plot(conductivity,salinity)
LM <- lm(salinity ~ conductivity + water.temp)
LM

par(mfrow=c(2,1)) #This is like subplot in matlab
plot(day,salinity,col="darkgreen",type="l")

> LM

Call:
lm(formula = salinity ~ conductivity + water.temp)

Coefficients:
 (Interceptconductivity    water.temp  
      0.8420       11.5014       -0.8414  
      
plot(day,0.842+11.5014*conductivity-0.8414*water.temp,type="l")
LM$residuals

par(mfrow=c(1,1))
plot(day,air.temp,ylab="temperature",xlab="DAY",col="yellow",type="l")
points(day,water.temp,col="orange",type="l",ltype=4)

quartz("title of window", width=5,height=5) #On a Mac
plot(salinity,water.temp)
#you can copy and paste the plotted figure.

#Matrix

A <- matrix(1,nrow=2,ncol=2)
A[1,1] <- 32
A[2,2] <- 21
rownames(A) <- c("Site.A", "site.B")
chisq.test(A, correct=FALSE)
library(help="stats")
library(help="datasets")
library(help="graphics")

plot(co2)

2013年9月16日月曜日

Aerosol note

Aerosol: small particles suspended in air

Impact of aerosols on the climate system: largest uncertainties in radiative forcing (IPCC, 2007)

Roles of aerosols:
! Scatter and absorb insolation
! Absorb infrared radiation
! Cloud formation
! Reduce albedo through deposition to snow

現段階(まだ何も知らないフレッシュな状態)で疑問に思うこと:

DMSはエアロゾル全体の何パーセントを構成しているのか?すなわちDMDを研究することの重要度。

2013年9月9日月曜日

Memo: Grad Students Welcome

GSS extended health insurance:

  • $75 eye exam every 2 calendar year
  • $200 eye glasses every 2 calendar year
  • 60 days travel (out of province for research purposes)
  • $750 dental every 1 calendar year
  • Pay once a year or apply for monthly payment option (deadline Sept.30)
  • Sept. 30 Deadline for opt-in/-out. You must do this every year.
Other tips:
  • Wednesdays 9-10:30am: Coffee and muffins for grad students at Grad House.
  • Validate UVic Bus Pass at the GSS office every semester.
  • Travel funding available (co-sponsored with FGS).
  • Childcare bursary.
  • Three minute thesis.
  • Learning and Teaching in Higher Education (LATHE).
  • CarShare Program membership available!
  • Sept.15 Deadline for tuition income offset plan ($25 application fee) & good till August 31. 

2013年9月5日木曜日

Wordleでこれから始まる研究内容をbrainstormしてみた。


Word Cloudということがわかった。

word cloud generatorと検索して一番気に入ったのがwordleというジェネレータ。javaが必要なのでchromeでは使えんかったけどsafariで使えた。

いじってみてすぐに疑問に思ったことが、二文字以上のキーワード(例climate change)はどうやったらバラバラにならずにまとまって表示されるか☞答えは「~」を単語の間に入れればいい(FAQ参照:http://www.wordle.net/faq#space)。

以下のキーワードを使って早速作ってみた。
DMS
DMSO
DMSP
CCN
Arctic
ocean~modeling
aerosols
under-ice~blooms
air-sea~interactions
climate~change
Canadian
black~carbon
radiative~forcing
clouds
ice~cloud~nucleation
ecosystem
sulfur


以下その他メモ:
Our task: perform ocean modeling
Summary:
address key uncertainties in the marine sources of aerosols in the Arctic and impacts of the decline of summer sea-ice extent.
DMS, the most important source of secondary aerosol, is oxidized to form SO_4^{2+} aerosols that may act as CCN, reducing insolation [the CLAW hypothesis; Charlson et al., 1987]. While this feedback mechanism between warming of climate and marine DMS production is questionable [Quinn and Bates, 2011], feedbacks between oceanic DMS and regional climate appear to be significant, particularly in the Arctic.
Sea ice algae is an important reservoir of DMSP, the non-volatile precursor of DMS [Levasseur et al., 1994]. We don't know how much of this ice-DMSP is converted to DMS and contributes to the atmpsheric DMS formation at the moment [Nomura et al., 2012]. DMSO may also be a source or sink for DMS either through the algal DMSO production and its subsequent reduction into DMS or through the production of DMSO by photochemical or bacterial oxidation of DMS, respectively [Hatton et al., 2004].
under-ice blooms promote DMSP production [Arrigo et al., 2012], but the transformations of DMSP and DMS are uncertain and hence limit our modeling work on air-sea feedbacks.