diff --git a/script/explorations.R b/script/explorations.R index ffa827c..80db46d 100644 --- a/script/explorations.R +++ b/script/explorations.R @@ -65,34 +65,8 @@ dynobs[, list(m3_end=sum(m3, na.rm=TRUE)), by=paste(osmid, bldindex)][, mean(m3_ cat("average end-size final church: \n") dynobs[, list(m3_end=sum(m3[bldindex==max(bldindex)], na.rm=TRUE)), by=osmid][, mean(m3_end)] -# distribution observations -# ------------------------- -pdf('figs/phasedistr_hc.pdf', height = 6, width = 10) -par(mfrow=c(2, 4), mar=c(4, 4, 2, 1), font.main = 1) -x = dynobs_sp[, grep('ctr$|year_crc', names(dynobs_sp)), with = F] -for (country in unique(x$ctr)){ - histmat = as.matrix(x[ctr == country, grep("year", names(x)), with = F]) - histmat[histmat < 700] = 700 - histmat[histmat > 1600] = 1600 - hi = hist(histmat, breaks = M, plot = F) - hi$counts = hi$counts / M - plot(hi, main='', xlab = 'year') - title(main=country, line = -0.1) -} -dev.off() - -pdf('figs/phasedistr.pdf', height = 6, width = 10) -par(mfrow=c(2, 4), mar = c(2, 2, 3, 1), font.main = 1) -x = dynobs_sp[, list(ctr, year)] -x[year > 1600, year := 1600] -x[year < 700, year := 700] -for (country in unique(x$ctr)){ - hist(x[ctr == country, year], breaks = 9, main = '') - title(main = country, line = -0.1) -} -dev.off() - # w. european totals +# ------------------ eutotal = fullobs[data.table::between(decade, 700, 1500), list(im3y20 = base::sum(.SD, na.rm=TRUE) / M / 1e6), by=decade, .SDcols = impvrbs] # m3 per 20y period en country @@ -187,26 +161,6 @@ geography_south = pcitobs[, `Coastal, Mediterranean` = mean(im3_cnt[coastal == 1 & mediterranean == 1], na.rm = TRUE)), by = list(year)] -pdf("figs/geography_hc.pdf", height=3, width=8) -par(mfrow=c(1, 3), font.main=1, mar = c(4.5, 4, 1.5, 0.2)) -matplot(geography[, 1], geography[, -1], - bty = 'l', type='b', col='gray', lty = 1, pch = 1, - ylab = m3y100lbl, - xlab = '') -lines(coastal ~ year, data = geography, type='b', lwd = 1.5) -title(main='Coastal', line = -0.3) -matplot(geography[, 1], geography[, -1], - bty = 'l', type='b', col='gray', lty = 1, pch = 1, - xlab = 'century') -lines(rivercanal ~ year, data = geography, type='b', lwd = 1.5) -title(main='River/canal', line = -0.3) -matplot(geography[, 1], geography[, -1], - bty = 'l', type='b', col='gray', lty = 1, pch = 1, - xlab = '') -lines(landlocked ~ year, data = geography, type='b', lwd = 1.5) -title(main='Landlocked', line = -0.3) -dev.off() - cat("annualised growth 900-1200:\n") geography[year %in% c(900, 1200), lapply(.SD, annualised_growth, delta = 300), diff --git a/script/m2imps.R b/script/m2imps.R index 66b02d0..ded070b 100644 --- a/script/m2imps.R +++ b/script/m2imps.R @@ -95,16 +95,16 @@ itmin = -0.025 itmax = 0.058 eumin = -0.00005 eumax = 0.00335 -pdf("figs/fittedpoints.pdf") -par(mfrow = c(1, 2)) -plot(ecdf(bldobs[ctr == "it", ratio_to_successor - ratio_predicted]), - pch = 1, xlim = c(-0.2, 0.2)) -abline(v = c(itmin, itmax)) # between these values -# rest -plot(ecdf(bldobs[ctr != "it" & endm2 != 0 & successor_endm2 != 0, ratio_to_successor - 0.53]), - xlim = c(-0.01, 0.01), pch = NA, lty = 1) -abline(v = c(eumin, eumax)) # between these values -dev.off() +# pdf("figs/fittedpoints.pdf") +# par(mfrow = c(1, 2)) +# plot(ecdf(bldobs[ctr == "it", ratio_to_successor - ratio_predicted]), +# pch = 1, xlim = c(-0.2, 0.2)) +# abline(v = c(itmin, itmax)) # between these values +# # rest +# plot(ecdf(bldobs[ctr != "it" & endm2 != 0 & successor_endm2 != 0, ratio_to_successor - 0.53]), +# xlim = c(-0.01, 0.01), pch = NA, lty = 1) +# abline(v = c(eumin, eumax)) # between these values +# dev.off() # = predicted in buildings bldobs[, predicted := "no"] @@ -229,23 +229,23 @@ m1 = lm(end_surface ~ previous_surface - 1, data=sfc[factor==1,]) m2 = lm(end_surface ~ previous_surface - 1, data=sfc[factor==2,]) m3 = lm(end_surface ~ previous_surface - 1, data=sfc[factor==3,]) -pdf("figs/surface_fits.pdf", height=3, width=8) -par(mfrow=c(1, 3), font.main=1, mar = c(4.5, 4, 1.5, 0)) -plot(end_surface ~ previous_surface, data=sfc, type='n', bty='l', - main='1st predecessor', xlab = '', ylab = 'End surface (m2)') -points(end_surface ~ previous_surface, data=sfc[factor==1,]) -abline(m1, col = 'gray') -abline(a=0, b=1.879) -# text(2000, 1000, "OLS fit", col=2) -# text(1000, 5000, "Rule of thumb", col=1) -plot(end_surface ~ previous_surface, data=sfc, type='n', bty='l', - main='2nd predecessor', xlab = 'Previous surface (m2)', ylab = '') -points(end_surface ~ previous_surface, data=sfc[factor==2,]) -abline(m2, col = 'gray') -abline(a=0, b=1.879^2) -plot(end_surface ~ previous_surface, data=sfc, type='n', bty='l', - main='3rd predecessor', xlab = '', ylab = '') -points(end_surface ~ previous_surface, data=sfc[factor==3,]) -abline(m3, col = 'gray') -abline(a=0, b=1.879^3) -dev.off() +# pdf("figs/surface_fits.pdf", height=3, width=8) +# par(mfrow=c(1, 3), font.main=1, mar = c(4.5, 4, 1.5, 0)) +# plot(end_surface ~ previous_surface, data=sfc, type='n', bty='l', +# main='1st predecessor', xlab = '', ylab = 'End surface (m2)') +# points(end_surface ~ previous_surface, data=sfc[factor==1,]) +# abline(m1, col = 'gray') +# abline(a=0, b=1.879) +# # text(2000, 1000, "OLS fit", col=2) +# # text(1000, 5000, "Rule of thumb", col=1) +# plot(end_surface ~ previous_surface, data=sfc, type='n', bty='l', +# main='2nd predecessor', xlab = 'Previous surface (m2)', ylab = '') +# points(end_surface ~ previous_surface, data=sfc[factor==2,]) +# abline(m2, col = 'gray') +# abline(a=0, b=1.879^2) +# plot(end_surface ~ previous_surface, data=sfc, type='n', bty='l', +# main='3rd predecessor', xlab = '', ylab = '') +# points(end_surface ~ previous_surface, data=sfc[factor==3,]) +# abline(m3, col = 'gray') +# abline(a=0, b=1.879^3) +# dev.off()