Changeset 218 for palm/trunk/SCRIPTS/NCL/timeseries.ncl
- Timestamp:
- Dec 10, 2008 9:14:34 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/NCL/timeseries.ncl
r194 r218 33 33 ; set up default parameter values and strings 34 34 ;*************************************************** 35 35 36 36 if (file_1 .EQ. "File in") then 37 37 print(" ") 38 print(" Please provide 1st input file 'file_1=' in 'ncl_preferences.ncl'")38 print("Declare input file 'file_1=' in 'ncl_preferences.ncl' or prompt") 39 39 print(" ") 40 40 exit … … 42 42 file_in = file_1 43 43 end if 44 if (.not. isfilepresent(file_in)) then45 print(" ")46 print("1st input file: '"+file_in+"' does not exist")47 print(" ")48 exit49 end if50 44 51 45 if (format_out .NE. "x11" .AND. format_out .NE. "pdf" .AND. format_out .NE. "eps" .AND. format_out .NE. "ps" .AND. format_out .NE. "epsi" .AND. format_out .NE. "ncgm")then … … 61 55 print(" ") 62 56 over = 0 63 end if 57 end if 58 59 if (norm_t .EQ. 0) then 60 print(" ") 61 print("Normalising with 0 is not allowed, 'norm_t' is set to 1.0") 62 print(" ") 63 norm_t = 1.0 64 end if 64 65 65 66 … … 67 68 ; open input file 68 69 ;*************************************************** 69 70 f = addfile(file_in , "r" ) 71 72 vNam = getfilevarnames(f) 70 71 file_in_1 = False 72 if (isStrSubset(file_in, ".nc"))then 73 start_f = -2 74 end_f = -2 75 file_in_1 = True 76 end if 77 78 if (start_f .EQ. -1)then 79 print(" ") 80 print("'start_f' must be one of the cyclic numbers (at least 0) of your input file(s)") 81 print(" ") 82 exit 83 end if 84 if (end_f .EQ. -1)then 85 print(" ") 86 print("'end_f' must be one of the cyclic numbers (at least 0) of your input file(s)") 87 print(" ") 88 exit 89 end if 90 91 files=new(end_f-start_f+1,string) 92 93 if (file_in_1)then 94 if (isfilepresent(file_in))then 95 files(0)=file_in 96 else 97 print(" ") 98 print("1st input file: '"+file_in+"' does not exist") 99 print(" ") 100 exit 101 end if 102 else 103 if (start_f .EQ. 0)then 104 if (isfilepresent(file_in+".nc"))then 105 files(0)=file_in+".nc" 106 do i=1,end_f 107 if (isfilepresent(file_in+"."+i+".nc"))then 108 files(i)=file_in+"."+i+".nc" 109 else 110 print(" ") 111 print("Input file: '"+file_in+"."+i+".nc' does not exist") 112 print(" ") 113 exit 114 end if 115 end do 116 else 117 print(" ") 118 print("Input file: '"+file_in+".nc' does not exist") 119 print(" ") 120 exit 121 end if 122 else 123 do i=start_f,end_f 124 if (isfilepresent(file_in+"."+i+".nc"))then 125 files(i-start_f)=file_in+"."+i+".nc" 126 else 127 print(" ") 128 print("Input file: '"+file_in+"."+i+".nc' does not exist") 129 print(" ") 130 exit 131 end if 132 end do 133 end if 134 end if 135 136 f=addfiles(files,"r") 137 f_att=addfile(files(0),"r") 138 ListSetType(f,"cat") 139 140 vNam=getfilevarnames(f_att) 141 73 142 print(" ") 74 143 print("Variables in input file:") … … 82 151 end if 83 152 84 t_all = f ->time153 t_all = f[:]->time 85 154 nt = dimsizes(t_all) 86 155 delta_t=t_all(nt-1)/nt 87 156 88 157 ;**************************************************** 89 158 ; start of time step and different types of mistakes that could be done … … 97 166 print("'start_time_step' = "+ start_time_step +"h is equal or greater than last time step = " + t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") 98 167 print(" ") 99 print(" Please select another 'start_time_step'")168 print("Select another 'start_time_step'") 100 169 print(" ") 101 170 exit … … 105 174 print("'start_time_step' = "+ start_time_step +"h is lower than first time step = " + t_all(0)+"s = "+t_all(0)/3600+"h") 106 175 print(" ") 107 print(" Please select another 'start_time_step'")176 print("Select another 'start_time_step'") 108 177 print(" ") 109 178 exit … … 123 192 print("'start_time_step' = "+ start_time_step +"h is invalid") 124 193 print(" ") 125 print(" Please select another 'start_time_step'")194 print("Select another 'start_time_step'") 126 195 print(" ") 127 196 exit … … 139 208 print("'end_time_step' = "+end_time_step+ "h is lower or equal than first time step = " + t_all(0)+"s = "+t_all(0)/3600+"h") 140 209 print(" ") 141 print(" Please select another 'end_time_step'")210 print("Select another 'end_time_step'") 142 211 print(" ") 143 212 exit … … 147 216 print("'end_time_step' = "+ end_time_step +"h is greater than last time step = " + t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") 148 217 print(" ") 149 print(" Please select another 'end_time_step'")218 print("Select another 'end_time_step'") 150 219 print(" ") 151 220 exit … … 155 224 print("'end_time_step' = "+ end_time_step +"h is equal or lower than 'start_time_step' = "+start_time_step+"h") 156 225 print(" ") 157 print(" Please select another 'start_time_step' or 'end_time_step'")226 print("Select another 'start_time_step' or 'end_time_step'") 158 227 print(" ") 159 228 exit … … 171 240 print("'end_time_step' = "+ end_time_step +"h is invalid") 172 241 print(" ") 173 print(" Please select another 'end_time_step'")242 print("Select another 'end_time_step'") 174 243 print(" ") 175 244 exit … … 186 255 print(" ") 187 256 188 t = f->time(start_time_step:end_time_step) 189 257 t = t_all(start_time_step:end_time_step)/norm_t 190 258 191 259 ; *************************************************** … … 210 278 res@xyLineColors = (/237/) 211 279 212 res@lgLabelFontHeightF = .02280 res@lgLabelFontHeightF = 0.02 213 281 214 282 resP = True 215 283 resP@txFont = "helvetica" 216 resP@txString = f @title+" time series "284 resP@txString = f_att@title+" time series " 217 285 resP@txFuncCode = "~" 218 286 resP@txFontHeightF = 0.015 287 288 res@tmXBMinorPerMajor = 4 289 res@tmYLMinorPerMajor = 4 219 290 220 291 res@vpWidthF=4 … … 290 361 count_var=count_var+1 291 362 292 data_all = f ->$vNam(varn)$ 293 unit(varn) = data_all@units 363 data_all = f[:]->$vNam(varn)$ 364 data_att = f_att->$vNam(varn)$ 365 unit(varn) = data_att@units 294 366 295 367 data(varn,:)=data_all(start_time_step:end_time_step) … … 303 375 if (mini(varn) .EQ. maxi(varn)) then 304 376 if (min(data(varn,:)) .EQ. 0)then 305 mini(varn)= mini(varn)- 1.306 maxi(varn)= maxi(varn)+ 1.377 mini(varn)= mini(varn)-0.1 378 maxi(varn)= maxi(varn)+0.1 307 379 end if 308 380 if (min(data(varn,:)) .LT. 0)then … … 322 394 if (mini(varn) .EQ. maxi(varn)) then 323 395 if (min(data(varn,:)) .EQ. 0)then 324 mini(varn)= mini(varn)- 1.325 maxi(varn)= maxi(varn)+ 1.396 mini(varn)= mini(varn)-0.1 397 maxi(varn)= maxi(varn)+0.1 326 398 end if 327 399 if (min(data(varn,:)) .LT. 0)then … … 341 413 if (mini(varn) .EQ. maxi(varn)) then 342 414 if (mini(varn) .EQ. 0)then 343 mini(varn)= mini(varn)- 1.344 maxi(varn)= maxi(varn)+ 1.415 mini(varn)= mini(varn)-0.1 416 maxi(varn)= maxi(varn)+0.1 345 417 end if 346 418 if (mini(varn) .LT. 0)then … … 360 432 if (mini(varn) .EQ. maxi(varn)) then 361 433 if (min(data(varn,:)) .EQ. 0)then 362 mini(varn)= mini(varn)- 1.363 maxi(varn)= maxi(varn)+ 1.434 mini(varn)= mini(varn)-0.1 435 maxi(varn)= maxi(varn)+0.1 364 436 end if 365 437 if (min(data(varn,:)) .LT. 0)then … … 379 451 if (mini(varn) .EQ. maxi(varn)) then 380 452 if (min(data(varn,:)) .EQ. 0)then 381 mini(varn)= mini(varn)- 1.382 maxi(varn)= maxi(varn)+ 1.453 mini(varn)= mini(varn)-0.1 454 maxi(varn)= maxi(varn)+0.1 383 455 end if 384 456 if (min(data(varn,:)) .LT. 0)then … … 398 470 if (mini(varn) .EQ. maxi(varn)) then 399 471 if (min(data(varn,:)) .EQ. 0)then 400 mini(varn)= mini(varn)- 1.401 maxi(varn)= maxi(varn)+ 1.472 mini(varn)= mini(varn)-0.1 473 maxi(varn)= maxi(varn)+0.1 402 474 end if 403 475 if (min(data(varn,:)) .LT. 0)then … … 417 489 if (mini(varn) .EQ. maxi(varn)) then 418 490 if (min(data(varn,:)) .EQ. 0)then 419 mini(varn)= mini(varn)- 1.420 maxi(varn)= maxi(varn)+ 1.491 mini(varn)= mini(varn)-0.1 492 maxi(varn)= maxi(varn)+0.1 421 493 end if 422 494 if (min(data(varn,:)) .LT. 0)then … … 459 531 if(check) then 460 532 461 if (isStrSubset(vNam(varn),"_0 " ))then533 if (isStrSubset(vNam(varn),"_0 " ))then 462 534 print(" ") 463 535 print("If you have Outputs of statistic regions you cannot overlay variables; 'over' is set to 0") … … 470 542 res@gsnLeftString = "overlayed plot" 471 543 res@gsnRightString = unit(varn) 472 res@tiXAxisString = " time [s] " 473 res@tiYAxisString = " " 474 res@tiXAxisFontHeightF = 0.07 475 res@txFontHeightF = 0.07 476 res@tiYAxisFontHeightF = 0.07 544 if (norm_t .NE. 1.)then 545 res@tiXAxisString = "t ["+unit_t+"]" 546 else 547 res@tiXAxisString = "t [s]" 548 end if 549 res@tiYAxisString = " " 550 res@tiXAxisFontHeightF = font_size 551 res@txFontHeightF = font_size 552 res@tiYAxisFontHeightF = font_size 477 553 478 554 if (vNam(varn) .EQ. "E") … … 1105 1181 if (min(data(varn,:)) .EQ. max(data(varn,:))) then 1106 1182 if (min(data(varn,:)) .EQ. 0)then 1107 res@trYMaxF = min(data(varn,:))- 1.1108 res@trYMinF = max(data(varn,:))+ 1.1183 res@trYMaxF = min(data(varn,:))-0.1 1184 res@trYMinF = max(data(varn,:))+0.1 1109 1185 end if 1110 1186 if (min(data(varn,:)) .LT. 0)then … … 1128 1204 res@gsnLeftString = vNam(varn) 1129 1205 res@gsnRightString = unit(varn) 1130 res@tiXAxisString = " time [s] " 1131 res@tiYAxisString = " " 1132 res@tiXAxisFontHeightF = 0.07 1133 res@txFontHeightF = 0.07 1134 res@tiYAxisFontHeightF = 0.07 1206 if (norm_t .NE. 1.)then 1207 res@tiXAxisString = "t ["+unit_t+"]" 1208 else 1209 res@tiXAxisString = "t [s]" 1210 end if 1211 res@tiYAxisString = " " 1212 res@tiXAxisFontHeightF = font_size 1213 res@txFontHeightF = font_size 1214 res@tiYAxisFontHeightF = font_size 1215 res@tmXBLabelFontHeightF = font_size 1216 res@tmYLLabelFontHeightF = font_size 1135 1217 res@trYMaxF = min(data(varn,:)) 1136 1218 res@trYMinF = max(data(varn,:)) 1137 1219 if (min(data(varn,:)) .EQ. max(data(varn,:))) then 1138 1220 if (min(data(varn,:)) .EQ. 0)then 1139 res@trYMaxF = min(data(varn,:))- 1.1140 res@trYMinF = max(data(varn,:))+ 1.1221 res@trYMaxF = min(data(varn,:))-0.1 1222 res@trYMinF = max(data(varn,:))+0.1 1141 1223 end if 1142 1224 if (min(data(varn,:)) .LT. 0)then … … 1162 1244 gsn_panel(wks_ps,plot_ps(1:n),(/n,1/),resP) 1163 1245 else 1164 do np = 1,n,no_ lines*no_columns1165 if ( np + no_ lines*no_columns .gt. n) then1166 gsn_panel(wks_ps, plot_ps(np:n),(/no_ lines,no_columns/),resP)1246 do np = 1,n,no_rows*no_columns 1247 if ( np + no_rows*no_columns .gt. n) then 1248 gsn_panel(wks_ps, plot_ps(np:n),(/no_rows,no_columns/),resP) 1167 1249 else 1168 gsn_panel(wks_ps, plot_ps(np:np+no_ lines*no_columns-1),(/no_lines,no_columns/),resP)1250 gsn_panel(wks_ps, plot_ps(np:np+no_rows*no_columns-1),(/no_rows,no_columns/),resP) 1169 1251 end if 1170 1252 end do
Note: See TracChangeset
for help on using the changeset viewer.