#++++++++++++++++ #.IDENTIFICATION SimViz.awk0 #.LANGUAGE AWK #.AUTHOR Francois Ochsenbein [CDS] #.ENVIRONMENT #.KEYWORDS #.VERSION 1.0 08-Jun-2000 #.VERSION 1.1 01-Apr-2001: Allow several items in Query (add -go) #.VERSION 1.2 22-Apr-2002: Always issue the -go #.PURPOSE Convert Dic.par into an AWK Script #.COMMENTS Several catalogues may be queried -- just with -go ! # Option sesame ==> choose just _RAJ _DEJ + Main Identification #---------------- BEGIN { # A few definitions... # Default options for the Query from Simbad sesame_arg = "-pos\n-oc=dec\n-out.max=6\n" \ "-out=_RAJ,_DEJ, *ID_MAIN" roman["I"] = 1 ; roman["II"] = 2 ; roman["III"] = 3 ; roman["IV"] = 4 ; roman["V"] = 5 ; roman["VI"] = 6 ; roman["VII"] = 7 ; roman["VIII"] = 8 ; roman["IX"] = 9 ; roman["X"] = 10 ; nqueries = 0 ; } #### Convert an Identifier from Simbad into a valid set of ASU Queries #### 1) When Only the Table Name is Specified function pr5t(table, colval, colname) { #if (nqueries > 0) nqueries++ ; if (sesame>0) print sesame_arg; else print "-4\n-out.add=." ; printf("-source=%s/%s\n", N, table) ; if (colname == "") printf("%s===", M) ; else printf("%s===", colname) ; print colval ; } #### 2) When Source and Constraint are Specified function pr5s(source, column) { #if (nqueries > 0) print "-go" ; nqueries++ ; if (sesame>0) print sesame_arg; else print "-4\n-out.add=." ; printf("-source=%s\n", source) ; if (column != "") print column; } #### Write Position from an IAU Name function outside_range(msg) { # Error message print "#!***" msg " outside range: " input_name exit(1) } function coo_uai(uai_name) ############################################################### # Input = IAU Designation ############################################################### { input_name = uai_name ; name = input_name ; gsub(/[\. ,]/, "", name) ; # Remove the blanks eqx = substr(name,1,1) ; if ((eqx == "J") || (eqx == "j")) equinox = 2000 ; else equinox = 1950 ; gsub(/[A-Za-z]/, "",name) ; # Keep only digits... i = index(name, "+") ; if (i == 0) i = index(name, "-") ; if (i == 0) { print "#!***No +/- sign, can't locate declination part: " input_name exit(1) } if (match(name, /^[0-9][0-9][0-9][0-9][0-9+-]*[0-9][0-9][0-9]*$/) == 0) { print "#!***Can't be a legal IAU format: " input_name exit(1) } sra = substr(name,1,i-1) ; # String RA dec = substr(name,i) ; # String Dec # Compute declination dd = substr(dec, 1, 3) + 0; if ((dd >= 90) || (dd <= -90)) outside_range("Dec.(deg)") ; if ((substr(sra,1,2)+0) >= 24) outside_range("R.A.(hrs)") ; cosdec = cos(dd*atan2(1,0)/90) # Convert degrees --> radians if (cosdec < 0.02) cosdec = 0.02 ##################################### # Estimate Center + Dim of RA ##################################### qra = substr(sra,1,2) " " substr(sra,3,2) ; if ((substr(sra,3,2) +0) >= 60) outside_range("R.A.(min)") ; i = length(sra) if (i == 4) { qra = qra " 30" ; dimra = 15 } else if (i == 5) { sec = substr(sra, 5)*6 ; if (sec > 54) outside_range("R.A.(sec)") ; qra = qra " " sec+3; dimra = 1.5 } else { sec = substr(sra,5,2) ; qra = qra " " sec ; dimra = 0.25 ; if ((sec+0) >= 60) outside_range("R.A.(sec)") ; if (i == 6) qra = qra ".5" ; else { qra = qra "." substr(sra,7) "5" ; dimra /= 10 } } dimra = dimra * 1.2 * cosdec ; ##################################### # Estimate Center + Dim of Dec ##################################### qde = substr(dec, 1, 3) ; i = length(dec) if (i == 3) { qde = qde " 30 00" ; dimde = 60 } # Just degrees else if (i == 4) { sec = substr(dec, 4, 1)*6 ; if (sec > 54) outside_range("Dec.(min)") ; qde = qde " " substr(dec, 4, 1)*6+3 " 00"; dimde = 6 } else { sec = substr(dec, 4, 2) ; if (sec >= 60) outside_range("Dec.(min)") ; qde = qde " " substr(dec, 4, 2) ; dimde = 1 ; if (i == 5) qde = qde " 30" ; else if (i == 6) { sec = substr(dec, 6, 1) *6 ; if (sec > 54) outside_range("Dec.(sec)") ; qde = qde " " sec+3 ; dimde = 0.1 } else { sec = substr(dec, 6, 2) ; qde = qde " " sec ; dimde = 1/60 ; if ((sec+0) >= 60) outside_range("Dec.(sec)") ; if (i == 7) qde = qde ".5" ; else qde = qde "." substr(dec, 8) "5" ; } } dimde = dimde * 1.2 ; ##################################### # Write the Constraints ##################################### print "-c=" qra qde; print "-c.eq=" equinox ; print "-c.bm=" dimra "/" dimde ; } ############################################################### # The Question Mark is a test: is the system up ? ############################################################### /^[?]/ { print "-source=METAhst\nhstid=0\n-go %#Sesame#%"; fflush(); next } ############################################################### # Acronyms made of a single word: insert a blank! ############################################################### NF==1 { if (index($0,"_") > 0) gsub(/_/, " ") ; else sub(/([1-9]*[0-9]*[A-Za-z]*)/, "& ") ; } ############################################################### # Now Come the Catalog-Specific Coding ###############################################################