[176] | 1 | load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" |
---|
| 2 | load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" |
---|
| 3 | load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" |
---|
| 4 | |
---|
[190] | 5 | ;*************************************************** |
---|
[418] | 6 | ; load .ncl.config or .ncl.config.default |
---|
[190] | 7 | ;*************************************************** |
---|
[194] | 8 | |
---|
| 9 | function which_script() |
---|
| 10 | local script |
---|
| 11 | begin |
---|
| 12 | script="spectra" |
---|
| 13 | return(script) |
---|
| 14 | end |
---|
[190] | 15 | |
---|
[418] | 16 | if (isfilepresent("$PALM_BIN/../../.ncl.config")) then |
---|
| 17 | loadscript("$PALM_BIN/../../.ncl.config") |
---|
[190] | 18 | else |
---|
[418] | 19 | if (isfilepresent("$PALM_BIN/NCL/.ncl.config.default")) then |
---|
| 20 | loadscript( "$PALM_BIN/NCL/.ncl.config.default") |
---|
[190] | 21 | else |
---|
[418] | 22 | palm_bin_path = getenv("PALM_BIN") |
---|
[190] | 23 | print(" ") |
---|
[418] | 24 | print("Neither the personal configuration file '.ncl.config' exists in") |
---|
| 25 | print("~/palm/current_version") |
---|
[566] | 26 | print("nor the default configuration file '.ncl.config.default' "+\ |
---|
| 27 | "exists in") |
---|
[418] | 28 | print(palm_bin_path + "/NCL") |
---|
[190] | 29 | print(" ") |
---|
| 30 | exit |
---|
[176] | 31 | end if |
---|
[418] | 32 | end if |
---|
[218] | 33 | |
---|
[190] | 34 | begin |
---|
[176] | 35 | |
---|
[190] | 36 | ;*************************************************** |
---|
[532] | 37 | ; Retrieving the NCL version used |
---|
| 38 | ;*************************************************** |
---|
| 39 | |
---|
| 40 | ncl_version_ch = systemfunc("ncl -V") |
---|
| 41 | ncl_version = stringtofloat(ncl_version_ch) |
---|
| 42 | |
---|
| 43 | ;*************************************************** |
---|
[526] | 44 | ; Retrieving the double quote character |
---|
| 45 | ;*************************************************** |
---|
| 46 | |
---|
| 47 | dq=str_get_dq() |
---|
| 48 | |
---|
| 49 | ;*************************************************** |
---|
[190] | 50 | ; set up default parameter values and strings |
---|
| 51 | ;*************************************************** |
---|
| 52 | |
---|
| 53 | if (file_1 .EQ. "File in") then |
---|
| 54 | print(" ") |
---|
[418] | 55 | print("Declare input file 'file_1=' in '.ncl.config' or prompt") |
---|
[190] | 56 | print(" ") |
---|
| 57 | exit |
---|
[176] | 58 | else |
---|
| 59 | file_in = file_1 |
---|
| 60 | end if |
---|
| 61 | |
---|
[566] | 62 | if (format_out .NE. "x11" .AND. format_out .NE. "pdf" .AND. \ |
---|
| 63 | format_out .NE. "eps" .AND. format_out .NE. "ps" .AND. \ |
---|
| 64 | format_out .NE. "epsi" .AND. format_out .NE. "ncgm" .AND. \ |
---|
| 65 | format_out .NE. "png")then |
---|
[190] | 66 | print(" ") |
---|
| 67 | print("'format_out = "+format_out+"' is invalid and set to'x11'") |
---|
| 68 | print(" ") |
---|
| 69 | format_out="x11" |
---|
| 70 | end if |
---|
[532] | 71 | |
---|
| 72 | if (ncl_version .LE. 5.1 .AND. format_out .EQ. "png") then |
---|
| 73 | print(" ") |
---|
| 74 | print("Output of png files not available") |
---|
| 75 | print("png output is avaiable with NCL version 5.2.0 and higher ") |
---|
| 76 | print("NCL version used: " + ncl_version_ch) |
---|
| 77 | print(" ") |
---|
| 78 | exit |
---|
| 79 | end if |
---|
[190] | 80 | |
---|
[218] | 81 | if (log_x .NE. 0 .AND. log_x .NE. 1)then |
---|
[190] | 82 | print(" ") |
---|
[218] | 83 | print("'log_x'= "+log_x+" is invalid and set to 1") |
---|
[190] | 84 | print(" ") |
---|
[218] | 85 | log_x = 1 |
---|
[190] | 86 | end if |
---|
| 87 | |
---|
[218] | 88 | if (log_y .NE. 0 .AND. log_y .NE. 1)then |
---|
[190] | 89 | print(" ") |
---|
[218] | 90 | print("'log_y'= "+log_y+" is invalid and set to 1") |
---|
[190] | 91 | print(" ") |
---|
[218] | 92 | log_y = 1 |
---|
[190] | 93 | end if |
---|
| 94 | |
---|
[218] | 95 | if (norm_y .EQ. 0.) then |
---|
[190] | 96 | print(" ") |
---|
[218] | 97 | print("Normalising with 0 is not allowed, 'norm_y' is set to 1.0") |
---|
[190] | 98 | print(" ") |
---|
[218] | 99 | norm_y = 1.0 |
---|
[176] | 100 | end if |
---|
[218] | 101 | if (norm_x .EQ. 0.) then |
---|
[190] | 102 | print(" ") |
---|
[218] | 103 | print("Normalising with 0 is not allowed, 'norm_x' is set to 1.0") |
---|
[190] | 104 | print(" ") |
---|
[218] | 105 | norm_x= 1.0 |
---|
[176] | 106 | end if |
---|
[190] | 107 | |
---|
| 108 | if (sort .NE. "height" .AND. sort .NE. "time") then |
---|
| 109 | print(" ") |
---|
| 110 | print("'sort'= "+sort+" is invalid and set to 'height'") |
---|
| 111 | print(" ") |
---|
| 112 | sort = "height" |
---|
[176] | 113 | end if |
---|
[190] | 114 | |
---|
| 115 | if (black .NE. 0 .AND. black .NE. 1)then |
---|
| 116 | print(" ") |
---|
| 117 | print("'black'= "+black+" is invalid and set to 0") |
---|
| 118 | print(" ") |
---|
[176] | 119 | black = 0 |
---|
| 120 | end if |
---|
[190] | 121 | |
---|
| 122 | if (dash .NE. 0 .AND. dash .NE. 1)then |
---|
| 123 | print(" ") |
---|
| 124 | print("'dash'= "+dash+" is invalid and set to 0") |
---|
| 125 | print(" ") |
---|
[176] | 126 | dash = 0 |
---|
| 127 | end if |
---|
| 128 | |
---|
[190] | 129 | ;*************************************************** |
---|
| 130 | ; open input file |
---|
| 131 | ;*************************************************** |
---|
[218] | 132 | |
---|
| 133 | file_in_1 = False |
---|
| 134 | if (isStrSubset(file_in, ".nc"))then |
---|
| 135 | start_f = -2 |
---|
| 136 | end_f = -2 |
---|
| 137 | file_in_1 = True |
---|
| 138 | end if |
---|
[176] | 139 | |
---|
[218] | 140 | if (start_f .EQ. -1)then |
---|
| 141 | print(" ") |
---|
[566] | 142 | print("'start_f' must be one of the cyclic numbers (at least 0) of "+\ |
---|
| 143 | "your input file(s)") |
---|
[218] | 144 | print(" ") |
---|
| 145 | exit |
---|
| 146 | end if |
---|
| 147 | if (end_f .EQ. -1)then |
---|
| 148 | print(" ") |
---|
[566] | 149 | print("'end_f' must be one of the cyclic numbers (at least 0) of "+\ |
---|
| 150 | "your input file(s)") |
---|
[218] | 151 | print(" ") |
---|
| 152 | exit |
---|
| 153 | end if |
---|
| 154 | |
---|
| 155 | files=new(end_f-start_f+1,string) |
---|
[176] | 156 | |
---|
[218] | 157 | if (file_in_1)then |
---|
| 158 | if (isfilepresent(file_in))then |
---|
| 159 | files(0)=file_in |
---|
| 160 | else |
---|
| 161 | print(" ") |
---|
| 162 | print("1st input file: '"+file_in+"' does not exist") |
---|
| 163 | print(" ") |
---|
| 164 | exit |
---|
| 165 | end if |
---|
| 166 | else |
---|
| 167 | if (start_f .EQ. 0)then |
---|
| 168 | if (isfilepresent(file_in+".nc"))then |
---|
| 169 | files(0)=file_in+".nc" |
---|
| 170 | do i=1,end_f |
---|
| 171 | if (isfilepresent(file_in+"."+i+".nc"))then |
---|
| 172 | files(i)=file_in+"."+i+".nc" |
---|
| 173 | else |
---|
| 174 | print(" ") |
---|
| 175 | print("Input file: '"+file_in+"."+i+".nc' does not exist") |
---|
| 176 | print(" ") |
---|
| 177 | exit |
---|
| 178 | end if |
---|
| 179 | end do |
---|
| 180 | else |
---|
| 181 | print(" ") |
---|
| 182 | print("Input file: '"+file_in+".nc' does not exist") |
---|
| 183 | print(" ") |
---|
| 184 | exit |
---|
| 185 | end if |
---|
| 186 | else |
---|
| 187 | do i=start_f,end_f |
---|
| 188 | if (isfilepresent(file_in+"."+i+".nc"))then |
---|
| 189 | files(i-start_f)=file_in+"."+i+".nc" |
---|
| 190 | else |
---|
| 191 | print(" ") |
---|
| 192 | print("Input file: '"+file_in+"."+i+".nc' does not exist") |
---|
| 193 | print(" ") |
---|
| 194 | exit |
---|
| 195 | end if |
---|
| 196 | end do |
---|
| 197 | end if |
---|
| 198 | end if |
---|
| 199 | |
---|
| 200 | f=addfiles(files,"r") |
---|
| 201 | f_att=addfile(files(0),"r") |
---|
| 202 | ListSetType(f,"cat") |
---|
| 203 | |
---|
| 204 | vNam = getfilevarnames(f_att) |
---|
[585] | 205 | vType = getfilevartypes(f_att,vNam) |
---|
| 206 | |
---|
| 207 | if ((all(vType .eq. "double"))) then ;distinction if data is double or float |
---|
| 208 | check_vType = True |
---|
| 209 | else |
---|
| 210 | check_vType = False |
---|
| 211 | end if |
---|
| 212 | |
---|
[176] | 213 | print(" ") |
---|
[190] | 214 | print("Variables in input file:") |
---|
| 215 | print("- "+ vNam) |
---|
[176] | 216 | print(" ") |
---|
| 217 | dim = dimsizes(vNam) |
---|
[218] | 218 | vDim = getfiledimsizes(f_att) |
---|
[176] | 219 | |
---|
[218] | 220 | t_all = f[:]->time |
---|
[176] | 221 | nt = dimsizes(t_all) |
---|
[827] | 222 | |
---|
| 223 | if (nt .EQ. 1)then |
---|
| 224 | delta_t=t_all(nt-1)/nt |
---|
| 225 | else |
---|
| 226 | delta_t_array = new(nt-1,double) |
---|
| 227 | |
---|
| 228 | do i=0,nt-2 |
---|
| 229 | delta_t_array(i) = t_all(i+1)-t_all(i) |
---|
| 230 | end do |
---|
| 231 | |
---|
| 232 | delta_t = min(delta_t_array) |
---|
| 233 | delete(delta_t_array) |
---|
| 234 | end if |
---|
[176] | 235 | |
---|
[218] | 236 | k_x=f_att->k_x |
---|
[190] | 237 | dimx=dimsizes(k_x) |
---|
[218] | 238 | k_y=f_att->k_y |
---|
[190] | 239 | dimy=dimsizes(k_y) |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | dim_level=dimsizes(height_level) |
---|
| 243 | |
---|
[176] | 244 | do i=0,dim-1 |
---|
| 245 | if (vNam(i) .EQ. "zu_sp")then |
---|
[218] | 246 | zu=f_att->zu_sp |
---|
[190] | 247 | if (height_level(0) .EQ. -1)then |
---|
| 248 | dimz=dimsizes(zu) |
---|
| 249 | else |
---|
| 250 | if (dim_level .GT. dimsizes(zu))then |
---|
| 251 | print(" ") |
---|
[566] | 252 | print("'height_level' has more elements than available "+\ |
---|
| 253 | "height levels in input file (= "+dimsizes(zu)+")") |
---|
[190] | 254 | print(" ") |
---|
| 255 | exit |
---|
| 256 | else |
---|
| 257 | zuh=new(dim_level,double) |
---|
| 258 | do le=0,dim_level-1 |
---|
[566] | 259 | if (height_level(le) .GE. dimsizes(zu)) then |
---|
| 260 | no_levels=dimsizes(zu)-1 |
---|
| 261 | print(" ") |
---|
| 262 | print("Element "+le+" of 'height_level' is greater " +\ |
---|
| 263 | "than the maximum available index in input file "+\ |
---|
| 264 | "which is "+no_levels+". Note that the first " +\ |
---|
| 265 | "element has the index 0.") |
---|
| 266 | print(" ") |
---|
| 267 | exit |
---|
| 268 | end if |
---|
[190] | 269 | zuh(le)=zu(height_level(le)) |
---|
| 270 | end do |
---|
| 271 | dimz=dim_level |
---|
| 272 | end if |
---|
| 273 | end if |
---|
[176] | 274 | else |
---|
| 275 | if (vNam(i) .EQ. "zw_sp")then |
---|
[218] | 276 | zw=f_att->zw_sp |
---|
[190] | 277 | if (height_level(0) .EQ. -1)then |
---|
| 278 | dimz=dimsizes(zw) |
---|
| 279 | else |
---|
| 280 | if (dim_level .GT. dimsizes(zw))then |
---|
| 281 | print(" ") |
---|
[566] | 282 | print("'height_level' has more elements than available "+\ |
---|
| 283 | "height levels in input file (= "+dimsizes(zw)+")") |
---|
[190] | 284 | print(" ") |
---|
| 285 | exit |
---|
| 286 | else |
---|
| 287 | zwh=new(dim_level,double) |
---|
| 288 | do le=0,dim_level-1 |
---|
[566] | 289 | if (height_level(le) .GE. dimsizes(zw)) then |
---|
| 290 | no_levels=dimsizes(zw)-1 |
---|
| 291 | print(" ") |
---|
| 292 | print("Element "+le+" of 'height_level' is greater "+\ |
---|
| 293 | "than the maximum available index in input " +\ |
---|
| 294 | "file which is "+no_levels+". Note that the " +\ |
---|
| 295 | "first element has the index 0.") |
---|
| 296 | print(" ") |
---|
| 297 | exit |
---|
| 298 | end if |
---|
[190] | 299 | zwh(le)=zw(height_level(le)) |
---|
| 300 | end do |
---|
| 301 | dimz=dim_level |
---|
| 302 | end if |
---|
| 303 | end if |
---|
[176] | 304 | end if |
---|
| 305 | end if |
---|
| 306 | end do |
---|
[190] | 307 | |
---|
| 308 | ;**************************************************** |
---|
[176] | 309 | ; start of time step and different types of mistakes that could be done |
---|
[190] | 310 | ;**************************************************** |
---|
[176] | 311 | |
---|
[190] | 312 | if (start_time_step .EQ. -1.d) then |
---|
[176] | 313 | start_time_step=t_all(0)/3600 |
---|
[190] | 314 | else |
---|
[176] | 315 | if (start_time_step .GT. t_all(nt-1)/3600)then |
---|
| 316 | print(" ") |
---|
[566] | 317 | print("'start_time_step' = "+ start_time_step +"h is greater than "+\ |
---|
| 318 | "last time step = "+ t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") |
---|
[176] | 319 | print(" ") |
---|
[218] | 320 | print("Select another 'start_time_step'") |
---|
[176] | 321 | print(" ") |
---|
| 322 | exit |
---|
| 323 | end if |
---|
| 324 | if (start_time_step .LT. t_all(0)/3600)then |
---|
| 325 | print(" ") |
---|
[566] | 326 | print("'start_time_step' = "+ start_time_step +"h is lower than "+\ |
---|
| 327 | "first time step = "+ t_all(0)+"s = "+t_all(0)/3600+"h") |
---|
[176] | 328 | exit |
---|
| 329 | end if |
---|
| 330 | end if |
---|
| 331 | |
---|
| 332 | do i=0,nt-1 |
---|
[566] | 333 | if (start_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \ |
---|
| 334 | start_time_step .LT. (t_all(i)+delta_t/2)/3600)then |
---|
[176] | 335 | st=i |
---|
| 336 | break |
---|
[769] | 337 | else |
---|
| 338 | st=0 |
---|
[176] | 339 | end if |
---|
| 340 | end do |
---|
| 341 | |
---|
[190] | 342 | ;**************************************************** |
---|
[176] | 343 | ; end of time step and different types of mistakes that could be done |
---|
[190] | 344 | ;**************************************************** |
---|
[176] | 345 | |
---|
[190] | 346 | if (end_time_step .EQ. -1.d) then |
---|
[176] | 347 | end_time_step = t_all(nt-1)/3600 |
---|
| 348 | else |
---|
| 349 | if (end_time_step .GT. t_all(nt-1)/3600)then |
---|
| 350 | print(" ") |
---|
[566] | 351 | print("'end_time_step' = "+ end_time_step +"h is greater than "+\ |
---|
| 352 | "last time step = " + t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") |
---|
[176] | 353 | print(" ") |
---|
[218] | 354 | print("Select another 'end_time_step'") |
---|
[176] | 355 | print(" ") |
---|
| 356 | exit |
---|
| 357 | end if |
---|
| 358 | if (end_time_step .LT. start_time_step/3600)then |
---|
| 359 | print(" ") |
---|
[566] | 360 | print("'end_time_step' = "+ end_time_step +"h is lower than "+\ |
---|
| 361 | "'start_time_step' = "+start_time_step+"h") |
---|
[176] | 362 | print(" ") |
---|
[218] | 363 | print("Select another 'start_time_step' or 'end_time_step'") |
---|
[176] | 364 | print(" ") |
---|
| 365 | exit |
---|
| 366 | end if |
---|
| 367 | end if |
---|
| 368 | |
---|
| 369 | do i=0,nt-1 |
---|
[566] | 370 | if (end_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \ |
---|
| 371 | end_time_step .LT. (t_all(i)+delta_t/2)/3600)then |
---|
[176] | 372 | et=i |
---|
| 373 | break |
---|
[769] | 374 | else |
---|
| 375 | et=0 |
---|
[176] | 376 | end if |
---|
| 377 | end do |
---|
| 378 | |
---|
| 379 | delete(start_time_step) |
---|
| 380 | start_time_step=round(st,3) |
---|
| 381 | delete(end_time_step) |
---|
| 382 | end_time_step=round(et,3) |
---|
| 383 | |
---|
| 384 | print(" ") |
---|
[566] | 385 | print("Output of time steps from "+t_all(start_time_step)/3600+" h = "+\ |
---|
| 386 | t_all(start_time_step)+" s => index = "+start_time_step) |
---|
| 387 | print(" till "+t_all(end_time_step)/3600+" h = "+\ |
---|
| 388 | t_all(end_time_step)+" s => index = "+end_time_step) |
---|
[176] | 389 | print(" ") |
---|
| 390 | |
---|
| 391 | dimt = end_time_step-start_time_step+1 |
---|
| 392 | |
---|
[190] | 393 | ;*************************************************** |
---|
[176] | 394 | ; set up recourses |
---|
[190] | 395 | ;*************************************************** |
---|
[176] | 396 | |
---|
| 397 | res = True |
---|
| 398 | res@gsnDraw = False |
---|
| 399 | res@gsnFrame = False |
---|
| 400 | res@txFont = "helvetica" |
---|
| 401 | res@tiMainFont = "helvetica" |
---|
| 402 | res@tiXAxisFont = "helvetica" |
---|
| 403 | res@tiYAxisFont = "helvetica" |
---|
| 404 | res@tmXBLabelFont = "helvetica" |
---|
| 405 | res@tmYLLabelFont = "helvetica" |
---|
| 406 | res@lgLabelFont = "helvetica" |
---|
| 407 | res@tmLabelAutoStride = True |
---|
| 408 | |
---|
[218] | 409 | res@lgLabelFontHeightF = font_size_legend |
---|
| 410 | res@lgTitleFontHeightF = font_size |
---|
| 411 | res@txFontHeightF = font_size |
---|
| 412 | res@tiXAxisFontHeightF = font_size |
---|
| 413 | res@tiYAxisFontHeightF = font_size |
---|
| 414 | res@tmXBLabelFontHeightF = font_size |
---|
| 415 | res@tmYLLabelFontHeightF = font_size |
---|
| 416 | |
---|
| 417 | res@tmXBMinorPerMajor = 4 |
---|
| 418 | res@tmYLMinorPerMajor = 4 |
---|
| 419 | |
---|
| 420 | if (log_x .EQ. 1) then |
---|
[176] | 421 | res@trXLog = True |
---|
[190] | 422 | else |
---|
| 423 | res@trXLog = False |
---|
| 424 | end if |
---|
[218] | 425 | if (log_y .EQ. 1)then |
---|
[176] | 426 | res@trYLog = True |
---|
[190] | 427 | else |
---|
[178] | 428 | res@trYLog = False |
---|
[176] | 429 | end if |
---|
| 430 | |
---|
[566] | 431 | legend_label=new(dimt,string) |
---|
[176] | 432 | legend_label_zu=new(dimz,double) |
---|
| 433 | legend_label_zw=new(dimz,double) |
---|
| 434 | legend_label_z=new(dimz,double) |
---|
| 435 | do p=start_time_step,end_time_step |
---|
[566] | 436 | legend_label(p-start_time_step)=sprintf("%6.2f", t_all(p)/3600) |
---|
[176] | 437 | end do |
---|
| 438 | if (sort .EQ. "time") |
---|
| 439 | plot = new(dim*dimz,graphic) |
---|
| 440 | np=dimt |
---|
[534] | 441 | res@lgTitleString = "Time (h)" |
---|
[176] | 442 | else |
---|
| 443 | plot = new(dim*dimt,graphic) |
---|
| 444 | np=dimz |
---|
[218] | 445 | |
---|
[176] | 446 | do p=0,dimz-1 |
---|
[190] | 447 | if (height_level(0) .EQ. -1)then |
---|
| 448 | legend_label_zu(p)=round(zu(p),3) |
---|
| 449 | legend_label_zw(p)=round(zw(p),3) |
---|
| 450 | else |
---|
| 451 | legend_label_zu(p)=round(zuh(p),3) |
---|
| 452 | legend_label_zw(p)=round(zwh(p),3) |
---|
| 453 | end if |
---|
[176] | 454 | end do |
---|
| 455 | end if |
---|
[194] | 456 | |
---|
| 457 | if (black .eq. 0 ) then |
---|
| 458 | if (np .EQ. 1)then |
---|
[218] | 459 | color = 237 |
---|
[194] | 460 | else |
---|
| 461 | step=round(235/(np-1),3) |
---|
[218] | 462 | color = ispan(2,237,step) |
---|
[194] | 463 | end if |
---|
[324] | 464 | else |
---|
| 465 | color = 2 |
---|
[176] | 466 | end if |
---|
| 467 | if ( dash .eq. 0 ) then |
---|
[190] | 468 | res@xyMonoDashPattern = True |
---|
[176] | 469 | end if |
---|
| 470 | |
---|
[532] | 471 | if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then |
---|
| 472 | format_out@wkPaperSize = "A4" |
---|
| 473 | end if |
---|
| 474 | if ( format_out .EQ. "png" ) then |
---|
| 475 | format_out@wkWidth = 1000 |
---|
| 476 | format_out@wkHeight = 1000 |
---|
| 477 | end if |
---|
| 478 | |
---|
[176] | 479 | wks=gsn_open_wks(format_out,file_out) |
---|
| 480 | gsn_define_colormap(wks,"rainbow+white") |
---|
| 481 | |
---|
| 482 | n=0 |
---|
| 483 | do varn =dim-1,0,1 |
---|
[178] | 484 | |
---|
[176] | 485 | check = True |
---|
| 486 | |
---|
[566] | 487 | if ( isStrSubset( vNam(varn), "time") .OR. \ |
---|
| 488 | isStrSubset( vNam(varn), "zu_sp") .OR. \ |
---|
| 489 | isStrSubset( vNam(varn), "zw_sp") .OR. \ |
---|
| 490 | isStrSubset( vNam(varn), "k_x") .OR. \ |
---|
| 491 | isStrSubset( vNam(varn), "k_y")) then |
---|
[176] | 492 | check = False |
---|
| 493 | end if |
---|
| 494 | |
---|
[190] | 495 | if (var .NE. "all") then |
---|
[176] | 496 | check = isStrSubset( var,","+vNam(varn)+"," ) |
---|
| 497 | end if |
---|
| 498 | |
---|
[190] | 499 | if(check) then |
---|
[218] | 500 | |
---|
| 501 | temp = f[:]->$vNam(varn)$ |
---|
[566] | 502 | data = temp(start_time_step:end_time_step,0:dimz-1,:) |
---|
[218] | 503 | |
---|
| 504 | temp_att = f_att->$vNam(varn)$ |
---|
| 505 | a=getvardims(temp_att) |
---|
[190] | 506 | b=dimsizes(a) |
---|
[534] | 507 | delete(temp_att) |
---|
[176] | 508 | |
---|
[190] | 509 | if (height_level(0) .NE. -1)then |
---|
| 510 | do te=0,dimz-1 |
---|
[566] | 511 | data(:,te,:) = temp(start_time_step:end_time_step,\ |
---|
| 512 | height_level(te),:) |
---|
[190] | 513 | end do |
---|
| 514 | end if |
---|
| 515 | |
---|
[566] | 516 | data=data/(norm_y*norm_x) |
---|
[190] | 517 | |
---|
[176] | 518 | do i=0,b-1 |
---|
| 519 | if (isStrSubset( a(i),"zu_sp" ))then |
---|
| 520 | legend_label_z=legend_label_zu |
---|
[190] | 521 | if (height_level(0) .NE. -1)then |
---|
| 522 | z=zuh |
---|
| 523 | else |
---|
| 524 | z=zu |
---|
| 525 | end if |
---|
[176] | 526 | else |
---|
| 527 | if (isStrSubset( a(i),"zw_sp" ))then |
---|
[190] | 528 | legend_label_z=legend_label_zw |
---|
| 529 | if (height_level(0) .NE. -1)then |
---|
| 530 | z=zwh |
---|
| 531 | else |
---|
| 532 | z=zw |
---|
| 533 | end if |
---|
[176] | 534 | end if |
---|
| 535 | end if |
---|
| 536 | end do |
---|
[218] | 537 | |
---|
[585] | 538 | if (check_vType) then |
---|
| 539 | min_y=new(dimz,double) |
---|
| 540 | max_y=new(dimz,double) |
---|
| 541 | else |
---|
| 542 | min_y=new(dimz,float) |
---|
| 543 | max_y=new(dimz,float) |
---|
| 544 | end if |
---|
[218] | 545 | min_x=new(dimz,double) |
---|
| 546 | max_x=new(dimz,double) |
---|
[585] | 547 | |
---|
[218] | 548 | plot_h = new(dimz,graphic) |
---|
| 549 | |
---|
[176] | 550 | if (isStrSubset(vNam(varn),"x"))then |
---|
[218] | 551 | x_axis = new((/dimz,dimx/),double) |
---|
| 552 | do q=0,dimz-1 |
---|
| 553 | x_axis(q,:) = f_att->k_x |
---|
| 554 | x_axis = x_axis/norm_x |
---|
| 555 | end do |
---|
| 556 | if (norm_x .NE. 1.)then |
---|
[534] | 557 | res@tiXAxisString = "k~B~x~N~ ("+unit_x+")" |
---|
[190] | 558 | else |
---|
[218] | 559 | if (norm_height .EQ. 1)then |
---|
[534] | 560 | res@tiXAxisString = "k~B~x~N~ x z (1" |
---|
[218] | 561 | else |
---|
[534] | 562 | res@tiXAxisString = "k~B~x~N~ (1/m)" |
---|
[218] | 563 | end if |
---|
[190] | 564 | end if |
---|
[218] | 565 | dim_r=dimx |
---|
[176] | 566 | else |
---|
[218] | 567 | x_axis=new((/dimz,dimy/),double) |
---|
| 568 | do q=0,dimz-1 |
---|
| 569 | x_axis(q,:) = f_att->k_y |
---|
| 570 | x_axis = x_axis/norm_x |
---|
| 571 | end do |
---|
| 572 | if (norm_x .NE. 1.)then |
---|
[534] | 573 | res@tiXAxisString = "k~B~x~N~ ("+unit_x+")" |
---|
[190] | 574 | else |
---|
[218] | 575 | if (norm_height .EQ. 1)then |
---|
[534] | 576 | res@tiXAxisString = "k~B~x~N~ x z (1)" |
---|
[218] | 577 | else |
---|
[534] | 578 | res@tiXAxisString = "k~B~x~N~ (1/m)" |
---|
[218] | 579 | end if |
---|
[190] | 580 | end if |
---|
[218] | 581 | dim_r=dimy |
---|
[176] | 582 | end if |
---|
| 583 | |
---|
| 584 | if (sort .EQ. "time") |
---|
[218] | 585 | res@xyLineColors = color |
---|
| 586 | res@pmLegendDisplayMode = "Always" |
---|
| 587 | res@pmLegendSide = "Top" |
---|
| 588 | res@pmLegendParallelPosF = 1.2 |
---|
| 589 | res@pmLegendOrthogonalPosF = -1.0 |
---|
| 590 | res@pmLegendWidthF = 0.12 |
---|
[566] | 591 | res@pmLegendHeightF = 0.04*\ |
---|
| 592 | (end_time_step-start_time_step+1) |
---|
[190] | 593 | do p=dimz-1,0,1 |
---|
[218] | 594 | if (log_y .EQ. 1)then |
---|
[190] | 595 | do q=0,dimt-1 |
---|
[218] | 596 | do r=0,dim_r-1 |
---|
| 597 | if (data(q,p,r) .EQ. 0)then |
---|
[190] | 598 | st=p+start_time_step |
---|
| 599 | print(" ") |
---|
[566] | 600 | print("'"+vNam(varn)+"("+st+","+q+","+r+")' is "+\ |
---|
| 601 | "equal 0. Logarithmic scale for y-axis "+\ |
---|
| 602 | "and height "+z(p)+" cannot be used") |
---|
[190] | 603 | print(" ") |
---|
| 604 | res@trYLog = False |
---|
| 605 | end if |
---|
| 606 | end do |
---|
[176] | 607 | end do |
---|
[190] | 608 | end if |
---|
[176] | 609 | res@gsnLeftString = vNam(varn) |
---|
[218] | 610 | res@gsnRightString = "Height = "+z(p)+"m" |
---|
[534] | 611 | res@tiYAxisString = "("+unit_y+")" |
---|
[218] | 612 | res@xyExplicitLegendLabels = legend_label |
---|
| 613 | if (norm_height .EQ. 1)then |
---|
| 614 | data(:,p,:)=data(:,p,:)*doubletofloat(z(p)) |
---|
| 615 | x_axis(p,:) = x_axis(p,:)*z(p) |
---|
| 616 | end if |
---|
| 617 | res@trXMinF = min(x_axis(p,:)) |
---|
| 618 | res@trXMaxF = max(x_axis(p,:)) |
---|
| 619 | plot(n) = gsn_csm_xy(wks,x_axis(p,:),data(:,p,:),res) |
---|
[176] | 620 | n=n+1 |
---|
| 621 | end do |
---|
| 622 | else |
---|
[190] | 623 | if (sort .EQ. "height") |
---|
| 624 | do p=0,dimt-1 |
---|
[176] | 625 | do q=0,dimz-1 |
---|
[218] | 626 | do r=0,dim_r-1 |
---|
| 627 | if (data(p,q,r) .EQ. 0)then |
---|
[176] | 628 | st=p+start_time_step |
---|
| 629 | print(" ") |
---|
[566] | 630 | print("'"+vNam(varn)+"("+st+","+q+","+r+")' "+\ |
---|
| 631 | "is equal 0. Logarithmic scale for y-axis "+\ |
---|
| 632 | "and time "+legend_label(p)+" h cannot be used") |
---|
[176] | 633 | print(" ") |
---|
| 634 | res@trYLog = False |
---|
| 635 | end if |
---|
| 636 | end do |
---|
[218] | 637 | if (norm_height .EQ. 1 .AND. p .EQ. 0)then |
---|
[566] | 638 | data(p,q,:) = data(p,q,:)*\ |
---|
| 639 | doubletofloat(legend_label_z(q)) |
---|
| 640 | x_axis(q,:) = x_axis(q,:)*\ |
---|
| 641 | doubletofloat(legend_label_z(q)) |
---|
[218] | 642 | end if |
---|
| 643 | max_y(q)=max(data(p,q,:)) |
---|
| 644 | min_y(q)=min(data(p,q,:)) |
---|
| 645 | min_x(q)=min(x_axis(q,:)) |
---|
[566] | 646 | max_x(q)=max(x_axis(q,:)) |
---|
[218] | 647 | end do |
---|
| 648 | do q=0,dimz-1 |
---|
| 649 | res@xyLineColor = color(q) |
---|
| 650 | if (dash .EQ. 1)then |
---|
| 651 | res@xyDashPattern = q |
---|
| 652 | end if |
---|
| 653 | if (q .EQ. 0)then |
---|
[566] | 654 | res@tiYAxisString = "("+unit_y+")" |
---|
[218] | 655 | res@gsnLeftString = vNam(varn) |
---|
| 656 | res@gsnRightString = "Time = "+legend_label(p)+"h" |
---|
| 657 | res@trXMinF = min(min_x) |
---|
| 658 | res@trXMaxF = max(max_x) |
---|
| 659 | res@trYMinF = min(min_y) |
---|
| 660 | res@trYMaxF = max(max_y) |
---|
| 661 | |
---|
[566] | 662 | plot_h(q) = gsn_csm_xy(wks,x_axis(q,:),\ |
---|
| 663 | data(p,q,:),res) |
---|
[218] | 664 | |
---|
| 665 | lgres = True |
---|
| 666 | if (dash .EQ. 0)then |
---|
| 667 | lgres@lgMonoDashIndex = True |
---|
| 668 | else |
---|
| 669 | lgres@lgDashIndexes = ispan(0,dimz-1,1) |
---|
| 670 | end if |
---|
| 671 | if (black .EQ. 1)then |
---|
| 672 | lgres@lgMonoLineColors = True |
---|
| 673 | else |
---|
| 674 | lgres@lgLineColors = color |
---|
| 675 | end if |
---|
[566] | 676 | lgres@lgTitleString = "Height (m)" |
---|
[218] | 677 | lgres@lgLabelFont = "helvetica" |
---|
[566] | 678 | lgres@lgLabelFontHeightF = font_size_legend*6 |
---|
| 679 | lgres@lgTitleFontHeightF = font_size |
---|
[218] | 680 | lgres@vpWidthF = 0.12 |
---|
[566] | 681 | lgres@vpHeightF = font_size_legend*(dimz+3) |
---|
[218] | 682 | |
---|
[566] | 683 | lbid = gsn_create_legend(wks,dimz,legend_label_z,lgres) |
---|
[218] | 684 | |
---|
| 685 | amres = True |
---|
| 686 | amres@amParallelPosF = 0.75 |
---|
| 687 | amres@amOrthogonalPosF = 0.15 |
---|
| 688 | annoid1 = gsn_add_annotation(plot_h(q),lbid,amres) |
---|
| 689 | else |
---|
[566] | 690 | plot_h(q) = gsn_csm_xy(wks,x_axis(q,:),\ |
---|
| 691 | data(p,q,:),res) |
---|
[218] | 692 | overlay(plot_h(0),plot_h(q)) |
---|
| 693 | end if |
---|
| 694 | end do |
---|
| 695 | plot(n)=plot_h(0) |
---|
| 696 | n=n+1 |
---|
[176] | 697 | end do |
---|
| 698 | end if |
---|
[190] | 699 | end if |
---|
[218] | 700 | delete(data) |
---|
| 701 | delete(temp) |
---|
[178] | 702 | delete(x_axis) |
---|
[218] | 703 | delete(min_x) |
---|
| 704 | delete(max_x) |
---|
| 705 | delete(min_y) |
---|
| 706 | delete(max_y) |
---|
| 707 | delete(plot_h) |
---|
[176] | 708 | end if |
---|
| 709 | end do |
---|
| 710 | |
---|
| 711 | if (n .EQ. 0) then |
---|
| 712 | print(" ") |
---|
[190] | 713 | print("The variables 'var="+var+"' do not exist on your input file;") |
---|
| 714 | print("be sure to have one comma berfore and after each variable") |
---|
[176] | 715 | print(" ") |
---|
| 716 | exit |
---|
| 717 | end if |
---|
| 718 | |
---|
| 719 | ; *************************************************** |
---|
| 720 | ; merge plots onto one page |
---|
| 721 | ; *************************************************** |
---|
| 722 | |
---|
| 723 | resP = True |
---|
| 724 | resP@txFont = "helvetica" |
---|
[218] | 725 | resP@txString = f_att@title |
---|
[176] | 726 | resP@txFuncCode = "~" |
---|
[218] | 727 | resP@txFontHeightF = 0.015 |
---|
[176] | 728 | |
---|
[534] | 729 | no_frames = 0 |
---|
| 730 | |
---|
[566] | 731 | if ((format_out .EQ. "eps" .OR. format_out .EQ. "epsi") .AND. \ |
---|
| 732 | n .gt. no_rows*no_columns) then |
---|
[183] | 733 | gsn_panel(wks,plot,(/n,1/),resP) |
---|
[250] | 734 | print(" ") |
---|
| 735 | print("Outputs to .eps or .epsi have only one frame") |
---|
| 736 | print(" ") |
---|
[176] | 737 | else |
---|
[218] | 738 | do i = 0,n-1, no_rows*no_columns |
---|
| 739 | if( (i+no_rows*no_columns) .gt. (n-1)) then |
---|
| 740 | gsn_panel(wks,plot(i:n-1),(/no_rows,no_columns/),resP) |
---|
[534] | 741 | no_frames = no_frames + 1 |
---|
[176] | 742 | else |
---|
[566] | 743 | gsn_panel(wks,plot(i:i+no_rows*no_columns-1),\ |
---|
| 744 | (/no_rows,no_columns/),resP) |
---|
[534] | 745 | no_frames = no_frames + 1 |
---|
[176] | 746 | end if |
---|
| 747 | end do |
---|
| 748 | end if |
---|
| 749 | |
---|
[532] | 750 | if (format_out .EQ. "png" ) then |
---|
| 751 | png_output = new((/no_frames/), string) |
---|
| 752 | j = 0 |
---|
| 753 | |
---|
[957] | 754 | if (no_frames .eq. 1) then |
---|
| 755 | if (ncl_version .GE. 6 ) then |
---|
| 756 | png_output(0) = file_out+".png" |
---|
| 757 | else |
---|
| 758 | png_output(0) = file_out+".00000"+1+".png" |
---|
| 759 | end if |
---|
| 760 | ;using imagemagick's convert for reducing the white |
---|
| 761 | ;space around the plot |
---|
| 762 | cmd = "convert -geometry 1000x1000 -density 300 -trim " + \ |
---|
| 763 | png_output(0) + " " + png_output(0) |
---|
[532] | 764 | system(cmd) |
---|
[957] | 765 | else |
---|
[532] | 766 | |
---|
[957] | 767 | do i=0, no_frames-1 |
---|
| 768 | j = i + 1 |
---|
| 769 | if (j .LE. 9) then |
---|
| 770 | png_output(i) = file_out+".00000"+j+".png" |
---|
| 771 | end if |
---|
| 772 | if (j .GT. 9 .AND. j .LE. 99) then |
---|
| 773 | png_output(i) = file_out+".0000"+j+".png" |
---|
| 774 | end if |
---|
| 775 | if (j .GT. 99 .AND. j .LE. 999) then |
---|
| 776 | png_output(i) = file_out+".000"+j+".png" |
---|
| 777 | end if |
---|
| 778 | if (j .GT. 999) then |
---|
| 779 | png_output(i) = file_out+".00"+j+".png" |
---|
| 780 | end if |
---|
| 781 | |
---|
| 782 | ;using imagemagick's convert for reducing the white |
---|
| 783 | ;space around the plot |
---|
| 784 | cmd = "convert -geometry 1000x1000 -density 300 -trim " + \ |
---|
| 785 | png_output(i) + " " + png_output(i) |
---|
| 786 | system(cmd) |
---|
| 787 | end do |
---|
| 788 | end if |
---|
| 789 | |
---|
[532] | 790 | print(" ") |
---|
| 791 | print("Output to: "+ png_output) |
---|
| 792 | print(" ") |
---|
| 793 | else |
---|
| 794 | print(" ") |
---|
| 795 | print("Output to: " + file_out +"."+ format_out) |
---|
| 796 | print(" ") |
---|
| 797 | end if |
---|
[176] | 798 | |
---|
[190] | 799 | end |
---|