Ignore:
Timestamp:
Aug 16, 2008 12:18:08 PM (14 years ago)
Author:
letzel
Message:
  • NCL scripts in trunk/SCRIPTS/NCL updated to version 2.0 (.ncl_preferences replaced by ncl_preferences.ncl)
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"
     16load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"
    22load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
    33load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
    44load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
    5 
     5 
     6;***************************************************
     7; load ncl_preferences.ncl
     8;***************************************************
     9   
     10if (isfilepresent("~/ncl_preferences.ncl")) then
     11   loadscript("~/ncl_preferences.ncl")
     12else
     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
     21end if
     22   
    623begin
    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
    2532   end if
    2633
    27    ; ***************************************************
    28    ; set up default parameter values and strings if not assigned in prompt or parameter list
    29    ; ***************************************************
     34   ;***************************************************
     35   ; set up default parameter values and strings
     36   ;***************************************************
    3037 
    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
    4043   else
    4144      file_in = file_1   
     
    4346   if (.not. isfilepresent(file_in)) then
    4447      print(" ")
    45       print("Your 1st input file: '"+file_in+"' does not exist")
     48      print("1st input file: '"+file_in+"' does not exist")
    4649      print(" ")
    4750      exit
    4851   end if
    4952
    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"
    8758   end if 
    8859
    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(" ")
    9464      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   ;***************************************************
    11469   ; open input file
    115    ; ***************************************************
     70   ;***************************************************
    11671
    11772   f  = addfile(file_in , "r" )
     
    11974   vNam  = getfilevarnames(f)
    12075   print(" ")
    121    print("Variable on netCDF file: " + vNam)
     76   print("Variables in input file:")
     77   print("- "+ vNam)
    12278   print(" ")
    12379   dim = dimsizes(vNam)
     
    13187   nt  = dimsizes(t_all)
    13288   delta_t=t_all(nt-1)/nt
    133 
    134    ; ****************************************************       
     89   
     90   ;****************************************************       
    13591   ; 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     
    15996   else
    16097      if (start_time_step .GE. t_all(nt-1)/3600)
     
    175112      end if
    176113   end if
    177    start_time_step = start_time_step*3600
    178114   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)then
     115      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
    180116         st=i
    181117         break
     
    185121      st=nt-2   
    186122   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   ;****************************************************
    189133   ; 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 
    221138   else
    222139      if (end_time_step .LE. t_all(0)/3600)
     
    245162      end if
    246163   end if
    247    end_time_step = end_time_step*3600
    248164   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)then
     165      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
    250166         et=i
    251167         break
    252168      end if
    253169   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
    254179 
    255180   delete(start_time_step)
     
    358283         check = True
    359284      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
    365287         check = isStrSubset( var,","+vNam(varn)+"," )
    366288      end if
     
    519441   if (count_var .EQ. 0) then
    520442      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")
    522445      print(" ")
    523446      exit
     
    531454         check = True
    532455      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
    538458         check = isStrSubset( var,","+vNam(varn)+"," )
    539459      end if
     
    709629         check = True
    710630      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
    716633         check = isStrSubset( var,","+vNam(varn)+"," )
    717634      end if
Note: See TracChangeset for help on using the changeset viewer.