Project

General

Profile

« Previous | Next » 

Revision 339fcf3d

Added by Benoit Parmentier about 8 years ago

Changes to plotting function for raster mosaic and other

View differences:

climate/research/oregon/interpolation/global_product_assessment_part2_functions.R
19 19
#
20 20
#setfacl -Rmd user:aguzman4:rwx /nobackupp8/bparmen1/output_run10_1500x4500_global_analyses_pred_1992_10052015
21 21

  
22
##COMMIT: time profiles run on multiple selected stations and fixing bugs 
22
##COMMIT: Changes to plotting function for raster mosaic and other 
23 23

  
24 24
#################################################################################################
25 25

  
......
153 153
  raster_name_tmp <- gsub(extension_str,"",basename(raster_name))
154 154
  
155 155
  date_proc <- l_dates[i]
156
  date_val <- as.Date(strptime(date_proc,"%Y%m%d"))
157
  #month_name <- month.name(date_val)
156
  if(class(date_proc)!="Date"){
157
    date_val <- as.Date(strptime(date_proc,"%Y%m%d"))
158
    #month_name <- month.name(date_val)
159
  }else{
160
    date_val <- date_proc
161
  }
162
  
158 163
  month_str <- format(date_val, "%b") ## Month, char, abbreviated
159 164
  year_str <- format(date_val, "%Y") ## Year with century
160 165
  day_str <- as.numeric(format(date_val, "%d")) ## numeric month
......
167 172
  
168 173
  
169 174
  if(is.null(zlim_val)){
175
    
176
    if(is.na(minValue(r_pred))){
177
      r_pred <- setMinMax(r_pred)
178
    }
179
    
170 180
    zlim_val_str <- paste(c(minValue(r_pred),maxValue(r_pred)),sep="_",collapse="_")
171 181
    #png_filename <-  file.path(out_dir,paste("Figure4_clim_mosaics_day_","_",date_proc,"_",region_name,"_zlim_",zlim_val_str,"_",out_suffix,".png",sep =""))
172
    raster_name_tmp
182
    #raster_name_tmp
173 183
    png_filename <-  file.path(out_dir,paste("Figure_",raster_name_tmp,"_zlim_",zlim_val_str,"_",out_suffix,".png",sep =""))
174 184
    
175 185
    title_str <-  paste("Predicted ",variable_name, " on ",date_str , " ", sep = "")
176
  
186
    #browser()
187
    
177 188
    png(filename=png_filename,width = col_mfrow * res_pix,height = row_mfrow * res_pix)
178 189

  
179 190
    plot(r_pred,main =title_str,cex.main =1.5,col=matlab.like(255),
......
183 194
       #legend.args=list(text='dNBR', side=4, line=2.49, cex=1.6))
184 195
    dev.off()
185 196
  }else{
197
    
186 198
    zlim_val_str <- paste(zlim_val,sep="_",collapse="_")
187 199
    #png_filename <-  file.path(out_dir,paste("Figure_mosaics_day_","_",date_proc,"_",region_name,"_",zlim_val_str,"_",out_suffix,".png",sep =""))
200
    
188 201
    png_filename <-  file.path(out_dir,paste("Figure_",raster_name_tmp,"_zlim_",zlim_val_str,"_",out_suffix,".png",sep =""))
189 202

  
190 203
    title_str <-  paste("Predicted ",variable_name, " on ",date_str , " ", sep = "")
204
    
191 205
    png(filename=png_filename,width = col_mfrow * res_pix,height = row_mfrow * res_pix)
192 206
    
193 207
    plot(r_pred,main =title_str,cex.main =1.5,col=matlab.like(255),zlim=zlim_val,
......
197 211
       #legend.args=list(text='dNBR', side=4, line=2.49, cex=1.6))
198 212
    dev.off()
199 213
  }
214
  
200 215
  return(png_filename)
201 216
}
202 217

  

Also available in: Unified diff