Project

General

Profile

Support #4863 » RLOGde52607a-a847-42f9-ac8c-e43ea5fd4ed9.txt

Paul Taconet, Aug 23, 2016 03:40 PM

 
1
R version 3.2.5 (2016-04-14) -- "Very, Very Secure Dishes"
2
Copyright (C) 2016 The R Foundation for Statistical Computing
3
Platform: x86_64-pc-linux-gnu (64-bit)
4

    
5
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
You are welcome to redistribute it under certain conditions.
7
Type 'license()' or 'licence()' for distribution details.
8

    
9
R is a collaborative project with many contributors.
10
Type 'contributors()' for more information and
11
'citation()' on how to cite R or R packages in publications.
12

    
13
Type 'demo()' for some demos, 'help()' for on-line help, or
14
'help.start()' for an HTML browser interface to help.
15
Type 'q()' to quit R.
16

    
17
> setwd("/home/gcube/tomcat/webapps/wps/config/../ecocfg/rscr_19ecc1bf-8b5e-4350-bc38-2e4c4ae7ac64/catches_by_gear")
18
> source('/home/gcube/tomcat/webapps/wps/config/../ecocfg/rscr_19ecc1bf-8b5e-4350-bc38-2e4c4ae7ac64/catches_by_gear/4b814d63-5d3f-4a75-887f-d633d90955b7main.R')
19
let's begin
20
> if (is.null(time_aggregation)) {
21
+     time_start <- as.Date(time_start)
22
+     time_end <- as.Date(time_end)
23
+     time_frame <- time_end - time_sta .... [TRUNCATED] 
24

    
25
> if (!is.null(tableToUse)) {
26
+     if (tableToUse == "total_catches") {
27
+         dbTable <- "tunaatlas.total_catches_ird_labels"
28
+     }
29
+     if (t .... [TRUNCATED] 
30

    
31
> if (is.null(tableToUse)) {
32
+     if (is.null(time_aggregation)) {
33
+         if (time_frame >= 730 & !substr(area_filter, (nchar(area_filter) + 
34
+    .... [TRUNCATED] 
35

    
36
> if (!is.null(species_filter)) {
37
+     sp_filter <- unlist(strsplit(species_filter, split = ","))
38
+     if (nchar(sp_filter) == 3) {
39
+         specie .... [TRUNCATED] 
40

    
41
> if (species_AggregationLevel == "speciesgroup_tunaatlas") {
42
+     col_species <- paste("id_", species_AggregationLevel, sep = "")
43
+ }
44

    
45
> if (species_AggregationLevel == "species") {
46
+     col_species <- paste("id_", species_AggregationLevel, "_", 
47
+         codelistRef, sep = "")
48
+ }
49

    
50
> if (gear_AggregationLevel == "geargroup_tunaatlas") {
51
+     col_gear <- paste("id_", gear_AggregationLevel, sep = "")
52
+ }
53

    
54
> if (gear_AggregationLevel == "gear") {
55
+     col_gear <- paste("id_", gear_AggregationLevel, "_", codelistRef, 
56
+         sep = "")
57
+ }
58

    
59
> col_flag <- paste("id_flag_", codelistRef, sep = "")
60

    
61
> if (is.null(time_aggregation)) {
62
+     if (time_frame < 730) {
63
+         time_aggregation = "month"
64
+     }
65
+     else {
66
+         time_aggregation  .... [TRUNCATED] 
67

    
68
> if (time_aggregation %in% c("month", "quarter", "semester")) {
69
+     col_time <- paste("time.", time_aggregation, ",time.year", 
70
+         sep = "") .... [TRUNCATED] 
71

    
72
> if (time_aggregation %in% c("year", "decade")) {
73
+     col_time <- paste("time.", time_aggregation, sep = "")
74
+ }
75

    
76
> select_column_query <- paste(col_gear, " AS gear,", 
77
+     col_time, sep = "")
78

    
79
> where_clause_function <- function(column_name, filter) {
80
+     if (!is.null(filter)) {
81
+         filter = gsub(",", "','", filter)
82
+         filter  .... [TRUNCATED] 
83

    
84
> time_query_where_clause <- paste("time.time_start>='", 
85
+     time_start, "' AND time.time_end<='", time_end, "'", sep = "")
86

    
87
> species_query_where_clause <- where_clause_function(col_species, 
88
+     species_filter)
89

    
90
> flag_query_where_clause <- where_clause_function(col_flag, 
91
+     flag_filter)
92

    
93
> if (substr(area_filter, (nchar(area_filter) + 1) - 
94
+     1, nchar(area_filter)) == ")") {
95
+     col_area = "geom"
96
+     area_query_where_clause <-  .... [TRUNCATED] 
97

    
98
> where_clause <- paste("WHERE ", time_query_where_clause, 
99
+     species_query_where_clause, flag_query_where_clause, area_query_where_clause)
100

    
101
> if (time_aggregation %in% c("month", "quarter", "semester")) {
102
+     groupby_clause_time <- paste("time.", time_aggregation, ",time.year", 
103
+        .... [TRUNCATED] 
104

    
105
> if (time_aggregation %in% c("year", "decade")) {
106
+     groupby_clause_time <- paste("time.", time_aggregation, sep = "")
107
+ }
108

    
109
> groupby_clause <- paste("GROUP BY ", col_gear, ",", 
110
+     groupby_clause_time, sep = "")
111

    
112
> query <- paste("SELECT trunc(sum(v_catch)::numeric,2) as var,", 
113
+     select_column_query, " FROM ", dbTable, " JOIN time.time USING (id_time) ", 
114
 .... [TRUNCATED] 
115

    
116
> library(ggplot2)
117

    
118
> library(cowplot)
119

    
120
> library(pryr)
121

    
122
> library(RPostgreSQL)
123

    
124
> library(scales)
125

    
126
> options(warn = -1)
127

    
128
> if (time_aggregation %in% c("month", "quarter", "semester")) {
129
+     df_plot$time <- as.Date(paste(df_plot[, "year"], "-", df_plot[, 
130
+         time .... [TRUNCATED] 
131

    
132
> message("ok1")
133

    
134
> if (time_aggregation %in% c("year", "decade")) {
135
+     df_plot$time <- df_plot$year
136
+     df_plot$year <- NULL
137
+ }
138

    
139
> message("ok2")
140

    
141
> df_plot <- df_plot[order(df_plot$time, df_plot$gear), 
142
+     ]
143

    
144
> message("ok3")
145

    
146
> resplt <- ggplot(df_plot, aes(x = time, y = var, ymax = max(var) * 
147
+     1.05, group = gear)) + xlab("time") + ylab("catches (t)") + 
148
+     geom_ar .... [TRUNCATED] 
149

    
150
> message("ok4")
151

    
152
> filename <- "plot.png"
153

    
154
> ggsave(filename = filename, plot = resplt, dpi = 300)
155

    
156
> resplt <- filename
157

    
158
> message("ok5")
159
  adding: plot.png (deflated 12%)
160
null
161
Attaching package: ‘cowplot’
162

    
163
The following object is masked from ‘package:ggplot2’:
164

    
165
    ggsave
166

    
167
Loading required package: DBI
168
Ok21
169
trying URL 'http://mdst-macroes.ird.fr/BlueBridge/Tuna_Atlas/plot1_libraryIRDTunaAtlas.zip'
170
Content type 'application/zip' length 4580 bytes
171
==================================================
172
downloaded 4580 bytes
173

    
174
Ok22
175
Ok23
176
ok10
177
ok11
178
ok12
179
ok1
180
ok2
181
ok3
182
ok4
183
Saving 7 x 7 in image
184
ok5
185
ok13
186
ok14
187
Ok24
188
Ok25
189
Ok26
190
Ok27
191
Ok28
192
Ok29
193
Ok30
194
Error in eval(expr, envir, enclos) : object 'gfsd' not found
195
Calls: source -> withVisible -> eval -> eval
196
Execution halted
197
null
    (1-1/1)
    Add picture from clipboard (Maximum size: 8.91 MB)