Changeset 190 for palm/trunk/SCRIPTS/NCL/timeseries.ncl
- Timestamp:
- Aug 16, 2008 12:18:08 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/NCL/timeseries.ncl
r175 r190 1 load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"1 6load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl" 2 2 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" 3 3 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" 4 4 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl" 5 5 6 ;*************************************************** 7 ; load ncl_preferences.ncl 8 ;*************************************************** 9 10 if (isfilepresent("~/ncl_preferences.ncl")) then 11 loadscript("~/ncl_preferences.ncl") 12 else 13 if (isfilepresent("~/palm/current_version/trunk/SCRIPTS/NCL/ncl_preferences.ncl")) then 14 loadscript( "~/palm/current_version/trunk/SCRIPTS/NCL/ncl_preferences.ncl") 15 else 16 print(" ") 17 print("'ncl_preferences.ncl' does not exist in $home or $home/palm/current_version/trunk/SCRIPTS/NCL/") 18 print(" ") 19 exit 20 end if 21 end if 22 6 23 begin 7 8 ; *************************************************** 9 ; read parameter_list 10 ; *************************************************** 11 12 if (isfilepresent("~/.ncl_preferences")) then 13 parameter = asciiread("~/.ncl_preferences",129,"string") 14 delete(parameter@_FillValue) 15 else 16 if (isfilepresent("~/palm/current_version/trunk/SRIPTS/NCL/.ncl_preferences")) then 17 parameter = asciiread("~/palm/current_version/trunk/SRIPTS/NCL/.ncl_preferences",129,"string") 18 delete(parameter@_FillValue) 19 else 20 print(" ") 21 print("'.ncl_preferences' is not present in '~/palm/current_version/trunk/SRIPTS/NCL/'") 22 print(" ") 23 exit 24 end if 24 25 if (cross_sections .NE. 0 .OR. profiles .NE. 0 .OR. timeseries .NE. 1 .OR. spectra .NE. 0)then 26 print(" ") 27 print("Please specify the used script in 'ncl_preferences.ncl' (Line 7-10)") 28 print(" ") 29 print("Set 'timeseries' equal 1 and the other variables equal 0") 30 print(" ") 31 exit 25 32 end if 26 33 27 ; 28 ; set up default parameter values and strings if not assigned in prompt or parameter list29 ; 34 ;*************************************************** 35 ; set up default parameter values and strings 36 ;*************************************************** 30 37 31 if ( .not. isvar("file_1") ) then 32 if (parameter(7) .EQ. "File in") then 33 print(" ") 34 print("Please provide 1st input file 'file_1=' either in prompt or parameter_list") 35 print(" ") 36 exit 37 else 38 file_in = parameter(7) 39 end if 38 if (file_1 .EQ. "File in") then 39 print(" ") 40 print("Please provide 1st input file 'file_1=' in 'ncl_preferences.ncl'") 41 print(" ") 42 exit 40 43 else 41 44 file_in = file_1 … … 43 46 if (.not. isfilepresent(file_in)) then 44 47 print(" ") 45 print(" Your1st input file: '"+file_in+"' does not exist")48 print("1st input file: '"+file_in+"' does not exist") 46 49 print(" ") 47 50 exit 48 51 end if 49 52 50 if ( .not. isvar("format_out") ) then 51 format_out = "x11" 52 if (parameter(9) .NE. "x11") then 53 format_out = parameter(9) 54 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 55 print(" ") 56 print("Your 'format_out = "+format_out+"' is invalid and set to'x11'") 57 print(" ") 58 end if 59 end if 60 else 61 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 62 print(" ") 63 print("Your 'format_out = "+format_out+"' is invalid and set to'x11'") 64 print(" ") 65 end if 66 end if 67 68 if ( .not. isvar("file_out") ) then ; path+name of output file 69 file_out = "test" 70 if (parameter(11) .NE. "test") then 71 file_out = parameter(11) 72 end if 73 end if 74 75 if ( .not. isvar("no_columns") ) then ; number of plots in one row 76 no_columns = 1 77 if (parameter(17) .NE. "1") then 78 no_columns = stringtointeger(parameter(17)) 79 end if 80 end if 81 82 if ( .not. isvar("no_lines") ) then ; number of plot-lines on one sheet 83 no_lines = 2 84 if (parameter(19) .NE. "2") then 85 no_lines = stringtointeger(parameter(19)) 86 end if 53 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 54 print(" ") 55 print("'format_out = "+format_out+"' is invalid and set to'x11'") 56 print(" ") 57 format_out="x11" 87 58 end if 88 59 89 if ( .not. isvar("var") ) then ; variable name 90 check = True 91 end if 92 93 if ( .not. isvar("over") ) then ; switches overlaying plots on 60 if (over .NE. 0 .AND. over .NE. 1) then 61 print(" ") 62 print("'over'= "+over+" is invalid and set to 0") 63 print(" ") 94 64 over = 0 95 if (stringtointeger(parameter(37)) .NE. 0) then 96 over = stringtointeger(parameter(37)) 97 if (stringtointeger(parameter(37)) .NE. 1) then 98 print(" ") 99 print("Your 'over'= "+over+" is invalid and set to 0") 100 print(" ") 101 over = 0 102 end if 103 end if 104 else 105 if (over .NE. 0 .AND. over .NE. 1)then 106 print(" ") 107 print("Your 'over'= "+over+" is invalid and set to 0") 108 print(" ") 109 over = 0 110 end if 111 end if 112 113 ; *************************************************** 65 end if 66 67 68 ;*************************************************** 114 69 ; open input file 115 ; 70 ;*************************************************** 116 71 117 72 f = addfile(file_in , "r" ) … … 119 74 vNam = getfilevarnames(f) 120 75 print(" ") 121 print("Variable on netCDF file: " + vNam) 76 print("Variables in input file:") 77 print("- "+ vNam) 122 78 print(" ") 123 79 dim = dimsizes(vNam) … … 131 87 nt = dimsizes(t_all) 132 88 delta_t=t_all(nt-1)/nt 133 134 ; 89 90 ;**************************************************** 135 91 ; start of time step and different types of mistakes that could be done 136 ; **************************************************** 137 138 if ( .not. isvar("start_time_step") ) then 139 start_time_step=t_all(0)/3600 140 if (parameter(13) .NE. "t(0)") then 141 if (stringtodouble(parameter(13)) .GE. t_all(nt-1)/3600) 142 print(" ") 143 print("'start_time_step' = "+ parameter(13) +"h is equal or greater than last time step = " + t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") 144 print(" ") 145 print("Please select another 'start_time_step'") 146 print(" ") 147 exit 148 end if 149 if (stringtofloat(parameter(13)) .LT. t_all(0)/3600) 150 print(" ") 151 print("'start_time_step' = "+ parameter(13) +"h is lower than first time step = " + t_all(0)+"s = "+t_all(0)/3600+"h") 152 print(" ") 153 print("Please select another 'start_time_step'") 154 print(" ") 155 exit 156 end if 157 start_time_step=stringtodouble(parameter(13)) 158 end if 92 ;**************************************************** 93 94 if (start_time_step .EQ. -1.) then 95 start_time_step=t_all(0)/3600 159 96 else 160 97 if (start_time_step .GE. t_all(nt-1)/3600) … … 175 112 end if 176 113 end if 177 start_time_step = start_time_step*3600178 114 do i=0,nt-2 179 if (start_time_step .GE. t_all(i)-delta_t/2 .AND. start_time_step .LT. t_all(i)+delta_t/2)then115 if (start_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. start_time_step .LT. (t_all(i)+delta_t/2)/3600)then 180 116 st=i 181 117 break … … 185 121 st=nt-2 186 122 end if 187 188 ; **************************************************** 123 if (.not. isvar("st"))then 124 print(" ") 125 print("'start_time_step' = "+ start_time_step +"h is invalid") 126 print(" ") 127 print("Please select another 'start_time_step'") 128 print(" ") 129 exit 130 end if 131 132 ;**************************************************** 189 133 ; end of time step and different types of mistakes that could be done 190 ; **************************************************** 191 192 if ( .not. isvar("end_time_step") ) then 193 end_time_step = t_all(nt-1)/3600 194 if (parameter(15) .NE. "t(end)") then 195 if (stringtodouble(parameter(15)) .LE. t_all(0)/3600) 196 print(" ") 197 print("'end_time_step' = "+parameter(15)+ "h is lower or equal than first time step = " + t_all(0)+"s = "+t_all(0)/3600+"h") 198 print(" ") 199 print("Please select another 'end_time_step'") 200 print(" ") 201 exit 202 end if 203 if (stringtodouble(parameter(15)) .GT. t_all(nt-1)/3600) 204 print(" ") 205 print("'end_time_step' = "+ parameter(15) +"h is greater than last time step = " + t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") 206 print(" ") 207 print("Please select another 'end_time_step'") 208 print(" ") 209 exit 210 end if 211 if (stringtodouble(parameter(15)) .LE. start_time_step/3600) 212 print(" ") 213 print("'end_time_step' = "+ parameter(15) +"h is equal or lower than 'start_time_step' = "+parameter(13)+"h") 214 print(" ") 215 print("Please select another 'start_time_step' or 'end_time_step'") 216 print(" ") 217 exit 218 end if 219 end_time_step = stringtodouble(parameter(15)) 220 end if 134 ;**************************************************** 135 136 if (end_time_step .EQ. -1.) then 137 end_time_step = t_all(nt-1)/3600 221 138 else 222 139 if (end_time_step .LE. t_all(0)/3600) … … 245 162 end if 246 163 end if 247 end_time_step = end_time_step*3600248 164 do i=0,nt-1 249 if (end_time_step .GE. t_all(i)-delta_t/2 .AND. end_time_step .LT. t_all(i)+delta_t/2)then165 if (end_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. end_time_step .LT. (t_all(i)+delta_t/2)/3600)then 250 166 et=i 251 167 break 252 168 end if 253 169 end do 170 171 if (.not. isvar("et"))then 172 print(" ") 173 print("'end_time_step' = "+ end_time_step +"h is invalid") 174 print(" ") 175 print("Please select another 'end_time_step'") 176 print(" ") 177 exit 178 end if 254 179 255 180 delete(start_time_step) … … 358 283 check = True 359 284 end if 360 if( isvar("var") ) then 361 check = isStrSubset( var,","+vNam(varn)+"," ) 362 end if 363 if (parameter(21) .NE. "variables") then 364 var = parameter(21) 285 286 if (var .NE. "all") then 365 287 check = isStrSubset( var,","+vNam(varn)+"," ) 366 288 end if … … 519 441 if (count_var .EQ. 0) then 520 442 print(" ") 521 print("The variables 'var=°"+var+"°' do not exist on your input file") 443 print("The variables 'var="+var+"' do not exist on your input file;") 444 print("be sure to have one comma berfore and after each variable") 522 445 print(" ") 523 446 exit … … 531 454 check = True 532 455 end if 533 if( isvar("var") ) then 534 check = isStrSubset( var,","+vNam(varn)+"," ) 535 end if 536 if (parameter(21) .NE. "variables") then 537 var = parameter(21) 456 457 if (var .NE. "all") then 538 458 check = isStrSubset( var,","+vNam(varn)+"," ) 539 459 end if … … 709 629 check = True 710 630 end if 711 if( isvar("var") ) then 712 check = isStrSubset( var,","+vNam(varn)+"," ) 713 end if 714 if (parameter(21) .NE. "variables") then 715 var = parameter(21) 631 632 if (var.NE. "all") then 716 633 check = isStrSubset( var,","+vNam(varn)+"," ) 717 634 end if
Note: See TracChangeset
for help on using the changeset viewer.