Find the answer to your Linux question:
Results 1 to 2 of 2
Hello all, I am an astronomy student using Ubunut 10.04, and a frequent user of IRAF ( an *nix image processing application geared toward astronomy). IRAF produces, amongst other things, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    1

    Extracting information from multiple text documents


    Hello all,

    I am an astronomy student using Ubunut 10.04, and a frequent user of IRAF ( an *nix image processing application geared toward astronomy). IRAF produces, amongst other things, a text document with various values on it (example below).

    Code:
    K IRAF       = NOAO/IRAFV2.14.1        version    %-23s     
    #K USER       =                         name       %-23s     
    #K HOST       = Balthazar               computer   %-23s     
    #K DATE       = 2010-04-29              yyyy-mm-dd %-23s     
    #K TIME       = 17:23:59                hh:mm:ss   %-23s     
    #K PACKAGE    = apphot                  name       %-23s     
    #K TASK       = phot                    name       %-23s     
    #
    #K SCALE      = 1.                      units      %-23.7g   
    #K FWHMPSF    = 5.                      scaleunit  %-23.7g   
    #K EMISSION   = yes                     switch     %-23b     
    #K DATAMIN    = INDEF                   counts     %-23.7g   
    #K DATAMAX    = INDEF                   counts     %-23.7g   
    #K EXPOSURE   = EXPTIME                 keyword    %-23s     
    #K AIRMASS    = AIRMASS                 keyword    %-23s     
    #K FILTER     = FILTERS                 keyword    %-23s     
    #K OBSTIME    = TIME                    keyword    %-23s     
    #
    #K NOISE      = poisson                 model      %-23s     
    #K SIGMA      = INDEF                   counts     %-23.7g   
    #K GAIN       = ""                      keyword    %-23s     
    #K EPADU      = 1.                      e-/adu     %-23.7g   
    #K CCDREAD    = ""                      keyword    %-23s     
    #K READNOISE  = 0.                      e-         %-23.7g   
    #
    #K CALGORITHM = centroid                algorithm  %-23s     
    #K CBOXWIDTH  = 5.                      scaleunit  %-23.7g   
    #K CTHRESHOLD = 0.                      sigma      %-23.7g   
    #K MINSNRATIO = 1.                      number     %-23.7g   
    #K CMAXITER   = 10                      number     %-23d     
    #K MAXSHIFT   = 1.                      scaleunit  %-23.7g   
    #K CLEAN      = no                      switch     %-23b     
    #K RCLEAN     = 1.                      scaleunit  %-23.7g   
    #K RCLIP      = 2.                      scaleunit  %-23.7g   
    #K KCLEAN     = 3.                      sigma      %-23.7g   
    #
    #K SALGORITHM = centroid                algorithm  %-23s     
    #K ANNULUS    = 10.                     scaleunit  %-23.7g   
    #K DANNULUS   = 10.                     scaleunit  %-23.7g   
    #K SKYVALUE   = 0.                      counts     %-23.7g   
    #K KHIST      = 3.                      sigma      %-23.7g   
    #K BINSIZE    = 0.1                     sigma      %-23.7g   
    #K SMOOTH     = no                      switch     %-23b     
    #K SMAXITER   = 10                      number     %-23d     
    #K SLOCLIP    = 0.                      percent    %-23.7g   
    #K SHICLIP    = 0.                      percent    %-23.7g   
    #K SNREJECT   = 50                      number     %-23d     
    #K SLOREJECT  = 3.                      sigma      %-23.7g   
    #K SHIREJECT  = 3.                      sigma      %-23.7g   
    #K RGROW      = 0.                      scaleunit  %-23.7g   
    #
    #K WEIGHTING  = constant                model      %-23s     
    #K APERTURES  = 3.                      scaleunit  %-23s     
    #K ZMAG       = 25.                     zeropoint  %-23.7g   
    #
    #N IMAGE               XINIT     YINIT     ID    COORDS                 LID    \
    #U imagename           pixels    pixels    ##    filename               ##     \
    #F %-23s               %-10.3f   %-10.3f   %-6d  %-23s                  %-6d    
    #
    #N XCENTER    YCENTER    XSHIFT  YSHIFT  XERR    YERR            CIER CERROR   \
    #U pixels     pixels     pixels  pixels  pixels  pixels          ##   cerrors  \
    #F %-14.3f    %-11.3f    %-8.3f  %-8.3f  %-8.3f  %-15.3f         %-5d %-9s      
    #
    #N MSKY           STDEV          SSKEW          NSKY   NSREJ     SIER SERROR   \
    #U counts         counts         counts         npix   npix      ##   serrors  \
    #F %-18.7g        %-15.7g        %-15.7g        %-7d   %-9d      %-5d %-9s      
    #
    #N ITIME          XAIRMASS       IFILTER                OTIME                  \
    #U timeunit       number         name                   timeunit               \
    #F %-18.7g        %-15.7g        %-23s                  %-23s                   
    #
    #N RAPERT   SUM           AREA       FLUX          MAG    MERR   PIER PERROR   \
    #U scale    counts        pixels     counts        mag    mag    ##   perrors  \
    #F %-12.2f  %-14.7g       %-11.7g    %-14.7g       %-7.3f %-6.3f %-5d %-9s      
    #
    jan1300074a_reduced.fit937.000   273.000   1     coords.out             1      \
       937.505    271.474    0.505   -1.526  0.004   0.004          107  BigShift  \
       91.81773       9.950597       6.256385       919    31       0    NoError   \
       20.            1.48085        v                      20:51:37               \
       3.00     141842.4      28.27911   139245.8      15.393 0.003 0    NoError
    Now, the information I'm actually interested is the X and Y coordinates down towards the bottom (in this case, 973.505, 271.474).

    I have about 800 of these output text files, and I was wondering if there's any sort of script or command that could go through them (presumably reading from a list of file names), and extract the coordinates. Ideally, the output would be a list of coordinates (i.e. X-coordinate, Y-coordinate).

    Any suggestions?

    Thanks!

  2. #2
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    The backslashes : \

    Do they appear as such in your files ? Or do they mean a line break in your post while they do not appear in your file ?

    If they appear as such, using tail, you can get the last 4 lines, then head will extract the first line and using awk, you can extract the first and second fields.

    If they do not appear as such in your file, get the last line with tail and pass it to awk to catch the sixth and seventh fields.
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •