[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20040127: 20040127: methods to export data in IDV question



>From: Jeffrey Buler <address@hidden>
>Organization: University of Southern Mississippi
>Keywords: 200401272246.i0RMkcp2006629 IDV radar printing

Hi Jeff-

>Thank you for the formula!  I was able to cut and paste the formula into the 
>Jython library editor and execute it on my data.  I get an ouput that is 
>exactly what I was looking for.  I noticed that in line 21 one can adjust 
>which range bins to output.  That is handy.  

Oops, I was working on this as I was answering and forgot to change the
code to output the entire sweep.  The loop should have been from 0 to c,
not 0 to 10.  

>However, there is only one ray (one azimuth) in the output.  I've tried to 
>decipher the formula to see where the loop to iterate the remaining rays is 
>located but cant find it (line 14?) and cannot get the rest of the rays in the
>sweep to output.  Would you please troubleshoot this for me? I am using IDV 
>version 1.1b2 in Windows XP. 

Here's a more annotated version:

import sys;
sys.add_package('visad');
sys.add_package('visad.util');
sys.add_package('ucar.visad');
def printField(a,filename="foo"):
  from visad import RealTupleType as rt
  from visad.util import DataUtility as du
  from ucar.visad.Util import *
  # open a file for writing
  file = open(filename,"w")
  mydu = du()
  # data has format like: 
  #   (Time -> ((Range, Azimuth, Elevation_Angle) -> Reflectivity))
  # get the outer time domain
  tdom = a.getDomainSet()
  l = tdom.getLength()
  # iterate over time domain
  for j in range(0,l):
    # write out the timestamp
    file.write(str(mydu.getSample(tdom, j))+"\n")
    #get first sweep
    b = a[j]
    # print out the datatype
    file.write(str(b.getType())+"\n")
    # dom will be (Range, Azimuth, Elevation_Angle)
    dom = b.getDomainSet()
    # convert to lat/lon/alt.  This does not account for
    # refraction
    lldom = convertDomain(dom, rt.LatitudeLongitudeAltitude,None)
    c = dom.getLength()
    # now loop over each point
    n = 0
    line = ""
    for i in range(0,c):
        # point in (Range, Azimuth, Elevation_Angle) space
        point = mydu.getSample(dom, i)
        # point in (Latitude, Longitude, Altitude) space
        llpoint = mydu.getSample(lldom,i)
        # value for data
        value = b[i].getValue()
        # format output - buffers 10 points before printing
        if n < 10:
           line = line+str(point)+" "+str(llpoint)+" = "+str(value)+"\n"
           n = n + 1
        else:
          # write it out to the file
          file.write(line)
          n = 0
          line=""
  file.close()
  return a

>
>Also, what spheroid did you use to generate lat&long?

We are using an earth radius of 6367681.04774543 meters for
our calculations.  We are under the process of reviewing this
calculation to account for refraction. 

Don
**************************************************************************** <
Unidata User Support                                    UCAR Unidata Program <
(303)497-8643                                                  P.O. Box 3000 <
address@hidden                                   Boulder, CO 80307 <
---------------------------------------------------------------------------- <
Unidata WWW Service              http://my.unidata.ucar.edu/content/support  <
**************************************************************************** <
NOTE: All email exchanges with Unidata User Support are recorded in the
Unidata inquiry tracking system and then made publically available
through the web.  If you do not want to have your interactions made
available in this way, you must let us know in each email you send to us.