Plotting Skew-Ts in GrADS-Need Help

Ren Diandong dd_ren at ROSSBY.METR.OU.EDU
Fri Mar 16 19:16:07 EDT 2007


Hi, Dale,

Hope the attached files are useful to you.

There are six files: a Fortran code for reading the raw dropsondes (only
tested for your sample sounding), make a simple QC and write into GrADS
readable BINARY file (may be what you need). Please read my comments
inside the code. The sorting code is from NCAR CCSM3 model, and I take
responsibility for remainder.

The *.dat (forHawaii.dat) GrADS binary are produced by the FORTRAN code
just mentioned. You need to run the FORTRAN code under the same
directory as your dropsondes. For example 'pgf90 hawaii.f90; a.out'.
   The variable names in the order of Press (mb), T(C),Td(C),Wdspd
   (M/s) and Wddir(degree). So, in the script you will use, refer to
   var1 as Pressure,  etc...

GrADS needs a CTL file for plotting (forHawaii.ctl).

The *.gs file, which is the scripts to launch, is upto you to modify for
your purpose. Thus, I usually do not provide ready-made scripts to
confine especially the new users' imagination. I provide this example
just to give you an example how to use the *.ctl file.

The sample plots of the sample sounding are enclosed as a ps and a *.gmf
file as well. Thanks for the offline response of a friend to hint me
that the previous eps files cannot be seen.

So, if you know a skewT-logP script, use it in the place of the sample
gs file suffices. Because my work in recent years do not involve too
much of the sounding, I had difficulty in fully refresh myself to a
level to change my Emagram script to a skewT-logP format, there are 6
plus places to consider together and the vertical integration scheme
need to be redone (accuracy consideration).

Let me know if I fully answered your questions.

Diandong Ren, PhD

SoM/OU, National Weather Center


On Thu, 2007-03-08 at 07:51 -1000, Dale E Unruh, Jr wrote:
> Hello all,
>
> I'm trying to do research using hurricane dropsondes and I would like to be able to plot the dropsonde data in a skew-T format with hodographs which I know can be done in GrADS. The problem is the dropsonde data is in what is called an AVAP format, which is basically a text document. From what I gather, GrADS can only read binary files. I'm really not sure how to convert these avaps files I have into a binary format that can be used by GrADS. I do have a program that can process the avaps files and turn them into the following file types: netCDF, Class, CSV, EOL and WMO. I would greatly appreciate any help with this matter. I've attached a sample dropsonde file so you could see what they look like.
> Thanks so much!
> -Dale Unruh
>
>
> Graduate Student
> University of Hawaii
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EMAgram.gmf
Type: audio/x-mp3
Size: 654524 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20070316/b95f6363/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EMAgram.ps
Type: application/postscript
Size: 1669735 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20070316/b95f6363/attachment.ps 
-------------- next part --------------
dset   forHawaii.dat
title  model output analysis
undef     999.00000
xdef    1 linear        0.00000       358.00000
ydef    1 linear        0.00000       176.00000
zdef 1760  linear 1  1
tdef    1  linear      00z01jan1900          1dy
vars   5
var1    1760  99 P (mb)
var2    1760  99 Tair(K)
var3    1760  99 Td(K)
var4    1760  99 Wdspd(m/s)
var5    1760  99 Wddir (Ged)
endvars
-------------- next part --------------
A non-text attachment was scrubbed...
Name: forHawaii.dat
Type: video/mpeg
Size: 35200 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20070316/b95f6363/attachment.m1v 
-------------- next part --------------
'clear'
'set font 0'
'set cterp    on'
'set csmooth  on'
'set frame on'
'set grads off'
'open forHawaii.ctl'
'set grid off'
'set annot 1 5'
'set xlopts 1 4 0.25'
'set xlpos  0.0 b'; 'set ylpos  0.0 l'
 'set vrange  -50   150 '; 'set ylint   50 '
 'set parea 1 10 1 8 '

 'set x  1             1'
 'set y  1             1'
 'set z  1             1760'
 'set t  1             1'

 'set gxout line'
 'set ccolor 1'; 'set cstyle 1'; 'set cthick 5'
 'set cmark 0'; 'set clopts 1 1 0.18'
 'set yflip on'; 'set ylab off'
 'd var3.1'
 'set string 1 c 4'
 'set strsiz 0.24 0.24'
 'draw string 5.3 8.3     Td (K) from sounding file g040925102.avp'

-------------- next part --------------
!AIM: To deal with the dropsounding in hurricanes... ...
!Organized by Diandong Ren (4:00 PM, March 16, 2007) for a help session to GrADS list

