#include #include #include #include "logio.h" #include "obs.h" #include "vlbutil.h" typedef struct { char *station; /* Prefix name to recognise station by */ char *array; /* If the station prefix is redundant name the array */ char *abrev; /* The abbreviation to refer to the telescope by */ } Sabrev; static Sabrev *stnabr(char *name); static Sabrev unknown = {"Unknown", NULL, "?"}; static Sabrev stntab[]={ {"HRAS", NULL, "F"},{"GRAS", NULL, "F"},{"NRAO", NULL, "G"}, {"HAY", NULL, "K"},{"HST", NULL, "K"},{"ILL", NULL, "V"}, {"EFF", NULL, "B"},{"ALG", NULL, "C"},{"ARO", NULL, "C"}, {"PU", NULL, "Pu"},{"CRI", NULL, "R"},{"KRI", NULL, "R"}, {"SIM", NULL, "R"},{"ONS", NULL, "S"},{"CHI", NULL, "U"}, {"DWI", NULL, "W"},{"SAF", NULL, "E"},{"HAR", NULL, "E"}, {"WESTF", NULL, "K"},{"MARY", NULL, "N"},{"VLA", "VLA", "Y"}, {"WSRT0", NULL, "W0"},{"MED", NULL, "L"},{"BGNA", NULL, "L"}, {"BOL", NULL, "L"},{"NOB", NULL, "M"},{"NRO", NULL, "M"}, {"JAP", NULL, "M"},{"NOTO", NULL, "No"},{"TOR", NULL, "Z"}, {"DEF", NULL, "Df"},{"CAM", NULL, "Cb"},{"LOV", NULL, "J1"}, {"JBNK1", NULL, "J1"},{"JBNK2", NULL, "J2"},{"MET", NULL, "V"}, {"FIN", NULL, "V"},{"ITA", NULL, "X"},{"ATI", NULL, "X"}, {"OOTY", NULL, "Oo"},{"SHA", NULL, "Sh"},{"KASH", NULL, "Ka"}, {"PER", NULL, "Pr"},{"ALI", NULL, "As"},{"PAR", NULL, "Pk"}, {"PKS", NULL, "Pk"},{"CUL", NULL, "Cg"},{"HOB", NULL, "Hb"}, {"NAN", NULL, "Nc"},{"MAD", NULL, "D"},{"DSS13", NULL, "Dv"}, {"DSS14", NULL, "Dm"},{"DSS15", NULL, "Dg"},{"DSS6", NULL, "Ds"}, {"DSS4", NULL, "Dt"},{"PIE", NULL, "Pt"},{"KIT", NULL, "Kp"}, {"LOS", NULL, "La"},{"VLBA_PT", NULL,"Pt"},{"VLBA_KP", NULL,"Kp"}, {"VLBA_LA", NULL,"La"},{"VLBA_FD", NULL,"Fd"},{"VLBA_NL", NULL,"Nl"}, {"VLBA_BR", NULL,"Br"},{"VLBA_OV", NULL,"Ov"},{"VLBA_SC", NULL,"Sc"}, {"VLBA_HN", NULL,"Hn"},{"VLBA_MK", NULL,"Mk"},{"BONN", NULL, "B"}, {"OVRO", NULL, "O"},{"AN", "mma", "Mm"},{"WSRT", "WSRT", "W"}, {0,0}}; /*....................................................................... * Given a station name return its standard abbreviation. * * Input: * name char * The station name. * Output: * return Sabrev * The container of the official telescope name and * its abbreviation. * If the telescope is not recognised &unkown will * be returned. */ static Sabrev *stnabr(char *name) { static char wrkstr[10]; static char *inptr; static char *ouptr; static Sabrev *sptr; static int i; /* * Make an upper case copy of the input name. */ inptr=name; ouptr= &wrkstr[0]; for(i=0; *inptr != '\0' && istation != 0; sptr++) { inptr=wrkstr; ouptr=sptr->station; for(;*inptr != '\0' && *ouptr != '\0';inptr++,ouptr++) if(*inptr != *ouptr) break; if(*ouptr == '\0') return sptr; }; /* * Station not found. */ return &unknown; } /*....................................................................... * Create a string of the concatenated telescope name standard * abbreviations. * * Input: * ob Observation * The observation whose stations are to be listed. * abrstr char * The return string of length 'slen'. * slen int The available length of string 'abrstr'. * Output: * return int 0 - normal completion. * 1 - string too short for station list. */ int stnstr(Observation *ob, char *abrstr, int slen) { Subarray *sub; /* Descriptor of the sub-array being processed */ char wrkstr[5]; /* String to hold abbreviation for one station */ char *aptr; /* Pointer into 'abrstr' */ int sleft=slen-1;/* Number of unused chars in 'abrstr' not including '\0' */ int wlen; /* Length of string in 'wrkstr' excluding '\0' */ int isub; /* The index of the sub-array being processed */ int i; /* * Check arguments. */ if(!ob_ready(ob, OB_INDEX, "stnstr")) return 1; /* * Get the abbreviation for each telescope in each sub-array of 'ob'. */ aptr = abrstr; sub = ob->sub; for(isub=0; isubnsub && sleft>1; isub++,sub++) { char *substr; /* Pointer to start of sub-array description */ Sabrev *first_stn=NULL; /* First station in sub-array */ int onetel=1; /* True if all stations in subarray are the same */ /* * If there is room add space between sub-array lists. */ if(isub!=0 && sleft >= 1) { *aptr++ = ' '; sleft -= 1; }; /* * Record the sub-array start position in the output string. */ substr = aptr; /* * List the abbreviations of each station in the sub-array. */ for(i=0; instat && sleft>1; i++) { Sabrev *sptr; /* * Get the abbreviation. */ sptr = stnabr(sub->tel[i].name); strcpy(wrkstr, sptr->abrev); /* * Make a note of whether any of the stations differ. If they don't then * they are probably part of a single array such as the VLA. */ if(first_stn==NULL) first_stn = sptr; onetel = onetel && sptr == first_stn; /* * If the abbreviation was not found "?" will have been returned. Replace * this with the first letter of the input name (uper case). */ if(wrkstr[0]=='?') wrkstr[0]=toupper((unsigned int) sub->tel[i].name[0]); /* * Check whether the new statio name will fit in the output string. */ wlen = strlen(wrkstr); sleft -= wlen; /* * Quit if input string too short. */ if(sleft<1) lprintf(stderr,"stnstr: Station list truncated due to string length\n"); /* * Copy to output slot. */ strcpy(aptr,wrkstr); aptr += wlen; }; /* * Did all the stations have the same recognised name? */ if(onetel && first_stn->array != NULL) { size_t start_len = (substr - abrstr); size_t name_len = strlen(first_stn->array); /* * Will the station name fit in the output string? */ if(start_len + name_len < slen-1) { /* * Overwrite the station abbreviations with the official station name. */ aptr = substr; strcpy(aptr, first_stn->array); aptr += name_len; sleft = slen-1 - (start_len + name_len); }; }; }; /* * Terminate the output string. */ *aptr = '\0'; return 0; }