[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

a sample of helper script



  The following is an awk script written by Y. Takenaka.  It helps inputting
  variable star observation data from the field notebook directly.
  The output can be sorted to get reports in alphabetical order of
  constellation codes.

------------------< file: vsustd --  cut here >-----------------------------
#!awk -f
#
#    Variable Star USTD (VSUSTD)      Version 1.0
#    Copylight (C) VSOLJ and Yasuto TAKENAKA (Tny)  1994-02-24
#
# Usage: awk -f vsustd.awk (in_file) > (out_file)

BEGIN{
  data["code"] = "Tny.VSOLJ" # Observers Code
  data["date"] = ""
  data["file"] = "/dev/stdout"
  data["cst"]  = ""
  time["h"] = ""
  time["m"] = ""
  time["s"] = ""
  td = +9   # timezone
  printf "      VSUSTD Ver 1.10 (AWK Version)\n" > "/dev/stderr"
  printf "        Copylight (C) VSOLJ and Yasuto TAKENAKA (Tny)\n" > "/dev/stderr"
}
{
  if(match($0,"=") != 0 ){
    split($0,option,"=")
    data[tolower(option[1])] = option[2]
  }else{
    split($0,_tmp,",")
    if(_tmp[1] != "" ){
      name = vsname(_tmp[1])
    }
    obsdate = odate(_tmp[2])
    printf "%-15s%10.3f%6s  %s\n",name,obsdate,_tmp[3],data["code"] >> data["file"]
  }
}
func vsname( vs )
{
  tmp[2] = ""
  time["s"]= ""
  if( substr( vs , 1 , 1) == " "){
    return (data["cst"] substr( vs,2 ))
  }else{
    split( vs , tmp , " ")
    if( tmp[2] != "" ){
      data["cst"] = toupper(tmp[2])
      return (data["cst"] tmp[1])
    }else{
      return tmp[1]
    }
  }
}
func odate( od )
{
  len = length( od )
  if(len == 6){
    time["h"] = substr(od,1,2)
    time["m"] = substr(od,3,2)
    time["s"] = substr(od,5,2)
  }else{
    if( time["s"] != "" ){
      if(len == 2){
        time["s"] = od
      }else{
        time["m"] = int(substr(od,1,2))
        time["s"] = int(substr(od,3,2))
      }
    }else{
      if(len == 2){
        time["m"] = od
      }else{
        time["h"] = substr(od,1,2)
        time["m"] = substr(od,3,2)
      }
    }
  }
  td2 = (time["h"]- td + time["m"] / 60 + time["s"] /3600 )/24
  return (data["date"] + td2 )
}
-------------------< a sample of input file --  cut here >-------------------
date=940518
R UMa,2043,65
T UMa,2000,78
 S,01,100
date=940519
R CrB,2000,61?
T Boo,2001,<144
 R,01,90:
---------------------------< cut here >-------------------------------------