program readAvpData
implicit none
real    :: r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13
integer ::i1,i2,  i,j,k,m,mm,istat,irec
REAL, PARAMETER    :: badvalue=999.0                   !sample *.avp data specific
integer, parameter :: nx=1,ny=1,nz=1760,nvar=5,ntime=1 !sample *.avp data specific
REAL, DIMENSION  (1:nx,1:ny,1:nz,1:nvar,1:ntime) :: output_data
CHARACTER (LEN=70) :: char1,char2
!>----- for quality control... ... (below)
real, dimension(1:nz,1:nvar) :: orig_dat
integer, dimension (1:nz) :: sort_index
real, dimension (1:nz) :: Peliminat
!<----- for quality control... ... (above)

!SECTION1. >=====READ SOUNDING
      close(131)
      open(131,file='g040925102.avp', status='old', iostat=istat)
       if(istat /= 0) then
         pause 'Could not create file:::131'
         stop
       else
           read(131,*)
           read(131,*)
           read(131,*)
           read(131,*)
           read(131,*)
do m=1,nz
           read(131,'(A30,f9.1,f8.2,5f7.2,f11.5,f10.5,f9.2,I4,f7.2,f7.2,I4,f6.2)')char1, &
                     r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,i1,r11,r12,i2,r13
            output_data(1,1,m,1,1)=r2
            output_data(1,1,m,2,1)=r3
            output_data(1,1,m,3,1)=r4    !perform this after QC elimination /100.0
            output_data(1,1,m,4,1)=r5
            output_data(1,1,m,5,1)=r6
enddo
!SECTION2. >=====SIMPLE QUALITY CONTROL and SORTING
        do mm=1,nvar
        do m=1,nz
            orig_dat(m,mm)=output_data(1,1,m,mm,1)
            if(orig_dat(m,mm).eq.9999.0.or.orig_dat(m,mm).eq.99.0)then
            orig_dat(m,mm)=badvalue     !Simple QC scheme... ...
            endif
        enddo
        enddo
    do mm=1,nz
      sort_index(mm)=mm
      Peliminat(mm)=orig_dat(mm,1)  !According Pressure
    enddo
    call shellsrt(nz, Peliminat, sort_index)

        do mm=1,nvar
        do m=1,nz
!if chose not to sort...            output_data(1,1,m,mm,1)=eliminat(m,mm)
!if sort            output_data(1,1,m,mm,1)=eliminat(sort_index(m),mm)
!>>>your choice
                    output_data(1,1,m,mm,1)=orig_dat(sort_index(m),mm)
!<<<your choice
        enddo
        enddo
            do m=1,nz
            output_data(1,1,m,3,1)= output_data(1,1,m,3,1)/100.0 !after QC
            enddo
      endif
      close(131)
          close(3)
!SECTION3. >=====Produce the GrADS style BIN...(COASIAN)
          open(3,file='forHawaii.dat',form='unformatted',access='direct',recl=1)
          irec=0
          do 2 i=1,ntime
          do 2 j=1,nvar
          do 2 k=1,nz
          irec=irec+1
2         write(3,rec=irec)((output_data(mm,m,k,j,i),mm=1,nx),m=1,ny)
          close(3)
end program readAvpData











            subroutine funcE (x,y)
!Diandong Ren
! Originally designed 1995, modified 2007
! p(mb), qs(g/g), and Temperature in Celsius... ...
!
              implicit none
               real :: x,y, a,b
               real, parameter :: coef=0.622
             if(x>0.0)then
              a=17.67
              b=243.5
              else
              a=21.8745
              b=265.0
              endif
              y=6.112*exp(a*x/(x+b))
           end subroutine funcE


  subroutine shellsrt(n, arr, karr)
  implicit none
!-----------------------------------------------
! Purpose:
!       Shell sort of an array.
! Method:
! Code adapted from Numerical recipes in fortran 90 :
!   the art of parallel scientific computing / William H. Press et al.
!   2nd ed., Cambridge [England] ; New York : Cambridge University Press,
!   1996.
! Author: William Collins
  integer , intent(in) :: n
  integer , intent(inout) :: karr(n)
  real, intent(inout) :: arr(n)
  integer :: i, j, inc, vk
  real :: va
  inc = 1
  do while(.TRUE.)
     inc = 3*inc + 1
     if (inc <= n) cycle
     exit
  end do
  do while(.TRUE.)
     inc = inc/3
     do i = inc + 1, n
        va = arr(i)
        vk = karr(i)
        j = i
        do while(.TRUE.)
           if (arr(j-inc) <= va) exit
           arr(j) = arr(j-inc)
           karr(j) = karr(j-inc)
           j = j - inc
           if (j > inc) cycle
           exit
        end do
        arr(j) = va
        karr(j) = vk
     end do
     if (inc > 1) cycle
     exit
  end do
  return
  end subroutine shellsrt



More information about the gradsusr mailing list