@@ -25,7 +25,7 @@ map.station <- function (x=NULL,FUN=NULL, it=NULL,is=NULL,new=FALSE,
2525 na.rm = TRUE ,show.val = FALSE ,
2626 # #colorbar=TRUE,
2727 legend.shrink = 1 ,... ) {
28- # #
28+ # #
2929 if (verbose ) print(' map.station' )
3030 arg <- list (... )
3131
@@ -195,7 +195,8 @@ map.station <- function (x=NULL,FUN=NULL, it=NULL,is=NULL,new=FALSE,
195195 }
196196
197197
198- # # Transform x using FUN and insert color bar
198+ # # Transform x using FUN and insert color bar
199+ # #
199200 if (! is.null(FUN )) {
200201 if (is.element(FUN ,c(' lon' ,' lat' ,' alt' )))
201202 eval(parse(text = paste(' y <-' ,FUN ,' (x)' ,sep = " " )))
@@ -209,12 +210,13 @@ map.station <- function (x=NULL,FUN=NULL, it=NULL,is=NULL,new=FALSE,
209210 else
210211 y <- apply(coredata(x ),2 ,FUN = FUN ) # # ,na.rm=TRUE)
211212 }
212-
213+ y <- attrcp(x ,y )
214+ class(y ) <- class(x )
213215 # # AM 30-06-2015 ...
214216 if (is.logical(colbar )) {
215217 # # If colbar set to FALSE, treat it as set to NULL
216218 if (! colbar ) colbar <- NULL else
217- colbar <- list (palette = ' t2m' ,rev = FALSE ,n = 10 ,
219+ colbar <- list (pal = ' t2m' ,rev = FALSE ,n = 10 ,
218220 breaks = NULL ,type = " p" ,cex = 2 ,h = 0.6 , v = 1 ,pos = 0.1 ,show = TRUE )
219221 }
220222 # #
@@ -249,7 +251,8 @@ map.station <- function (x=NULL,FUN=NULL, it=NULL,is=NULL,new=FALSE,
249251 # # cex = cex*scale, xlab = "", ylab = "", xlim = xlim, ylim = ylim,...)
250252
251253 if (is.null(colbar $ pos )) pos <- 0.05
252- # #
254+
255+ # #
253256 # #fig0 <- par0$fig
254257 if (is.null(colbar $ show )) colbar $ show <- TRUE # # quick fix REB
255258 if (! is.null(FUN ) & (! is.null(colbar )) & colbar $ show ) {
@@ -291,7 +294,7 @@ map.station <- function (x=NULL,FUN=NULL, it=NULL,is=NULL,new=FALSE,
291294 # # par(fig=par0$fig)
292295 # # print(par()$fig)
293296 # # add search info to plot
294-
297+
295298 if (text ) {
296299 if (! is.null(highlight )) {
297300 title(main = paste(" SOURCE(S): " ,
@@ -328,11 +331,12 @@ map.station <- function (x=NULL,FUN=NULL, it=NULL,is=NULL,new=FALSE,
328331 if (text )
329332 mtext(paste((" ESD package - map.station() - MET Norway 2014" ),
330333 " (www.met.no)" ,sep = " " ),side = 1 ,line = 4 ,cex = 0.6 )
331-
332- if (! is.null(FUN )) {
334+ par1 <- par()
335+ if (! is.null(FUN )) {
333336 # #if (is.null(col)) colbar$col <- rep(col,length(colbar$col[icol]))
334337 # #
335338 if (! is.null(col )) col <- col else col <- colbar $ col [icol ]
339+
336340 points(ss $ longitude , ss $ latitude , pch = pch ,
337341 bg = colbar $ col [icol ], col = col , # #col=colbar$col[icol]
338342 cex = cex * scale , xlab = " " , ylab = " " ,
@@ -423,6 +427,7 @@ map.station <- function (x=NULL,FUN=NULL, it=NULL,is=NULL,new=FALSE,
423427 # # lines(geoborders$x, geoborders$y, col = "black")
424428 # # lines(attr(geoborders, "borders")$x, attr(geoborders, "borders")$y, col = "grey90")
425429 }
430+ return (par1 )
426431}
427432
428433
0 commit comments